opencypher

package
v1.0.0-beta10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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")
)
View Source
var ErrIncompatibleCells = errors.New("Incompatible result set cells")
View Source
var ErrRowsHaveDifferentSizes = errors.New("Rows have different sizes")

Functions

func GetParser

func GetParser(input string) *parser.CypherParser

GetParser returns a parser that will parse the input string

Types

type AddOrSubtractExpression

type AddOrSubtractExpression struct {
	Add []MultiplyDivideModuloExpression
	Sub []MultiplyDivideModuloExpression
	// contains filtered or unexported fields
}

func (*AddOrSubtractExpression) Evaluate

func (expr *AddOrSubtractExpression) Evaluate(ctx *EvalContext) (Value, error)

type AndExpression

type AndExpression struct {
	Parts []Evaluatable
}

func (AndExpression) Evaluate

func (expr AndExpression) Evaluate(ctx *EvalContext) (Value, error)

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
}

func (Case) Evaluate

func (cs Case) Evaluate(ctx *EvalContext) (Value, error)

type CaseAlternative

type CaseAlternative struct {
	When Expression
	Then Expression
}

type ComparisonExpression

type ComparisonExpression struct {
	First  Expression
	Second []PartialComparisonExpression
}

func (ComparisonExpression) Evaluate

func (expr ComparisonExpression) Evaluate(ctx *EvalContext) (Value, error)

type CountAtom

type CountAtom struct{}

func (CountAtom) Evaluate

func (cnt CountAtom) Evaluate(ctx *EvalContext) (Value, error)

type DoubleLiteral

type DoubleLiteral float64

func (DoubleLiteral) Evaluate

func (literal DoubleLiteral) Evaluate(ctx *EvalContext) (Value, error)

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 ErrInvalidValueReferenceInPattern

type ErrInvalidValueReferenceInPattern struct {
	Symbol string
}

func (ErrInvalidValueReferenceInPattern) Error

type ErrSyntax

type ErrSyntax string

func (ErrSyntax) Error

func (e ErrSyntax) 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) GetVar

func (ctx *EvalContext) GetVar(name 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 Filter

type Filter struct {
}

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 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 MultiPartQuery

type MultiPartQuery struct {
	Parts       []MultiPartQueryPart
	SingleQuery SinglePartQuery
}

func (MultiPartQuery) Evaluate

func (mq MultiPartQuery) Evaluate(ctx *EvalContext) (Value, error)

type MultiPartQueryPart

type MultiPartQueryPart struct {
	Read   []ReadingClause
	Update []UpdatingClause
	With   WithClause
}

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 PowerOfExpression
}

type NodeLabels

type NodeLabels []SchemaName

type NodePattern

type NodePattern struct {
	Var        *Variable
	Labels     *NodeLabels
	Properties *Properties
}

type NotExpression

type NotExpression struct {
	Part ComparisonExpression
}

func (NotExpression) Evaluate

func (expr NotExpression) Evaluate(ctx *EvalContext) (Value, error)

type NullLiteral

type NullLiteral struct{}

func (NullLiteral) Evaluate

func (literal NullLiteral) Evaluate(ctx *EvalContext) (Value, error)

type OrExpression

type OrExpression struct {
	Parts []Evaluatable
}

func (OrExpression) Evaluate

func (expr OrExpression) Evaluate(ctx *EvalContext) (Value, error)

type Order

type Order struct {
	Items []SortItem
}

type Parameter

type Parameter string

func (Parameter) Evaluate

func (expr Parameter) Evaluate(ctx *EvalContext) (Value, error)

type PartialComparisonExpression

type PartialComparisonExpression struct {
	Op   string
	Expr AddOrSubtractExpression
}

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
}

type PowerOfExpression

type PowerOfExpression struct {
	Parts []UnaryAddOrSubtractExpression
	// 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 {
	Backwards  bool
	Var        *Variable
	RelTypes   *RelationshipTypes
	Range      *RangeLiteral
	Properties *Properties
}

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

type ResultSet struct {
	Nodes graph.NodeSet
	Edges graph.EdgeSet

	Rows []map[string]Value
}

ResultSet is a table of values

func (*ResultSet) Add

func (r *ResultSet) Add(rs ResultSet)

func (*ResultSet) AddPath

func (r *ResultSet) AddPath(node graph.Node, edges []graph.Edge)

func (*ResultSet) Append

func (r *ResultSet) Append(row map[string]Value) error

Append the row to the resultset.

func (ResultSet) String

func (r ResultSet) String() string

func (*ResultSet) Union

func (r *ResultSet) Union(src ResultSet, all bool) error

Union adds the src resultset to this. If all is set, it adds all rows, otherwise, it adds unique rows

type ReturnClause

type ReturnClause struct {
	Projection ProjectionBody
}

type SchemaName

type SchemaName struct {
	*SymbolicName
	*ReservedWord
}

func (SchemaName) String

func (s SchemaName) String() string

type SinglePartQuery

type SinglePartQuery struct {
	Read   []ReadingClause
	Update []UpdatingClause
	Return *ReturnClause
}

func (SinglePartQuery) Evaluate

func (query SinglePartQuery) Evaluate(ctx *EvalContext) (Value, error)

type SortItem

type SortItem struct {
	Asc  bool
	Expr Expression
}

type StringListNullOperatorExpression

type StringListNullOperatorExpression struct {
	PropertyOrLabels PropertyOrLabelsExpression
	Parts            []StringListNullOperatorExpressionPart
}

func (StringListNullOperatorExpression) Evaluate

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 Union

type Union struct {
	All         bool
	SingleQuery Evaluatable
}

type Unwind

type Unwind struct {
	Expr Expression
	As   Variable
}

func (Unwind) GetResults

func (unwind Unwind) GetResults(ctx *EvalContext) (ResultSet, error)

type UpdatingClause

type UpdatingClause interface {
	Evaluatable
}

type Value

type Value struct {
	Value    interface{}
	Constant bool
}

Value represents a computer value. Possible data types it can contain are:

 primitives:
  int
  float64
  bool
  string
  neo4j.Duration
  neo4j.Date
  neo4j.LocalDateTime
  neo4j.LocalTime

composites:
  []Value
  map[string]Value
  graph.StringSet
  Node
  []Edge
  ResultSet

func ParseAndEvaluate

func ParseAndEvaluate(input string, ctx *EvalContext) (Value, error)

func ValueOf

func ValueOf(in interface{}) Value

func (Value) AsBool

func (v Value) AsBool() (bool, bool)

AsBool returns the bool value, or if it is not bool, false,false

func (Value) Evaluate

func (v Value) Evaluate(ctx *EvalContext) (Value, error)

func (Value) IsPrimitive

func (v Value) IsPrimitive() bool

IsPrimitive returns true if the value is int, float64, bool, string, duration, date, datetime, localDateTime, or localTime

func (Value) IsSame

func (v Value) IsSame(v2 Value) bool

IsSame compares two values and decides if the two are the same

func (Value) String

func (v Value) String() string

type Variable

type Variable SymbolicName

func (Variable) Evaluate

func (v Variable) Evaluate(ctx *EvalContext) (Value, error)

type WithClause

type WithClause struct {
	Projection ProjectionBody
	Where      Expression
}

type XorExpression

type XorExpression struct {
	Parts []Evaluatable
}

func (XorExpression) Evaluate

func (expr XorExpression) Evaluate(ctx *EvalContext) (Value, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL