pql

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package pql defines the Pilosa Query Language.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyArgs

func CopyArgs(m map[string]interface{}) map[string]interface{}

CopyArgs returns a copy of m.

func NewParser

func NewParser(r io.Reader) *parser

NewParser returns a new instance of Parser.

Types

type Call

type Call struct {
	Name     string
	Args     map[string]interface{}
	Children []*Call
}

Call represents a function call in the AST.

func (*Call) BoolArg

func (c *Call) BoolArg(key string) (bool, bool, error)

BoolArg is for reading the value at key from call.Args as a bool. If the key is not in Call.Args, the value of the returned bool will be false, and the error will be nil. The value is assumed to be a bool. An error is returned if the value is not a bool.

func (*Call) CallArg

func (c *Call) CallArg(key string) (*Call, bool, error)

CallArg is for reading the value at key from call.Args as a Call. If the key is not in Call.Args, the value of the returned value will be nil, and the error will be nil. An error is returned if the value is not a Call.

func (*Call) Clone

func (c *Call) Clone() *Call

Clone returns a copy of c.

func (*Call) FieldArg

func (c *Call) FieldArg() (string, error)

FieldArg determines which key-value pair contains the field and rowID, in the case of arguments like Set(colID, field=rowID). Returns the field as a string if present, or an error if not.

func (*Call) HasConditionArg

func (c *Call) HasConditionArg() bool

HasConditionArg returns true if any arg is a conditional.

func (*Call) IntArg

func (c *Call) IntArg(key string) (int64, bool, error)

IntArg is for reading the value at key from call.Args as an int64. If the key is not in Call.Args, the value of the returned bool will be false, and the error will be nil. The value is assumed to be a unt64 or an int64 and then cast to an int64. An error is returned if the value is not an int64 or uint64.

func (*Call) String

func (c *Call) String() string

String returns the string representation of the call.

func (*Call) UintArg

func (c *Call) UintArg(key string) (uint64, bool, error)

UintArg is for reading the value at key from call.Args as a uint64. If the key is not in Call.Args, the value of the returned bool will be false, and the error will be nil. The value is assumed to be a uint64 or an int64 and then cast to a uint64. An error is returned if the value is not an int64 or uint64.

func (*Call) UintSliceArg

func (c *Call) UintSliceArg(key string) ([]uint64, bool, error)

UintSliceArg reads the value at key from call.Args as a slice of uint64. If the key is not in Call.Args, the value of the returned bool will be false, and the error will be nil. If the value is a slice of int64 it will convert it to []uint64. Otherwise, if it is not a []uint64 it will return an error.

type Condition

type Condition struct {
	Op    Token
	Value interface{}
}

Condition represents an operation & value. When used in an argument map it represents a binary expression.

func (*Condition) IntSliceValue

func (cond *Condition) IntSliceValue() ([]int64, error)

IntSliceValue reads cond.Value as a slice of uint64. If the value is a slice of uint64 it will convert it to []int64. Otherwise, if it is not a []int64 it will return an error.

func (*Condition) String

func (cond *Condition) String() string

String returns the string representation of the condition.

type PQL

type PQL struct {
	Query

	Buffer string

	Pretty bool
	// contains filtered or unexported fields
}

func (*PQL) AST

func (t *PQL) AST() *node32

func (*PQL) Add

func (t *PQL) Add(rule pegRule, begin, end, index uint32)

func (*PQL) Execute

func (p *PQL) Execute()

func (*PQL) Init

func (p *PQL) Init()

func (*PQL) Parse

func (p *PQL) Parse(rule ...int) error

func (*PQL) PrettyPrintSyntaxTree

func (t *PQL) PrettyPrintSyntaxTree(buffer string)

func (*PQL) Print

func (t *PQL) Print()

func (*PQL) PrintSyntaxTree

func (p *PQL) PrintSyntaxTree()

func (*PQL) Reset

func (p *PQL) Reset()

func (*PQL) Tokens

func (t *PQL) Tokens() []token32

func (*PQL) Trim

func (t *PQL) Trim(length uint32)

type Query

type Query struct {
	Calls []*Call
	// contains filtered or unexported fields
}

Query represents a PQL query.

func ParseString

func ParseString(s string) (*Query, error)

ParseString parses s into a query.

func (*Query) String

func (q *Query) String() string

String returns a string representation of the query.

func (*Query) WriteCallN

func (q *Query) WriteCallN() int

WriteCallN returns the number of mutating calls.

type Token

type Token int

Token is a lexical token of the PQL language.

const (
	// Special tokens
	ILLEGAL Token = iota

	ASSIGN  // =
	EQ      // ==
	NEQ     // !=
	LT      // <
	LTE     // <=
	GT      // >
	GTE     // >=
	BETWEEN // ><
)

func (Token) String

func (tok Token) String() string

String returns the string representation of the token.

Jump to

Keyboard shortcuts

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