dongjoon-hyun commented on code in PR #1574:
URL: https://github.com/apache/orc/pull/1574#discussion_r1290620807


##########
java/core/src/test/org/apache/orc/impl/TestRecordReaderUtils.java:
##########
@@ -140,6 +147,44 @@ public void testExtraBytesReadWithinThreshold() {
     assertEquals(chunkReader.getReadBytes(), 
chunkReader.getFrom().getData().array().length);
   }
 
+  @Test
+  public void testZeroCopyReadAndRelease() throws IOException {
+    int blockSize = 4096;
+    ByteBuffer hdfsBlockMMapBuffer = makeByteBuffer(blockSize, 0);
+    int blockStartPosition = 4096;
+    MockDFSDataInputStream dis = new 
MockDFSDataInputStream(hdfsBlockMMapBuffer, blockStartPosition);
+    FSDataInputStream fis = new FSDataInputStream(dis);
+    RecordReaderUtils.ByteBufferAllocatorPool pool = new 
RecordReaderUtils.ByteBufferAllocatorPool();
+    HadoopShims.ZeroCopyReaderShim zrc = 
RecordReaderUtils.createZeroCopyShim(fis, null, pool);
+    BufferChunkList rangeList = new TestOrcLargeStripe.RangeBuilder()
+            .range(5000, 1000)
+            .range(6000, 1000)
+            .range(7000, 500).build();
+    RecordReaderUtils.zeroCopyReadRanges(fis, zrc, rangeList.get(0), 
rangeList.get(2), false);
+
+    
Assertions.assertArrayEquals(Arrays.copyOfRange(hdfsBlockMMapBuffer.array(), 
5000 - blockStartPosition, 5000 - blockStartPosition + 1000), 
byteBufferToArray(rangeList.get(0).getData()));
+    
Assertions.assertArrayEquals(Arrays.copyOfRange(hdfsBlockMMapBuffer.array(), 
6000 - blockStartPosition, 6000 - blockStartPosition + 1000), 
byteBufferToArray(rangeList.get(1).getData()));
+    
Assertions.assertArrayEquals(Arrays.copyOfRange(hdfsBlockMMapBuffer.array(), 
7000 - blockStartPosition, 7000 - blockStartPosition + 500), 
byteBufferToArray(rangeList.get(2).getData()));

Review Comment:
   Since this is used multiple times, shall we import 
`Assertions.assertArrayEquals`?



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