Skip to content

Conversation

@KarthikSubbarao
Copy link
Member

@KarthikSubbarao KarthikSubbarao commented Jan 16, 2026

Add SeekForwardPosition API to TextIterator interface and all the derived iterators.

This will help in cases where there is an ordering violation identified based on the initial primed positions of the text iterators. To resolve the ordering violation, we try to seek when possible to avoid repetitive NextPosition calls

Note: It will only ever be used by an search query with an AND Intersection with some proximity property thus requiring a ProximityIterator

Signed-off-by: KarthikSubbarao <[email protected]>
Signed-off-by: KarthikSubbarao <[email protected]>
Signed-off-by: KarthikSubbarao <[email protected]>
Signed-off-by: KarthikSubbarao <[email protected]>
Signed-off-by: KarthikSubbarao <[email protected]>
Signed-off-by: KarthikSubbarao <[email protected]>
}
// No violations: advance the term appearing first physically
size_t first_idx = in_order_ ? 0 : pos_with_idx_[0].second;
if (!iters_[first_idx]->DonePositions()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What would happen if the iterator is exhausted?

Copy link
Member Author

Choose a reason for hiding this comment

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

If it was exhausted, then we should not try advancing, since it is against the contract (and can crash). There is a check at the top in the loop condition which will exit if any iterator is done once the curr iteration is done

Signed-off-by: KarthikSubbarao <[email protected]>
Signed-off-by: KarthikSubbarao <[email protected]>
@KarthikSubbarao KarthikSubbarao merged commit 143f2c6 into valkey-io:main Jan 21, 2026
7 checks passed
eliastam pushed a commit to eliastam/valkey-search that referenced this pull request Jan 21, 2026
…ived iterators (valkey-io#620)

* seekforwardposition

Signed-off-by: KarthikSubbarao <[email protected]>

* implement seekforward for unordered positions case and also in orproximityiterator

Signed-off-by: KarthikSubbarao <[email protected]>

* updates

Signed-off-by: KarthikSubbarao <[email protected]>

* Cleaning code

Signed-off-by: KarthikSubbarao <[email protected]>

* Refactor

Signed-off-by: KarthikSubbarao <[email protected]>

* cleanup

Signed-off-by: KarthikSubbarao <[email protected]>

* Add comment

Signed-off-by: KarthikSubbarao <[email protected]>

* fix

Signed-off-by: KarthikSubbarao <[email protected]>

* Remove noop check

Signed-off-by: KarthikSubbarao <[email protected]>

---------

Signed-off-by: KarthikSubbarao <[email protected]>
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.

2 participants