adamkennedy commented on code in PR #37178:
URL: https://github.com/apache/arrow/pull/37178#discussion_r1296346656


##########
java/memory/memory-core/src/main/java/org/apache/arrow/memory/util/GlobalAllocator.java:
##########
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.arrow.memory.util;
+
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.stream.Collectors;
+
+import org.apache.arrow.memory.BufferAllocator;
+import org.apache.arrow.memory.RootAllocator;
+import org.apache.arrow.util.VisibleForTesting;
+
+/**
+ * Default implementation for memory allocation in case you are using a global
+ * allocator, otherwise, you should pass root allocator explicitly on demand.
+ */
+public final class GlobalAllocator {
+  private GlobalAllocator() {}
+
+  private static final RootAllocator GLOBAL_ROOT_ALLOCATOR = new 
RootAllocator();
+  private static final AtomicInteger CHILD_NUMBER = new AtomicInteger(0);
+
+  /**
+   * Get default new child allocator.
+   *
+   * @return a new child {@link BufferAllocator}.
+   */
+  public static BufferAllocator getChildAllocator() {
+    return getChildAllocator(0, Long.MAX_VALUE);
+  }
+
+  /**
+   * Get custom new child allocator with initial reservation and maximum 
allocation.
+   *
+   * @return a new child {@link BufferAllocator}.
+   */
+  public static BufferAllocator getChildAllocator(final long initReservation, 
final long maxAllocation) {
+    return GLOBAL_ROOT_ALLOCATOR.newChildAllocator(nextChildName(), 
initReservation, maxAllocation);
+  }
+
+  private static String nextChildName() {
+    return "ChildAllocator-" + CHILD_NUMBER.incrementAndGet();

Review Comment:
   Doesn't have a lot of meaning here because "ChildAllocator" has no obvious 
relation to the GlobalAllocator.
   
   Perhaps explicitly call out the source of the child in the name? 
`"GlobalAllocator-"` or `"GlobalAllocator-Child#"` or something?



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