Documentation ¶
Overview ¶
Copyright 2021 The tKeel Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 The tKeel Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 The tKeel Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 The tKeel Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 The tKeel Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 The tKeel Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 The tKeel Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 The tKeel Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 The tKeel Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Variables
- func Byte(raw string) []byte
- func Combine(cKey *Collect, cValue *Collect) ([]byte, error)
- func Dump(x Expr) error
- func DumpMore(x ...Expr) error
- func EvalFilter(ctx Context, expr Expr) bool
- func Fprint(w io.Writer, x Expr) error
- func GetTopic(expr Expr) (string, bool)
- func HasDimensions(expr Expr) bool
- type BinaryExpr
- type BoolNode
- type By
- type CallExpr
- type CaseExpr
- type CaseListExpr
- type Collect
- func (cc *Collect) Append(path string, value Node)
- func (cc *Collect) Copy() *JSONNode
- func (cc *Collect) Del(path ...string)
- func (cc *Collect) Foreach(fn ForeachHandle)
- func (cc *Collect) Get(path ...string) *Collect
- func (cc *Collect) GetError() error
- func (cc *Collect) GroupBy(path string) *Collect
- func (c *Collect) KeyBy(path string) *Collect
- func (cc *Collect) Map(handle MapHandle)
- func (cc *Collect) Merge(mc *Collect) *Collect
- func (c *Collect) MergeBy(paths ...string) *Collect
- func (cc *Collect) Node() Node
- func (cc *Collect) Set(path string, value Node)
- func (cc *Collect) SortBy(fn func(p1 *Collect, p2 *Collect) bool)
- type Context
- type ContextCallable
- type ContextCallableFunc
- type ContextFunc
- type ContextValuable
- type DimensionExpr
- type DimensionsExpr
- type Expr
- type FieldExpr
- type FieldsExpr
- type FilterExpr
- type FloatNode
- type ForeachHandle
- type IntNode
- type JSONNode
- type JSONPathExpr
- type MapHandle
- type MutilContext
- type Node
- type Result
- type SelectStatementExpr
- type SortHandle
- type StringNode
- type SwitchExpr
- type TDTL
- type TDTLListener
- func (l *TDTLListener) ExitBinary(c *parser.BinaryContext)
- func (l *TDTLListener) ExitBoolean(c *parser.BooleanContext)
- func (l *TDTLListener) ExitCall_expr(c *parser.Call_exprContext)
- func (l *TDTLListener) ExitDotnotation(c *parser.DotnotationContext)
- func (l *TDTLListener) ExitFieldElemAs(c *parser.FieldElemAsContext)
- func (l *TDTLListener) ExitFieldElemExpr(c *parser.FieldElemExprContext)
- func (l *TDTLListener) ExitFieldElemSource(c *parser.FieldElemSourceContext)
- func (l *TDTLListener) ExitFields(c *parser.FieldsContext)
- func (l *TDTLListener) ExitFilter_condition(c *parser.Filter_conditionContext)
- func (l *TDTLListener) ExitFilter_condition_not(c *parser.Filter_condition_notContext)
- func (l *TDTLListener) ExitFilter_condition_or(c *parser.Filter_condition_orContext)
- func (l *TDTLListener) ExitFloat(c *parser.FloatContext)
- func (l *TDTLListener) ExitIdentifierWithQualifier(c *parser.IdentifierWithQualifierContext)
- func (l *TDTLListener) ExitIdentifierWithTOPICITEM(c *parser.IdentifierWithTOPICITEMContext)
- func (l *TDTLListener) ExitInteger(c *parser.IntegerContext)
- func (l *TDTLListener) ExitRoot(c *parser.RootContext)
- func (l *TDTLListener) ExitString(c *parser.StringContext)
- func (l *TDTLListener) ExitSwitch_stmt(c *parser.Switch_stmtContext)
- func (l *TDTLListener) ExitTarget(c *parser.TargetContext)
- func (l *TDTLListener) ExitTargetAsElem(c *parser.TargetAsElemContext)
- func (l *TDTLListener) ExitXpath_name(c *parser.Xpath_nameContext)
- func (l *TDTLListener) Expr() Expr
- func (l *TDTLListener) ReportAmbiguity(recognizer antlr.Parser, dfa *antlr.DFA, startIndex, stopIndex int, exact bool, ...)
- func (l *TDTLListener) ReportAttemptingFullContext(recognizer antlr.Parser, dfa *antlr.DFA, startIndex, stopIndex int, ...)
- func (l *TDTLListener) ReportContextSensitivity(recognizer antlr.Parser, dfa *antlr.DFA, startIndex, stopIndex, prediction int, ...)
- func (l *TDTLListener) SyntaxError(recognizer antlr.Recognizer, offendingSymbol interface{}, line, column int, ...)
- type TopicExpr
- type Type
- type WindowExpr
- type WindowInterval
- type WindowLength
- type WindowType
Constants ¶
This section is empty.
Variables ¶
var ( UNDEFINED_RESULT = &JSONNode{datatype: Undefined} NULL_RESULT = &JSONNode{datatype: Undefined} )
var DefaultValue = &value{ functions: map[string]ContextFunc{ "abs": absFunc, "base64": base64Func, }, }
DefaultValue default eval context
var EmptyBytes = []byte("")
var EvalCallExpr = func(ctx Context, expr *CallExpr) Node { return UNDEFINED_RESULT }
var ( JSONRaw = struct { SimpleJSON string JSON string EventJSON string EmptyJSON string }{ SimpleJSON: `{ "YX_0002":1, "YX_0003":2, "color":"red", "temperature":50, "metadata": {"name": "Light1", "price": 11.05} }`, JSON: `{ "name": {"first": "Tom", "last": "Anderson"}, "age":37, "temperature":50, "children": ["Sara","Alex","Jack"], "fav.movie": "Deer Hunter", "movie": {"1111": [{"1111": "Tom", "last": "Anderson"},{"first": "Neo"}], "last": "Anderson"}, "friends": [ {"first": "Dale", "last": "Murphy", "age": 44}, {"first": "Roger", "last": "Craig", "age": 68}, {"first": "Jane", "last": "Murphy", "age": 47} ] }`, EventJSON: `{ "id": "10000000000000000000000000DF0EF6", "version": "1.0", "params": { "Power": { "id": "10000000000000000000000000000001", //32 "type": "text", "value": "on", "time": 1524448722000 }, "Color": { "id": "10000000000000000000000000000001", //32 "type": "text", "value": "red", "time": 1524448722000 }, "Temperature": { "id": "10000000000000000000000000000002", //32 "type": "float", "value": 50.1, "time": 1524448722000 } } }`, EmptyJSON: `{}`, } )
var SymbolicNames []string
Functions ¶
func Dump ¶
Print prints x to standard output, skipping nil fields. Print(fset, x) is the same as Fprint(os.Stdout, fset, x, NotNilFilter).
func EvalFilter ¶
func Fprint ¶
Fprint prints the (sub-)tree starting at AST node x to w. If fset != nil, position information is interpreted relative to that file set. Otherwise positions are printed as integer values (file set specific offsets).
A non-nil FieldFilter f may be provided to control the output: struct fields for which f(fieldname, fieldvalue) is true are printed; all others are filtered from the output. Unexported struct fields are never printed.
func HasDimensions ¶
Types ¶
type Collect ¶
type Collect = JSONNode
func NewFloat64 ¶ added in v0.1.4
func (*Collect) Foreach ¶
func (cc *Collect) Foreach(fn ForeachHandle)
type Context ¶
type Context interface { ContextValuable ContextCallable }
Context eval context
func NewJSONContext ¶
NewJSONContext new context from json
func NewMapContext ¶
func NewMapContext(values map[string]Node, functions map[string]ContextFunc) Context
NewMapContext new context from map
type ContextCallable ¶
ContextCallable eval context function
type ContextCallable interface { Call(key string, args []Node) Node }
type ContextCallableFunc ¶
type ContextValuable ¶
ContextValuable eval context
type DimensionExpr ¶
type DimensionExpr struct {
// contains filtered or unexported fields
}
type DimensionsExpr ¶
type DimensionsExpr struct {
// contains filtered or unexported fields
}
GroupExpr
type Expr ¶
type Expr interface {
// contains filtered or unexported methods
}
Expr
func ParseField ¶
func ParseFilter ¶
type FieldsExpr ¶
type FieldsExpr []*FieldExpr
FieldExpr
func (FieldsExpr) String ¶
func (r FieldsExpr) String() string
type FilterExpr ¶
type FilterExpr struct {
// contains filtered or unexported fields
}
FilterExpr
func (*FilterExpr) String ¶
func (r *FilterExpr) String() string
type ForeachHandle ¶
type JSONNode ¶
type JSONNode struct {
// contains filtered or unexported fields
}
JSONNode maybe Object or Array
type JSONPathExpr ¶
type JSONPathExpr struct {
// contains filtered or unexported fields
}
JSONPathExpr xpath
type MutilContext ¶
type MutilContext []Context
MutilContext mutil-context
func (MutilContext) Call ¶
func (mc MutilContext) Call(expr *CallExpr, args []Node) Node
Call call function from context
func (MutilContext) Value ¶
func (mc MutilContext) Value(key string) Node
Value get value from context
type SelectStatementExpr ¶
type SelectStatementExpr struct {
// contains filtered or unexported fields
}
SelectStatementExpr
func (*SelectStatementExpr) String ¶
func (r *SelectStatementExpr) String() string
type SortHandle ¶
type StringNode ¶
type StringNode string
func (StringNode) Error ¶
func (r StringNode) Error() error
func (StringNode) Raw ¶
func (r StringNode) Raw() []byte
func (StringNode) String ¶
func (r StringNode) String() string
func (StringNode) To ¶
func (r StringNode) To(typ Type) Node
func (StringNode) Type ¶
func (r StringNode) Type() Type
type TDTL ¶
type TDTLListener ¶
type TDTLListener struct { *parser.BaseTDTLListener // contains filtered or unexported fields }
TDTLListener construct expr
func (*TDTLListener) ExitBinary ¶
func (l *TDTLListener) ExitBinary(c *parser.BinaryContext)
func (*TDTLListener) ExitBoolean ¶
func (l *TDTLListener) ExitBoolean(c *parser.BooleanContext)
func (*TDTLListener) ExitCall_expr ¶
func (l *TDTLListener) ExitCall_expr(c *parser.Call_exprContext)
func (*TDTLListener) ExitDotnotation ¶
func (l *TDTLListener) ExitDotnotation(c *parser.DotnotationContext)
func (*TDTLListener) ExitFieldElemAs ¶
func (l *TDTLListener) ExitFieldElemAs(c *parser.FieldElemAsContext)
func (*TDTLListener) ExitFieldElemExpr ¶
func (l *TDTLListener) ExitFieldElemExpr(c *parser.FieldElemExprContext)
ExitFieldElemExpr
func (*TDTLListener) ExitFieldElemSource ¶
func (l *TDTLListener) ExitFieldElemSource(c *parser.FieldElemSourceContext)
func (*TDTLListener) ExitFields ¶
func (l *TDTLListener) ExitFields(c *parser.FieldsContext)
ExitFields construct fields from select statement
func (*TDTLListener) ExitFilter_condition ¶
func (l *TDTLListener) ExitFilter_condition(c *parser.Filter_conditionContext)
func (*TDTLListener) ExitFilter_condition_not ¶
func (l *TDTLListener) ExitFilter_condition_not(c *parser.Filter_condition_notContext)
func (*TDTLListener) ExitFilter_condition_or ¶
func (l *TDTLListener) ExitFilter_condition_or(c *parser.Filter_condition_orContext)
func (*TDTLListener) ExitFloat ¶
func (l *TDTLListener) ExitFloat(c *parser.FloatContext)
func (*TDTLListener) ExitIdentifierWithQualifier ¶
func (l *TDTLListener) ExitIdentifierWithQualifier(c *parser.IdentifierWithQualifierContext)
func (*TDTLListener) ExitIdentifierWithTOPICITEM ¶
func (l *TDTLListener) ExitIdentifierWithTOPICITEM(c *parser.IdentifierWithTOPICITEMContext)
func (*TDTLListener) ExitInteger ¶
func (l *TDTLListener) ExitInteger(c *parser.IntegerContext)
func (*TDTLListener) ExitRoot ¶
func (l *TDTLListener) ExitRoot(c *parser.RootContext)
func (*TDTLListener) ExitString ¶
func (l *TDTLListener) ExitString(c *parser.StringContext)
func (*TDTLListener) ExitSwitch_stmt ¶
func (l *TDTLListener) ExitSwitch_stmt(c *parser.Switch_stmtContext)
func (*TDTLListener) ExitTarget ¶
func (l *TDTLListener) ExitTarget(c *parser.TargetContext)
ExitTarget construct target entity from select statement
func (*TDTLListener) ExitTargetAsElem ¶
func (l *TDTLListener) ExitTargetAsElem(c *parser.TargetAsElemContext)
func (*TDTLListener) ExitXpath_name ¶
func (l *TDTLListener) ExitXpath_name(c *parser.Xpath_nameContext)
func (*TDTLListener) ReportAmbiguity ¶
func (*TDTLListener) ReportAttemptingFullContext ¶
func (l *TDTLListener) ReportAttemptingFullContext(recognizer antlr.Parser, dfa *antlr.DFA, startIndex, stopIndex int, conflictingAlts *antlr.BitSet, configs antlr.ATNConfigSet)
func (*TDTLListener) ReportContextSensitivity ¶
func (l *TDTLListener) ReportContextSensitivity(recognizer antlr.Parser, dfa *antlr.DFA, startIndex, stopIndex, prediction int, configs antlr.ATNConfigSet)
func (*TDTLListener) SyntaxError ¶
func (l *TDTLListener) SyntaxError(recognizer antlr.Recognizer, offendingSymbol interface{}, line, column int, msg string, e antlr.RecognitionException)
type Type ¶
type Type int
Type node type
const ( // Undefine is Not a value // This isn't explicitly representable in JSON except by omitting the value. Undefined Type = iota // Null is a null json value Null // Bool is a json boolean Bool // Number is json number, include Int and Float Number // Int is json number, a discrete Int Int // Float is json number Float // String is a json string String // JSON is a raw block of JSON JSON // Object is a type of JSON Object // Array is a type of JSON Array )
type WindowExpr ¶
type WindowExpr struct { WindowType WindowType Length WindowLength Interval WindowInterval }
func GetWindow ¶
func GetWindow(expr Expr) *WindowExpr
type WindowInterval ¶
type WindowInterval int
type WindowLength ¶
type WindowLength int
type WindowType ¶
type WindowType int
const ( NOT_WINDOW WindowType = iota TUMBLING_WINDOW HOPPING_WINDOW SLIDING_WINDOW SESSION_WINDOW )
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
pkg
|
|
json/gjson
Package gjson provides searching for json strings.
|
Package gjson provides searching for json strings. |
json/sjson
Package sjson provides setting json values.
|
Package sjson provides setting json values. |