Skip to content

Commit

Permalink
Add LongConsumer ioSizeRecorder in TsFileSequenceReader for IoTDB scan
Browse files Browse the repository at this point in the history
  • Loading branch information
JackieTien97 authored Nov 13, 2024
1 parent 755de79 commit 69fb039
Show file tree
Hide file tree
Showing 5 changed files with 256 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.util.function.LongConsumer;

public class ChunkHeader {

Expand Down Expand Up @@ -189,7 +190,23 @@ public static ChunkHeader deserializeFrom(InputStream inputStream, byte chunkTyp
* @throws IOException IOException
*/
public static ChunkHeader deserializeFrom(TsFileInput input, long offset) throws IOException {
return deserializeFrom(input, offset, null);
}

/**
* deserialize from TsFileInput, the marker has not been read.
*
* @param input TsFileInput
* @param offset offset
* @param ioSizeRecorder can be null
* @return CHUNK_HEADER object
* @throws IOException IOException
*/
public static ChunkHeader deserializeFrom(
TsFileInput input, long offset, LongConsumer ioSizeRecorder) throws IOException {

// only 6 bytes, no need to call ioSizeRecorder.accept alone, combine into the remaining raed
// operation
ByteBuffer buffer = ByteBuffer.allocate(Byte.BYTES + Integer.BYTES + 1);
input.read(buffer, offset);
buffer.flip();
Expand All @@ -208,6 +225,10 @@ public static ChunkHeader deserializeFrom(TsFileInput input, long offset) throws
+ TSEncoding.getSerializedSize();
buffer = ByteBuffer.allocate(remainingBytes);

if (ioSizeRecorder != null) {
ioSizeRecorder.accept((long) alreadyReadLength + remainingBytes);
}

input.read(buffer, offset + alreadyReadLength);
buffer.flip();

Expand Down
Loading

0 comments on commit 69fb039

Please sign in to comment.