Documentation
¶
Overview ¶
Package semantic contains the semantic analysis required to have a senantically valid parser. It includes the data conversion required to turn tokens into valid BadWolf structures. It also provides the hooks implementations required for buliding an actionable execution plan.
Index ¶
- func ToLiteral(ce ConsumedElement) (*literal.Literal, error)
- func ToNode(ce ConsumedElement) (*node.Node, error)
- func ToPredicate(ce ConsumedElement) (*predicate.Predicate, error)
- type AlwaysReturn
- type ClauseHook
- func GroupByBindingsChecker() ClauseHook
- func HavingExpressionBuilder() ClauseHook
- func OrderByBindingsChecker() ClauseHook
- func TypeBindingClauseHook(t StatementType) ClauseHook
- func VarBindingsGraphChecker() ClauseHook
- func WhereInitWorkingClauseHook() ClauseHook
- func WhereNextWorkingClauseHook() ClauseHook
- type ConsumedElement
- type ElementHook
- func CollectGlobalBounds() ElementHook
- func DataAccumulatorHook() ElementHook
- func GraphAccumulatorHook() ElementHook
- func GroupByBindings() ElementHook
- func HavingExpression() ElementHook
- func LimitCollection() ElementHook
- func OrderByBindings() ElementHook
- func VarAccumulatorHook() ElementHook
- func WhereObjectClauseHook() ElementHook
- func WherePredicateClauseHook() ElementHook
- func WhereSubjectClauseHook() ElementHook
- type Evaluator
- type GraphClause
- type OP
- type Projection
- type Statement
- func (s *Statement) AddData(d *triple.Triple)
- func (s *Statement) AddGraph(g string)
- func (s *Statement) AddWorkingGrpahClause()
- func (s *Statement) AddWorkingProjection()
- func (s *Statement) BindType(st StatementType)
- func (s *Statement) Bindings() []string
- func (s *Statement) BindingsMap() map[string]int
- func (s *Statement) Data() []*triple.Triple
- func (s *Statement) GlobalLookupOptions() *storage.LookupOptions
- func (s *Statement) GraphPatternClauses() []*GraphClause
- func (s *Statement) Graphs() []string
- func (s *Statement) GroupByBindings() []string
- func (s *Statement) HasHavingClause() bool
- func (s *Statement) HavingEvaluator() Evaluator
- func (s *Statement) InputBindings() []string
- func (s *Statement) IsLimitSet() bool
- func (s *Statement) Limit() int64
- func (s *Statement) OrderByConfig() table.SortConfig
- func (s *Statement) OutputBindings() []string
- func (s *Statement) Projections() []*Projection
- func (s *Statement) ResetProjection()
- func (s *Statement) ResetWorkingGraphClause()
- func (s *Statement) SortedGraphPatternClauses() []*GraphClause
- func (s *Statement) Type() StatementType
- func (s *Statement) WorkingClause() *GraphClause
- func (s *Statement) WorkingProjection() *Projection
- type StatementType
- type Symbol
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToLiteral ¶
func ToLiteral(ce ConsumedElement) (*literal.Literal, error)
ToLiteral converts the node found by the lexer and converts it into a BadWolf literal.
func ToNode ¶
func ToNode(ce ConsumedElement) (*node.Node, error)
ToNode converts the node found by the lexer and converts it into a BadWolf node.
func ToPredicate ¶
func ToPredicate(ce ConsumedElement) (*predicate.Predicate, error)
ToPredicate converts the node found by the lexer and converts it into a BadWolf predicate.
Types ¶
type AlwaysReturn ¶
type AlwaysReturn struct {
V bool
}
AlwaysReturn evaluator always return the provided boolean value.
type ClauseHook ¶
type ClauseHook func(*Statement, Symbol) (ClauseHook, error)
ClauseHook is a function hook for the parser that gets called on clause wide events.
func GroupByBindingsChecker ¶
func GroupByBindingsChecker() ClauseHook
GroupByBindingsChecker returns the singleton to check that the group by bindings are valid.
func HavingExpressionBuilder ¶
func HavingExpressionBuilder() ClauseHook
HavingExpressionBuilder returns the singleton to collect the tokens that form the having clause.
func OrderByBindingsChecker ¶
func OrderByBindingsChecker() ClauseHook
OrderByBindingsChecker returns the singleton to check that the group by bindings are valid.
func TypeBindingClauseHook ¶
func TypeBindingClauseHook(t StatementType) ClauseHook
TypeBindingClauseHook returns a ClauseHook that sets the binding type.
func VarBindingsGraphChecker ¶
func VarBindingsGraphChecker() ClauseHook
VarBindingsGraphChecker returns the singleton for checking a query statement for valid bidings in the select variables.
func WhereInitWorkingClauseHook ¶
func WhereInitWorkingClauseHook() ClauseHook
WhereInitWorkingClauseHook returns the singleton for graph accumulation.
func WhereNextWorkingClauseHook ¶
func WhereNextWorkingClauseHook() ClauseHook
WhereNextWorkingClauseHook returns the singleton for graph accumulation.
type ConsumedElement ¶
type ConsumedElement struct {
// contains filtered or unexported fields
}
ConsumedElement groups the curernt element being processed by the parser.
func NewConsumedSymbol ¶
func NewConsumedSymbol(s Symbol) ConsumedElement
NewConsumedSymbol create a new consumed element that boxes a symbol.
func NewConsumedToken ¶
func NewConsumedToken(tkn *lexer.Token) ConsumedElement
NewConsumedToken create a new consumed element that boxes a roken.
func (ConsumedElement) IsSymbol ¶
func (c ConsumedElement) IsSymbol() bool
IsSymbol returns true if the boxed element is a symbol; false otherwise.
func (ConsumedElement) Symbol ¶
func (c ConsumedElement) Symbol() Symbol
Symbol returns the boxed symbol.
func (ConsumedElement) Token ¶
func (c ConsumedElement) Token() *lexer.Token
Token returns the boxed token.
type ElementHook ¶
type ElementHook func(*Statement, ConsumedElement) (ElementHook, error)
ElementHook is a function hook for the parser that gets called after an Element is confused.
func CollectGlobalBounds ¶
func CollectGlobalBounds() ElementHook
CollectGlobalBounds returns the global temporary bounds hook.
func DataAccumulatorHook ¶
func DataAccumulatorHook() ElementHook
DataAccumulatorHook returns the singleton for data accumulation.
func GraphAccumulatorHook ¶
func GraphAccumulatorHook() ElementHook
GraphAccumulatorHook returns the singleton for graph accumulation.
func GroupByBindings ¶
func GroupByBindings() ElementHook
GroupByBindings returns the singleton for collecting all the group by bidings.
func HavingExpression ¶
func HavingExpression() ElementHook
HavingExpression returns the singleton to collect the tokens that form the having clause.
func LimitCollection ¶
func LimitCollection() ElementHook
LimitCollection returns the limit collection hook.
func OrderByBindings ¶
func OrderByBindings() ElementHook
OrderByBindings returns the singleton for collecting all the group by bidings.
func VarAccumulatorHook ¶
func VarAccumulatorHook() ElementHook
VarAccumulatorHook returns the singleton for accumulating variable projections.
func WhereObjectClauseHook ¶
func WhereObjectClauseHook() ElementHook
WhereObjectClauseHook returns the singleton for working clause hooks that populates the object.
func WherePredicateClauseHook ¶
func WherePredicateClauseHook() ElementHook
WherePredicateClauseHook returns the singleton for working clause hooks that populates the predicate.
func WhereSubjectClauseHook ¶
func WhereSubjectClauseHook() ElementHook
WhereSubjectClauseHook returns the singleton for working clause hooks that populates the subject.
type Evaluator ¶
type Evaluator interface { // Evaluate computes the boolean value of the expression given a certain // restults table row. It will return an // error if it could not be evaluated for the provided table row. Evaluate(r table.Row) (bool, error) }
Evaluator interface computes the evaluation of a boolean expression.
func NewBinaryBooleanExpression ¶
NewBinaryBooleanExpression creates a new binary boolean evalautor.
func NewEvaluationExpression ¶
NewEvaluationExpression creates a new evaluator for two bindings in a row.
func NewEvaluator ¶
func NewEvaluator(ce []ConsumedElement) (Evaluator, error)
NewEvaluator construct an evaluator given a sequence of tokens. It will return a descriptive error if it could build it properly.
type GraphClause ¶
type GraphClause struct { S *node.Node SBinding string SAlias string STypeAlias string SIDAlias string P *predicate.Predicate PID string PBinding string PAlias string PIDAlias string PAnchorBinding string PAnchorAlias string PLowerBound *time.Time PUpperBound *time.Time PLowerBoundAlias string PUpperBoundAlias string PTemporal bool O *triple.Object OBinding string OAlias string OID string OTypeAlias string OIDAlias string OAnchorBinding string OAnchorAlias string OLowerBound *time.Time OUpperBound *time.Time OLowerBoundAlias string OUpperBoundAlias string OTemporal bool }
GraphClause represents a clause of a graph pattern in a where clause.
func (*GraphClause) Bindings ¶
func (c *GraphClause) Bindings() []string
Bindings returns the list of unique bindings listed int he graph clause.
func (*GraphClause) BindingsMap ¶
func (c *GraphClause) BindingsMap() map[string]int
BindingsMap returns the binding map fo he graph clause.
func (*GraphClause) IsEmpty ¶
func (c *GraphClause) IsEmpty() bool
IsEmpty will return true if the are no set values in the clause.
type Projection ¶
type Projection struct { Binding string Alias string OP lexer.TokenType // The information about what function to use. Modifier lexer.TokenType // The modifier for the selected op. }
Projection contails the information required to project the outcome of querying with GraphClauses. It also contains the information of what aggregation function should be used.
func (*Projection) IsEmpty ¶
func (p *Projection) IsEmpty() bool
IsEmpty check if the given projection is empty.
func (*Projection) String ¶
func (p *Projection) String() string
String returns a readable form of the projection.
type Statement ¶
type Statement struct {
// contains filtered or unexported fields
}
Statement contains all the semantic information extract from the parsing
func (*Statement) AddGraph ¶
AddGraph adds a graph to a given https://critique.corp.google.com/#review/101398527statement.
func (*Statement) AddWorkingGrpahClause ¶
func (s *Statement) AddWorkingGrpahClause()
AddWorkingGrpahClause add the current working graph clause to the set of clauses that form the graph pattern.
func (*Statement) AddWorkingProjection ¶
func (s *Statement) AddWorkingProjection()
AddWorkingProjection add the current projection variableto the set of projects that this statement.
func (*Statement) BindType ¶
func (s *Statement) BindType(st StatementType)
BindType set he type of a statement.
func (*Statement) Bindings ¶
Bindings retuns the list of bindings available on the graph clauses for he statement.
func (*Statement) BindingsMap ¶
BindingsMap retuns the set of bindings available on the graph clauses for he statement.
func (*Statement) GlobalLookupOptions ¶
func (s *Statement) GlobalLookupOptions() *storage.LookupOptions
GlobalLookupOptions returns the global lookup options available in the statement.
func (*Statement) GraphPatternClauses ¶
func (s *Statement) GraphPatternClauses() []*GraphClause
GraphPatternClauses return the list of graph pattern clauses
func (*Statement) GroupByBindings ¶
GroupByBindings returns the bindings used on the group by statement.
func (*Statement) HasHavingClause ¶
HasHavingClause returns true if there is a having clause.
func (*Statement) HavingEvaluator ¶
HavingEvaluator returns the evaluator constructed for the provided having clause.
func (*Statement) InputBindings ¶
InputBindings returns the list of incomming binding feed from a where clause.
func (*Statement) IsLimitSet ¶
IsLimitSet returns true if the limit is set.
func (*Statement) OrderByConfig ¶
func (s *Statement) OrderByConfig() table.SortConfig
OrderByConfig returns the sort configuration specified by the order by statement.
func (*Statement) OutputBindings ¶
OutputBindings returns the list of binding that a query will return.
func (*Statement) Projections ¶
func (s *Statement) Projections() []*Projection
Projections returns all the available projections.
func (*Statement) ResetProjection ¶
func (s *Statement) ResetProjection()
ResetProjection resets the current working variable projection.
func (*Statement) ResetWorkingGraphClause ¶
func (s *Statement) ResetWorkingGraphClause()
ResetWorkingGraphClause resets the current working graph clause.
func (*Statement) SortedGraphPatternClauses ¶
func (s *Statement) SortedGraphPatternClauses() []*GraphClause
SortedGraphPatternClauses return the list of graph pattern clauses
func (*Statement) Type ¶
func (s *Statement) Type() StatementType
Type returns the type of the statement.
func (*Statement) WorkingClause ¶
func (s *Statement) WorkingClause() *GraphClause
WorkingClause returns the current working clause.
func (*Statement) WorkingProjection ¶
func (s *Statement) WorkingProjection() *Projection
WorkingProjection returns the current working variable projection.
type StatementType ¶
type StatementType int8
StatementType describes the type of statement being represented.
const ( // Query statement. Query StatementType = iota // Insert statemrnt. Insert // Delete statement. Delete // Create statement. Create // Drop statement. Drop )
func (StatementType) String ¶
func (t StatementType) String() string
String provides a readable version of the StatementType.