MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / id_score_pairs

Function id_score_pairs

nodedb/tests/sql_fts_strict.rs:50–63  ·  view source on GitHub ↗

Pull `(id, bm25_score)` from each row. NULL/empty score → `None`.

(rows: &[Vec<String>])

Source from the content-addressed store, hash-verified

48
49/// Pull `(id, bm25_score)` from each row. NULL/empty score → `None`.
50fn id_score_pairs(rows: &[Vec<String>]) -> Vec<(String, Option<f64>)> {
51 rows.iter()
52 .map(|r| {
53 let id = r[0].trim().to_string();
54 let cell = r[1].trim();
55 let score = if cell.is_empty() {
56 None
57 } else {
58 cell.parse::<f64>().ok()
59 };
60 (id, score)
61 })
62 .collect()
63}
64
65fn pair<'a>(pairs: &'a [(String, Option<f64>)], id: &str) -> &'a (String, Option<f64>) {
66 pairs

Calls 5

collectMethod · 0.80
to_stringMethod · 0.80
iterMethod · 0.45
is_emptyMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected