zgramana commented on a change in pull request #7032: URL: https://github.com/apache/arrow/pull/7032#discussion_r416154898
########## File path: csharp/src/Apache.Arrow/Arrays/BinaryArray.cs ########## @@ -73,61 +80,88 @@ public TArray Build(MemoryAllocator allocator = default) { ValueOffsets.Append(Offset); - var data = new ArrayData(DataType, ValueOffsets.Length - 1, 0, 0, - new[] { ArrowBuffer.Empty, ValueOffsets.Build(allocator), ValueBuffer.Build(allocator) }); + var data = new ArrayData(DataType, ValueOffsets.Length - 1, NullCount, 0, + new[] { ValidityBuffer.Build(allocator).ValueBuffer, ValueOffsets.Build(allocator), ValueBuffer.Build(allocator) }); return Build(data); } - public TBuilder Append(byte value) + public TBuilder AppendNull() + { + ValueOffsets.Append(Offset); + Offset++; + NullCount++; + return Instance; + } + + public TBuilder Append(T value) { ValueOffsets.Append(Offset); ValueBuffer.Append(value); Offset++; + ValidityBuffer.Append(true); return Instance; } - public TBuilder Append(ReadOnlySpan<byte> span) + public TBuilder Append(ReadOnlySpan<T> span) { ValueOffsets.Append(Offset); ValueBuffer.Append(span); - Offset += span.Length; + ValidityBuffer.Append(true); + Offset += span == Span<T>.Empty + ? 1 + : span.Length; return Instance; } - public TBuilder AppendRange(IEnumerable<byte[]> values) + public TBuilder AppendRange(IEnumerable<T[]> values) { foreach (var arr in values) { + if (arr != null && arr.Length > 0) Review comment: Fixed ---------------------------------------------------------------- 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