Documentation ¶
Index ¶
- Variables
- func BuildPatternSymbols(ctx *EvalContext, pattern lpg.Pattern) (map[string]*lpg.PatternSymbol, error)
- func EscapeLabelLiteral(s string) string
- func EscapePropertyKeyLiteral(s string) string
- func EscapeStringLiteral(s string) string
- func GetParser(input string) *parser.CypherParser
- func IsNamedResult(name string) bool
- func IsNamedVar(name string) bool
- func IsValuePrimitive(v Value) bool
- func IsValueSame(v, v2 Value) bool
- func RegisterGlobalFunc(fn ...Function)
- func ValueAsBool(v Value) (bool, bool)
- func ValueAsInt(v Value, err ...error) (int, error)
- func ValueAsString(v Value, err ...error) (string, error)
- type Date
- type Duration
- type ErrInvalidAssignment
- type ErrInvalidExpression
- type ErrInvalidFunctionCall
- type ErrInvalidIndirection
- type ErrInvalidValueReferenceInPattern
- type ErrSyntax
- type ErrUnknownFunction
- type ErrUnknownParameter
- type ErrUnknownVariable
- type ErrValueDoesNotHaveProperties
- type EvalContext
- func (ctx *EvalContext) GetFunction(name []string) (Function, error)
- func (ctx *EvalContext) GetParameter(key string) (Value, error)
- func (ctx *EvalContext) GetVar(name string) (Value, error)
- func (ctx *EvalContext) GetVarsNearestScope() map[string]Value
- func (ctx *EvalContext) PropertyValueFromNative(key string, value interface{}) interface{}
- func (ctx *EvalContext) RemoveVar(name string)
- func (ctx *EvalContext) SetParameter(key string, value Value) *EvalContext
- func (ctx *EvalContext) SetVar(name string, value Value)
- func (ctx *EvalContext) SetVars(m map[string]Value)
- func (ctx *EvalContext) SubContext() *EvalContext
- type Evaluatable
- type Expression
- type Function
- type LValue
- type LocalDateTime
- type LocalTime
- type Match
- type NodeLabels
- type Parameter
- type Pattern
- type PatternPart
- type Properties
- type RValue
- type ReadingClause
- type ResultSet
- func (r *ResultSet) Add(rs ResultSet)
- func (r *ResultSet) AddPath(node *lpg.Node, edges []*lpg.Edge)
- func (r *ResultSet) Append(row map[string]Value) error
- func (r ResultSet) CartesianProduct(f func(map[string]Value) bool) bool
- func (r *ResultSet) Column(key string) []Value
- func (r ResultSet) String() string
- func (r *ResultSet) Union(src ResultSet, all bool) error
- type Time
- type UpdatingClause
- type Value
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") ErrStringValueRequired = errors.New("String value required") ErrNeo4jDateValueRequired = errors.New("Neo4j Date value required") ErrNeo4jDateTimeValueRequired = errors.New("Neo4j LocalDateTime 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") 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 lpg.Pattern) (map[string]*lpg.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 IsNamedResult ¶
IsNamedResult checks if the given name is a symbol name (i.e. it does not start with a number)
func IsNamedVar ¶
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 RegisterGlobalFunc ¶
func RegisterGlobalFunc(fn ...Function)
func ValueAsBool ¶
ValueAsBool returns the bool value, or if it is not bool, false,false
func ValueAsInt ¶
ValueAsInt returns the int value. If value is not int, returns ErrIntValueRequired. If an err argument is given, that error is returned.
Types ¶
type Date ¶
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 ErrValueDoesNotHaveProperties ¶
type ErrValueDoesNotHaveProperties struct { Value interface{} Property string }
func (ErrValueDoesNotHaveProperties) Error ¶
func (e ErrValueDoesNotHaveProperties) Error() string
type EvalContext ¶
type EvalContext struct { // If this function is non-nil, it will be called to filter property // values when setting properties of nodes or edges PropertyValueFromNativeFilter func(string, interface{}) interface{} // contains filtered or unexported fields }
func NewEvalContext ¶
func NewEvalContext(graph *lpg.Graph) *EvalContext
func (*EvalContext) GetFunction ¶
func (ctx *EvalContext) GetFunction(name []string) (Function, error)
func (*EvalContext) GetParameter ¶
func (ctx *EvalContext) GetParameter(key string) (Value, error)
func (*EvalContext) GetVarsNearestScope ¶
func (ctx *EvalContext) GetVarsNearestScope() map[string]Value
func (*EvalContext) PropertyValueFromNative ¶
func (ctx *EvalContext) PropertyValueFromNative(key string, value interface{}) interface{}
PropertyValueFromNative calls the ctx.PropertyValueFromNativeFilter to give the caller a chance to change property values
func (*EvalContext) RemoveVar ¶
func (ctx *EvalContext) RemoveVar(name string)
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) SetVars ¶
func (ctx *EvalContext) SetVars(m map[string]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 Function ¶
type Function struct { Name string MinArgs int MaxArgs int Func func(*EvalContext, []Evaluatable) (Value, error) ValueFunc func(*EvalContext, []Value) (Value, error) }
Function describes a function
type LValue ¶
type LValue struct {
// contains filtered or unexported fields
}
LValue is a pointer to a value
type LocalDateTime ¶
func NewLocalDateTime ¶
func NewLocalDateTime(t time.Time) LocalDateTime
NewLocalDateTime creates a LocalDateTime from time.Time.
func (LocalDateTime) String ¶
func (t LocalDateTime) String() string
func (LocalDateTime) Time ¶
func (t LocalDateTime) Time() time.Time
Time casts LocalDateTime to time.Time
type LocalTime ¶
func NewLocalTime ¶
NewLocalTime creates a LocalTime from time.Time. Year, month and day are set to zero and location is set to local.
type Match ¶
type Match struct { Optional bool Pattern Pattern Where Expression }
func (Match) GetResults ¶
func (match Match) GetResults(ctx *EvalContext) (ResultSet, error)
type NodeLabels ¶
type NodeLabels []schemaName
type Pattern ¶
type Pattern struct {
Parts []PatternPart
}
type PatternPart ¶
type PatternPart struct {
// contains filtered or unexported fields
}
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) (*lpg.Node, *lpg.Path, error)
func (PatternPart) FindRelative ¶
func (p PatternPart) FindRelative(this *lpg.Node) ([]*lpg.Node, error)
FindRelative evaluates a pattern expression starting at the given node. It may return zero or more nodes reached from the node
type Properties ¶
type Properties struct { Map *mapLiteral Param *Parameter }
func (Properties) AsLiteral ¶
func (properties Properties) AsLiteral(ctx *EvalContext) ([]mapKeyValue, error)
type ReadingClause ¶
type ReadingClause interface {
GetResults(*EvalContext) (ResultSet, error)
}
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 NewResultSet ¶
func NewResultSet() *ResultSet
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 UpdatingClause ¶
type UpdatingClause interface { Update(*EvalContext, ResultSet) (Value, error) TopLevelUpdate(*EvalContext) (Value, error) }
type Value ¶
type Value interface { Evaluatable Get() interface{} IsConst() bool }
func ParseAndEvaluate ¶
func ParseAndEvaluate(input string, ctx *EvalContext) (Value, error)