Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chunk Index record doesn't tell me how big my chunk record is #39

Closed
defunctzombie opened this issue Jan 21, 2022 · 6 comments
Closed
Labels
feature New feature or request

Comments

@defunctzombie
Copy link
Contributor

After reading a chunk index record, I know which message index record to read, but I don't know how big my chunk record is which means I have to go read the size of the record and then go read the record itself.

@defunctzombie defunctzombie added the feature New feature or request label Jan 21, 2022
@jtbandes
Copy link
Member

+1

@jtbandes
Copy link
Member

Current workaround:

const chunkOpcodeAndLength = await this.readable.read(chunkIndex.chunkOffset, 1n + 8n);
const chunkOpcodeAndLengthView = new DataView(
chunkOpcodeAndLength.buffer,
chunkOpcodeAndLength.byteOffset,
chunkOpcodeAndLength.byteLength,
);
if (chunkOpcodeAndLengthView.getUint8(0) !== Opcode.CHUNK) {
throw new Error(
`Chunk index offset does not point to chunk record (expected opcode ${
Opcode.CHUNK
}, found ${chunkOpcodeAndLengthView.getUint8(0)})`,
);
}
const chunkRecordLength = getBigUint64.call(chunkOpcodeAndLengthView, 1, true);

@defunctzombie
Copy link
Contributor Author

Change offset to start_offset and end_offset so we can identify the bytes in the file containing the opcode+record lengh+record data for a chunk index record.

@defunctzombie
Copy link
Contributor Author

chunk_start_offset - points to an opcode
chunk_end_offset - one past the end of the chunk

[start_offset, end_offset)

@defunctzombie
Copy link
Contributor Author

Add chunk_trailer_byte_length? chunk_trailer_end_offset?

@defunctzombie
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Development

No branches or pull requests

2 participants