Repository navigation
[UIO] Open UniversalMapIndex with S::Fs - #9256
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR refactors UniversalMapIndex to accept a configurable filesystem abstraction instead of hardcoding MmapFs. open and build are generic over a filesystem type S (UniversalRead/UniversalWrite) and take an explicit fs: &S::Fs; config and bitset IO use read_json_via and StoredBitSlice:: Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
lib/segment/src/index/field_index/map_index/universal_map_index/lifecycle.rs (2)
41-75:⚠️ Potential issue | 🟠 Major | ⚡ Quick win
openstill bypassesS::Fsfor part of the index state.Line 42 probes the host filesystem with
Path::is_file(), and Lines 65-75 still loaddeleted.binthroughMmapFs. That means this new genericopen(fs, ...)will returnOk(None)or merge the wrong deletion bitmap as soon as a non-MmapFsbackend is used. Please route both checks through the supplied filesystem abstraction instead of the local path APIs.🤖 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/lifecycle.rs` around lines 41 - 75, The code still probes the real host FS and opens the deletion bitmap via MmapFs instead of using the supplied filesystem abstraction: replace the direct Path::is_file() check on config_path and any local Path APIs with the corresponding S::Fs methods (e.g. fs.exists/is_file or metadata via the provided fs) when deciding whether to return Ok(None) and when reading config (read_json_via already accepts fs so ensure it uses the same check), and pass the supplied fs into MmapBitSlice::open (instead of MmapFs) so deleted_path is opened through the provided filesystem abstraction; keep the same Populate/do_populate logic and other opens (UniversalHashMap::open, StoredPointToValues::open) unchanged except for using the supplied fs where applicable.
107-177:⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift
buildstill writes multiple artifacts outside the supplied filesystem.Lines 122-145 persist
config,hashmap, andpoint_to_valuesvia local/mmap-specific helpers, then Line 177 reopens the index throughfs. With any backend other thanMmapFs, the new genericbuild(fs, ...)will create a split index where some files live behindfsand others do not. Either keepbuildmmap-only for now, or move all writes behind the universal IO abstraction before exposing the generic signature.🤖 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/lifecycle.rs` around lines 107 - 177, The build function currently writes config, hashmap and point-to-values using mmap-specific helpers (atomic_save_json, serialize_hashmap, StoredPointToValues::<N, MmapFile>::from_iter and MmapFs) while reopening via the generic fs in Self::open, causing split storage backends; fix by either making build accept/require an MmapFs (narrow the signature) OR replace all mmap-specific writes with fs-backed implementations: use fs.create/write for config (instead of atomic_save_json), implement or call a serialize_hashmap variant that writes through S::Fs, replace StoredPointToValues::<N, MmapFile>::from_iter with the generic StoredPointToValues::<N, S::File>::from_iter (or a constructor that uses fs), and ensure create_and_ensure_length and StoredBitSlice::<S>::open operate exclusively via the provided fs so all artifacts live behind the supplied S::Fs before calling Self::open.
🤖 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.
Outside diff comments:
In
`@lib/segment/src/index/field_index/map_index/universal_map_index/lifecycle.rs`:
- Around line 41-75: The code still probes the real host FS and opens the
deletion bitmap via MmapFs instead of using the supplied filesystem abstraction:
replace the direct Path::is_file() check on config_path and any local Path APIs
with the corresponding S::Fs methods (e.g. fs.exists/is_file or metadata via the
provided fs) when deciding whether to return Ok(None) and when reading config
(read_json_via already accepts fs so ensure it uses the same check), and pass
the supplied fs into MmapBitSlice::open (instead of MmapFs) so deleted_path is
opened through the provided filesystem abstraction; keep the same
Populate/do_populate logic and other opens (UniversalHashMap::open,
StoredPointToValues::open) unchanged except for using the supplied fs where
applicable.
- Around line 107-177: The build function currently writes config, hashmap and
point-to-values using mmap-specific helpers (atomic_save_json,
serialize_hashmap, StoredPointToValues::<N, MmapFile>::from_iter and MmapFs)
while reopening via the generic fs in Self::open, causing split storage
backends; fix by either making build accept/require an MmapFs (narrow the
signature) OR replace all mmap-specific writes with fs-backed implementations:
use fs.create/write for config (instead of atomic_save_json), implement or call
a serialize_hashmap variant that writes through S::Fs, replace
StoredPointToValues::<N, MmapFile>::from_iter with the generic
StoredPointToValues::<N, S::File>::from_iter (or a constructor that uses fs),
and ensure create_and_ensure_length and StoredBitSlice::<S>::open operate
exclusively via the provided fs so all artifacts live behind the supplied S::Fs
before calling Self::open.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: 831f5d73-17c7-4021-a812-8ec78daf4f85
📒 Files selected for processing (3)
lib/segment/src/index/field_index/map_index/builders.rslib/segment/src/index/field_index/map_index/lifecycle.rslib/segment/src/index/field_index/map_index/universal_map_index/lifecycle.rs
| @@ -36,22 +43,22 @@ impl<N: MapIndexKey + Key + ?Sized> UniversalMapIndex<N> { | |||
| return Ok(None); | |||
| } | |||
|
|
|||
| let config: UniversalMapIndexConfig = read_json(&config_path)?; | |||
| let config: UniversalMapIndexConfig = read_json_via(fs, &config_path)?; | |||
There was a problem hiding this comment.
| let config: UniversalMapIndexConfig = read_json_via(fs, &config_path)?; | |
| let config: UniversalMapIndexConfig = match read_json_via(fs, &config_path) { | |
| Ok(config) => config, | |
| Err(err) => { | |
| return if err.is_not_found() { | |
| Ok(None) | |
| } else { | |
| Err(OperationError::from(err)) | |
| }; | |
| } | |
| }; |
There was a problem hiding this comment.
we need to avoid config_path.is_file(). First - it is not implemented, second - it is extra call
There was a problem hiding this comment.
P.S. is_not_found needs to be implemented
There was a problem hiding this comment.
I missed this, thanks
Makes sure to use
S::Fsfor openingUniversalMapIndex