mr-smidge commented on a change in pull request #7671:
URL: https://github.com/apache/arrow/pull/7671#discussion_r453692211



##########
File path: csharp/src/Apache.Arrow/Arrays/BinaryArray.cs
##########
@@ -66,87 +66,158 @@ protected BuilderBase(IArrowType dataType)
                 ValueOffsets = new ArrowBuffer.Builder<int>();
                 ValueBuffer = new ArrowBuffer.Builder<byte>();
                 ValidityBuffer = new ArrowBuffer.BitmapBuilder();
+
+                // From the docs:
+                //
+                // The offsets buffer contains length + 1 signed integers 
(either 32-bit or 64-bit, depending on the
+                // logical type), which encode the start position of each slot 
in the data buffer. The length of the
+                // value in each slot is computed using the difference between 
the offset at that slot’s index and the
+                // subsequent offset.
+                //
+                // In this builder, we choose to append the first offset 
(zero) upon construction, and each trailing
+                // offset is then added after each individual item has been 
appended.
+                ValueOffsets.Append(this.Offset);
             }
 
             protected abstract TArray Build(ArrayData data);
 
-            public int Length => ValueOffsets.Length;
+            /// <summary>
+            /// Gets the length of the array built so far.
+            /// </summary>
+            public int Length => ValueOffsets.Length - 1;
 
+            /// <summary>
+            /// Build an Arrow array from the appended contents so far.
+            /// </summary>
+            /// <param name="allocator">Optional memory allocator.</param>
+            /// <returns>Returns an array of type <typeparamref 
name="TArray"/>.</returns>
             public TArray Build(MemoryAllocator allocator = default)
             {
-                ValueOffsets.Append(Offset);
-
-                ArrowBuffer validityBuffer = NullCount > 0
-                                        ? ValidityBuffer.Build(allocator)
-                                        : ArrowBuffer.Empty;
-
-                var data = new ArrayData(DataType, ValueOffsets.Length - 1, 
NullCount, 0,
-                    new[] { validityBuffer, ValueOffsets.Build(allocator), 
ValueBuffer.Build(allocator) });
+                var bufs = new[]
+                {
+                    NullCount > 0 ? ValidityBuffer.Build(allocator) : 
ArrowBuffer.Empty,
+                    ValueOffsets.Build(allocator),
+                    ValueBuffer.Build(allocator),
+                };
+                var data = new ArrayData(
+                    DataType,
+                    length: ValueOffsets.Length - 1,

Review comment:
       Yes it can - changed.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to