Repository navigation
read only map index - #9025
read only map index#9025
Conversation
Wires `ReadOnlyFieldIndex` into the read-only field-index surface that
`ReadOnlyMapIndex` and `ReadOnlyNullIndex` already provide, sharing the
non-trivial bodies with the existing `MapIndex` impls.
- Extracted per-`N` `PayloadFieldIndexRead` bodies (filter,
estimate_cardinality, for_each_payload_block, condition_checker) in
`payload_index_impl/{str,int,uuid}.rs` into free functions over
`T: MapIndexRead<N>`. Both `MapIndex<N>` and `ReadOnlyMapIndex<N, S>`
now impl `PayloadFieldIndexRead` via thin delegation to those bodies.
- Lifted `value_retriever` bodies in `value_indexer_impl.rs` the same
way; `ReadOnlyMapIndex<N, S>` gets the per-K closure for free.
- Added `telemetry_index_type` (required) + `get_telemetry_data`
(default) to `MapIndexRead`, mirroring the `NullIndexRead` pattern;
every map-index variant now reports telemetry without an inherent
method on the enum.
- Promoted `MapIndexRead` + its module to `pub` so
`field_index_base/read_only/` can name them.
- Implemented `FacetIndex for ReadOnlyMapIndex<N, S>` and extended
`FacetIndexEnum` with `S: UniversalRead = MmapFile` plus the three
read-only variants. `FieldIndex::as_facet_index` pins
`S = MmapFile` via turbofish to keep inference happy.
- `ReadOnlyFieldIndex::as_numeric` returns `None` for now; no concrete
read-only numeric type exists yet (the doc on `NumericFieldIndexRead`
already notes this is intended for a future `ReadOnlySegment`).
📝 WalkthroughWalkthroughThis PR generalizes the mmap-specific map index implementation to support arbitrary storage backends and introduces a read-only abstraction layer. The core changes rename Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
lib/segment/src/index/field_index/map_index/universal_map_index/read_ops.rs (1)
223-225: 💤 Low valueConsider renaming telemetry type identifier to match the new type name.
The method returns
"mmap_map"but the type is nowUniversalMapIndex. If this string is kept for backwards compatibility with existing telemetry collection, consider adding a comment explaining that. Otherwise,"universal_map"would better reflect the new type name.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lib/segment/src/index/field_index/map_index/universal_map_index/read_ops.rs` around lines 223 - 225, The telemetry_index_type method currently returns "mmap_map" which no longer matches the type name UniversalMapIndex; update telemetry_index_type (in UniversalMapIndex) to return "universal_map" to reflect the new type name, or if you must preserve existing telemetry values for backwards compatibility, keep "mmap_map" but add a brief comment above telemetry_index_type explaining that the string is intentionally unchanged for telemetry compatibility.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@lib/segment/src/index/field_index/map_index/universal_map_index/read_ops.rs`:
- Around line 223-225: The telemetry_index_type method currently returns
"mmap_map" which no longer matches the type name UniversalMapIndex; update
telemetry_index_type (in UniversalMapIndex) to return "universal_map" to reflect
the new type name, or if you must preserve existing telemetry values for
backwards compatibility, keep "mmap_map" but add a brief comment above
telemetry_index_type explaining that the string is intentionally unchanged for
telemetry compatibility.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: abc946f3-ea79-4efc-8a02-76bfb8f83269
📒 Files selected for processing (15)
lib/segment/src/index/field_index/facet_index.rslib/segment/src/index/field_index/field_index_base/field_index_read_impl.rslib/segment/src/index/field_index/field_index_base/mod.rslib/segment/src/index/field_index/field_index_base/read_only/mod.rslib/segment/src/index/field_index/field_index_base/read_only/read_ops.rslib/segment/src/index/field_index/map_index/facet_index_impl.rslib/segment/src/index/field_index/map_index/immutable_map_index/read_ops.rslib/segment/src/index/field_index/map_index/mod.rslib/segment/src/index/field_index/map_index/mutable_map_index/inner.rslib/segment/src/index/field_index/map_index/mutable_map_index/read_only/read_ops.rslib/segment/src/index/field_index/map_index/mutable_map_index/read_ops.rslib/segment/src/index/field_index/map_index/read_only/read_ops.rslib/segment/src/index/field_index/map_index/read_ops.rslib/segment/src/index/field_index/map_index/universal_map_index/read_ops.rslib/segment/src/index/field_index/map_index/value_indexer_impl.rs
✅ Files skipped from review due to trivial changes (1)
- lib/segment/src/index/field_index/field_index_base/mod.rs
🚧 Files skipped from review as they are similar to previous changes (2)
- lib/segment/src/index/field_index/map_index/read_only/read_ops.rs
- lib/segment/src/index/field_index/map_index/mod.rs
* rename mmap -> universal * [AI] Introduce `ReadOnlyMapIndex` and implement `MapIndexRead` for it * add missing file * [AI] Implement read-only PayloadFieldIndexRead / FieldIndexRead (#9026) Wires `ReadOnlyFieldIndex` into the read-only field-index surface that `ReadOnlyMapIndex` and `ReadOnlyNullIndex` already provide, sharing the non-trivial bodies with the existing `MapIndex` impls. - Extracted per-`N` `PayloadFieldIndexRead` bodies (filter, estimate_cardinality, for_each_payload_block, condition_checker) in `payload_index_impl/{str,int,uuid}.rs` into free functions over `T: MapIndexRead<N>`. Both `MapIndex<N>` and `ReadOnlyMapIndex<N, S>` now impl `PayloadFieldIndexRead` via thin delegation to those bodies. - Lifted `value_retriever` bodies in `value_indexer_impl.rs` the same way; `ReadOnlyMapIndex<N, S>` gets the per-K closure for free. - Added `telemetry_index_type` (required) + `get_telemetry_data` (default) to `MapIndexRead`, mirroring the `NullIndexRead` pattern; every map-index variant now reports telemetry without an inherent method on the enum. - Promoted `MapIndexRead` + its module to `pub` so `field_index_base/read_only/` can name them. - Implemented `FacetIndex for ReadOnlyMapIndex<N, S>` and extended `FacetIndexEnum` with `S: UniversalRead = MmapFile` plus the three read-only variants. `FieldIndex::as_facet_index` pins `S = MmapFile` via turbofish to keep inference happy. - `ReadOnlyFieldIndex::as_numeric` returns `None` for now; no concrete read-only numeric type exists yet (the doc on `NumericFieldIndexRead` already notes this is intended for a future `ReadOnlySegment`).
Implement
Which mirrors
They also share implementations of the read methods, so no code duplication