Skip to content

Commit

Permalink
ref merge core (#1604)
Browse files Browse the repository at this point in the history
* ref merge core

* more ref

* fix

* more testing + fixes

* increase test

* fix comment

* add tests + fix bug

* one more test

* one more test just in cade
  • Loading branch information
hermeGarcia authored Nov 28, 2023
1 parent d98d6f6 commit eb802a8
Show file tree
Hide file tree
Showing 2 changed files with 393 additions and 101 deletions.
15 changes: 8 additions & 7 deletions nucliadb_vectors/src/data_point/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ impl<'a, Dlog: DeleteLog> Retriever<'a, Dlog> {
nodes,
delete_log,
similarity,
no_nodes: key_value::get_no_elems(nodes),
no_nodes: key_value::elements_in_total(nodes),
min_score,
}
}
Expand Down Expand Up @@ -441,7 +441,7 @@ impl AsRef<DataPoint> for DataPoint {

impl DataPoint {
pub fn stored_len(&self) -> Option<u64> {
if key_value::get_no_elems(&self.nodes) == 0 {
if key_value::elements_in_total(&self.nodes) == 0 {
return None;
}
let node = key_value::get_value(Node, &self.nodes, 0);
Expand Down Expand Up @@ -481,7 +481,7 @@ impl DataPoint {
min_score,
);

let no_nodes = key_value::get_no_elems(&self.nodes);
let no_nodes = key_value::elements_in_total(&self.nodes);

let filter = FormulaFilter::new(
filter,
Expand Down Expand Up @@ -540,13 +540,14 @@ impl DataPoint {
.iter()
.map(|dp| ((dp.0, Node), dp.1.nodes.as_ref()));
{
let node_producers: Vec<_> = node_producers.collect();
let mut node_buffer = BufWriter::new(&mut nodes);
key_value::merge(&mut node_buffer, node_producers.collect())?;
key_value::merge(&mut node_buffer, &node_producers)?;
node_buffer.flush()?;
}

let nodes = unsafe { Mmap::map(&nodes)? };
let no_nodes = key_value::get_no_elems(&nodes);
let no_nodes = key_value::elements_in_total(&nodes);

// Creating the FSTs with the new nodes
let (label_index, key_index) = if channel == Channel::EXPERIMENTAL {
Expand Down Expand Up @@ -655,7 +656,7 @@ impl DataPoint {
root_dir: &path::Path,
nodes: &[u8],
) -> VectorR<(Option<LabelIndex>, Option<KeyIndex>)> {
let no_nodes = key_value::get_no_elems(nodes);
let no_nodes = key_value::elements_in_total(nodes);

// building the KeyIndex and LabelIndex FSTs
let fst_dir = root_dir.join(file_names::FST);
Expand Down Expand Up @@ -741,7 +742,7 @@ impl DataPoint {
nodesf_buffer.flush()?;
}
let nodes = unsafe { Mmap::map(&nodesf)? };
let no_nodes = key_value::get_no_elems(&nodes);
let no_nodes = key_value::elements_in_total(&nodes);

// Creating the FSTs
let (label_index, key_index) = if channel == Channel::EXPERIMENTAL {
Expand Down
Loading

0 comments on commit eb802a8

Please sign in to comment.