interpreter

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package interpreter contains the EQL interpreter.

Index

Constants

View Source
const GroupNodeKind = "group"

GroupNodeKind is a special group node kind

Variables

View Source
var (
	ErrNotARegex        = errors.New("Value of operand is not a valid regex")
	ErrNotANumber       = errors.New("Value of operand is not a number")
	ErrNotAList         = errors.New("Value of operand is not a list")
	ErrInvalidConstruct = errors.New("Invalid construct")
	ErrUnknownNodeKind  = errors.New("Unknown node kind")
	ErrInvalidSpec      = errors.New("Invalid traversal spec")
	ErrInvalidWhere     = errors.New("Invalid where clause")
	ErrInvalidColData   = errors.New("Invalid column data spec")
	ErrEmptyTraversal   = errors.New("Empty traversal")
)

Runtime related error types

Functions

This section is empty.

Types

type CondRuntime

type CondRuntime interface {

	/*
	   CondEval evaluates this condition runtime element.
	*/
	CondEval(node data.Node, edge data.Edge) (interface{}, error)
}

CondRuntime is a component of a condition which can be evaluated with a node and an edge.

type FuncShow

type FuncShow interface {
	// contains filtered or unexported methods
}

FuncShow is the interface definition for show related functions

type FuncShowInst

type FuncShowInst func(astNode *parser.ASTNode, rtp *eqlRuntimeProvider) (FuncShow, string, string, error)

FuncShowInst creates a function object. Returns which column data should be queried and how the colummn should be named.

type FuncWhere

type FuncWhere func(astNode *parser.ASTNode, rtp *eqlRuntimeProvider,
	node data.Node, edge data.Edge) (interface{}, error)

FuncWhere represents a where related function.

type GetRuntimeProvider

type GetRuntimeProvider struct {
	// contains filtered or unexported fields
}

GetRuntimeProvider data structure

func NewGetRuntimeProvider

func NewGetRuntimeProvider(name string, part string, gm *graph.Manager, ni NodeInfo) *GetRuntimeProvider

NewGetRuntimeProvider creates a new GetRuntimeProvider object. This provider can interpret GET queries.

func (*GetRuntimeProvider) Runtime

func (rtp *GetRuntimeProvider) Runtime(node *parser.ASTNode) parser.Runtime

Runtime returns a runtime component for a given ASTNode.

type LookupRuntimeProvider

type LookupRuntimeProvider struct {
	// contains filtered or unexported fields
}

LookupRuntimeProvider data structure

func NewLookupRuntimeProvider

func NewLookupRuntimeProvider(name string, part string, gm *graph.Manager, ni NodeInfo) *LookupRuntimeProvider

NewLookupRuntimeProvider creates a new LookupRuntimeProvider object. This provider can interpret LOOKUP queries.

func (*LookupRuntimeProvider) Runtime

func (rtp *LookupRuntimeProvider) Runtime(node *parser.ASTNode) parser.Runtime

Runtime returns a runtime component for a given ASTNode.

type NodeInfo

type NodeInfo interface {
	/*
		SummaryAttributes returns the attributes which should be shown
		in a list view for a given node kind.
	*/
	SummaryAttributes(kind string) []string

	/*
	   Return the display string for a given attribute.
	*/
	AttributeDisplayString(kind string, attr string) string

	/*
		Check if a given string can be a valid node attribute.
	*/
	IsValidAttr(attr string) bool
}

NodeInfo interface. NodeInfo objects are used by the EQL interpreter to format search results.

func NewDefaultNodeInfo

func NewDefaultNodeInfo(gm *graph.Manager) NodeInfo

NewDefaultNodeInfo creates a new default NodeInfo instance. The default NodeInfo provides the most generic rendering information to the interpreter.

type ResultError

type ResultError struct {
	Source string // Name of the source which was given to the parser
	Type   error  // Error type (to be used for equal checks)
	Detail string // Details of this error
}

ResultError is a result related error (e.g. wrong defined show clause)

func (*ResultError) Error

func (re *ResultError) Error() string

Error returns a human-readable string representation of this error.

type RuntimeError

type RuntimeError struct {
	Source string          // Name of the source which was given to the parser
	Type   error           // Error type (to be used for equal checks)
	Detail string          // Details of this error
	Node   *parser.ASTNode // AST Node where the error occurred
	Line   int             // Line of the error
	Pos    int             // Position of the error
}

RuntimeError is a runtime related error

func (*RuntimeError) Error

func (re *RuntimeError) Error() string

Error returns a human-readable string representation of this error.

type SearchHeader

type SearchHeader struct {
	ResPrimaryKind string   // Primary node kind
	ResPartition   string   // Partition of result
	ColLabels      []string // Labels for columns
	ColFormat      []string // Format for columns
	ColData        []string // Data which should be displayed in the columns
}

SearchHeader is the header of a search result.

func (*SearchHeader) Data

func (sh *SearchHeader) Data() []string

Data returns the data which is displayed in each column of a search result. (e.g. 1:n:name - Name of starting nodes,

3:e:key  - Key of edge traversed in the second traversal)

func (*SearchHeader) Format

func (sh *SearchHeader) Format() []string

Format returns all column format definitions of a search result.

func (*SearchHeader) Labels

func (sh *SearchHeader) Labels() []string

Labels returns all column labels of a search result.

func (*SearchHeader) Partition

func (sh *SearchHeader) Partition() string

Partition returns the partition of a search result.

func (*SearchHeader) PrimaryKind

func (sh *SearchHeader) PrimaryKind() string

PrimaryKind returns the primary kind of a search result.

type SearchResult

type SearchResult struct {
	SearchHeader // Embedded search header

	Source [][]string      // Special string holding the data source (node / edge) for each column
	Data   [][]interface{} // Data which is held by this search result
	// contains filtered or unexported fields
}

SearchResult data structure. A search result represents the result of an EQL query.

func (*SearchResult) CSV

func (sr *SearchResult) CSV() string

CSV returns this search result as comma-separated strings.

func (*SearchResult) Header

func (sr *SearchResult) Header() *SearchHeader

Header returns all column headers.

func (*SearchResult) Query

func (sr *SearchResult) Query() string

Query returns the query which produced this result.

func (*SearchResult) Row

func (sr *SearchResult) Row(line int) []interface{}

Row returns a row of the result.

func (*SearchResult) RowCount

func (sr *SearchResult) RowCount() int

RowCount returns the number of rows of the result.

func (*SearchResult) RowSource

func (sr *SearchResult) RowSource(line int) []string

RowSource returns the sources of a result row. Format is either: <n/e>:<kind>:<key> or q:<query>

func (*SearchResult) RowSources

func (sr *SearchResult) RowSources() [][]string

RowSources returns the sources of a result.

func (*SearchResult) Rows

func (sr *SearchResult) Rows() [][]interface{}

Rows returns all rows.

func (*SearchResult) StableSort

func (sr *SearchResult) StableSort()

StableSort sorts the rows of the result in a stable 100% reproducible way.

func (*SearchResult) String

func (sr *SearchResult) String() string

String returns a string representation of this search result.

type SearchResultRowComparator

type SearchResultRowComparator struct {
	Ascening bool            // Sort should be ascending
	Column   int             // Column to sort
	Data     [][]interface{} // Data to sort
	Source   [][]string      // Source entries which follow the data
}

SearchResultRowComparator is a comparator object used for sorting the result

func (SearchResultRowComparator) Len

func (SearchResultRowComparator) Less

func (c SearchResultRowComparator) Less(i, j int) bool

func (SearchResultRowComparator) Swap

func (c SearchResultRowComparator) Swap(i, j int)

Jump to

Keyboard shortcuts

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