chutchinson commented on a change in pull request #7158:
URL: https://github.com/apache/arrow/pull/7158#discussion_r437591301



##########
File path: csharp/src/Apache.Arrow/ArrowBuffer.Builder.cs
##########
@@ -80,27 +140,63 @@ public Builder<T> AppendRange(IEnumerable<T> values)
                 return this;
             }
 
-            public Builder<T> Reserve(int capacity)
+            /// <summary>
+            /// Reserve a given number of items' additional capacity.
+            /// </summary>
+            /// <param name="additionalCapacity">Number of items of required 
additional capacity.</param>
+            /// <returns>Returns the builder (for fluent-style 
composition).</returns>
+            public Builder<T> Reserve(int additionalCapacity)
             {
-                EnsureCapacity(capacity);
+                if (additionalCapacity < 0)
+                {
+                    throw new 
ArgumentOutOfRangeException(nameof(additionalCapacity));
+                }
+
+                EnsureAdditionalCapacity(additionalCapacity);
                 return this;
             }
 
+            /// <summary>
+            /// Resize the buffer to a given size.
+            /// </summary>
+            /// <remarks>
+            /// Note that if the required capacity is larger than the current 
length of the populated buffer so far,
+            /// the buffer's contents in the new, expanded region are 
undefined.

Review comment:
       To expand here, I think a reasonable design would give the consumer the 
option. When allocating large blocks of memory it can be advantageous to avoid 
clearing memory if you intend on writing over every byte.




----------------------------------------------------------------
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:
[email protected]


Reply via email to