Skip to content

Commit

Permalink
feat: update readme (#4)
Browse files Browse the repository at this point in the history
* feat: update readme

* feat: remove github.com/tkeel-io/core/pkg/tql

* feat: update gomod
  • Loading branch information
imneov authored Feb 23, 2022
1 parent cd8d167 commit 12e919c
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 111 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# TQL

TKeel Digital Twins Language (TDTL) is language of Digital Twins in tKeel, which solves the problem:
TKeel Query Language (TQL) is language in tKeel, which solves the problem:
- [ ] define the entity(Digital Object)
- [ ] define the relationship(Digital Object)
- [ ] data transmission between entities
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ go 1.17
require (
github.com/Jeffail/gabs v1.4.0
github.com/a8m/djson v0.0.0-20170509170705-c02c5aef757f
//github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20211026222012-6af4c774c47b
//github.com/antlr/antlr4 v0.0.0-20200503195918-621b933c7a7f
github.com/antlr/antlr4 v0.0.0-20200503195918-621b933c7a7f
github.com/antonholmquist/jason v1.0.0
github.com/bitly/go-simplejson v0.5.0
Expand Down
67 changes: 0 additions & 67 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,67 +0,0 @@
github.com/Jeffail/gabs v1.4.0 h1://5fYRRTq1edjfIrQGvdkcd22pkYUrHZ5YC/H2GJVAo=
github.com/Jeffail/gabs v1.4.0/go.mod h1:6xMvQMK4k33lb7GUUpaAPh6nKMmemQeg5d4gn7/bOXc=
github.com/a8m/djson v0.0.0-20170509170705-c02c5aef757f h1:su5fhWd5UCmmRQEFPQPalJ304Qtcgk9ZDDnKnvpsraU=
github.com/a8m/djson v0.0.0-20170509170705-c02c5aef757f/go.mod h1:w3s8fnedJo6LJQ7dUUf1OcetqgS1hGpIDjY5bBowg1Y=
github.com/antlr/antlr4 v0.0.0-20200503195918-621b933c7a7f h1:0cEys61Sr2hUBEXfNV8eyQP01oZuBgoMeHunebPirK8=
github.com/antlr/antlr4 v0.0.0-20200503195918-621b933c7a7f/go.mod h1:T7PbCXFs94rrTttyxjbyT5+/1V8T2TYDejxUfHJjw1Y=
github.com/antonholmquist/jason v1.0.0 h1:Ytg94Bcf1Bfi965K2q0s22mig/n4eGqEij/atENBhA0=
github.com/antonholmquist/jason v1.0.0/go.mod h1:+GxMEKI0Va2U8h3os6oiUAetHAlGMvxjdpAH/9uvUMA=
github.com/bitly/go-simplejson v0.5.0 h1:6IH+V8/tVMab511d5bn4M7EwGXZf9Hj6i2xSwkNEM+Y=
github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mreiferson/go-ujson v0.0.0-20200614021406-c02629f4935e h1:d62FkSNtPk3+foLRLC43qnUlrMxf6icm/pJYop5nfpQ=
github.com/mreiferson/go-ujson v0.0.0-20200614021406-c02629f4935e/go.mod h1:pRizrH03mzcoHZVa3eK2eoMfq4COW0kGOqapG3/ewkE=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7 h1:xoIK0ctDddBMnc74udxJYBqlo9Ylnsp1waqjLsnef20=
github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7/go.mod h1:YARuvh7BUWHNhzDq2OM5tzR2RiCcN2D7sapiKyCel/M=
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/smartystreets/assertions v1.2.0 h1:42S6lae5dvLc7BrLu/0ugRtcFVjoJNMC/N3yZFZkDFs=
github.com/smartystreets/assertions v1.2.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo=
github.com/smartystreets/goconvey v1.7.2 h1:9RBaZCeXEQ3UselpuwUQHltGVXvdwm6cv1hgR6gDIPg=
github.com/smartystreets/goconvey v1.7.2/go.mod h1:Vw0tHAZW6lzCRk3xgdin6fKYcG+G3Pg9vgXWeJpQFMM=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/tidwall/gjson v1.12.0 h1:61wEp/qfvFnqKH/WCI3M8HuRut+mHT6Mr82QrFmM2SY=
github.com/tidwall/gjson v1.12.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tkeel-io/collectjs v0.0.0-20220223040031-79acd37e4d90 h1:uJihdKjukQuUyxeuwVpcLtdNuDJuH8U3n8MnXGNjIIw=
github.com/tkeel-io/collectjs v0.0.0-20220223040031-79acd37e4d90/go.mod h1:c5fSVnTPWUv9SphLl+R+sWKTU/g8UmPRKa13cvI/nQ4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
7 changes: 6 additions & 1 deletion sample/parseTS.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ var input = `{
}`

func main() {
tqlString := `insert into entity3 select json(telemetryV1(entity1.input), 'values') as property1, entity2.property2.name as property2, entity1.property1 + entity2.property3 as property3`
tqlString := `
insert into entity3
select
json(telemetryV1(entity1.input), 'values') as property1,
entity2.property2.name as property2,
entity1.property1 + entity2.property3 as property3`

tqlInst, err := tdtl.NewTDTL(tqlString, map[string]tdtl.ContextFunc{
"json": func(args ...tdtl.Node) tdtl.Node {
Expand Down
48 changes: 10 additions & 38 deletions tdtl.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ limitations under the License.
package tdtl

import (
"strings"

"github.com/antlr/antlr4/runtime/Go/antlr"
)

Expand All @@ -27,15 +25,15 @@ var _ TDTL = (*tdtl)(nil)
type tdtl struct {
target string
sources map[string][]string
tentacles []TentacleConfig
listener *TDTLListener
extFunc map[string]ContextFunc
fields map[string]string
}

type TDTL interface {
Target() string
Entities() []string
Tentacles() []TentacleConfig
Entities() map[string][]string
Fields() map[string]string
Exec(map[string]Node) (map[string]Node, error)
}

Expand All @@ -50,35 +48,21 @@ func NewTDTL(sql string, extFunc map[string]ContextFunc) (TDTL, error) {
listener: listener,
target: listener.target,
sources: listener.sources,
//fields: listener.fields,
extFunc: extFunc,
tentacles: nil,
fields: listener.fields,
extFunc: extFunc,
}, nil
}

func (Q *tdtl) Target() string {
return Q.target
}

func (Q *tdtl) Entities() []string {
sources := make([]string, 0)
for source := range Q.sources {
sources = append(sources, source)
}
return sources
func (Q *tdtl) Entities() map[string][]string {
return Q.sources
}

func (Q *tdtl) Tentacles() []TentacleConfig {
tentacleCfgs := make([]TentacleConfig, 0, len(Q.sources))
for entityID, keys := range Q.sources {
tentacleCfg := TentacleConfig{SourceEntity: entityID}
for index := range keys {
arr := strings.SplitN(keys[index], ".", 2)
tentacleCfg.PropertyKeys = append(tentacleCfg.PropertyKeys, arr[1])
}
tentacleCfgs = append(tentacleCfgs, tentacleCfg)
}
return tentacleCfgs
func (Q *tdtl) Fields() map[string]string {
return Q.fields
}

func (Q *tdtl) expr() Expr {
Expand All @@ -94,16 +78,4 @@ func (Q *tdtl) Exec(input map[string]Node) (map[string]Node, error) {
ret[k] = retCtx.Value(k)
}
return ret, nil
}

// ------------------------.
type TentacleConfig struct {
SourceEntity string
PropertyKeys []string
}

type TQLConfig struct { // nolint
TargetEntity string
SourceEntities []string
Tentacles []TentacleConfig
}
}
4 changes: 2 additions & 2 deletions tdtl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ func TestExec3(t *testing.T) {
t.Log(tqlString)
t.Log("target: ", tqlInst.Target())
t.Log("sources: ", tqlInst.Entities())
for _, tentacle := range tqlInst.Tentacles() {
t.Log("tentacle: ", tentacle)
for k, tentacle := range tqlInst.Fields() {
t.Log("tentacle: ", k, tentacle)
}

result, err := tqlInst.Exec(map[string]Node{
Expand Down

0 comments on commit 12e919c

Please sign in to comment.