jixuan1989 commented on a change in pull request #34: fix sonar
URL: https://github.com/apache/incubator-iotdb/pull/34#discussion_r251871864
##########
File path:
tsfile/src/main/java/org/apache/iotdb/tsfile/utils/ReadWriteIOUtils.java
##########
@@ -536,6 +536,41 @@ public static ByteBuffer
readByteBufferWithSelfDescriptionLength(ByteBuffer buff
return byteBuffer;
}
+ /**
+ * Used by 'deserializeFrom' function of both class 'ChunkHeader' and class
'ChunkGroupFooter'.
+ *
+ * @param channel FileChannel
+ * @param offset offset position
+ * @param markerRead read marker
+ * @param isHeader true if it is used by ChunkHeader, false if it is used by
ChunkGroupFooter
+ * @param len an array passed as a parameter to this method to transmit the
length information
+ * @return ByteBuffer got from FileChannel
+ */
+ public static ByteBuffer getByteBufferFromFileChannel(FileChannel channel,
long offset,
Review comment:
A more clear implementation:
1. ByteBuffer sizeBuffer = ByteBuffer.allocate(Integer.BYTES);
2. read an integer into sizeBuffer, called size;
3. ByteBuffer buffer = ByteBuffer.allocate(Integer.BYTES + size);
4. write the sizeBuffer (or the integer `size`) into buffer.
5. return buffer;
In this way, the returned buffer is a completed Header or Footer, then you
can get `String device` by `readString()`.
In the new implementation, `int[] len` is no more needed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services