Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
achim-k committed Jan 14, 2025
1 parent b5ddcaf commit 6a67730
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions typescript/core/src/ChunkCursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ export class ChunkCursor {
this.#startTime = params.startTime;
this.#endTime = params.endTime;
this.#reverse = params.reverse;

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`,
);
}
}
}

/**
Expand Down Expand Up @@ -104,16 +114,6 @@ export class ChunkCursor {
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 6a67730

Please sign in to comment.