CurtHagenlocher commented on code in PR #504:
URL: https://github.com/apache/arrow-dotnet/pull/504#discussion_r4581152760


##########
src/Apache.Arrow/Ipc/ArrowReaderImplementation.cs:
##########
@@ -230,27 +294,39 @@ private List<IArrowArray> BuildArrays(
                 return arrays;
             }
 
-            using var bufferCreator = 
GetBufferCreator(recordBatchMessage.Compression);
-            var recordBatchEnumerator = new RecordBatchEnumerator(in 
recordBatchMessage);
-            int schemaFieldIndex = 0;
-            do
+            try
             {
-                Field field = schema.GetFieldByIndex(schemaFieldIndex++);
-                Flatbuf.FieldNode fieldNode = 
recordBatchEnumerator.CurrentNode;
+                using var bufferCreator = 
GetBufferCreator(recordBatchMessage.Compression, body);
+                var recordBatchEnumerator = new RecordBatchEnumerator(in 
recordBatchMessage);
+                int schemaFieldIndex = 0;
+                do
+                {
+                    Field field = schema.GetFieldByIndex(schemaFieldIndex++);
+                    Flatbuf.FieldNode fieldNode = 
recordBatchEnumerator.CurrentNode;
 
-                ArrayData arrayData = LoadField(version, ref 
recordBatchEnumerator, field, in fieldNode, messageBuffer, bufferCreator);
+                    ArrayData arrayData = LoadField(version, ref 
recordBatchEnumerator, field, in fieldNode, messageBuffer, bufferCreator);
 
-                arrays.Add(ArrowArrayFactory.BuildArray(arrayData));
-            } while (recordBatchEnumerator.MoveNextNode());
+                    arrays.Add(ArrowArrayFactory.BuildArray(arrayData));

Review Comment:
   Agreed, fixed in 8ed8845. `LoadField` now releases the buffers it has 
created, and any children, if a later buffer or child fails, and `GetChildren` 
releases the siblings already built when a child fails. A new test reads a 
batch with nulls, strings and a list column through a codec that fails on the 
n-th decompression, for every n a successful read makes, and checks that a 
caller-owned allocator has nothing outstanding afterwards. It failed before the 
fix.
   



##########
src/Apache.Arrow.Operations/Shredding/ShreddedVariantArrayBuilder.cs:
##########
@@ -83,7 +83,7 @@ public static VariantArray Build(
             // metadata column: emit the shared bytes once per row. (A 
dictionary-encoded
             // or run-end-encoded representation would compress this; 
VariantArray's reader
             // already handles those, but for simplicity we emit the plain 
binary form.)
-            BinaryArray.Builder metadataBuilder = new BinaryArray.Builder();
+            using BinaryArray.Builder metadataBuilder = new 
BinaryArray.Builder(BinaryType.Default, allocator);

Review Comment:
   Agreed, fixed in 8ed8845: the top-level validity bitmap now uses the 
supplied allocator, so the result is handed over instead of copied. It's also a 
`using` declaration now, since that builder was never disposed.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to