Skip to content

Commit

Permalink
throw exception if empty chunk idx has non-zero start and end times
Browse files Browse the repository at this point in the history
  • Loading branch information
achim-k committed Jan 8, 2025
1 parent e5c9da3 commit b5ddcaf
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions typescript/core/src/ChunkCursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@ export class ChunkCursor {
const reverse = this.#reverse;
let messageIndexStartOffset: bigint | undefined;
let relevantMessageIndexStartOffset: bigint | undefined;

if (this.chunkIndex.messageIndexLength === 0n) {
// Chunk has no message indexes.
// We only allow that if the chunk has no messages and the start and end times are 0.
if (this.chunkIndex.messageStartTime !== 0n || this.chunkIndex.messageEndTime !== 0n) {
throw new Error(
`Encountered a chunk index without message indexes and non-zero start and end times`,
);
}
}

for (const [channelId, offset] of this.chunkIndex.messageIndexOffsets) {
if (messageIndexStartOffset == undefined || offset < messageIndexStartOffset) {
messageIndexStartOffset = offset;
Expand Down

0 comments on commit b5ddcaf

Please sign in to comment.