liyafan82 commented on a change in pull request #6323:
URL: https://github.com/apache/arrow/pull/6323#discussion_r414332379



##########
File path: 
java/memory/src/test/java/org/apache/arrow/memory/TestLargeArrowBuf.java
##########
@@ -0,0 +1,68 @@
+/*
+ * 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;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ArrowBuf;
+
+/**
+ * Integration test for large (more than 2GB) {@link io.netty.buffer.ArrowBuf}.
+ * To run this test, please
+ *<li>Make sure there are 4GB memory available in the system.</li>
+ * <li>
+ *   Make sure the default allocation manager type is unsafe.
+ *   This can be achieved by the environmental variable or system property.
+ *   The details can be found in {@link DefaultAllocationManagerOption}.
+ * </li>
+ */
+public class TestLargeArrowBuf {
+
+  private static void testLargeArrowBuf() {
+    final long bufSize = 4 * 1024 * 1024 * 1024L;
+    try (BufferAllocator allocator = new RootAllocator(Long.MAX_VALUE);
+         ArrowBuf largeBuf = allocator.buffer(bufSize)) {
+      assertEquals(bufSize, largeBuf.capacity());
+      System.out.println("Successfully allocated a buffer with capacity " + 
largeBuf.capacity());
+
+      for (long i = 0; i < bufSize / 8; i++) {
+        largeBuf.setLong(i * 8, i);
+
+        if ((i + 1) % 10000 == 0) {
+          System.out.println("Successfully written " + (i + 1) + " long 
words");
+        }
+      }
+      System.out.println("Successfully written " + (bufSize / 8) + " long 
words");
+
+      for (long i = 0; i < bufSize / 8; i++) {
+        long val = largeBuf.getLong(i * 8);
+        assertEquals(i, val);
+
+        if ((i + 1) % 10000 == 0) {
+          System.out.println("Successfully read " + (i + 1) + " long words");
+        }
+      }
+      System.out.println("Successfully read " + (bufSize / 8) + " long words");
+    }
+    System.out.println("Successfully released the large buffer.");
+  }
+
+  public static void main(String[] args) {

Review comment:
       Sounds good. 
   I have revised the code to make the cut-off value configurable, and added 
cases to test the scenarios when the request size is below/above the cut-off 
value. Please see if it looks good to you. Thanks. 




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


Reply via email to