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

Method convert_rows_to_processor_format

graphlite/src/exec/executor.rs:1634–1728  ·  view source on GitHub ↗

Convert Vec to the format expected by WithClauseProcessor

(
        &self,
        input_rows: Vec<Row>,
    )

Source from the content-addressed store, hash-verified

1632
1633 /// Convert Vec<Row> to the format expected by WithClauseProcessor
1634 fn convert_rows_to_processor_format(
1635 &self,
1636 input_rows: Vec<Row>,
1637 ) -> Result<
1638 (
1639 std::collections::HashMap<String, Vec<crate::storage::Node>>,
1640 Vec<crate::storage::Edge>,
1641 ),
1642 ExecutionError,
1643 > {
1644 use crate::storage::Edge;
1645 use std::collections::HashMap;
1646
1647 let mut variable_bindings = HashMap::new();
1648 let mut edges = Vec::new();
1649
1650 // Extract variables for nodes and edges - we need to handle both node references and property accesses
1651 for row in input_rows.iter() {
1652 // First collect all variables (keys without dots)
1653 let mut vars = std::collections::HashSet::new();
1654 let mut edge_vars = std::collections::HashSet::new();
1655
1656 for key in row.values.keys() {
1657 if !key.contains('.') {
1658 // Check if this variable represents an edge (common patterns: t, r, e, rel)
1659 // Also check for variables that have an associated .amount property (likely transaction edges)
1660 if key == "t"
1661 || key == "r"
1662 || key == "e"
1663 || key == "rel"
1664 || row.values.contains_key(&format!("{}.amount", key))
1665 {
1666 edge_vars.insert(key.clone());
1667 } else {
1668 vars.insert(key.clone());
1669 }
1670 }
1671 }
1672
1673 // For each edge variable, create an edge with properties from the row
1674 for edge_var in &edge_vars {
1675 // Create a synthetic edge for aggregation purposes
1676 let mut edge_props = HashMap::new();
1677
1678 // Collect properties for this edge
1679 for (key, value) in &row.values {
1680 if key.starts_with(&format!("{}.", edge_var)) {
1681 let property_name = key.strip_prefix(&format!("{}.", edge_var)).unwrap();
1682 edge_props.insert(property_name.to_string(), value.clone());
1683 } else if key == edge_var {
1684 // If the edge variable itself has a value (like t: Number),
1685 // treat it as the amount for Transaction edges
1686 if let crate::storage::Value::Number(_amount) = value {
1687 edge_props.insert("amount".to_string(), value.clone());
1688 }
1689 }
1690 }
1691

Callers 1

Calls 8

containsMethod · 0.80
cloneMethod · 0.80
unwrapMethod · 0.80
iterMethod · 0.45
contains_keyMethod · 0.45
insertMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected