bxfjb commented on issue #8017:
URL: https://github.com/apache/rocketmq/issues/8017#issuecomment-2051537917

   > `ByteStreams.toByteArray()` creates large array in memory and is 
unnecessary. It seems `FileChannel.transferFrom()` with NIO channel would be 
more efficient for writing streams to a file.
   
   Thx for reply, I tried `FileChannel.transferFrom()` but find out some 
unittest failed:
   ```
   @Test
   public void consumeQueueTest() throws ClassNotFoundException, 
NoSuchMethodException {
       ...
       ByteBuffer cqItem1 = fileSegment.read(initPosition, unitSize);
       Assert.assertEquals(baseOffset, cqItem1.getLong());  // failed
       ...
   }
   ```
   
   > java.lang.AssertionError: 
   Expected :1000
   Actual   :0
   
   It turns out the cq data was not flush correctly by debugging, I wonder if 
the way I use `FileChannel.transferFrom()` is wrong:


-- 
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: commits-unsubscr...@rocketmq.apache.org

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

Reply via email to