Skip to content

Commit 5a7bacc

Browse files
committed
Unbind nns_to_hvectors 'txn lifetime
get_item bound HVector to 'txn lifetime, doing zero-copy, but this complicates some traversal operations. So now, when data is required, we allocates using the arena and therefore binds HVector's lifetime to the arena
1 parent 9b9d6a7 commit 5a7bacc

File tree

2 files changed

+6
-10
lines changed
  • helix-db/src/helix_engine

2 files changed

+6
-10
lines changed

helix-db/src/helix_engine/traversal_core/ops/vectors/search.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ pub trait SearchVAdapter<'db, 'arena, 'txn>:
2525
where
2626
F: Fn(&HVector, &RoTxn) -> bool,
2727
K: TryInto<usize>,
28-
K::Error: std::fmt::Debug,
29-
'txn: 'arena;
28+
K::Error: std::fmt::Debug;
3029
}
3130

3231
impl<'db, 'arena, 'txn, I: Iterator<Item = Result<TraversalValue<'arena>, GraphError>>>
@@ -48,7 +47,6 @@ impl<'db, 'arena, 'txn, I: Iterator<Item = Result<TraversalValue<'arena>, GraphE
4847
F: Fn(&HVector, &RoTxn) -> bool,
4948
K: TryInto<usize>,
5049
K::Error: std::fmt::Debug,
51-
'txn: 'arena,
5250
{
5351
let vectors = self.storage.vectors.search(
5452
self.txn,

helix-db/src/helix_engine/vector_core/mod.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -514,16 +514,13 @@ impl VectorCore {
514514
}
515515
}
516516

517-
pub fn nns_to_hvectors<'arena, 'txn>(
517+
pub fn nns_to_hvectors<'arena>(
518518
&self,
519-
txn: &'txn RoTxn,
519+
txn: &RoTxn,
520520
nns: bumpalo::collections::Vec<'arena, (ItemId, f32)>,
521521
with_data: bool,
522522
arena: &'arena bumpalo::Bump,
523-
) -> VectorCoreResult<bumpalo::collections::Vec<'arena, HVector<'arena>>>
524-
where
525-
'txn: 'arena,
526-
{
523+
) -> VectorCoreResult<bumpalo::collections::Vec<'arena, HVector<'arena>>> {
527524
let mut results = bumpalo::collections::Vec::<'arena, HVector<'arena>>::with_capacity_in(
528525
nns.len(),
529526
arena,
@@ -567,7 +564,8 @@ impl VectorCore {
567564
deleted: false,
568565
level: None,
569566
version: 0,
570-
data: get_item(self.hsnw, index.id, txn, item_id).unwrap(),
567+
data: get_item(self.hsnw, index.id, txn, item_id)?
568+
.map(|data| data.clone_in(arena)),
571569
});
572570
}
573571
} else {

0 commit comments

Comments
 (0)