You've already forked pgvecto.rs
mirror of
https://github.com/tensorchord/pgvecto.rs.git
synced 2025-07-30 19:23:05 +03:00
feat: allow user to set vbase range (#206)
* feat: allow user to set vbase range Signed-off-by: silver-ymz <yinmingzhuo@gmail.com> * separate the enable_vbase and vbase_range settings Signed-off-by: silver-ymz <yinmingzhuo@gmail.com> --------- Signed-off-by: silver-ymz <yinmingzhuo@gmail.com>
This commit is contained in:
@ -330,11 +330,9 @@ impl<S: G> IndexView<S> {
|
||||
.map(|x| Pointer::from_u48(x.payload >> 16))
|
||||
.collect()
|
||||
}
|
||||
pub fn vbase(&self, vector: &[S::Scalar]) -> impl Iterator<Item = Pointer> + '_ {
|
||||
pub fn vbase(&self, vector: &[S::Scalar], range: usize) -> impl Iterator<Item = Pointer> + '_ {
|
||||
assert_eq!(self.options.vector.dims as usize, vector.len());
|
||||
|
||||
let range = 86;
|
||||
|
||||
struct Comparer<'a, S: G> {
|
||||
iter: ComparerIter<'a, S>,
|
||||
item: Option<HeapElement>,
|
||||
|
@ -139,43 +139,44 @@ impl InstanceView {
|
||||
pub fn vbase(
|
||||
&self,
|
||||
vector: DynamicVector,
|
||||
range: usize,
|
||||
) -> Result<impl Iterator<Item = Pointer> + '_, FriendlyError> {
|
||||
match (self, vector) {
|
||||
(InstanceView::F32Cos(x), DynamicVector::F32(vector)) => {
|
||||
if x.options.vector.dims as usize != vector.len() {
|
||||
return Err(FriendlyError::Unmatched2);
|
||||
}
|
||||
Ok(Box::new(x.vbase(&vector)) as Box<dyn Iterator<Item = Pointer>>)
|
||||
Ok(Box::new(x.vbase(&vector, range)) as Box<dyn Iterator<Item = Pointer>>)
|
||||
}
|
||||
(InstanceView::F32Dot(x), DynamicVector::F32(vector)) => {
|
||||
if x.options.vector.dims as usize != vector.len() {
|
||||
return Err(FriendlyError::Unmatched2);
|
||||
}
|
||||
Ok(Box::new(x.vbase(&vector)))
|
||||
Ok(Box::new(x.vbase(&vector, range)))
|
||||
}
|
||||
(InstanceView::F32L2(x), DynamicVector::F32(vector)) => {
|
||||
if x.options.vector.dims as usize != vector.len() {
|
||||
return Err(FriendlyError::Unmatched2);
|
||||
}
|
||||
Ok(Box::new(x.vbase(&vector)))
|
||||
Ok(Box::new(x.vbase(&vector, range)))
|
||||
}
|
||||
(InstanceView::F16Cos(x), DynamicVector::F16(vector)) => {
|
||||
if x.options.vector.dims as usize != vector.len() {
|
||||
return Err(FriendlyError::Unmatched2);
|
||||
}
|
||||
Ok(Box::new(x.vbase(&vector)))
|
||||
Ok(Box::new(x.vbase(&vector, range)))
|
||||
}
|
||||
(InstanceView::F16Dot(x), DynamicVector::F16(vector)) => {
|
||||
if x.options.vector.dims as usize != vector.len() {
|
||||
return Err(FriendlyError::Unmatched2);
|
||||
}
|
||||
Ok(Box::new(x.vbase(&vector)))
|
||||
Ok(Box::new(x.vbase(&vector, range)))
|
||||
}
|
||||
(InstanceView::F16L2(x), DynamicVector::F16(vector)) => {
|
||||
if x.options.vector.dims as usize != vector.len() {
|
||||
return Err(FriendlyError::Unmatched2);
|
||||
}
|
||||
Ok(Box::new(x.vbase(&vector)))
|
||||
Ok(Box::new(x.vbase(&vector, range)))
|
||||
}
|
||||
_ => Err(FriendlyError::Unmatched2),
|
||||
}
|
||||
|
Reference in New Issue
Block a user