MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / execute_node_seq_scan_with_graph

Method execute_node_seq_scan_with_graph

graphlite/src/exec/executor.rs:3901–3995  ·  view source on GitHub ↗

Execute a sequential node scan with specific graph

(
        &self,
        variable: &str,
        labels: &[String],
        properties: Option<&HashMap<String, Expression>>,
        _context: &mut ExecutionContext,
        graph: &Arc<GraphCache>,

Source from the content-addressed store, hash-verified

3899
3900 /// Execute a sequential node scan with specific graph
3901 fn execute_node_seq_scan_with_graph(
3902 &self,
3903 variable: &str,
3904 labels: &[String],
3905 properties: Option<&HashMap<String, Expression>>,
3906 _context: &mut ExecutionContext,
3907 graph: &Arc<GraphCache>,
3908 ) -> Result<Vec<Row>, ExecutionError> {
3909 let mut rows = Vec::new();
3910
3911 // Get nodes by label (if label specified, otherwise all nodes)
3912 let nodes = if labels.is_empty() {
3913 graph.get_all_nodes()
3914 } else {
3915 // For simplicity, just use the first label
3916 graph.get_nodes_by_label(&labels[0])
3917 };
3918
3919 // Create a row for each node that matches property filters
3920 for node in nodes {
3921 // Check property filters if specified
3922 if let Some(property_filters) = properties {
3923 let mut matches_all_properties = true;
3924
3925 for (prop_name, expected_expr) in property_filters {
3926 // Evaluate the expected value expression
3927 let expected_value = match expected_expr {
3928 Expression::Literal(literal) => self.literal_to_value(literal),
3929 Expression::Variable(var) => {
3930 // For variables, we'd need to look them up in context
3931 // For now, treat as string literal of the variable name
3932 Value::String(var.name.clone())
3933 }
3934 _ => {
3935 // For complex expressions, skip this property check for now
3936 continue;
3937 }
3938 };
3939
3940 // Check if the node has this property with the expected value
3941 match node.properties.get(prop_name) {
3942 Some(actual_value) => {
3943 if actual_value != &expected_value {
3944 matches_all_properties = false;
3945 break;
3946 }
3947 }
3948 None => {
3949 // Node doesn't have this property
3950 matches_all_properties = false;
3951 break;
3952 }
3953 }
3954 }
3955
3956 // Skip this node if it doesn't match all property filters
3957 if !matches_all_properties {
3958 continue;

Callers 1

Calls 9

get_all_nodesMethod · 0.80
get_nodes_by_labelMethod · 0.80
cloneMethod · 0.80
with_entityMethod · 0.80
NodeClass · 0.50
is_emptyMethod · 0.45
literal_to_valueMethod · 0.45
getMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected