mirror of
https://github.com/qdrant/qdrant.git
synced 2026-09-21 13:37:46 -05:00
[edge] Actually use batched vector reads (#9855)
* override default impls * Fix clippy needless_borrow in batched dense read ops Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: root <111755117+qdrant-cloud-bot@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
root
parent
3e22d70fd0
commit
553b6d6988
@@ -23,6 +23,27 @@ impl<T: PrimitiveVectorElement, S: UniversalRead> DenseVectorStorageRead<T>
|
||||
.get_vector_opt::<P>(key)
|
||||
.expect("vector not found")
|
||||
}
|
||||
|
||||
fn read_dense_bytes<P: AccessPattern, U: Copy + common::universal_io::UserData>(
|
||||
&self,
|
||||
keys: impl IntoIterator<Item = (U, PointOffsetType)>,
|
||||
mut callback: impl FnMut(U, PointOffsetType, Vec<u8>),
|
||||
) -> crate::common::operation_error::OperationResult<()> {
|
||||
let (user_data, keys): (Vec<_>, Vec<_>) = keys.into_iter().unzip();
|
||||
self.vectors.for_each_in_batch(&keys, |idx, dense| {
|
||||
let user_data = user_data[idx];
|
||||
let key = keys[idx];
|
||||
callback(user_data, key, bytemuck::cast_slice(dense).to_vec());
|
||||
})
|
||||
}
|
||||
|
||||
fn for_each_in_dense_batch<F: FnMut(usize, &[T])>(
|
||||
&self,
|
||||
keys: &[PointOffsetType],
|
||||
f: F,
|
||||
) -> crate::common::operation_error::OperationResult<()> {
|
||||
self.vectors.for_each_in_batch(keys, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: PrimitiveVectorElement, S: UniversalRead> VectorStorageRead
|
||||
|
||||
@@ -6,6 +6,7 @@ use common::types::PointOffsetType;
|
||||
use common::universal_io::{UniversalRead, UserData};
|
||||
|
||||
use super::ReadOnlyChunkedDenseVectorStorage;
|
||||
use crate::common::operation_error::OperationResult;
|
||||
use crate::data_types::named_vectors::CowVector;
|
||||
use crate::data_types::primitive::PrimitiveVectorElement;
|
||||
use crate::types::{Distance, VectorStorageDatatype};
|
||||
@@ -23,6 +24,27 @@ impl<T: PrimitiveVectorElement, S: UniversalRead> DenseVectorStorageRead<T>
|
||||
.get::<P>(key as VectorOffsetType)
|
||||
.expect("vector not found")
|
||||
}
|
||||
|
||||
fn read_dense_bytes<P: AccessPattern, U: Copy + UserData>(
|
||||
&self,
|
||||
keys: impl IntoIterator<Item = (U, PointOffsetType)>,
|
||||
mut callback: impl FnMut(U, PointOffsetType, Vec<u8>),
|
||||
) -> crate::common::operation_error::OperationResult<()> {
|
||||
let (user_datas, keys): (Vec<_>, Vec<_>) = keys.into_iter().unzip();
|
||||
self.vectors.for_each_in_batch(&keys, |idx, dense| {
|
||||
let user_data = user_datas[idx];
|
||||
let key = keys[idx];
|
||||
callback(user_data, key, bytemuck::cast_slice(dense).to_vec());
|
||||
})
|
||||
}
|
||||
|
||||
fn for_each_in_dense_batch<F: FnMut(usize, &[T])>(
|
||||
&self,
|
||||
keys: &[PointOffsetType],
|
||||
callback: F,
|
||||
) -> OperationResult<()> {
|
||||
self.vectors.for_each_in_batch(keys, callback)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: PrimitiveVectorElement, S: UniversalRead> VectorStorageRead
|
||||
|
||||
Reference in New Issue
Block a user