Documentation
¶
Index ¶
- Variables
- func BuildPatternSymbols(ctx *EvalContext, pattern graph.Pattern) (map[string]*graph.PatternSymbol, error)
- func EscapeLabelLiteral(s string) string
- func EscapePropertyKeyLiteral(s string) string
- func EscapeStringLiteral(s string) string
- func GetParser(input string) *parser.CypherParser
- func IsValuePrimitive(v Value) bool
- func IsValueSame(v, v2 Value) bool
- func ValueAsBool(v Value) (bool, bool)
- type Atom
- type BooleanLiteral
- type Case
- type CaseAlternative
- type CountAtom
- type DoubleLiteral
- type ErrInvalidAssignment
- type ErrInvalidExpression
- type ErrInvalidFunctionCall
- type ErrInvalidIndirection
- type ErrInvalidValueReferenceInPattern
- type ErrSyntax
- type ErrUnknownFunction
- type ErrUnknownParameter
- type ErrUnknownVariable
- type EvalContext
- func (ctx *EvalContext) GetFunction(name []SymbolicName) (Function, error)
- func (ctx *EvalContext) GetParameter(key string) (Value, error)
- func (ctx *EvalContext) GetVar(name string) (Value, error)
- func (ctx *EvalContext) SetParameter(key string, value Value) *EvalContext
- func (ctx *EvalContext) SetVar(name string, value Value)
- func (ctx *EvalContext) SubContext() *EvalContext
- type Evaluatable
- type Expression
- type Filter
- type FilterAtom
- type FilterExpression
- type Function
- type FunctionInvocation
- type IntLiteral
- type LValue
- type ListComprehension
- type ListLiteral
- type ListRangeExpression
- type MapKeyValue
- type MapLiteral
- type Match
- type MultiplyDivideModuloExpression
- type MultiplyDivideModuloExpressionPart
- type NodeLabels
- type NodePattern
- type NullLiteral
- type Order
- type Parameter
- type Pattern
- type PatternChain
- type PatternComprehension
- type PatternPart
- type PowerOfExpression
- type ProjectionBody
- type ProjectionItem
- type ProjectionItems
- type Properties
- type PropertyOrLabelsExpression
- type RValue
- type RangeLiteral
- type ReadingClause
- type RegularQuery
- type RelationshipPattern
- type RelationshipTypes
- type RelationshipsPattern
- type ReservedWord
- type ResultSet
- func (r *ResultSet) Add(rs ResultSet)
- func (r *ResultSet) AddPath(node graph.Node, edges []graph.Edge)
- func (r *ResultSet) Append(row map[string]Value) error
- func (r ResultSet) CartesianProduct(f func(map[string]Value) bool) bool
- func (r ResultSet) String() string
- func (r *ResultSet) Union(src ResultSet, all bool) error
- type ReturnClause
- type SchemaName
- type SortItem
- type StringListNullOperatorExpression
- type StringListNullOperatorExpressionPart
- type StringLiteral
- type StringOperatorExpression
- type SymbolicName
- type UnaryAddOrSubtractExpression
- type UpdatingClause
- type Value
- type Variable
Constants ¶
This section is empty.
Variables ¶
var ( ErrDivideByZero = errors.New("Divide by zero") ErrInvalidUnaryOperation = errors.New("Invalid unary operation") ErrInvalidPowerOperation = errors.New("Invalid power operation") ErrInvalidMultiplicativeOperation = errors.New("Invalid multiplicative operation") ErrInvalidDurationOperation = errors.New("Invalid duration operation") ErrOperationWithNull = errors.New("Operation with null") ErrInvalidStringOperation = errors.New("Invalid string operation") ErrInvalidDateOperation = errors.New("Invalid date operation") ErrInvalidAdditiveOperation = errors.New("Invalid additive operation") ErrInvalidComparison = errors.New("Invalid comparison") ErrInvalidListIndex = errors.New("Invalid list index") ErrNotAList = errors.New("Not a list") ErrNotABooleanExpression = errors.New("Not a boolean expression") ErrMapKeyNotString = errors.New("Map key is not a string") ErrInvalidMapKey = errors.New("Invalid map key") ErrNotAStringSet = errors.New("Not a string set") ErrIntValueRequired = errors.New("Int value required") ErrExpectingResultSet = errors.New("Expecting a result set") ErrPropertiesParameterExpected = errors.New("Parameter value cannot be used for properties") ErrPropertiesExpected = errors.New("Value cannot be used for properties") ErrValueDoesNotHaveProperties = errors.New("Value does not have properties") ErrNotAnLValue = errors.New("Not and lvalue") )
var ErrIncompatibleCells = errors.New("Incompatible result set cells")
var ErrRowsHaveDifferentSizes = errors.New("Rows have different sizes")
Functions ¶
func BuildPatternSymbols ¶
func BuildPatternSymbols(ctx *EvalContext, pattern graph.Pattern) (map[string]*graph.PatternSymbol, error)
BuildPatternSymbols copies all the symbols referenced in the pattern from the context, and puts them in a map
func EscapeLabelLiteral ¶
EscapeLabelLiteral escape a literal that can be used as a label. It returns `s`
func EscapePropertyKeyLiteral ¶
EscapePropertyKeyLiteral escapes a literal that can be used as a property key. Returns `s`
func EscapeStringLiteral ¶
EscapeStringLiteral returns "s" where backslashes and quotes in s are escaped
func GetParser ¶
func GetParser(input string) *parser.CypherParser
GetParser returns a parser that will parse the input string
func IsValuePrimitive ¶
IsValuePrimitive returns true if the value is int, float64, bool, string, duration, date, datetime, localDateTime, or localTime
func IsValueSame ¶
IsValueSame compares two values and decides if the two are the same
func ValueAsBool ¶
ValueAsBool returns the bool value, or if it is not bool, false,false
Types ¶
type Atom ¶
type Atom interface {
Evaluatable
}
type BooleanLiteral ¶
type BooleanLiteral bool
func (BooleanLiteral) Evaluate ¶
func (literal BooleanLiteral) Evaluate(ctx *EvalContext) (Value, error)
type Case ¶
type Case struct {
Test Expression
Alternatives []CaseAlternative
Default Expression
}
type CaseAlternative ¶
type CaseAlternative struct {
When Expression
Then Expression
}
type DoubleLiteral ¶
type DoubleLiteral float64
func (DoubleLiteral) Evaluate ¶
func (literal DoubleLiteral) Evaluate(ctx *EvalContext) (Value, error)
type ErrInvalidAssignment ¶
type ErrInvalidAssignment string
func (ErrInvalidAssignment) Error ¶
func (e ErrInvalidAssignment) Error() string
type ErrInvalidExpression ¶
type ErrInvalidExpression string
func (ErrInvalidExpression) Error ¶
func (e ErrInvalidExpression) Error() string
type ErrInvalidFunctionCall ¶
type ErrInvalidFunctionCall struct {
Msg string
}
func (ErrInvalidFunctionCall) Error ¶
func (e ErrInvalidFunctionCall) Error() string
type ErrInvalidIndirection ¶
type ErrInvalidIndirection string
func (ErrInvalidIndirection) Error ¶
func (e ErrInvalidIndirection) Error() string
type ErrInvalidValueReferenceInPattern ¶
type ErrInvalidValueReferenceInPattern struct {
Symbol string
}
func (ErrInvalidValueReferenceInPattern) Error ¶
func (e ErrInvalidValueReferenceInPattern) Error() string
type ErrUnknownFunction ¶
type ErrUnknownFunction struct {
Name string
}
func (ErrUnknownFunction) Error ¶
func (e ErrUnknownFunction) Error() string
type ErrUnknownParameter ¶
type ErrUnknownParameter struct {
Key string
}
func (ErrUnknownParameter) Error ¶
func (e ErrUnknownParameter) Error() string
type ErrUnknownVariable ¶
type ErrUnknownVariable struct {
Name string
}
func (ErrUnknownVariable) Error ¶
func (e ErrUnknownVariable) Error() string
type EvalContext ¶
type EvalContext struct {
// contains filtered or unexported fields
}
func NewEvalContext ¶
func NewEvalContext(graph graph.Graph) *EvalContext
func (*EvalContext) GetFunction ¶
func (ctx *EvalContext) GetFunction(name []SymbolicName) (Function, error)
func (*EvalContext) GetParameter ¶
func (ctx *EvalContext) GetParameter(key string) (Value, error)
func (*EvalContext) SetParameter ¶
func (ctx *EvalContext) SetParameter(key string, value Value) *EvalContext
SetParameter sets a parameter to be used in expressions
func (*EvalContext) SetVar ¶
func (ctx *EvalContext) SetVar(name string, value Value)
func (*EvalContext) SubContext ¶
func (ctx *EvalContext) SubContext() *EvalContext
SubContext creates a new subcontext with a new variable set
type Evaluatable ¶
type Evaluatable interface {
Evaluate(*EvalContext) (Value, error)
}
func Parse ¶
func Parse(input string) (Evaluatable, error)
GetEvaluatable returns an evaluatable object
type Expression ¶
type Expression interface {
Evaluatable
}
type FilterAtom ¶
type FilterAtom struct {
Op string
Filter FilterExpression
}
func (FilterAtom) Evaluate ¶
func (flt FilterAtom) Evaluate(ctx *EvalContext) (Value, error)
type FilterExpression ¶
type FilterExpression struct {
Variable Variable
InExpr Expression
Where Expression
}
type Function ¶
type Function func(*EvalContext, []Evaluatable) (Value, error)
type FunctionInvocation ¶
type FunctionInvocation struct {
Name []SymbolicName
Distinct bool
Args []Expression
// contains filtered or unexported fields
}
func (*FunctionInvocation) Evaluate ¶
func (f *FunctionInvocation) Evaluate(ctx *EvalContext) (Value, error)
type IntLiteral ¶
type IntLiteral int
func DecimalInteger ¶
func DecimalInteger(ctx antlr.TerminalNode) IntLiteral
func (IntLiteral) Evaluate ¶
func (literal IntLiteral) Evaluate(ctx *EvalContext) (Value, error)
type LValue ¶
type LValue struct {
// contains filtered or unexported fields
}
LValue is a pointer to a value
type ListComprehension ¶
type ListComprehension struct {
Filter FilterExpression
Expr Expression
}
func (ListComprehension) Evaluate ¶
func (ls ListComprehension) Evaluate(ctx *EvalContext) (Value, error)
type ListLiteral ¶
type ListLiteral struct {
Values []Expression
// contains filtered or unexported fields
}
func (*ListLiteral) Evaluate ¶
func (lst *ListLiteral) Evaluate(ctx *EvalContext) (Value, error)
type ListRangeExpression ¶
type ListRangeExpression struct {
First Expression
Second Expression
}
type MapKeyValue ¶
type MapKeyValue struct {
Key string
Value Expression
}
type MapLiteral ¶
type MapLiteral struct {
KeyValues []MapKeyValue
// contains filtered or unexported fields
}
func (*MapLiteral) Evaluate ¶
func (mp *MapLiteral) Evaluate(ctx *EvalContext) (Value, error)
type Match ¶
type Match struct {
Optional bool
Pattern Pattern
Where Expression
}
func (Match) GetResults ¶
func (match Match) GetResults(ctx *EvalContext) (ResultSet, error)
type MultiplyDivideModuloExpression ¶
type MultiplyDivideModuloExpression struct {
Parts []MultiplyDivideModuloExpressionPart
// contains filtered or unexported fields
}
func (*MultiplyDivideModuloExpression) Evaluate ¶
func (expr *MultiplyDivideModuloExpression) Evaluate(ctx *EvalContext) (Value, error)
type MultiplyDivideModuloExpressionPart ¶
type MultiplyDivideModuloExpressionPart struct {
// For the first element of parts, Op=0
Op rune
Expr Evaluatable
}
type NodeLabels ¶
type NodeLabels []SchemaName
type NodePattern ¶
type NodePattern struct {
Var *Variable
Labels *NodeLabels
Properties *Properties
}
func (NodePattern) Create ¶
func (np NodePattern) Create(ctx *EvalContext) (string, graph.Node, error)
type NullLiteral ¶
type NullLiteral struct{}
func (NullLiteral) Evaluate ¶
func (literal NullLiteral) Evaluate(ctx *EvalContext) (Value, error)
type Pattern ¶
type Pattern struct {
Parts []PatternPart
}
type PatternChain ¶
type PatternChain struct {
Rel RelationshipPattern
Node NodePattern
}
type PatternComprehension ¶
type PatternComprehension struct {
Var *Variable
Rel RelationshipsPattern
Where Expression
Expr Expression
}
func (PatternComprehension) Evaluate ¶
func (p PatternComprehension) Evaluate(ctx *EvalContext) (Value, error)
type PatternPart ¶
type PatternPart struct {
Var *Variable
Start NodePattern
Path []PatternChain
}
func ParsePatternExpr ¶
func ParsePatternExpr(expr string) (PatternPart, error)
ParsePatternExpr parses the pattern expression that starts at the current node named 'this', and describes a path reaching one or more nodes named 'target'. For instance:
(this)-[]->(target)
will return all nodes reachable from the current node by one step.
This expression:
(this)<[a]-()-[]->(target :x)
will start from the current node, go back one nore following an edge with label `a`, and then move to a node with label `x`
func (PatternPart) Create ¶
func (part PatternPart) Create(ctx *EvalContext) error
func (PatternPart) FindRelative ¶
FindRelative evaluates a pattern expression starting at the given node. It may return zero or more nodes reached from the node
type PowerOfExpression ¶
type PowerOfExpression struct {
Parts []Evaluatable
// contains filtered or unexported fields
}
func (*PowerOfExpression) Evaluate ¶
func (expr *PowerOfExpression) Evaluate(ctx *EvalContext) (Value, error)
type ProjectionBody ¶
type ProjectionBody struct {
Distinct bool
Items ProjectionItems
Order *Order
Skip Expression
Limit Expression
}
type ProjectionItem ¶
type ProjectionItem struct {
Var *Variable
Expr Expression
}
type ProjectionItems ¶
type ProjectionItems struct {
All bool
Items []ProjectionItem
}
func (ProjectionItems) Project ¶
func (prj ProjectionItems) Project(ctx *EvalContext, values map[string]Value) (map[string]Value, error)
type Properties ¶
type Properties struct {
Map *MapLiteral
Param *Parameter
}
func (Properties) AsLiteral ¶
func (properties Properties) AsLiteral(ctx *EvalContext) ([]MapKeyValue, error)
type PropertyOrLabelsExpression ¶
type PropertyOrLabelsExpression struct {
Atom Atom
PropertyLookup []SchemaName
NodeLabels *NodeLabels
}
func (PropertyOrLabelsExpression) Evaluate ¶
func (pl PropertyOrLabelsExpression) Evaluate(ctx *EvalContext) (Value, error)
type RangeLiteral ¶
type RangeLiteral struct {
From, To *IntLiteral
}
func (*RangeLiteral) Evaluate ¶
func (r *RangeLiteral) Evaluate(ctx *EvalContext) (from, to *int, err error)
type ReadingClause ¶
type ReadingClause interface {
GetResults(*EvalContext) (ResultSet, error)
}
type RegularQuery ¶
type RegularQuery struct {
SingleQuery Evaluatable
Unions []union
}
func (RegularQuery) Evaluate ¶
func (query RegularQuery) Evaluate(ctx *EvalContext) (Value, error)
Evaluate a regular query, which is a single query with an optional union list
type RelationshipPattern ¶
type RelationshipPattern struct {
ToLeft bool
ToRight bool
Var *Variable
RelTypes *RelationshipTypes
Range *RangeLiteral
Properties *Properties
}
func (RelationshipPattern) Create ¶
func (rel RelationshipPattern) Create(ctx *EvalContext, from, to graph.Node) (graph.Edge, error)
type RelationshipTypes ¶
type RelationshipTypes struct {
Rel []SchemaName
}
type RelationshipsPattern ¶
type RelationshipsPattern struct {
Start NodePattern
Chain []PatternChain
}
func (RelationshipsPattern) Evaluate ¶
func (rel RelationshipsPattern) Evaluate(ctx *EvalContext) (Value, error)
type ReservedWord ¶
type ReservedWord string
type ResultSet ¶
ResultSet is a table of values
func CartesianProduct ¶
func CartesianProduct(resultsets []ResultSet, all bool, filter func(map[string]Value) bool) ResultSet
CartesianProuduct builds the product of all the resultsets
func (ResultSet) CartesianProduct ¶
CartesianProduct calls f with all permutations of rows until f returns false. The map passed to f is reused, so copy if you need a copy of it.
type ReturnClause ¶
type ReturnClause struct {
Projection ProjectionBody
}
type SchemaName ¶
type SchemaName struct {
*SymbolicName
*ReservedWord
}
func (SchemaName) String ¶
func (s SchemaName) String() string
type SortItem ¶
type SortItem struct {
Asc bool
Expr Expression
}
type StringListNullOperatorExpression ¶
type StringListNullOperatorExpression struct {
PropertyOrLabels PropertyOrLabelsExpression
Parts []StringListNullOperatorExpressionPart
}
func (StringListNullOperatorExpression) Evaluate ¶
func (expr StringListNullOperatorExpression) Evaluate(ctx *EvalContext) (Value, error)
type StringListNullOperatorExpressionPart ¶
type StringListNullOperatorExpressionPart struct {
String *StringOperatorExpression
ListIn Expression
ListIndex Expression
ListRange *ListRangeExpression
IsNull *bool
}
type StringLiteral ¶
type StringLiteral string
func (StringLiteral) Evaluate ¶
func (literal StringLiteral) Evaluate(ctx *EvalContext) (Value, error)
type StringOperatorExpression ¶
type StringOperatorExpression struct {
Operator string
Expr Expression
}
type SymbolicName ¶
type SymbolicName string
type UnaryAddOrSubtractExpression ¶
type UnaryAddOrSubtractExpression struct {
Neg bool
Expr StringListNullOperatorExpression
// contains filtered or unexported fields
}
func (*UnaryAddOrSubtractExpression) Evaluate ¶
func (expr *UnaryAddOrSubtractExpression) Evaluate(ctx *EvalContext) (Value, error)
type UpdatingClause ¶
type UpdatingClause interface {
Update(*EvalContext, ResultSet) (Value, error)
TopLevelUpdate(*EvalContext) error
}
type Value ¶
type Value interface {
Evaluatable
Get() interface{}
IsConst() bool
}
func ParseAndEvaluate ¶
func ParseAndEvaluate(input string, ctx *EvalContext) (Value, error)
type Variable ¶
type Variable SymbolicName