Commit Graph

151 Commits

Author SHA1 Message Date
xzfc
694ec10f3d GraphLinks: replace trait with enum (#5651)
* GraphLinks: replace trait with enum

* Vec::with_capacity
2024-12-23 18:59:53 +00:00
Luis Cossío
6e1245c414 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>
2024-12-18 16:53:06 -03:00
Arnaud Gourlay
7712f828ab Extract plain vector index (#5675) 2024-12-18 14:56:38 +01:00
Ivan Pleshkov
73259267ae GPU HNSW integration (#5535)
* gpu hnsw

---------

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
2024-12-05 00:58:49 +01:00
Andrey Vasnetsov
e81e45beb0 it is easy if you know where to look (#5543) 2024-11-28 22:03:11 +01:00
Luis Cossío
608736219f restructure sparse storages module (#5532) 2024-11-27 13:46:57 -06:00
Luis Cossío
2de122adea 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-11-27 11:45:16 -06:00
Arnaud Gourlay
9dcd3dd406 Fix path to new payload storage for optimized segments (#5530)
* Fix path to storage for optimized segment

* add minimal test

* clippy
2024-11-27 16:59:46 +01:00
Luis Cossío
6a20f2bc2c Refactor bool index (#5524)
* rename binary->bool

* restructure bool_index module

* rename Boolean->Bool

* rename memory_bool_index -> simple_bool_index
2024-11-26 11:33:27 -06:00
Luis Cossío
d902422203 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-13 08:49:42 -06:00
Arnaud Gourlay
a9c45313e7 Remove redundant clones (#5402)
* Remove redundant clones

* fmt
2024-11-08 13:02:23 +01:00
Andrey Vasnetsov
633d996e61 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-10-25 18:47:03 +02:00
Arnaud Gourlay
2e0f72364f Payload storage can include files in snapshots (#5214) 2024-10-14 09:26:19 +02:00
Dominik Kellner
60d4ddd623 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-16 20:47:31 +02:00
Arnaud Gourlay
ea6376feb1 Rename payload storage operations for consistency (#5087) 2024-09-16 12:42:11 +02:00
Luis Cossío
b49e416382 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-27 11:30:57 -04:00
Tim Visée
cae2cbbc79 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-26 20:02:08 +02:00
Jojii
2cb03610d8 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-07 19:45:42 +02:00
Andrey Vasnetsov
e77b6332dd 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-07 16:34:58 +02:00
xzfc
7bbb7eed36 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-03 22:00:03 +02:00
Ivan Pleshkov
3a610d97f6 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-02 13:01:19 +02:00
Jojii
ec0cc86953 Enable new idtracker (#4692)
* enable immutable_id_tracker and in_memory_id_tracker

* remove redundent flush

---------

Co-authored-by: generall <andrey@vasnetsov.com>
2024-07-26 18:38:35 +02:00
Jojii
17462ef1a7 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-07-26 16:59:34 +02:00
xzfc
a0ea3caccf 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-07-22 08:19:19 +00:00
Jojii
68373fb600 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-07-18 11:43:56 +02:00
Jojii
760180ff32 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-07-17 19:45:22 +02:00
xzfc
b9c0bd0f7d Drop SparseVectorIndexDatatype in favor of VectorStorageDatatype (#4541)
* Drop SparseVectorIndexDatatype in favour of VectorStorageDatatype

* Split Datatype doc for VectorParams and SparseIndexParams
2024-06-24 19:27:34 +02:00
xzfc
dd3102baeb U8 quantization for sparse vector index (#4514)
* U8 quantization for sparse index

* Spelling
2024-06-24 14:12:29 +00:00
xzfc
cde39fb8a2 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-24 14:44:34 +02:00
Andrey Vasnetsov
d4807dcc8b Api consistency update (#4533)
* rename search_params -> params

* rename multivector_config + generate schema

* upd tests
2024-06-23 23:56:42 +02:00
xzfc
53e883ea48 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-18 13:32:06 +00:00
xzfc
05ff867ff3 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-17 14:41:38 +02:00
Andrey Vasnetsov
308f611fe0 initialize sparse vectors in the segment builder (#4396) 2024-06-05 12:01:20 +02:00
Ivan Pleshkov
a629fc4d4c 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-04 11:16:11 +02:00
Jojii
e41661a4e4 Add IdTrackerEnum (#4356)
* add IdTrackerEnum

* rename enum variant
2024-05-31 09:02:34 +02:00
Tim Visée
1af6a9b234 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-27 19:03:02 +02:00
Arnaud Gourlay
b7396202b1 Minor cleanup from Rover's lints (#4249) 2024-05-16 21:47:43 +02:00
xzfc
ccf7f1d24f 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-16 06:47:47 +00:00
Ivan Pleshkov
e80844969f Float16 integration and API (#4234)
* f16 integration

tests

api

fix test

are you happy clippy

* fix build
2024-05-15 10:36:55 +02:00
Arnaud Gourlay
86ca51aa2d 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-14 17:54:11 +02:00
Kamyar Salahi
c230a48c50 Half-precision float vector metrics (#4122)
* Adding half-precision floating point SIMD-optimized implementation for vector distance metrics.

* Primitives adjustment

* Remove ds store

* Load assembly only for neon

* Fixing linter errors

* Adding float16 type

* Addressing f16 comments

* Refactoring and adding benchmarks

* Renaming simd functions

* Cleaning openapi

* Merging in changes to dev

* Fixing linter error

* fix clippy

* disable float16 feature in API

---------

Co-authored-by: generall <andrey@vasnetsov.com>
2024-05-13 23:19:21 +02:00
Ivan Pleshkov
ea1f8a84af integrate multivector mmap and byte storages (#4194) 2024-05-07 13:27:58 +02:00
Ivan Pleshkov
679d6fcd06 Mmap multivector storage (#4106)
* mmap multivector storage

update_from

fix build

are you happy fmt

fix bug

share multivector storages tests

* review remarks
2024-05-07 10:28:31 +02:00
Tim Visée
5f7caf6052 Improve performance of dynamic mmap flags counting (#4176)
* Add dynamic mmap flags function to count flags

* Remove stopped flag

* Add test for new count function to check correctness

* Add benchmark for flag count function

* Fix clippy warning

* Rename bench from deleted to flag count

* Fix typo

Co-authored-by: Arnaud Gourlay <arnaud.gourlay@gmail.com>

* Construct stoppable flag outside bench, add non-stoppable bench

---------

Co-authored-by: Arnaud Gourlay <arnaud.gourlay@gmail.com>
2024-05-06 16:00:35 +02:00
Arnaud Gourlay
571143ae87 Simplify MaxSim configuration (#4171)
* Simplify MaxSim configuration

* enable extension of multivectorconfig

* rename multi_vec_config to multivec_config
2024-05-06 14:19:42 +02:00
Andrey Vasnetsov
49bfc07170 Clean-up unversioned points (#4156)
* allow unversioned points in optimized (with warning) + remove unversioned points after WAL recovery

* Change unwrap with debug statement to match

---------

Co-authored-by: timvisee <tim@visee.me>
2024-05-02 16:54:39 +02:00
Andrey Vasnetsov
44f2744d74 Byte storage api support (#4065)
* wip: include datatype in vector params API

* generate api schemas

* propagate datatype to segment creation

* fix review

* fmt
2024-04-18 15:22:28 +02:00
Ivan Pleshkov
224e4f600a Byte storage integration into segment (#4049)
* byte storage with quantization

raw scorer integration

config and test

are you happy fmt

fn renamings

cow refactor

use quantization branch

quantization update

* are you happy clippy

* don't use distance in quantized scorers

* fix build

* add fn quantization_preprocess

* apply preprocessing for only cosine float metric

* fix sparse vectors tests

* update openapi

* more complicated integration test

* update openapi comment

* mmap byte storages support

* fix async test

* move .unwrap closer to the actual check of the vector presence

* fmt

* remove distance similarity function

* avoid copying data while working with cow

---------

Co-authored-by: generall <andrey@vasnetsov.com>
2024-04-18 00:42:17 +02:00
Arnaud Gourlay
54d28d2d53 Integrate Multivector at segment level (#3973)
* Integrate Multivector at segment level

* more tests - green with lower accuracy

* decrease expected accuracy to fix test

* cleanup test

* multivector can not be empty

* vary number of vector per multivec point
2024-04-08 12:22:24 +02:00
Arnaud Gourlay
b49000858a Multivec knob for SegmentConfig (#3963)
* Multivec knob for SegmentConfig

* regen openapi

* add TODO for next step

* introduce multivecconfig to support more similarity aggregation

* update openapi
2024-04-04 16:38:09 +02:00