pql

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2020 License: Apache-2.0 Imports: 10 Imported by: 15

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 IsReservedArg added in v1.3.0

func IsReservedArg(name string) bool

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 added in v1.2.0

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 added in v1.2.0

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 added in v1.0.0

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 added in v0.7.0

func (c *Call) HasConditionArg() bool

HasConditionArg returns true if any arg is a conditional.

func (*Call) IntArg added in v1.0.0

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 added in v0.7.0

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 added in v0.7.0

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 added in v0.7.0

func (cond *Condition) String() string

String returns the string representation of the condition.

type PQL added in v1.0.0

type PQL struct {
	Query

	Buffer string

	Pretty bool
	// contains filtered or unexported fields
}

func (*PQL) AST added in v1.0.0

func (t *PQL) AST() *node32

func (*PQL) Add added in v1.0.0

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

func (*PQL) Execute added in v1.0.0

func (p *PQL) Execute()

func (*PQL) Init added in v1.0.0

func (p *PQL) Init()

func (*PQL) Parse added in v1.0.0

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

func (*PQL) PrettyPrintSyntaxTree added in v1.0.0

func (t *PQL) PrettyPrintSyntaxTree(buffer string)

func (*PQL) Print added in v1.0.0

func (t *PQL) Print()

func (*PQL) PrintSyntaxTree added in v1.0.0

func (p *PQL) PrintSyntaxTree()

func (*PQL) Reset added in v1.0.0

func (p *PQL) Reset()

func (*PQL) Tokens added in v1.0.0

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

func (*PQL) Trim added in v1.0.0

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 added in v0.4.0

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