| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- package main
- import (
- //"fmt"
- "encoding/json"
- "git.wecise.com/wecise/odbserver/odb/test"
- "gitee.com/wecisecode/util/logger"
- )
- func main() {
- //options := map[string]interface{} {"cache":odb.CacheAll}
- //g,err:= odb.New( options )
- //option := &StoreOption{Cache:CacheAll}
- option := &Option{Cache: CacheAll, Keyspace: "matrix", DisableInitialHostLookup: true}
- g, err := test.NewG(option)
- if err != nil {
- logger.Error(err.Error())
- } else {
- defer g.Close()
- }
- /*g.Query(`create class if not exists /matrix/testgroup (
- g1 varchar,
- g2 varchar,
- g3 varchar,
- v1 int,
- v2 int,
- f1 float,
- f2 float,
- keys(g1, g2, g3),
- index(g1, g2, g3, v1, v2, f1, f2)
- );`, &QueryMeta{Return: ReturnAll, MinAsteriskField: false, KeepClassID: false} )*/
- //g.Query(`insert into /matrix/testgroup g1='g1' , g2='g2', g3='g34' , v1=1 , v2=2 , f1=1.1 , f2=1.2`)
- //rst,meta, err :=g.Query(`insert into /matrix/testgroup g1='g1' , g2='g2', g3='g35' , v1=3 , v2=5 , f1=1.2 , f2=1.4`)
- //g.Query(`insert into /matrix/testgroup g1='g1' , g2='g2' , g3={"bank":"tag1","core":"tag2"} , v1=1 , v2=2 , f1=1.1 , f2=1.2`)
- //rst,meta, err := g.Search(`#/matrix/testgroup: | avg v1 as name_avgv1,sum v2 as name_sumv2 | group by g1 `)
- //rst,meta, err := g.Search(`#/matrix/testgroup: | group g1 with topo`)
- //rst,meta, err := g.Search(`#/matrix/devops/event: | group with topo | top 1000`)
- //rst,meta, err := g.Search(`#/matrix/devops/event/ | group with topo | top 100`)
- //bug
- rst, meta, err := g.Search(`#/matrix/devops/log/cassandra | host=wecise | print id,biz,host | count as fff| group by host`)
- if err != nil {
- logger.Info("Query error:" + err.Error())
- } else {
- logger.Info("rst ===>", rst)
- // for graph
- if graph, err := json.Marshal(rst); err != nil {
- logger.Error(err.Error())
- } else {
- logger.Error("graph ===>", string(graph))
- }
- logger.Error("meta ===>", meta)
- if meta["trace"] != nil && len(meta["trace"].([]string)) > 0 {
- for _, msg := range meta["trace"].([]string) {
- logger.Error(msg)
- }
- }
- logger.Warn(meta["columns"])
- logger.Warn(meta["summary"])
- }
- }
|