query

package
v0.19.4 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2017 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QUERY_NOP = QueryOpCode(iota)
	SELECT
	JOIN
)
View Source
const (
	WHERE_NOOP = QueryWhereOpCode(iota)
	AND
	OR
	PREDICATE
)
View Source
const (
	PREDICATE_NOP = QueryPredicateOpCode(iota)
	STR_EQ
)
View Source
const (
	MESSAGE_NOOP = uint32(iota)
	MESSAGE_SELECT
	MESSAGE_JOIN
)
View Source
const (
	MESSAGE_WHERE_NOOP = uint32(iota)
	MESSAGE_AND
	MESSAGE_OR
	MESSAGE_PREDICATE
)
View Source
const (
	MESSAGE_PREDICATE_NOOP = uint32(iota)
	MESSAGE_STR_EQ
	MESSAGE_STR_NEQ
)

Variables

This section is empty.

Functions

func EncodeQuery

func EncodeQuery(query *Query, w io.Writer) error

func MakeQueryJoinMessage

func MakeQueryJoinMessage(join QueryJoin) *proto.QueryJoinMessage

func MakeQueryMessage

func MakeQueryMessage(query *Query) *proto.QueryMessage

func MakeQueryPredicateMessage

func MakeQueryPredicateMessage(predicate QueryPredicate) *proto.QueryPredicateMessage

func MakeQueryRowJoinMessage

func MakeQueryRowJoinMessage(row QueryRowJoin) *proto.QueryRowJoinMessage

func MakeQuerySelectMessage

func MakeQuerySelectMessage(querySelect QuerySelect) *proto.QuerySelectMessage

func MakeQueryWhereMessage

func MakeQueryWhereMessage(queryWhere QueryWhere) *proto.QueryWhereMessage

Types

type CompileContext added in v0.19.0

type CompileContext struct {
	Variables []interface{}
}

type ErrorCollectVisitor

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

func (*ErrorCollectVisitor) BadOpcode

func (visitor *ErrorCollectVisitor) BadOpcode(opCode QueryOpCode)

func (*ErrorCollectVisitor) BadPredicateOpCode

func (visitor *ErrorCollectVisitor) BadPredicateOpCode(predicate *QueryPredicate)

func (*ErrorCollectVisitor) BadPublicKey

func (visitor *ErrorCollectVisitor) BadPublicKey(hash crypto.PublicKeyHash)

func (*ErrorCollectVisitor) BadWhereOpCode

func (visitor *ErrorCollectVisitor) BadWhereOpCode(position int, where *QueryWhere)

func (*ErrorCollectVisitor) CollectError

func (visitor *ErrorCollectVisitor) CollectError(err error)

func (*ErrorCollectVisitor) Error

func (visitor *ErrorCollectVisitor) Error() error

type NoDebugVisitor

type NoDebugVisitor struct{}

func (*NoDebugVisitor) VisitAST

func (visitor *NoDebugVisitor) VisitAST(*QueryAST)

func (*NoDebugVisitor) VisitParser

func (visitor *NoDebugVisitor) VisitParser(*QueryParser)

type NoJoinVisitor

type NoJoinVisitor struct{}

func (*NoJoinVisitor) LeaveJoin

func (visitor *NoJoinVisitor) LeaveJoin(*QueryJoin)

func (*NoJoinVisitor) VisitJoin

func (visitor *NoJoinVisitor) VisitJoin(*QueryJoin)

func (*NoJoinVisitor) VisitRowJoin

func (visitor *NoJoinVisitor) VisitRowJoin(int, *QueryRowJoin)

type NoSelectVisitor

type NoSelectVisitor struct{}

func (*NoSelectVisitor) LeaveSelect

func (visitor *NoSelectVisitor) LeaveSelect(*QuerySelect)

func (*NoSelectVisitor) LeaveWhere

func (visitor *NoSelectVisitor) LeaveWhere(*QueryWhere)

func (*NoSelectVisitor) VisitPredicate

func (visitor *NoSelectVisitor) VisitPredicate(*QueryPredicate)

func (*NoSelectVisitor) VisitSelect

func (visitor *NoSelectVisitor) VisitSelect(*QuerySelect)

func (*NoSelectVisitor) VisitWhere

func (visitor *NoSelectVisitor) VisitWhere(int, *QueryWhere)

type PredicateValue added in v0.19.0

type PredicateValue struct {
	IsKey   bool
	Key     crdt.EntryName
	Literal crdt.PointText
}

func PredicateKey added in v0.19.0

func PredicateKey(entry crdt.EntryName) PredicateValue

func PredicateLiteral added in v0.19.0

func PredicateLiteral(point crdt.PointText) PredicateValue

type Query

type Query struct {
	AST        *QueryAST    `json:"-"`
	Parser     *QueryParser `json:"-"`
	OpCode     QueryOpCode  `json:",omitempty"`
	TableKey   crdt.TableName
	Join       QueryJoin   `json:",omitempty"`
	Select     QuerySelect `json:",omitempty"`
	PublicKeys []crypto.PublicKeyHash
}

func Compile

func Compile(source string, variables ...interface{}) (*Query, error)

func DecodeQuery

func DecodeQuery(r io.Reader) (*Query, error)

func GenQuery

func GenQuery(rand *rand.Rand, size int) *Query

func ReadQueryMessage

func ReadQueryMessage(message *proto.QueryMessage) (*Query, error)

func (*Query) Analyse

func (query *Query) Analyse() string

func (*Query) Equals

func (query *Query) Equals(other *Query) bool

func (*Query) OpCodePanic

func (query *Query) OpCodePanic()

func (*Query) PrettyPrint

func (query *Query) PrettyPrint(w io.Writer) error

func (*Query) PrettyText

func (query *Query) PrettyText() (string, error)

func (*Query) Validate

func (query *Query) Validate(context ValidationContext) error

func (*Query) Visit

func (query *Query) Visit(visitor QueryVisitor)

type QueryAST

type QueryAST struct {
	Command      string
	TableKey     *astVariable
	Select       QuerySelectAST `json:",omitempty"`
	Join         QueryJoinAST   `json:",omitempty"`
	PublicKeys   []*astVariable
	Placeholders []*astVariable

	WhereStack []*QueryWhereAST
	// contains filtered or unexported fields
}

func (*QueryAST) AddCryptoKey

func (ast *QueryAST) AddCryptoKey(publicKey string)

func (*QueryAST) AddJoin

func (ast *QueryAST) AddJoin()

func (*QueryAST) AddJoinRow

func (ast *QueryAST) AddJoinRow()

func (*QueryAST) AddPredicateKey

func (ast *QueryAST) AddPredicateKey(key string)

func (*QueryAST) AddPredicateKeyPlaceholder added in v0.19.0

func (ast *QueryAST) AddPredicateKeyPlaceholder(begin int)

func (*QueryAST) AddPredicateLiteral

func (ast *QueryAST) AddPredicateLiteral(literal string)

func (*QueryAST) AddPredicateLiteralPlaceholder added in v0.19.0

func (ast *QueryAST) AddPredicateLiteralPlaceholder(begin int)

func (*QueryAST) AddSelect

func (ast *QueryAST) AddSelect()

func (*QueryAST) Compile

func (ast *QueryAST) Compile(context CompileContext) (*Query, error)

func (*QueryAST) InitPredicate

func (ast *QueryAST) InitPredicate()

func (*QueryAST) PopWhere

func (ast *QueryAST) PopWhere()

func (*QueryAST) PushWhere

func (ast *QueryAST) PushWhere()

func (*QueryAST) SetJoinKey

func (ast *QueryAST) SetJoinKey(key string)

func (*QueryAST) SetJoinKeyPlaceholder added in v0.19.0

func (ast *QueryAST) SetJoinKeyPlaceholder(begin int)

func (*QueryAST) SetJoinRowKey

func (ast *QueryAST) SetJoinRowKey(key string)

func (*QueryAST) SetJoinRowKeyPlaceholder added in v0.19.0

func (ast *QueryAST) SetJoinRowKeyPlaceholder(begin int)

func (*QueryAST) SetJoinValue

func (ast *QueryAST) SetJoinValue(value string)

func (*QueryAST) SetJoinValuePlaceholder added in v0.19.0

func (ast *QueryAST) SetJoinValuePlaceholder(begin int)

func (*QueryAST) SetLimit

func (ast *QueryAST) SetLimit(limit string)

func (*QueryAST) SetLimitPlaceholder added in v0.19.0

func (ast *QueryAST) SetLimitPlaceholder(begin int)

func (*QueryAST) SetPredicateCommand

func (ast *QueryAST) SetPredicateCommand(command string)

func (*QueryAST) SetTableName

func (ast *QueryAST) SetTableName(key string)

func (*QueryAST) SetTableNamePlaceholder added in v0.19.0

func (ast *QueryAST) SetTableNamePlaceholder(begin int)

func (*QueryAST) SetWhereCommand

func (ast *QueryAST) SetWhereCommand(command string)

func (*QueryAST) UsePredicateRowKey

func (ast *QueryAST) UsePredicateRowKey()

type QueryJoin

type QueryJoin struct {
	Rows []QueryRowJoin `json:",omitempty"`
}

func (QueryJoin) IsEmpty

func (join QueryJoin) IsEmpty() bool

type QueryJoinAST

type QueryJoinAST struct {
	Rows []*QueryRowJoinAST `json:",omitempty"`
}

func (*QueryJoinAST) Compile

func (ast *QueryJoinAST) Compile() (QueryJoin, error)

type QueryOpCode

type QueryOpCode uint16

type QueryParser

type QueryParser struct {
	QueryAST

	Buffer string

	Pretty bool
	// contains filtered or unexported fields
}

func (*QueryParser) AST

func (t *QueryParser) AST() *node32

func (*QueryParser) Add

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

func (*QueryParser) Execute

func (p *QueryParser) Execute()

func (*QueryParser) Init

func (p *QueryParser) Init()

func (*QueryParser) Parse

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

func (*QueryParser) PrettyPrintSyntaxTree

func (t *QueryParser) PrettyPrintSyntaxTree(buffer string)

func (*QueryParser) Print

func (t *QueryParser) Print()

func (*QueryParser) PrintSyntaxTree

func (p *QueryParser) PrintSyntaxTree()

func (*QueryParser) Reset

func (p *QueryParser) Reset()

func (*QueryParser) Tokens

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

func (*QueryParser) Trim

func (t *QueryParser) Trim(length uint32)

type QueryPredicate

type QueryPredicate struct {
	FunctionName  string
	Values        []PredicateValue
	IncludeRowKey bool `json:",omitempty"`
}

func (QueryPredicate) IsEmpty

func (pred QueryPredicate) IsEmpty() bool

func (QueryPredicate) Keys

func (pred QueryPredicate) Keys() []crdt.EntryName

func (QueryPredicate) Literals

func (pred QueryPredicate) Literals() []crdt.PointText

type QueryPredicateAST

type QueryPredicateAST struct {
	Command       string
	Values        []*astVariable
	IncludeRowKey bool
}

func (*QueryPredicateAST) Compile

func (ast *QueryPredicateAST) Compile() (QueryPredicate, error)

type QueryPredicateOpCode

type QueryPredicateOpCode uint16

type QueryRowJoin

type QueryRowJoin struct {
	RowKey crdt.RowName
	// TODO would this be clearer/more performant as a slice of pair structures?
	Entries map[crdt.EntryName]crdt.PointText `json:",omitempty"`
}

type QueryRowJoinAST

type QueryRowJoinAST struct {
	RowKey *astVariable
	Values []QueryRowJoinValueAST `json:",omitempty"`
}

type QueryRowJoinValueAST added in v0.19.0

type QueryRowJoinValueAST struct {
	Key   *astVariable
	Value *astVariable
}

type QuerySelect

type QuerySelect struct {
	Where QueryWhere `json:",omitempty"`
	Limit uint32     `json:",omitempty"`
}

func (QuerySelect) IsEmpty

func (querySelect QuerySelect) IsEmpty() bool

type QuerySelectAST

type QuerySelectAST struct {
	Where *QueryWhereAST `json:",omitempty"`
	Limit *astVariable
}

func (*QuerySelectAST) Compile

func (ast *QuerySelectAST) Compile() (QuerySelect, error)

type QueryVisitor

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

type QueryWhere

type QueryWhere struct {
	OpCode    QueryWhereOpCode `json:",omitempty"`
	Clauses   []QueryWhere     `json:",omitempty"`
	Predicate QueryPredicate   `json:",omitempty"`
}

func (QueryWhere) IsEmpty

func (where QueryWhere) IsEmpty() bool

type QueryWhereAST

type QueryWhereAST struct {
	Command   string
	Clauses   []*QueryWhereAST   `json:",omitempty"`
	Predicate *QueryPredicateAST `json:",omitempty"`
}

func (*QueryWhereAST) Compile

func (ast *QueryWhereAST) Compile() (QueryWhere, error)

func (*QueryWhereAST) CompileClauses

func (ast *QueryWhereAST) CompileClauses(out *QueryWhere) error

func (*QueryWhereAST) Configure

func (ast *QueryWhereAST) Configure(where *QueryWhere) error

type QueryWhereOpCode

type QueryWhereOpCode uint16

type ValidationContext added in v0.19.0

type ValidationContext struct {
	Functions function.FunctionNamespace
}

type WhereStack

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

func MakeWhereStack

func MakeWhereStack(where *QueryWhere) *WhereStack

func (*WhereStack) Visit

func (stack *WhereStack) Visit(visitor whereVisitor)

Jump to

Keyboard shortcuts

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