pql

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2017 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package pql defines the Pilosa Query Language.

Index

Constants

View Source
const TimeFormat = "2006-01-02T15:04"

TimeFormat is the go-style time format used to parse string dates.

Variables

This section is empty.

Functions

func CopyArgs

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

CopyArgs returns a copy of m.

func FormatValue added in v0.7.0

func FormatValue(v interface{}) string

Types

type Call

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

Call represents a function call in the AST.

func (*Call) Clone

func (c *Call) Clone() *Call

Clone returns a copy of c.

func (*Call) HasConditionArg added in v0.7.0

func (c *Call) HasConditionArg() bool

HasConditionArg returns true if any arg is a conditional.

func (*Call) IsInverse

func (c *Call) IsInverse(rowLabel, columnLabel string) bool

IsInverse specifies if the call is for an inverse view. Return defaults to false unless absolutely sure of inversion.

func (*Call) Keys

func (c *Call) Keys() []string

Keys returns a list of argument keys in sorted order.

func (*Call) String

func (c *Call) String() string

String returns the string representation of the call.

func (*Call) SupportsInverse

func (c *Call) SupportsInverse() bool

SupportsInverse indicates that the call may be on an inverse frame.

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 ParseError

type ParseError struct {
	Message string
	Pos     Pos
}

ParseError represents an error that occurred while parsing a PQL query.

func (*ParseError) Error

func (e *ParseError) Error() string

Error returns a string representation of e.

type Parser

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

Parser represents a parser for the PQL language.

func NewParser

func NewParser(r io.Reader) *Parser

NewParser returns a new instance of Parser.

func (*Parser) Parse

func (p *Parser) Parse() (*Query, error)

Parse parses the next node in the query.

type Pos

type Pos struct {
	Line int
	Char int
}

Pos specifies the line and character position of a token. The Char and Line are both zero-based indexes.

type Query

type Query struct {
	Calls []*Call
}

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 Scanner

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

Scanner represents a PQL lexical scanner.

func NewScanner

func NewScanner(r io.Reader) *Scanner

NewScanner returns a new instance of Scanner.

func (*Scanner) Scan

func (s *Scanner) Scan() (tok Token, pos Pos, lit string)

Scan returns the next token and position from the underlying reader.

type Token

type Token int

Token is a lexical token of the PQL language.

const (
	// Special tokens
	ILLEGAL Token = iota
	EOF
	WS

	IDENT     // main
	STRING    // "foo"
	BADSTRING // bad escape or unclosed string
	INTEGER   // 12345
	FLOAT     // 100.2

	ALL

	ASSIGN  // =
	EQ      // ==
	LT      // <
	LTE     // <=
	GT      // >
	GTE     // >=
	BETWEEN // ><
	COMMA   // ,
	LPAREN  // (
	RPAREN  // )
	LBRACK  // (
	RBRACK  // )
)

func Lookup

func Lookup(ident string) Token

Lookup returns the token associated with a given string.

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