本文整理汇总了Golang中github.com/couchbaselabs/query/expression.NewStringer函数的典型用法代码示例。如果您正苦于以下问题:Golang NewStringer函数的具体用法?Golang NewStringer怎么用?Golang NewStringer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewStringer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: MarshalJSON
/*
Marshals input into byte array.
*/
func (this *SetTerm) MarshalJSON() ([]byte, error) {
r := map[string]interface{}{"type": "setTerm"}
r["path"] = expression.NewStringer().Visit(this.path)
r["value"] = expression.NewStringer().Visit(this.value)
r["updateFor"] = this.updateFor
return json.Marshal(r)
}
示例2: MarshalJSON
/*
Marshals the input keyspace into a byte array.
*/
func (this *KeyspaceTerm) MarshalJSON() ([]byte, error) {
r := map[string]interface{}{"type": "keyspaceTerm"}
r["as"] = this.as
if this.keys != nil {
r["keys"] = expression.NewStringer().Visit(this.keys)
}
r["namespace"] = this.namespace
r["keyspace"] = this.keyspace
if this.projection != nil {
r["projection"] = expression.NewStringer().Visit(this.projection)
}
return json.Marshal(r)
}
示例3: MarshalJSON
func (this *InitialGroup) MarshalJSON() ([]byte, error) {
r := map[string]interface{}{"#operator": "InitialGroup"}
keylist := make([]string, 0, len(this.keys))
for _, key := range this.keys {
keylist = append(keylist, expression.NewStringer().Visit(key))
}
r["group_keys"] = keylist
s := make([]interface{}, 0, len(this.aggregates))
for _, agg := range this.aggregates {
s = append(s, expression.NewStringer().Visit(agg))
}
r["aggregates"] = s
return json.Marshal(r)
}
示例4: MarshalJSON
func (this *InitialProject) MarshalJSON() ([]byte, error) {
r := map[string]interface{}{"#operator": "InitialProject"}
if this.projection.Distinct() {
r["distinct"] = this.projection.Distinct()
}
if this.projection.Raw() {
r["raw"] = this.projection.Raw()
}
s := make([]interface{}, 0, len(this.terms))
for _, term := range this.terms {
t := make(map[string]interface{})
if term.Result().Star() {
t["star"] = term.Result().Star()
}
if term.Result().As() != "" {
t["as"] = term.Result().As()
}
expr := term.Result().Expression()
if expr != nil {
t["expr"] = expression.NewStringer().Visit(expr)
}
s = append(s, t)
}
r["result_terms"] = s
return json.Marshal(r)
}
示例5: indexKeyToIndexKeyStringArray
func indexKeyToIndexKeyStringArray(key expression.Expressions) []string {
rv := make([]string, len(key))
for i, kp := range key {
rv[i] = expression.NewStringer().Visit(kp)
}
return rv
}
示例6: Test2iCondition
func Test2iCondition(t *testing.T) {
whereKey := index.Condition()
v := expression.NewStringer().Visit(whereKey)
if v != "(30 < `age`)" {
t.Fatalf("failed Condition() - %v, expected (30 < `age`)", v)
}
}
示例7: Test2iSeekKey
func Test2iSeekKey(t *testing.T) {
equalKey := index.SeekKey()
if len(equalKey) != 1 {
t.Fatalf("failed SeekKey() - %v, expected 1", len(equalKey))
} else if v := expression.NewStringer().Visit(equalKey[0]); v != "`gender`" {
t.Fatalf("failed SeekKey() - %v, expected `gender`", v)
}
}
示例8: MarshalJSON
/*
Marshals input receiver into byte array.
*/
func (this *CreateIndex) MarshalJSON() ([]byte, error) {
r := map[string]interface{}{"type": "createIndex"}
r["keyspaceRef"] = this.keyspace
r["name"] = this.name
if this.partition != nil {
r["partition"] = expression.NewStringer().Visit(this.partition)
}
if this.where != nil {
r["where"] = expression.NewStringer().Visit(this.where)
}
r["using"] = this.using
if this.with != nil {
r["with"] = this.with
}
return json.Marshal(r)
}
示例9: Test2iRangeKey
func Test2iRangeKey(t *testing.T) {
rangeKey := index.RangeKey()
if len(rangeKey) != 1 {
t.Fatalf("failed RangeKey() - %v, expected 1", len(rangeKey))
} else if v := expression.NewStringer().Visit(rangeKey[0]); v != "`name`" {
t.Fatalf("failed RangeKey() - %v, expected `name`")
}
}
示例10: MarshalJSON
/*
Marshal input ResultTerm into byte array.
*/
func (this *ResultTerm) MarshalJSON() ([]byte, error) {
r := map[string]interface{}{"type": "resultTerm"}
r["alias"] = this.alias
r["as"] = this.as
if this.expr != nil {
r["expr"] = expression.NewStringer().Visit(this.expr)
}
r["star"] = this.star
return json.Marshal(r)
}
示例11: MarshalJSON
func (this *Merge) MarshalJSON() ([]byte, error) {
r := map[string]interface{}{"#operator": "Merge"}
r["keyspace"] = this.keyspace.Name()
r["namespace"] = this.keyspace.NamespaceId()
r["keyspaceRef"] = this.ref
r["key"] = expression.NewStringer().Visit(this.key)
r["update"] = this.update
r["delete"] = this.delete
r["insert"] = this.insert
return json.Marshal(r)
}
示例12: MarshalJSON
func (this *Fetch) MarshalJSON() ([]byte, error) {
r := map[string]interface{}{"#operator": "Fetch"}
if this.term.Projection() != nil {
r["projection"] = expression.NewStringer().Visit(this.term.Projection())
}
r["namespace"] = this.term.Namespace()
r["keyspace"] = this.term.Keyspace()
if this.term.As() != "" {
r["as"] = this.term.As()
}
return json.Marshal(r)
}
示例13: MarshalJSON
func (this *Unnest) MarshalJSON() ([]byte, error) {
r := map[string]interface{}{"#operator": "Unnest"}
if this.term.Outer() {
r["outer"] = this.term.Outer()
}
r["expr"] = expression.NewStringer().Visit(this.term.Expression())
if this.alias != "" {
r["as"] = this.alias
}
return json.Marshal(r)
}
示例14: MarshalJSON
func (this *Order) MarshalJSON() ([]byte, error) {
r := map[string]interface{}{"#operator": "Order"}
/* generate sort terms */
s := make([]interface{}, 0, len(this.terms))
for _, term := range this.terms {
q := make(map[string]interface{})
q["expr"] = expression.NewStringer().Visit(term.Expression())
if term.Descending() {
q["desc"] = term.Descending()
}
s = append(s, q)
}
r["sort_terms"] = s
return json.Marshal(r)
}
示例15: collectAggregates
func collectAggregates(aggs map[string]algebra.Aggregate, exprs ...expression.Expression) {
stringer := expression.NewStringer()
for _, expr := range exprs {
agg, ok := expr.(algebra.Aggregate)
if ok {
str := stringer.Visit(agg)
aggs[str] = agg
}
_, ok = expr.(*algebra.Subquery)
if !ok {
children := expr.Children()
if len(children) > 0 {
collectAggregates(aggs, children...)
}
}
}
}