Documentation
¶
Overview ¶
Package matchers provides pattern matching functionality for Cypher queries. It implements the MATCH clause execution by traversing the graph and finding nodes and relationships that match the specified patterns.
The matcher supports:
- Node pattern matching with labels and properties
- Relationship pattern matching with types and directions
- Path traversal through the graph
- WHERE clause filtering
- Property comparisons
Example:
matcher := matchers.NewMatcher(store, index)
rows, columns, err := matcher.ExecuteMatch(matchStmt, params)
if err != nil {
log.Fatal(err)
}
for _, row := range rows {
fmt.Println(row)
}
Index ¶
- func ToFloat64(v interface{}) (float64, bool)
- func ToInt64(v interface{}) (int64, bool)
- type Matcher
- func (m *Matcher) EvaluateExpression(path map[string]interface{}, expr ast.Expr, params map[string]interface{}) bool
- func (m *Matcher) EvaluateExpressionWithContext(path map[string]interface{}, expr ast.Expr, params map[string]interface{}, ...) bool
- func (m *Matcher) ExecuteMatch(stmt *ast.MatchStmt, params map[string]interface{}) (rows []map[string]interface{}, columns []string, err error)
- func (m *Matcher) ExecuteMatchWithContext(stmt *ast.MatchStmt, params map[string]interface{}, ...) (rows []map[string]interface{}, columns []string, err error)
- func (m *Matcher) ExecutePathForMerge(path *ast.PathExpr, params map[string]interface{}) ([]map[string]interface{}, error)
- func (m *Matcher) ExecuteUnwind(stmt *ast.UnwindStmt, params map[string]interface{}) (rows []map[string]interface{}, columns []string, err error)
- func (m *Matcher) ProcessReturnStmt(rows []map[string]interface{}, returnExpr *ast.ReturnExpr) ([]map[string]interface{}, []string, error)
- func (m *Matcher) PropertyToInterface(prop graph.PropertyValue) interface{}
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Matcher ¶
type Matcher struct {
// Store is the underlying storage database.
Store *storage.DB
// Index provides efficient lookups for nodes and relationships.
Index *graph.Index
}
Matcher executes pattern matching for Cypher MATCH queries. It traverses the graph to find nodes and relationships that match the specified patterns.
func NewMatcher ¶
NewMatcher creates a new Matcher instance.
Parameters:
- store: The storage database
- index: The graph index for efficient lookups
Returns a new Matcher instance.
Example:
matcher := matchers.NewMatcher(store, index)
func NewMatcherForMerge ¶ added in v0.2.0
NewMatcherForMerge creates a new Matcher for MERGE operations. This is an alias for NewMatcher.
Parameters:
- store: The storage database
- index: The graph index for efficient lookups
Returns a new Matcher instance.
func (*Matcher) EvaluateExpression ¶
func (m *Matcher) EvaluateExpression(path map[string]interface{}, expr ast.Expr, params map[string]interface{}) bool
EvaluateExpression evaluates a WHERE clause expression against a path.
Parameters:
- path: The matched path containing nodes and relationships
- expr: The expression to evaluate
- params: Query parameters
Returns true if the expression evaluates to true for the given path.
func (*Matcher) EvaluateExpressionWithContext ¶ added in v0.2.3
func (*Matcher) ExecuteMatch ¶ added in v0.2.0
func (m *Matcher) ExecuteMatch(stmt *ast.MatchStmt, params map[string]interface{}) (rows []map[string]interface{}, columns []string, err error)
ExecuteMatch executes a MATCH statement and returns the matched rows.
Parameters:
- stmt: The MATCH statement AST node
- params: Query parameters for parameterized queries
Returns the matched rows, column names, and any error encountered.
Example:
rows, columns, err := matcher.ExecuteMatch(matchStmt, map[string]interface{}{
"name": "Alice",
})
func (*Matcher) ExecuteMatchWithContext ¶ added in v0.2.3
func (*Matcher) ExecutePathForMerge ¶ added in v0.2.0
func (*Matcher) ExecuteUnwind ¶ added in v0.2.3
func (*Matcher) ProcessReturnStmt ¶ added in v0.2.3
func (*Matcher) PropertyToInterface ¶
func (m *Matcher) PropertyToInterface(prop graph.PropertyValue) interface{}
PropertyToInterface converts a PropertyValue to a Go interface{}. Delegates to graph.PropertyValue.InterfaceValue().