diff --git a/.gitignore b/.gitignore index a64211fa..a63cd6c6 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,5 @@ other_data/ *.jsonl !examples/rag_demo/** test-store/ +helixdb-cfg/ diff --git a/clippy_check.sh b/clippy_check.sh index dd9fa0b3..7ed22ee5 100644 --- a/clippy_check.sh +++ b/clippy_check.sh @@ -1 +1 @@ -cargo clippy --workspace --locked -- -D warnings -A clippy::too_many_arguments -A clippy::let-and-return -A clippy::module-inception -A clippy::new-ret-no-self -A clippy::wrong-self-convention -A clippy::large-enum-variant -A clippy::inherent-to-string -A clippy::inherent_to_string_shadow_display \ No newline at end of file +cargo clippy --workspace --locked -- -D warnings -A clippy::too_many_arguments -A clippy::let-and-return -A clippy::module-inception -A clippy::new-ret-no-self -A clippy::wrong-self-convention -A clippy::large-enum-variant -A clippy::inherent-to-string -A clippy::inherent_to_string_shadow_display diff --git a/helix-container/src/queries.rs b/helix-container/src/queries.rs index a38f25ca..6b7b3d61 100644 --- a/helix-container/src/queries.rs +++ b/helix-container/src/queries.rs @@ -4,3 +4,4 @@ use helix_db::helix_engine::graph_core::config::Config; pub fn config() -> Option { None } + diff --git a/helix-db/src/helix_engine/bm25/bm25.rs b/helix-db/src/helix_engine/bm25/bm25.rs index b564819a..34529e33 100644 --- a/helix-db/src/helix_engine/bm25/bm25.rs +++ b/helix-db/src/helix_engine/bm25/bm25.rs @@ -5,6 +5,7 @@ use crate::{ vector_core::{hnsw::HNSW, vector::HVector}, }, protocol::value::Value, + debug_println, }; use heed3::{types::*, Database, Env, RoTxn, RwTxn}; @@ -335,6 +336,8 @@ impl BM25 for HBM25Config { results.sort_by(|a, b| b.1.partial_cmp(&a.1).unwrap_or(std::cmp::Ordering::Equal)); results.truncate(limit); + debug_println!("found {} results in bm25 search", results.len()); + Ok(results) } } @@ -429,6 +432,7 @@ impl BM25Flatten for HashMap { s.push_str(k); s.push(' '); s.push_str(&v.to_string()); + s.push(' '); s }) } diff --git a/helix-db/src/helix_engine/graph_core/ops/source/add_n.rs b/helix-db/src/helix_engine/graph_core/ops/source/add_n.rs index 93c8eecf..2aa3c05e 100644 --- a/helix-db/src/helix_engine/graph_core/ops/source/add_n.rs +++ b/helix-db/src/helix_engine/graph_core/ops/source/add_n.rs @@ -98,14 +98,13 @@ impl<'a, 'b, I: Iterator>> AddNAdapter<' } } - if let Some(bm25) = &self.storage.bm25 { - if let Some(props) = node.properties.as_ref() { + if let Some(bm25) = &self.storage.bm25 + && let Some(props) = node.properties.as_ref() { let mut data = props.flatten_bm25(); data.push_str(&node.label); if let Err(e) = bm25.insert_doc(self.txn, node.id, &data) { result = Err(e); } - } } if result.is_ok() { diff --git a/helix-db/src/helix_engine/graph_core/ops/util/drop.rs b/helix-db/src/helix_engine/graph_core/ops/util/drop.rs index a3f71473..3985103f 100644 --- a/helix-db/src/helix_engine/graph_core/ops/util/drop.rs +++ b/helix-db/src/helix_engine/graph_core/ops/util/drop.rs @@ -25,10 +25,9 @@ where match item { TraversalVal::Node(node) => match storage.drop_node(txn, &node.id) { Ok(_) => { - if let Some(bm25) = &storage.bm25 { - if let Err(e) = bm25.delete_doc(txn, node.id) { + if let Some(bm25) = &storage.bm25 + && let Err(e) = bm25.delete_doc(txn, node.id) { println!("failed to delete doc from bm25: {e}"); - } } println!("Dropped node: {:?}", node.id); Ok(()) diff --git a/helix-db/src/helix_engine/graph_core/ops/util/update.rs b/helix-db/src/helix_engine/graph_core/ops/util/update.rs index bd00d77f..f428bd7c 100644 --- a/helix-db/src/helix_engine/graph_core/ops/util/update.rs +++ b/helix-db/src/helix_engine/graph_core/ops/util/update.rs @@ -58,8 +58,8 @@ impl<'scope, 'env, I: Iterator>> UpdateA if let Some(ref props) = props { for (key, _new_value) in props.iter() { - if let Some(db) = storage.secondary_indices.get(key) { - if let Some(old_value) = properties.get(key) { + if let Some(db) = storage.secondary_indices.get(key) + && let Some(old_value) = properties.get(key) { match bincode::serialize(old_value) { Ok(old_serialized) => { if let Err(e) = db.delete_one_duplicate( @@ -73,7 +73,6 @@ impl<'scope, 'env, I: Iterator>> UpdateA Err(e) => vec.push(Err(GraphError::from(e))), } } - } } } @@ -128,13 +127,12 @@ impl<'scope, 'env, I: Iterator>> UpdateA Ok(TraversalVal::Edge(edge)) => match storage.get_edge(self.txn, &edge.id) { Ok(old_edge) => { let mut old_edge = old_edge.clone(); - if let Some(mut properties) = old_edge.properties.clone() { - if let Some(ref props) = props { + if let Some(mut properties) = old_edge.properties.clone() + && let Some(ref props) = props { for (k, v) in props.iter() { properties.insert(k.clone(), v.clone()); } old_edge.properties = Some(properties); - } } match old_edge.encode_edge() { Ok(serialized) => { diff --git a/helix-db/src/helix_engine/vector_core/utils.rs b/helix-db/src/helix_engine/vector_core/utils.rs index 064e40a1..b6734d1d 100644 --- a/helix-db/src/helix_engine/vector_core/utils.rs +++ b/helix-db/src/helix_engine/vector_core/utils.rs @@ -124,14 +124,11 @@ impl VectorFilter for BinaryHeap { None => None, // TODO: maybe should be an error? }; - if SHOULD_CHECK_DELETED { - if let Ok(is_deleted) = item.check_property("is_deleted") { - if let Value::Boolean(is_deleted) = is_deleted.as_ref() { - if *is_deleted { + if SHOULD_CHECK_DELETED + && let Ok(is_deleted) = item.check_property("is_deleted") + && let Value::Boolean(is_deleted) = is_deleted.as_ref() + && *is_deleted { continue; - } - } - } } if item.label() == label diff --git a/helix-db/src/helix_gateway/builtin/all_nodes_and_edges.rs b/helix-db/src/helix_gateway/builtin/all_nodes_and_edges.rs index 9608bd2b..d502571b 100644 --- a/helix-db/src/helix_gateway/builtin/all_nodes_and_edges.rs +++ b/helix-db/src/helix_gateway/builtin/all_nodes_and_edges.rs @@ -144,11 +144,10 @@ fn get_all_nodes_edges_json( if let Some(prop) = &node_label { let node = Node::decode_node(value, id)?; - if let Some(props) = node.properties { - if let Some(prop_value) = props.get(prop) { + if let Some(props) = node.properties + && let Some(prop_value) = props.get(prop) { json_node["label"] = sonic_rs::to_value(&prop_value.to_string()) .unwrap_or_else(|_| sonic_rs::Value::from("")); - } } } nodes.push(json_node); diff --git a/helix-db/src/helixc/analyzer/methods/graph_step_validation.rs b/helix-db/src/helixc/analyzer/methods/graph_step_validation.rs index b347914d..6fded19f 100644 --- a/helix-db/src/helixc/analyzer/methods/graph_step_validation.rs +++ b/helix-db/src/helixc/analyzer/methods/graph_step_validation.rs @@ -359,10 +359,9 @@ pub(crate) fn apply_graph_step<'a>( cur_ty.kind_str() ); } - if let Some(ref ty) = sv.vector_type { - if !ctx.vector_set.contains(ty.as_str()) { + if let Some(ref ty) = sv.vector_type + && !ctx.vector_set.contains(ty.as_str()) { generate_error!(ctx, original_query, sv.loc.clone(), E103, ty.as_str()); - } } let vec = match &sv.data { Some(VectorData::Vector(v)) => { diff --git a/helix-db/src/helixc/analyzer/methods/infer_expr_type.rs b/helix-db/src/helixc/analyzer/methods/infer_expr_type.rs index 8123a97e..ed9ae6a1 100644 --- a/helix-db/src/helixc/analyzer/methods/infer_expr_type.rs +++ b/helix-db/src/helixc/analyzer/methods/infer_expr_type.rs @@ -715,10 +715,9 @@ pub(crate) fn infer_expr_type<'a>( // Type::Vector(add.vector_type.as_deref()) // } SearchVector(sv) => { - if let Some(ref ty) = sv.vector_type { - if !ctx.vector_set.contains(ty.as_str()) { + if let Some(ref ty) = sv.vector_type + && !ctx.vector_set.contains(ty.as_str()) { generate_error!(ctx, original_query, sv.loc.clone(), E103, ty.as_str()); - } } let vec: VecData = match &sv.data { Some(VectorData::Vector(v)) => { @@ -980,8 +979,8 @@ pub(crate) fn infer_expr_type<'a>( Empty => (Type::Unknown, Some(GeneratedStatement::Empty)), BM25Search(bm25_search) => { // TODO: look into how best do type checking for type passed in - if let Some(ref ty) = bm25_search.type_arg { - if !ctx.node_set.contains(ty.as_str()) { + if let Some(ref ty) = bm25_search.type_arg + && !ctx.node_set.contains(ty.as_str()) { generate_error!( ctx, original_query, @@ -989,7 +988,6 @@ pub(crate) fn infer_expr_type<'a>( E101, ty.as_str() ); - } } let vec = match &bm25_search.data { Some(ValueType::Literal { value, loc: _ }) => { diff --git a/helix-db/src/helixc/analyzer/methods/migration_validation.rs b/helix-db/src/helixc/analyzer/methods/migration_validation.rs index cd41c467..3e9fb21c 100644 --- a/helix-db/src/helixc/analyzer/methods/migration_validation.rs +++ b/helix-db/src/helixc/analyzer/methods/migration_validation.rs @@ -130,19 +130,17 @@ pub(crate) fn validate_migration(ctx: &mut Ctx, migration: &Migration) { } // check default value is valid for the new field type - if let Some(default) = &default { - if to_property_field.field_type != *default { + if let Some(default) = &default + && to_property_field.field_type != *default { // schema error - default value is not valid for the new field type panic!("default value is not valid for the new field type"); - } } // check the cast is valid for the new field type - if let Some(cast) = &cast { - if to_property_field.field_type != cast.cast_to { + if let Some(cast) = &cast + && to_property_field.field_type != cast.cast_to { // schema error - cast is not valid for the new field type panic!("cast is not valid for the new field type"); - } } // // warnings if name is same diff --git a/helix-db/src/helixc/analyzer/methods/query_validation.rs b/helix-db/src/helixc/analyzer/methods/query_validation.rs index 0a6eb3e0..f9151e82 100644 --- a/helix-db/src/helixc/analyzer/methods/query_validation.rs +++ b/helix-db/src/helixc/analyzer/methods/query_validation.rs @@ -38,8 +38,8 @@ pub(crate) fn validate_query<'a>(ctx: &mut Ctx<'a>, original_query: &'a Query) { // Parameter validation // ------------------------------------------------- for param in &original_query.parameters { - if let FieldType::Identifier(ref id) = param.param_type.1 { - if is_valid_identifier(ctx, original_query, param.param_type.0.clone(), id.as_str()) { + if let FieldType::Identifier(ref id) = param.param_type.1 + && is_valid_identifier(ctx, original_query, param.param_type.0.clone(), id.as_str()) { // TODO: add support for edges if !ctx.node_set.contains(id.as_str()) { generate_error!( @@ -51,7 +51,6 @@ pub(crate) fn validate_query<'a>(ctx: &mut Ctx<'a>, original_query: &'a Query) { ¶m.name.1 ); } - } } // constructs parameters and sub‑parameters for generator GeneratedParameter::unwrap_param( diff --git a/helix-db/src/helixc/analyzer/methods/traversal_validation.rs b/helix-db/src/helixc/analyzer/methods/traversal_validation.rs index 484a7c32..3f56583a 100644 --- a/helix-db/src/helixc/analyzer/methods/traversal_validation.rs +++ b/helix-db/src/helixc/analyzer/methods/traversal_validation.rs @@ -89,19 +89,17 @@ pub(crate) fn validate_traversal<'a>( ); } else if let ValueType::Literal { ref value, ref loc } = *value - { - if !field.field_type.eq(value) { - generate_error!( - ctx, - original_query, - loc.clone(), - E205, - &value.to_string(), - &field.field_type.to_string(), - "node", - node_type - ); - } + && !field.field_type.eq(value) { + generate_error!( + ctx, + original_query, + loc.clone(), + E205, + &value.to_string(), + &field.field_type.to_string(), + "node", + node_type + ); } } None => { @@ -291,10 +289,9 @@ pub(crate) fn validate_traversal<'a>( parent } StartNode::SearchVector(sv) => { - if let Some(ref ty) = sv.vector_type { - if !ctx.vector_set.contains(ty.as_str()) { + if let Some(ref ty) = sv.vector_type + && !ctx.vector_set.contains(ty.as_str()) { generate_error!(ctx, original_query, sv.loc.clone(), E103, ty.as_str()); - } } let vec: VecData = match &sv.data { Some(VectorData::Vector(v)) => { @@ -1055,10 +1052,9 @@ pub(crate) fn validate_traversal<'a>( } StepType::AddEdge(add) => { - if let Some(ref ty) = add.edge_type { - if !ctx.edge_map.contains_key(ty.as_str()) { + if let Some(ref ty) = add.edge_type + && !ctx.edge_map.contains_key(ty.as_str()) { generate_error!(ctx, original_query, add.loc.clone(), E102, ty); - } } cur_ty = Type::Edges(add.edge_type.clone()); excluded.clear(); @@ -1077,8 +1073,8 @@ pub(crate) fn validate_traversal<'a>( scope, i.as_str(), ); - if let Some(ty) = ty { - if !ty.is_integer() { + if let Some(ty) = ty + && !ty.is_integer() { generate_error!( ctx, original_query, @@ -1088,12 +1084,11 @@ pub(crate) fn validate_traversal<'a>( [i.as_str()] ); return cur_ty.clone(); // Not sure if this should be here - } }; let ty = type_in_scope(ctx, original_query, end.loc.clone(), scope, j.as_str()); - if let Some(ty) = ty { - if !ty.is_integer() { + if let Some(ty) = ty + && !ty.is_integer() { generate_error!( ctx, original_query, @@ -1103,7 +1098,6 @@ pub(crate) fn validate_traversal<'a>( [j.as_str()] ); return cur_ty.clone(); // Not sure if this should be here - } } ( gen_identifier_or_param(original_query, i.as_str(), false, true), @@ -1124,8 +1118,8 @@ pub(crate) fn validate_traversal<'a>( scope, i.as_str(), ); - if let Some(ty) = ty { - if !ty.is_integer() { + if let Some(ty) = ty + && !ty.is_integer() { generate_error!( ctx, original_query, @@ -1135,7 +1129,6 @@ pub(crate) fn validate_traversal<'a>( [i.as_str()] ); return cur_ty.clone(); // Not sure if this should be here - } } ( @@ -1147,8 +1140,8 @@ pub(crate) fn validate_traversal<'a>( is_valid_identifier(ctx, original_query, end.loc.clone(), j.as_str()); let ty = type_in_scope(ctx, original_query, end.loc.clone(), scope, j.as_str()); - if let Some(ty) = ty { - if !ty.is_integer() { + if let Some(ty) = ty + && !ty.is_integer() { generate_error!( ctx, original_query, @@ -1158,7 +1151,6 @@ pub(crate) fn validate_traversal<'a>( [j.as_str()] ); return cur_ty.clone(); - } } ( GeneratedValue::Primitive(GenRef::Std(i.to_string())), diff --git a/helix-db/src/helixc/generator/queries.rs b/helix-db/src/helixc/generator/queries.rs index f1bbca26..613b1282 100644 --- a/helix-db/src/helixc/generator/queries.rs +++ b/helix-db/src/helixc/generator/queries.rs @@ -120,3 +120,4 @@ impl Display for Parameter { } } } + diff --git a/hql-tests/file14/file14.hx b/hql-tests/file14/file14.hx index 02dd2ab5..4ae458f1 100644 --- a/hql-tests/file14/file14.hx +++ b/hql-tests/file14/file14.hx @@ -6,3 +6,4 @@ N::File14 { QUERY file14() => res <- SearchBM25("John", 10) RETURN res +