Skip to content

Commit

Permalink
add the size of magic string
Browse files Browse the repository at this point in the history
  • Loading branch information
THUMarkLau committed May 30, 2024
1 parent dbc130e commit ba2b184
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ protected LogWriter(File logFile) throws IOException {
this.logChannel = this.logStream.getChannel();
if (!logFile.exists() || logFile.length() == 0) {
this.logChannel.write(ByteBuffer.wrap(WALWriter.MAGIC_STRING.getBytes()));
size += logChannel.position();
}
if (compressionAlg != CompressionType.UNCOMPRESSED) {
compressedByteBuffer =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,10 @@ public void skipToGivenPosition(long pos) throws IOException {
}
dataBuffer = ByteBuffer.allocate(currSegmentSize);
channel.read(dataBuffer);
dataBuffer.flip();
dataBuffer.position((int) posRemain);
} else {
dataBuffer.clear();
dataBuffer = null;
channel.position(pos);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ private void endFile() throws IOException {
buffer.putInt(metaDataSize);
// add magic string
buffer.put(MAGIC_STRING.getBytes());
size += buffer.position();
writeMetadata(buffer);
}

Expand Down

0 comments on commit ba2b184

Please sign in to comment.