Commit Graph

161 Commits

Author SHA1 Message Date
Luis Cossío
b4328bb7c5 [mmap sparse vector storage] return cancelled error if stopped (#5938)
* return cancelled error if stopped

* add doc comment and renames
2025-02-11 14:40:25 +01:00
xzfc
cf3240d923 Use simple_segment_constructor (#5919)
* VECTOR1_NAME and VECTOR2_NAME

* Use simple_segment_constructor
2025-02-11 14:38:10 +01:00
xzfc
6e1316bfb5 Add payload_json! macro (#5881)
* Add payload_json! macro

* Replace usage of `json!({...})` with `payload_json! {...}`

* Drop `impl From<Value> for Payload`
2025-01-28 10:44:27 +01:00
xzfc
64d5beb141 Pass old_indices to HNSWIndex::new (#5835) 2025-01-27 18:25:53 +01:00
xzfc
e85a9f18b4 Add VectorName type alias (#5763)
* Add VectorName/VectorNameBuf type aliases [1/2]

* Add VectorName/VectorNameBuf type aliases [2/2]
2025-01-27 18:25:41 +01:00
xzfc
dc421536ea Split HNSWIndex::open and HNSWIndex::build (#5853)
* HNSWSearchesTelemetry::new()

* Split HNSWIndex::open and HNSWIndex::build
2025-01-27 18:25:38 +01:00
Jojii
c815a1bd43 Implement more IO measurements for PayloadStorage (#5822)
* Finish io measurement for payload storage

* Remove done TODOs

* review remarks

* make signature of `wipe()` consistent

* Remove hardware_counter from tracker.rs and make interfaces consistent

* Add hw_counter to payloads update_storage function from dev
2025-01-23 14:29:39 +01:00
Jojii
b0eb8d3431 Io measurement rename functions (#5816)
* replace _measured functions with original name

* Rename more functions
2025-01-23 14:29:32 +01:00
xzfc
4c178230e3 Optimize merged_points computation in SegmentBuilder::update() (#5820)
* Optimize `merged_points` computation in `SegmentBuilder::update()`

* Fixes
2025-01-23 14:29:02 +01:00
Jojii
38f478ddf7 Measure payload read IO (#5773)
* Measure read io for payload storage

* Add Hardware Counter to update functions

* Fix tests and benches

* Rename (some) *_measured functions back to original
2025-01-23 14:27:40 +01:00
xzfc
0132648041 GraphLinks: replace trait with enum (#5651)
* GraphLinks: replace trait with enum

* Vec::with_capacity
2025-01-08 14:08:55 +01:00
Luis Cossío
f2b142620f Fast loading of mmap sparse storage (#5533)
* use mmap bitslice and a metadata file to avoid loading

* fix and test reported files

* add new files to flusher

* update rocksdb+blob_store compatibility test

* switch to DynamicMmapFlags

* fix setting deleted to `false` on short bitslice

* remove `MmapBitSlice::extend`

* add some more tests to mmap sparse vector storage

* calculate deleted_count and next_point_offset on load

* get rid of metadata file

* cleanup

* fix test

---------

Co-authored-by: generall <andrey@vasnetsov.com>
2025-01-08 14:07:46 +01:00
Arnaud Gourlay
ced3a29f7e Extract plain vector index (#5675) 2025-01-08 14:07:36 +01:00
Ivan Pleshkov
4f99e728aa GPU HNSW integration (#5535)
* gpu hnsw

---------

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
2024-12-09 11:18:16 +01:00
Andrey Vasnetsov
eec2044309 it is easy if you know where to look (#5543) 2024-12-09 11:08:46 +01:00
Luis Cossío
443358dbe7 restructure sparse storages module (#5532) 2024-12-09 11:07:04 +01:00
Luis Cossío
c10c145a75 Compatibility for mmap sparse vectors (#5454)
* implement mmap sparse vector storage

* add to VectorStorageEnum

* clippy

* add tests, fix both simple and mmap storages

* smol correction on total_vector_count

* add sparse storage type to config

* fix reading config without storage type

* generate openapi

* use blob_store by path

* hidden setting to enable new storage

* validate existing path in `BlobStore::open()`

* use new dir for each sparse vector name

* fix and rename `max_point_offset`

Plus some extra refactors

* add storage compat test, to always check both storages work

* fix opening of storage + other misc fixes

* FIX!!!

`Unset` operations in the Tracker weren't updating the
`next_pointer_id`. So, when reopening the storage, those points wouldn't
get marked as deleted in the bitslice, thus creating the illusion that
they should exist, when they did not.

* refactor naming from `iter_*` to `for_each_*`

* fix checking for BlobStore existance

* fix typo

* fix error message

* better docs for open_or_create

* fix after rebase
2024-12-09 11:07:01 +01:00
Arnaud Gourlay
ec90e162ec Fix path to new payload storage for optimized segments (#5530)
* Fix path to storage for optimized segment

* add minimal test

* clippy
2024-12-09 11:06:54 +01:00
Luis Cossío
82daa2121c Refactor bool index (#5524)
* rename binary->bool

* restructure bool_index module

* rename Boolean->Bool

* rename memory_bool_index -> simple_bool_index
2024-12-09 11:02:33 +01:00
Luis Cossío
6c162656f3 Backward compatibility for mmap payload storage (#5398)
* support mmap storage backward compat

* fix clippy

* review fixes + bump + restore Cargo.lock

* fix clippy

* map_err instead of match

* add sanity tests for payload storage trait

* fix clippy

* error conversion

* test persistance too

* add config to enable mmap storage (#5434)
2024-11-18 11:11:56 +01:00
Arnaud Gourlay
28dfb3ef74 Remove redundant clones (#5402)
* Remove redundant clones

* fmt
2024-11-08 14:49:24 +01:00
Andrey Vasnetsov
bcf05d9e23 HasVector filtering condition (#5303)
* include vector storage into struct vector index

* implement has_vector

* generate schemas

* refactor query filter optimizer so avoid too many function arguments

* test + fix for sparse vectors

* Update lib/segment/src/index/struct_payload_index.rs

Co-authored-by: Jojii <15957865+JojiiOfficial@users.noreply.github.com>

* Update lib/segment/src/index/query_optimization/optimizer.rs

Co-authored-by: Jojii <15957865+JojiiOfficial@users.noreply.github.com>

* fmt

---------

Co-authored-by: Jojii <15957865+JojiiOfficial@users.noreply.github.com>
2024-11-08 11:17:37 +01:00
Arnaud Gourlay
eaa338d458 Payload storage can include files in snapshots (#5214) 2024-11-08 10:59:15 +01:00
Dominik Kellner
0c755cdc0c Clean temporary segments if optimization is cancelled (#5090)
This uses `TempDir` and comes with its caveats, e.g. the temporary segment
directory will not be deleted if the process exits. This should not be a
problem in practice, as all temporary segments get deleted when the shard is
loaded (see PR #2319).

Fixes #2978.
2024-09-17 15:30:14 +02:00
Arnaud Gourlay
4f59f72c02 Rename payload storage operations for consistency (#5087) 2024-09-17 15:29:55 +02:00
Luis Cossío
4b429214cc Integer and UUID facets (#4946)
* move FacetIndex into facet_index.rs

* add support for integer facets

* add support for uuid facets

* use separate internal structure

* rename FacetValue::Keyword into FacetValue::String in REST

* fix after rebase
2024-08-28 15:18:21 +02:00
Tim Visée
6e48f588a1 Fix point deletions on mmap segment optimization (#4952)
* Don't use ID but current point offset when optimizing dense mmap storage

This change now matches the implementation in all other storage types.

* Remove now obsolete point offsets in update_from point iterator

* Fix test
2024-08-27 01:15:28 +02:00
Jojii
564c085d4b On-disk Uuid hybrid-index (#4825)
* Migrate uuid index to mmap

* add uuid numeric index

* select correct index + tenants

* Only serialize if necessary

* select correct index

* reset Cargo.toml

* review: use only map index for uuid for now

---------

Co-authored-by: generall <andrey@vasnetsov.com>
2024-08-09 18:19:39 +02:00
Andrey Vasnetsov
649560fefd Use mmap lock as default vector storage (#4828)
* add force_ram parameter to chuncked mmap vector storage

* enable mlocked mmap vector storage on unix by default

* regen openapi

* add mlock on creation of chunck

* minor unrelated renaming

* rollback changes in LockedChunkedMmap

* fmt

* make AppendableMmapDenseVectorStorage generic of storage type

* make AppendableMmapMultiDenseVectorStorage generic of storage type

* implement initialization of InRamChunkedMmap

* implement MultiDenseAppendableInRam and variations

* enable InRamChunkedMmap for multivectors

* use same CHUNK_SIZE for mmap and regular chuncked vectors

* enable InRamChunkedMmap by default

* fix tests

* rollback usage of InRamChunkedMmap by default

* review changes

* add assertion on chunk_capacity [skip-ci]
2024-08-09 18:19:35 +02:00
xzfc
624b29daa4 Integration tests for on-disk payload indices (#4819)
* refactor: let SegmentBuilder::update take unlocked segments

* style: split long lines

* refactor: introduce TestSegments

* test: add tests for mmap indices
2024-08-09 18:17:53 +02:00
Ivan Pleshkov
a9784f7f60 Mmap map index (#4779)
* define mmap map index

add point to values

add mmap hash map

are you happy fmt

use new mmap hashmap methods

build index

saturating_sub

are you happy clippy

fix tests build

* integrate facets for mmap index

* mmap tests

* fix ci

* review remarks

* review remarks
2024-08-09 18:17:08 +02:00
Jojii
30a6aa4e74 Enable new idtracker (#4692)
* enable immutable_id_tracker and in_memory_id_tracker

* remove redundent flush

---------

Co-authored-by: generall <andrey@vasnetsov.com>
2024-08-09 18:14:59 +02:00
Jojii
745b1621df UUID payload index (#4738)
* add UuidIndex

* fix clippy

* rebase to dev

* update api docs

* don't use wrapper type for Uuid index

* rebase to `dev`

* remove existence checking

* rename UuidPayloadKeyType => UuidIntType

* apply review changes

* rebase to dev

* post-rebase fixes

* Improve estimation

* Improve naming

* Apply suggestions from code review

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>

* use u128 in histogram and improve uuid sorting

* Also allow defragmentation for completely random Uuids

---------

Co-authored-by: generall <andrey@vasnetsov.com>
2024-08-09 18:14:51 +02:00
xzfc
07c278ad51 Enable some of the pedantic clippy lints (#4715)
* Use workspace lints

* Enable lint: manual_let_else

* Enable lint: enum_glob_use

* Enable lint: filter_map_next

* Enable lint: ref_as_ptr

* Enable lint: ref_option_ref

* Enable lint: manual_is_variant_and

* Enable lint: flat_map_option

* Enable lint: inefficient_to_string

* Enable lint: implicit_clone

* Enable lint: inconsistent_struct_constructor

* Enable lint: unnecessary_wraps

* Enable lint: needless_continue

* Enable lint: unused_self

* Enable lint: from_iter_instead_of_collect

* Enable lint: uninlined_format_args

* Enable lint: doc_link_with_quotes

* Enable lint: needless_raw_string_hashes

* Enable lint: used_underscore_binding

* Enable lint: ptr_as_ptr

* Enable lint: explicit_into_iter_loop

* Enable lint: cast_lossless
2024-08-09 18:10:10 +02:00
Jojii
38522784b7 Basic defragmentation (#4610)
* sorting

* migrate tests and move logic into SegmentBuilder

* add test and improve implementation

* improve code

* review

* code review improvements

* add index building to test

* Do not clone ranges

* Resolve clippy warnings due to recent PR on dev

* review suggestions

* Defragmentation in api (#4684)

* add tenant config to api

* deduplicate used defragmentation keys

* rename is_tenant to is_primary

* use all values to defrag key

* rename is_primary -> is_tenant

* update schema

---------

Co-authored-by: generall <andrey@vasnetsov.com>
Co-authored-by: timvisee <tim@visee.me>
2024-08-09 18:08:52 +02:00
Jojii
6650e5885f Merge pull request #4403
* add immutable_id_tracker

* add dirty flag in test

* don't use immutable_id_tracker for now

* improve and integrate new immutable_id_tracker

* split external_to_internal into two BTreeMaps

* apply rquested changes

* delay mmap writes until flush

* remove unnecessary clone

* single source of truth for file path

* use custom de/serialization for more performance

* disable id tracker and fix codespell

* improve code & test

* Other minor nitpicks

* Apply suggestions from code review

* fix rebase issues

* basic custom mappings storage implementation

* add tests & fix bugs

* add more tests and fix bugs

* undo .codespellrc

* disable immutable_id_tracker completely for now

* fix clippy

* Remove unnecessary pub

* minor renaming
2024-08-09 18:08:39 +02:00
xzfc
7e7a96c80f Drop SparseVectorIndexDatatype in favor of VectorStorageDatatype (#4541)
* Drop SparseVectorIndexDatatype in favour of VectorStorageDatatype

* Split Datatype doc for VectorParams and SparseIndexParams
2024-06-25 13:33:37 +02:00
xzfc
a5cb30c208 U8 quantization for sparse vector index (#4514)
* U8 quantization for sparse index

* Spelling
2024-06-25 13:33:24 +02:00
xzfc
1a4d8c827a Move build_index out of VectorIndex (#4490)
* Move build_index out of VectorIndex

* Build index in HNSWIndex::open()

* Introduce HnswIndexOpenArgs

* Proper deletion

* Improve tests

* HNSW::open(): add warn, comment and assert

* Revert to making up the config if it does not exist
2024-06-25 13:33:18 +02:00
Andrey Vasnetsov
eba2c6be61 Api consistency update (#4533)
* rename search_params -> params

* rename multivector_config + generate schema

* upd tests
2024-06-25 13:32:31 +02:00
xzfc
b389b4e422 Add datatype option for sparse vector index (#4454)
* Add SparseVectorIndexDatatype

* Update tests

* Review fixes

* review

* gen openAPI

---------

Co-authored-by: generall <andrey@vasnetsov.com>
2024-06-21 23:40:07 +02:00
xzfc
d62a455da1 Integrate compressed posting list (attempt 2) (#4453)
* Rename InvertedIndex* -> InvertedIndexCompressed*

* Extract method VectorIndexEnum::fill_idf_statistics

* Extend VectorIndexEnum with new variants

* Introduce sparse::InvertedIndex::Version

* Replace SparseVectorIndexVersion -> InvertedIndex::Version

* Introduce sparse_vector_index::OpenArgs

* SparseVectorIndex::open: do not build index if directory is empty

Otherwise it would build the index twice since `SegmentBuilder::build()`
calls `::open()`, then `::build_index()`. This restores the old (<=v1.9)
behavior.

* Renames
2024-06-21 23:37:54 +02:00
Andrey Vasnetsov
8615ffb56d initialize sparse vectors in the segment builder (#4396) 2024-06-11 13:15:33 +02:00
Ivan Pleshkov
96ecd2cca8 Fix hnsw full scan threshold (#4369)
* fix hnsw full scan threshold

* add test

* are you happy clippy

* separate open_vector_storage

* remove public fields from builder

* wip: do not create segment in builder before build

* avoid arc in storage test and low-level loading functions

* WIP: remove internal segment from SegmentBuilder

* fmt

* finalize segment builder fixes

* Revert "are you happy clippy"

This reverts commit c04afa6989.

* Revert "add test"

This reverts commit 8e7ad6207e.

* Revert "fix hnsw full scan threshold"

This reverts commit 8904443fcb.

* remove _daatabse from builder

* fix optimizer test

* fix id tracker versions persistence

* do flush for segment components on build

---------

Co-authored-by: generall <andrey@vasnetsov.com>
2024-06-11 13:15:11 +02:00
Jojii
09e1dcbb86 Add IdTrackerEnum (#4356)
* add IdTrackerEnum

* rename enum variant
2024-06-11 13:14:08 +02:00
Tim Visée
aad9db1fe9 Fix missing segments, use correct path for new segment created during snapshot (#4332)
* Put temporary segment in correct path

* Use shard directory rather than collection directory in test

* Fix collection path getter, it actually returns segments path

* Use segments path for temporary segment

* The build segment function actually wants the segments path

* Refactor parameter name
2024-05-28 13:44:17 +02:00
Arnaud Gourlay
45b3d94a7f Minor cleanup from Rover's lints (#4249) 2024-05-26 12:33:30 +02:00
xzfc
1d724579df InvertedIndexImmutableRam and index migrations (#4220)
* Move StorageVersion from segment crate to common/io

* Refine StorageVersion API

* Move methods from SparseVectorDataConfig to enum SparseIndexType

* Introduce InvertedIndexImmutableRam

* Add migrate

* Don't migrate
2024-05-26 12:32:50 +02:00
Ivan Pleshkov
78b16a16a4 Float16 integration and API (#4234)
* f16 integration

tests

api

fix test

are you happy clippy

* fix build
2024-05-26 12:31:15 +02:00
Arnaud Gourlay
88c8ad8523 Allow basic multivec search on legacy API (#4203)
* Allow multivec search on legacy REST API

* show that it works for gRPC as well

* better error message

* update error assertion

* show validation on REST as well

* remove unecessary test

* fix conversion - dim is not vec count

* fmt

* Use TypedMultiDenseVectorRef everywhere (#4224)

* Use TypedMultiDenseVectorRef everywhere

* remove obsolete test

* fix codespell

* fix build

* test single dense vector expansion on upsert

---------

Co-authored-by: Ivan Pleshkov <pleshkov.ivan@gmail.com>
2024-05-26 12:31:08 +02:00