You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "asmirnov82 (via GitHub)" <gi...@apache.org> on 2023/05/06 11:22:55 UTC

[GitHub] [arrow] asmirnov82 commented on a diff in pull request #35342: GH-32605: [C#] Extend validity buffer api

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


##########
csharp/src/Apache.Arrow/ArrowBuffer.BitmapBuilder.cs:
##########
@@ -138,6 +138,28 @@ public BitmapBuilder AppendRange(IEnumerable<bool> values)
                 return this;
             }
 
+
+            /// <summary>
+            /// Append multiple bits.
+            /// </summary>
+            /// <param name="value">Value of bits to append.</param>
+            /// <param name="length">Number of times the value should be added.</param>
+            /// <returns>Returns the builder (for fluent-style composition).</returns>
+            public BitmapBuilder AppendRange(bool value, int length)
+            {
+                EnsureAdditionalCapacity(length);
+
+                for (int i = 0; i < length; i++)
+                {
+                    BitUtility.SetBit(Span, Length, value);
+                    Length++;
+                }
+                                
+                SetBitCount += value ? length : 0;
+
+                return this;
+            }

Review Comment:
   Thanks for you suggestion. I like the idea! Similar approach is used in BitUtility.CountBits method, so I added a complementary implementation of SetBits method to BitUtility and used it in BitmapBuilder. I also changed CountBits to follow project official coding style.



-- 
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: github-unsubscribe@arrow.apache.org

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