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

Method convert_logical_node

graphlite/src/plan/operators/physical.rs:481–1122  ·  view source on GitHub ↗

Convert a logical node to physical node

(logical: &LogicalNode)

Source from the content-addressed store, hash-verified

479
480 /// Convert a logical node to physical node
481 fn convert_logical_node(logical: &LogicalNode) -> PhysicalNode {
482 match logical {
483 LogicalNode::NodeScan {
484 variable,
485 labels,
486 properties,
487 } => {
488 let estimated_rows = 1000; // Should use statistics
489 let estimated_cost = estimated_rows as f64 * 0.1;
490
491 // Choose between sequential and index scan based on selectivity
492 if labels.is_empty() {
493 PhysicalNode::NodeSeqScan {
494 variable: variable.clone(),
495 labels: labels.clone(),
496 properties: properties.clone(),
497 estimated_rows,
498 estimated_cost,
499 }
500 } else {
501 PhysicalNode::NodeIndexScan {
502 variable: variable.clone(),
503 labels: labels.clone(),
504 properties: properties.clone(),
505 estimated_rows: estimated_rows / 10, // More selective
506 estimated_cost: estimated_cost * 0.5, // Cheaper with index
507 }
508 }
509 }
510
511 LogicalNode::EdgeScan {
512 variable,
513 labels,
514 properties,
515 } => {
516 let estimated_rows = 5000;
517 let estimated_cost = estimated_rows as f64 * 0.1;
518
519 PhysicalNode::EdgeSeqScan {
520 variable: variable.clone(),
521 labels: labels.clone(),
522 properties: properties.clone(),
523 estimated_rows,
524 estimated_cost,
525 }
526 }
527
528 LogicalNode::Expand {
529 from_variable,
530 edge_variable,
531 to_variable,
532 edge_labels,
533 direction,
534 properties,
535 input,
536 } => {
537 let input_physical = Box::new(Self::convert_logical_node(input));
538 let input_rows = input_physical.get_row_count();

Callers

nothing calls this directly

Calls 6

cloneMethod · 0.80
get_row_countMethod · 0.80
get_costMethod · 0.80
is_emptyMethod · 0.45
iterMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected