Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pgvectorscale/src/access_method/sbq/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ impl<'a> SbqNodeDistanceMeasure<'a> {
index_pointer: IndexPointer,
stats: &mut T,
) -> Self {
let cache = &mut storage.qv_cache.borrow_mut();
let cache = &mut storage.qv_cache.as_ref().unwrap().borrow_mut();
let vec = cache.get(index_pointer, storage, stats);
Self {
vec: vec.to_vec(),
Expand All @@ -212,7 +212,7 @@ impl NodeDistanceMeasure for SbqNodeDistanceMeasure<'_> {
index_pointer: IndexPointer,
stats: &mut T,
) -> f32 {
let cache = &mut self.storage.qv_cache.borrow_mut();
let cache = &mut self.storage.qv_cache.as_ref().unwrap().borrow_mut();
let vec1 = cache.get(index_pointer, self.storage, stats);
distance_xor_optimized(vec1, self.vec.as_slice()) as f32
}
Expand Down
12 changes: 6 additions & 6 deletions pgvectorscale/src/access_method/sbq/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub struct SbqSpeedupStorage<'a> {
quantizer: SbqQuantizer,
heap_rel: &'a PgRelation,
heap_attr: AttrNumber,
pub qv_cache: RefCell<QuantizedVectorCache>,
pub qv_cache: Option<RefCell<QuantizedVectorCache>>,
has_labels: bool,
}

Expand All @@ -52,7 +52,7 @@ impl<'a> SbqSpeedupStorage<'a> {
quantizer: SbqQuantizer::new(meta_page),
heap_rel,
heap_attr: get_index_vector_attribute(index),
qv_cache: RefCell::new(QuantizedVectorCache::new(1000)),
qv_cache: Some(RefCell::new(QuantizedVectorCache::new(1000))),
has_labels: meta_page.has_labels(),
}
}
Expand All @@ -77,7 +77,7 @@ impl<'a> SbqSpeedupStorage<'a> {
quantizer: Self::load_quantizer(index_relation, meta_page, stats),
heap_rel,
heap_attr: get_index_vector_attribute(index_relation),
qv_cache: RefCell::new(QuantizedVectorCache::new(1000)),
qv_cache: Some(RefCell::new(QuantizedVectorCache::new(1000))),
has_labels: meta_page.has_labels(),
}
}
Expand All @@ -95,7 +95,7 @@ impl<'a> SbqSpeedupStorage<'a> {
quantizer: quantizer.clone(),
heap_rel: heap_relation,
heap_attr: get_index_vector_attribute(index_relation),
qv_cache: RefCell::new(QuantizedVectorCache::new(1000)),
qv_cache: None,
has_labels: meta_page.has_labels(),
}
}
Expand Down Expand Up @@ -205,7 +205,7 @@ impl<'a> SbqSpeedupStorage<'a> {
}
}

let mut cache = self.qv_cache.borrow_mut();
let mut cache = self.qv_cache.as_ref().unwrap().borrow_mut();
let bq_vector = cache.get(neighbor_index_pointer, self, &mut lsr.stats);
let distance = lsr
.sdm
Expand Down Expand Up @@ -280,7 +280,7 @@ impl Storage for SbqSpeedupStorage<'_> {
neighbors: &[NeighborWithDistance],
stats: &mut S,
) {
let mut cache = self.qv_cache.borrow_mut();
let mut cache = self.qv_cache.as_ref().unwrap().borrow_mut();
/* It's important to preload cache with all the items since you can run into deadlocks
if you try to fetch a quantized vector while holding the SbqNode::modify lock */
let iter = neighbors
Expand Down