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
2 changes: 1 addition & 1 deletion src/bench/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl BenchResult {
println!("║ RECALL ║");
println!("║ Recall@{}: {:>6.2}% ║", self.config.k, self.recall_at_k * 100.0);

if let Some(ref cmp) = self.comparison {
if let Some(cmp) = self.comparison.as_ref() {
println!("╠════════════════════════════════════════════════════════════════╣");
println!("║ VS FLOAT32 COSINE BASELINE ║");
println!("║ RAM savings: {:>6.1}x less memory ║", cmp.ram_savings_factor);
Expand Down
6 changes: 3 additions & 3 deletions src/bin/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ fn handle_topk(body: &str, state: &SharedState) -> String {
scored.truncate(k);

let results: Vec<String> = scored.iter().map(|&(idx, dist, sim)| {
let (ref id, _, ref meta): &(String, Fingerprint, HashMap<String, String>) = &db.fingerprints[idx];
let (id, _, meta) = &db.fingerprints[idx];
let meta_json = meta.iter()
.map(|(k, v)| format!(r#""{}":"{}""#, k, v))
.collect::<Vec<_>>().join(",");
Expand Down Expand Up @@ -550,7 +550,7 @@ fn handle_resonate(body: &str, state: &SharedState) -> String {
scored.truncate(limit);

let results: Vec<String> = scored.iter().map(|&(idx, sim)| {
let (ref id, _, ref _meta): &(String, Fingerprint, HashMap<String, String>) = &db.fingerprints[idx];
let (id, _, _meta) = &db.fingerprints[idx];
format!(r#"{{"index":{},"id":"{}","similarity":{:.6}}}"#, idx, id, sim)
}).collect();

Expand Down Expand Up @@ -758,7 +758,7 @@ fn handle_lance_search(body: &str, state: &SharedState) -> String {
scored.truncate(limit);

let results: Vec<String> = scored.iter().map(|&(idx, dist, sim)| {
let (ref id, _, ref meta): &(String, Fingerprint, HashMap<String, String>) = &db.fingerprints[idx];
let (id, _, meta) = &db.fingerprints[idx];
let text = meta.get("text").cloned().unwrap_or_default();
format!(r#"{{"id":"{}","_distance":{},"_similarity":{:.6},"text":"{}"}}"#,
id, dist, sim, text.replace('"', "'"))
Expand Down
4 changes: 2 additions & 2 deletions src/extensions/spo/jina_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ impl JinaCache {
}

fn save_to_disk(&self) {
if let Some(ref path) = self.cache_path {
if let Some(path) = self.cache_path.as_ref() {
if let Ok(file) = File::create(path) {
let mut writer = BufWriter::new(file);

Expand All @@ -299,7 +299,7 @@ impl JinaCache {
}

fn load_from_disk(&mut self) {
if let Some(ref path) = self.cache_path {
if let Some(path) = self.cache_path.as_ref() {
if let Ok(file) = File::open(path) {
let mut reader = BufReader::new(file);

Expand Down
4 changes: 2 additions & 2 deletions src/fabric/udp_transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ impl UdpReceiver {
}

// Notify callback
if let Some(ref callback) = self.on_result {
if let Some(callback) = self.on_result.as_ref() {
callback(packet.from, result);
}
}
Expand Down Expand Up @@ -400,7 +400,7 @@ impl LaneRouter {
pub fn route(&mut self, packet: FramePacket) -> ExecResult {
let lane_id = packet.frame.header.lane_id as usize;

if let Some(Some(ref mut executor)) = self.lanes.get_mut(lane_id) {
if let Some(Some(executor)) = self.lanes.get_mut(lane_id) {
executor.execute(&packet.frame)
} else {
ExecResult::Error(format!("lane {} not found", lane_id))
Expand Down
10 changes: 5 additions & 5 deletions src/query/cypher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,7 @@ impl CypherTranspiler {
}

// Build SELECT clause
let select_cols = if let Some(ref ret) = query.return_clause {
let select_cols = if let Some(ret) = query.return_clause.as_ref() {
ret.items.iter()
.map(|item| Self::expr_to_sql(&item.expr))
.collect::<Vec<_>>()
Expand All @@ -1102,7 +1102,7 @@ impl CypherTranspiler {
}

// WHERE clause
if let Some(ref where_clause) = query.where_clause {
if let Some(where_clause) = query.where_clause.as_ref() {
where_parts.push(Self::condition_to_sql(&where_clause.condition));
}

Expand All @@ -1111,7 +1111,7 @@ impl CypherTranspiler {
}

// ORDER BY
if let Some(ref order) = query.order_by {
if let Some(order) = query.order_by.as_ref() {
let order_sql = order.items.iter()
.map(|item| {
let dir = if item.direction == SortDirection::Desc { "DESC" } else { "ASC" };
Expand Down Expand Up @@ -1194,7 +1194,7 @@ ORDER BY t.depth, t.amplification DESC
edge_type_filter = edge_type_filter,
max_depth = edge.max_hops,
min_depth = edge.min_hops,
end_label_filter = if let Some(ref end) = end_node {
end_label_filter = if let Some(end) = end_node.as_ref() {
if !end.labels.is_empty() {
format!(" AND n.label = '{}'", end.labels[0])
} else {
Expand All @@ -1203,7 +1203,7 @@ ORDER BY t.depth, t.amplification DESC
} else {
String::new()
},
user_where = if let Some(ref w) = query.where_clause {
user_where = if let Some(w) = query.where_clause.as_ref() {
format!(" AND ({})", Self::condition_to_sql(&w.condition))
} else {
String::new()
Expand Down
10 changes: 5 additions & 5 deletions src/query/hybrid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ impl HybridEngine {
fn execute_graph(&self, query: &HybridQuery, candidates: Vec<(Addr, f32)>) -> Result<Vec<(Addr, f32)>, String> {
match &query.graph {
Some(gc) => {
if let Some(ref parsed) = gc.parsed {
if let Some(parsed) = gc.parsed.as_ref() {
// Apply pattern constraints (simplified - check labels)
Ok(candidates
.into_iter()
Expand All @@ -432,13 +432,13 @@ impl HybridEngine {
fn matches_pattern(&self, addr: Addr, query: &CypherQuery) -> bool {
if let Some(node) = self.bind_space.read(addr) {
// Check label matches if specified in pattern
if let Some(ref match_clause) = query.match_clause {
if let Some(match_clause) = query.match_clause.as_ref() {
for pattern in &match_clause.patterns {
for element in &pattern.elements {
if let PatternElement::Node(node_pat) = element {
for label in &node_pat.labels {
// Check if node has matching label
if let Some(ref node_label) = node.label {
if let Some(node_label) = node.label.as_ref() {
if !node_label.to_lowercase().contains(&label.to_lowercase()) {
return false;
}
Expand Down Expand Up @@ -482,14 +482,14 @@ impl HybridEngine {
for (addr, similarity) in candidates {
if let Some(node) = self.bind_space.read(addr) {
// Apply qualia filter
if let Some(ref qf) = query.qualia {
if let Some(qf) = query.qualia.as_ref() {
if !qf.matches(node.qidx) {
continue;
}
}

// Apply label filter
if let Some(ref label_filter) = query.label_filter {
if let Some(label_filter) = query.label_filter.as_ref() {
match &node.label {
Some(label) if label.contains(label_filter) => {}
_ => continue,
Expand Down
2 changes: 1 addition & 1 deletion src/storage/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ impl Database {
.with_content(&thought.content);

// Add fingerprint if available
let node = if let Some(ref fp) = thought.fingerprint {
let node = if let Some(fp) = thought.fingerprint.as_ref() {
node.with_fingerprint(fp)
} else {
node
Expand Down
16 changes: 8 additions & 8 deletions src/storage/hardening.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ impl WriteAheadLog {
/// Append entry to WAL
pub fn append(&mut self, entry: &WalEntry) -> std::io::Result<()> {
let bytes = entry.to_bytes();
if let Some(ref mut file) = self.file {
if let Some(file) = self.file.as_mut() {
file.write_all(&bytes)?;
self.size += bytes.len();
self.entries_since_checkpoint += 1;
Expand All @@ -436,7 +436,7 @@ impl WriteAheadLog {
/// Perform checkpoint (truncate WAL)
pub fn checkpoint(&mut self) -> std::io::Result<()> {
// Flush and close current file
if let Some(ref mut file) = self.file {
if let Some(file) = self.file.as_mut() {
file.flush()?;
}
self.file = None;
Expand Down Expand Up @@ -752,7 +752,7 @@ impl HardenedBindSpace {
}

// WAL
if let Some(ref wal) = self.wal {
if let Some(wal) = self.wal.as_ref() {
if let Ok(mut wal) = wal.lock() {
let entry = WalEntry::Write {
addr: addr.0,
Expand Down Expand Up @@ -786,7 +786,7 @@ impl HardenedBindSpace {
}

// WAL
if let Some(ref wal) = self.wal {
if let Some(wal) = self.wal.as_ref() {
if let Ok(mut wal) = wal.lock() {
let entry = WalEntry::Delete { addr: addr.0 };
let _ = wal.append(&entry);
Expand All @@ -798,7 +798,7 @@ impl HardenedBindSpace {
/// Record a link
pub fn on_link(&self, from: Addr, verb: Addr, to: Addr) {
// WAL
if let Some(ref wal) = self.wal {
if let Some(wal) = self.wal.as_ref() {
if let Ok(mut wal) = wal.lock() {
let entry = WalEntry::Link {
from: from.0,
Expand Down Expand Up @@ -832,7 +832,7 @@ impl HardenedBindSpace {
}

// Check WAL
if let Some(ref wal) = self.wal {
if let Some(wal) = self.wal.as_ref() {
if let Ok(wal) = wal.lock() {
needs_checkpoint = wal.needs_checkpoint();
}
Expand All @@ -843,7 +843,7 @@ impl HardenedBindSpace {

/// Perform WAL checkpoint
pub fn checkpoint(&self) -> std::io::Result<()> {
if let Some(ref wal) = self.wal {
if let Some(wal) = self.wal.as_ref() {
if let Ok(mut wal) = wal.lock() {
wal.checkpoint()?;
self.metrics.checkpoints.fetch_add(1, Ordering::Relaxed);
Expand All @@ -869,7 +869,7 @@ impl HardenedBindSpace {

/// Recover from WAL
pub fn recover(&self) -> std::io::Result<Vec<WalEntry>> {
if let Some(ref wal) = self.wal {
if let Some(wal) = self.wal.as_ref() {
if let Ok(wal) = wal.lock() {
return wal.recover();
}
Expand Down
2 changes: 1 addition & 1 deletion src/storage/lance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ impl NodeRecord {
let fp_builder = FixedSizeBinaryBuilder::new(FINGERPRINT_BYTES as i32);
let mut fp_array = fp_builder;
for node in nodes {
if let Some(ref fp) = node.fingerprint {
if let Some(fp) = node.fingerprint.as_ref() {
fp_array.append_value(fp)?;
} else {
fp_array.append_null();
Expand Down
2 changes: 1 addition & 1 deletion src/storage/lance_zero_copy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2593,7 +2593,7 @@ impl CsrBuilder {
for neighbors in &self.adj_list {
for &(dst, weight) in neighbors {
edges.push(dst);
if let Some(ref mut w) = weights {
if let Some(w) = weights.as_mut() {
w.push(weight);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/storage/substrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ impl Substrate {
// Promote candidates
for (old_addr, fingerprint, label) in promote_candidates {
// Write to node space
let new_addr = if let Some(ref lbl) = label {
let new_addr = if let Some(lbl) = label.as_ref() {
self.write_labeled(fingerprint, lbl)
} else {
self.write(fingerprint)
Expand Down Expand Up @@ -895,7 +895,7 @@ impl Substrate {
drop(bind_space);

// Write to node space
let new_addr = if let Some(ref lbl) = label {
let new_addr = if let Some(lbl) = label.as_ref() {
self.write_labeled(fingerprint, lbl)
} else {
self.write(fingerprint)
Expand Down