Skip to content

Conversation

@roderickvd
Copy link
Member

@roderickvd roderickvd commented Jan 14, 2026

Clarify Source::current_span_len() returns total span length (not remaining), while size_hint() returns remaining samples of the entire iterator. Fix multiple bugs in span boundary detection, seeking, and iterator implementations.

Opportunistic fixes:

  • fix division by zero, off-by-one error, and zero case handling
  • prevent counter overflows
  • optimize vector allocations

Mid-span seeking: best-effort tracking after try_seek() to detect span boundaries when seeking lands mid-span.

Fixes #691

Clarify Source::current_span_len() returns total span length (not remaining),
while size_hint() returns remaining samples. Fix multiple bugs in span boundary
detection, seeking, and iterator implementations.

Opportunistic fixes:
- fix division by zero, off-by-one error, and zero case handling
- prevent counter overflows
- optimize vector allocations

Mid-span seeking: best-effort tracking after try_seek() to detect span boundaries
when seeking lands mid-span.

Fixes #691
@roderickvd roderickvd requested a review from yara-blue January 14, 2026 23:11
@roderickvd
Copy link
Member Author

I did not fix the decoders because I had already done so with the infamous #786.

@roderickvd roderickvd force-pushed the fix/span-fixes-clean branch from 16c90ba to 7538971 Compare January 22, 2026 21:33

// Detect span boundaries by TWO mechanisms:
// 1. Reached end of span (by length) - handles same-parameter consecutive spans
// 2. Parameters changed - handles mid-stream parameter changes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 breaks the contract right? You are only allowed to change parameters at the end of a span. Or is 2 here in case of seeking? Should be removed from Source and allowed only on FixedSource, its seems really complex and costly to get right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Seek breaks span

3 participants