asmirnov82 commented on code in PR #13810:
URL: https://github.com/apache/arrow/pull/13810#discussion_r1158513012


##########
csharp/src/Apache.Arrow/ArrowBuffer.BitmapBuilder.cs:
##########
@@ -89,6 +89,37 @@ public BitmapBuilder Append(bool value)
                 return this;
             }
 
+            /// <summary>
+            /// Append a span of bits.
+            /// </summary>
+            /// <param name="source">Source of bit span.</param>
+            /// <param name="validBits">Number of valid bits in the bit 
span</param>
+            /// <returns>Returns the builder (for fluent-style 
composition).</returns>
+            public BitmapBuilder Append(ReadOnlySpan<byte> source, int 
validBits)
+            {
+                var length = source.IsEmpty ? validBits : 
Math.Min(source.Length * 8, validBits);
+
+                // Check if memory copy can be used from the source array 
(performance optimization for byte-aligned coping)
+                if (!source.IsEmpty && this.Length % 8 == 0)
+                {
+                    EnsureAdditionalCapacity(length * 8);
+                    source.Slice(0, 
BitUtility.ByteCount(length)).CopyTo(Span.Slice(Length / 8));
+                    
+                    Length += length;
+                    SetBitCount = BitUtility.CountBits(Span, 0, Length);

Review Comment:
   Agree. 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.

To unsubscribe, e-mail: [email protected]

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

Reply via email to