Skip to content

use inverted index to serve labels/label_values instead of forward - #13

Merged
agavra merged 1 commit into
mainfrom
use_ii_for_labels
Dec 19, 2025
Merged

use inverted index to serve labels/label_values instead of forward#13
agavra merged 1 commit into
mainfrom
use_ii_for_labels

Conversation

@agavra

@agavra agavra commented Dec 19, 2025

Copy link
Copy Markdown
Contributor

Summary

The original approach was embarrassingly bad... I can't believe I merged it that way! I had to change it from the Aion implementation because we don't have explicit dictionaries.

  • Optimizes labels() and label_values() endpoints to use inverted index keys instead of iterating through forward index
  • Implements hybrid approach: forward index for filtered queries (match[]), inverted index for unfiltered queries
  • Adds InvertedIndexKey::attribute_range() for efficient storage scans by label name
  • Adds QueryReader::label_values() method that scans only keys matching the requested label

Test plan

  • Existing tests pass (322 tests)
  • Added unit test for attribute_range() key matching
  • Existing integration tests for labels() and label_values() endpoints cover both filtered and unfiltered cases

Checklist

  • Tests added/updated
  • cargo fmt and cargo clippy pass
  • Documentation updated (if applicable)

@agavra

agavra commented Dec 19, 2025

Copy link
Copy Markdown
Contributor Author

I'm going to optimistically merge this to unblock some perf testing, but it's definitely wroth specifying all the query paths in an RFC

@agavra
agavra merged commit 5d78e36 into main Dec 19, 2025
1 check passed
@agavra
agavra deleted the use_ii_for_labels branch December 19, 2025 00:36
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.

1 participant