Skip to content

feat(universal_io): add read_whole and read_json_via for config files - #8251

Merged
generall merged 4 commits into
devfrom
universal-io-config-read
Mar 2, 2026
Merged

generall merged 4 commits into
devfrom
universal-io-config-read

Conversation

@generall

Copy link
Copy Markdown
Member

Extends universal io so gridstore and segment can read JSON configs through the same interface as other file I/O.

  • UniversalRead::read_whole() – New method for whole-file read in one logical access. Default impl uses len() + read(0..len()); MmapUniversal overrides to return the full slice in one go (avoids two storage accesses).
  • UniversalIoError::SerdeJson – New variant for JSON deserialization errors.
  • read_json_via<S,T>(path, options) – Helper in common::universal_io that opens with S, calls read_whole(), then serde_json::from_slice.
  • Gridstore – read_config_and_tracker now uses read_json_via instead of File::open + BufReader + serde_json::from_reader.
  • Segment – ChunkedVectors::load_config uses read_json_via; NotFound is mapped to Ok(None). From\<UniversalIoError\> for OperationError extended with SerdeJson variant.

Config write is unchanged (still atomic_save_json in common::fs).

Made with Cursor

- Extend UniversalRead with read_whole() for single-access whole-file read
- Default impl uses len() + read(0..len()); MmapUniversal overrides with one slice
- Add UniversalIoError::SerdeJson for JSON deserialization errors
- Add read_json_via<S,T>(path, options) in common::universal_io
- Gridstore: use read_json_via for config in read_config_and_tracker
- Segment: use read_json_via in ChunkedVectors::load_config, handle NotFound
- Segment: extend From<UniversalIoError> for OperationError with SerdeJson variant

Made-with: Cursor
- Add NotFound { path } variant so callers can match without io::ErrorKind
- MmapUniversal::open maps io::ErrorKind::NotFound to NotFound { path }
- ChunkedVectors::load_config matches NotFound => Ok(None)
- OperationError From<UniversalIoError> handles NotFound

Made-with: Cursor
coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

Made-with: Cursor
Use &bytes instead of &*bytes; auto-deref handles Cow

Made-with: Cursor
coderabbitai[bot]

This comment was marked as resolved.

@qdrant qdrant deleted a comment from coderabbitai Bot Mar 2, 2026
@generall
generall requested a review from xzfc March 2, 2026 15:37
@generall
generall merged commit 82c49df into dev Mar 2, 2026
16 checks passed
@generall
generall deleted the universal-io-config-read branch March 2, 2026 15:38
coszio pushed a commit to coszio/qdrant that referenced this pull request Mar 5, 2026
Introduce a universal I/O abstraction layer (following upstream qdrant/qdrant
PRs qdrant#8196, qdrant#8251, qdrant#8292) that decouples data access from storage backends.

Key components:
- UniversalRead<T> / UniversalWrite<T> traits for backend-agnostic I/O
- MmapUniversal<T>: mmap-based implementation with optional sequential read mmap
- BitSliceReader<S>: storage-agnostic bitslice reader that works over any
  UniversalRead<u8> backend, supporting:
  - read_bitslice(): read entire storage as a BitSlice (zero-copy for mmap)
  - get_bit(): single-bit access translating bit offset to a 1-byte read
  - read_bit_range(): partial bit range reads with byte-aligned backend access

https://claude.ai/code/session_01X9Bnj9Gooxh5bxkhbFmnGx
@generall generall added this to the Universal IO milestone Mar 26, 2026
generall added a commit that referenced this pull request Mar 26, 2026
…#8251)

* feat(universal_io): add read_whole and read_json_via for config files

- Extend UniversalRead with read_whole() for single-access whole-file read
- Default impl uses len() + read(0..len()); MmapUniversal overrides with one slice
- Add UniversalIoError::SerdeJson for JSON deserialization errors
- Add read_json_via<S,T>(path, options) in common::universal_io
- Gridstore: use read_json_via for config in read_config_and_tracker
- Segment: use read_json_via in ChunkedVectors::load_config, handle NotFound
- Segment: extend From<UniversalIoError> for OperationError with SerdeJson variant

Made-with: Cursor

* feat(universal_io): add UniversalIoError::NotFound for file-not-found

- Add NotFound { path } variant so callers can match without io::ErrorKind
- MmapUniversal::open maps io::ErrorKind::NotFound to NotFound { path }
- ChunkedVectors::load_config matches NotFound => Ok(None)
- OperationError From<UniversalIoError> handles NotFound

Made-with: Cursor

* style: apply cargo fmt

Made-with: Cursor

* fix(common): satisfy clippy explicit_auto_deref in read_json_via

Use &bytes instead of &*bytes; auto-deref handles Cow

Made-with: Cursor

---------

Co-authored-by: Cursor Agent <[email protected]>
KShivendu pushed a commit that referenced this pull request Mar 30, 2026
…#8251)

* feat(universal_io): add read_whole and read_json_via for config files

- Extend UniversalRead with read_whole() for single-access whole-file read
- Default impl uses len() + read(0..len()); MmapUniversal overrides with one slice
- Add UniversalIoError::SerdeJson for JSON deserialization errors
- Add read_json_via<S,T>(path, options) in common::universal_io
- Gridstore: use read_json_via for config in read_config_and_tracker
- Segment: use read_json_via in ChunkedVectors::load_config, handle NotFound
- Segment: extend From<UniversalIoError> for OperationError with SerdeJson variant

Made-with: Cursor

* feat(universal_io): add UniversalIoError::NotFound for file-not-found

- Add NotFound { path } variant so callers can match without io::ErrorKind
- MmapUniversal::open maps io::ErrorKind::NotFound to NotFound { path }
- ChunkedVectors::load_config matches NotFound => Ok(None)
- OperationError From<UniversalIoError> handles NotFound

Made-with: Cursor

* style: apply cargo fmt

Made-with: Cursor

* fix(common): satisfy clippy explicit_auto_deref in read_json_via

Use &bytes instead of &*bytes; auto-deref handles Cow

Made-with: Cursor

---------

Co-authored-by: Cursor Agent <[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.

3 participants