• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang expression.NewStringer函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/couchbase/query/expression.NewStringer函数的典型用法代码示例。如果您正苦于以下问题:Golang NewStringer函数的具体用法?Golang NewStringer怎么用?Golang NewStringer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NewStringer函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
}
开发者ID:jmptrader,项目名称:query,代码行数:10,代码来源:update.go


示例2: MarshalJSON

/*
Marshals input into byte array.
*/
func (this *SetTerm) MarshalJSON() ([]byte, error) {
	r := make(map[string]interface{}, 3)
	r["path"] = expression.NewStringer().Visit(this.path)
	r["value"] = expression.NewStringer().Visit(this.value)
	if this.updateFor != nil {
		r["path_for"] = this.updateFor
	}

	return json.Marshal(r)
}
开发者ID:pkdevboxy,项目名称:query,代码行数:13,代码来源:update_set.go


示例3: 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)
}
开发者ID:pkdevboxy,项目名称:query,代码行数:16,代码来源:from_keyspace.go


示例4: putDesignDoc

func (idx *viewIndex) putDesignDoc() error {
	var view cb.ViewDefinition
	view.Map = idx.ddoc.mapfn

	var put ddocJSON
	put.Views = make(map[string]cb.ViewDefinition)
	put.Views[idx.name] = view
	put.IndexChecksum = idx.ddoc.checksum()
	put.PrimaryIndex = idx.IsPrimary()

	// add view update options
	put.Options = map[string]interface{}{"updateMinChanges": 1}

	put.IndexOn = make([]string, len(idx.on))
	for idx, expr := range idx.on {
		put.IndexOn[idx] = expression.NewStringer().Visit(expr)
	}

	if condition := idx.Condition(); condition != nil {
		put.Condition = expression.NewStringer().Visit(condition)
	}

	if err := idx.keyspace.cbbucket.PutDDoc(idx.DDocName(), &put); err != nil {
		return err
	}

	var saved *ddocJSON = nil
	var err error = nil

	// give the PUT some time to register
	for i := 0; i < 3; i++ {
		if i > 1 {
			time.Sleep(time.Duration(i*3) * time.Second)
		}

		saved, err = getDesignDoc(idx.keyspace, idx.DDocName())
		if err == nil {
			break
		}
	}

	if err != nil {
		return errors.New("Creating index '" + idx.name + "' failed: " + err.Error())
	}

	if saved.IndexChecksum != idx.ddoc.checksum() {
		return errors.New("Checksum mismatch after creating index '" + idx.name + "'")
	}

	return nil
}
开发者ID:jmptrader,项目名称:query,代码行数:51,代码来源:view_builder.go


示例5: 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)
}
开发者ID:jmptrader,项目名称:query,代码行数:14,代码来源:group.go


示例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)
	}
}
开发者ID:pkdevboxy,项目名称:query,代码行数:7,代码来源:secondary_index_test.go


示例7: MarshalJSON

func (this *IndexNest) MarshalJSON() ([]byte, error) {
	r := map[string]interface{}{"#operator": "IndexNest"}
	r["namespace"] = this.term.Namespace()
	r["keyspace"] = this.term.Keyspace()
	r["on_key"] = expression.NewStringer().Visit(this.term.Keys())
	r["for"] = this.keyFor

	if this.outer {
		r["outer"] = this.outer
	}

	if this.term.As() != "" {
		r["as"] = this.term.As()
	}

	scan := map[string]interface{}{
		"index": this.index.Name(),
		"using": this.index.Type(),
	}

	if this.covers != nil {
		scan["covers"] = this.covers
	}

	r["scan"] = scan
	return json.Marshal(r)
}
开发者ID:pkdevboxy,项目名称:query,代码行数:27,代码来源:nest_index.go


示例8: 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
}
开发者ID:mschoch,项目名称:query,代码行数:7,代码来源:system_keyspace_indexes.go


示例9: 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)
}
开发者ID:pkdevboxy,项目名称:query,代码行数:33,代码来源:project.go


示例10: 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)
}
开发者ID:jmptrader,项目名称:query,代码行数:20,代码来源:index_create.go


示例11: 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`")
	}
}
开发者ID:pkdevboxy,项目名称:query,代码行数:8,代码来源:secondary_index_test.go


示例12: 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)
	}
}
开发者ID:pkdevboxy,项目名称:query,代码行数:8,代码来源:secondary_index_test.go


示例13: CreateIndex

// CreateIndex implements datastore.Indexer{} interface. Create a secondary
// index on this keyspace
func (gsi *gsiKeyspace) CreateIndex(
	requestId, name string, seekKey, rangeKey expression.Expressions,
	where expression.Expression, with value.Value) (
	datastore.Index, errors.Error) {

	var partnStr string
	if seekKey != nil && len(seekKey) > 0 {
		partnStr = expression.NewStringer().Visit(seekKey[0])
	}

	var whereStr string
	if where != nil {
		whereStr = expression.NewStringer().Visit(where)
	}

	secStrs := make([]string, len(rangeKey))
	for i, key := range rangeKey {
		s := expression.NewStringer().Visit(key)
		secStrs[i] = s
	}

	var withJSON []byte
	var err error
	if with != nil {
		if withJSON, err = with.MarshalJSON(); err != nil {
			return nil, errors.NewError(err, "GSI error marshalling WITH clause")
		}
	}
	defnID, err := gsi.gsiClient.CreateIndex(
		name,
		gsi.keyspace,       /*bucket-name*/
		string(c.ForestDB), /*using, by default always forestdb*/
		"N1QL",             /*exprType*/
		partnStr, whereStr, secStrs,
		false, /*isPrimary*/
		withJSON)
	if err != nil {
		return nil, errors.NewError(err, "GSI CreateIndex()")
	}
	// refresh to get back the newly created index.
	if err := gsi.Refresh(); err != nil {
		return nil, err
	}
	return gsi.IndexById(defnID2String(defnID))
}
开发者ID:prataprc,项目名称:indexing,代码行数:47,代码来源:secondary_index.go


示例14: MarshalJSON

/*
Marshals input unnest terms into byte array.
*/
func (this *Unnest) MarshalJSON() ([]byte, error) {
	r := map[string]interface{}{"type": "unnest"}
	r["left"] = this.left
	r["as"] = this.as
	r["outer"] = this.outer
	if this.expr != nil {
		r["expr"] = expression.NewStringer().Visit(this.expr)
	}
	return json.Marshal(r)
}
开发者ID:mschoch,项目名称:query,代码行数:13,代码来源:from.go


示例15: 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)
}
开发者ID:pkdevboxy,项目名称:query,代码行数:13,代码来源:result.go


示例16: 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)
}
开发者ID:pkdevboxy,项目名称:query,代码行数:12,代码来源:fetch.go


示例17: 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)
}
开发者ID:mschoch,项目名称:query,代码行数:13,代码来源:join.go


示例18: MarshalJSON

func (this *PrimaryScan) MarshalJSON() ([]byte, error) {
	r := map[string]interface{}{"#operator": "PrimaryScan"}
	r["index"] = this.index.Name()
	r["namespace"] = this.term.Namespace()
	r["keyspace"] = this.term.Keyspace()
	r["using"] = this.index.Type()

	if this.limit != nil {
		r["limit"] = expression.NewStringer().Visit(this.limit)
	}

	return json.Marshal(r)
}
开发者ID:pkdevboxy,项目名称:query,代码行数:13,代码来源:scan_primary.go


示例19: 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
	if this.offset != nil {
		r["offset"] = expression.NewStringer().Visit(this.offset.Expression())
	}
	if this.limit != nil {
		r["limit"] = expression.NewStringer().Visit(this.limit.Expression())
	}
	return json.Marshal(r)
}
开发者ID:pkdevboxy,项目名称:query,代码行数:24,代码来源:order.go


示例20: CreateSecondaryIndex

// Creates an index and waits for it to become active
func CreateSecondaryIndex(
	indexName, bucketName, server, whereExpr string, indexFields []string, isPrimary bool, with []byte,
	skipIfExists bool, indexActiveTimeoutSeconds int64, client *qc.GsiClient) error {

	if client == nil {
		c, e := CreateClient(server, "2itest")
		if e != nil {
			return e
		}
		client = c
		defer client.Close()
	}

	indexExists := IndexExistsWithClient(indexName, bucketName, server, client)
	if skipIfExists == true && indexExists == true {
		return nil
	}
	var secExprs []string
	if isPrimary == false {
		for _, indexField := range indexFields {
			expr, err := n1ql.ParseExpression(indexField)
			if err != nil {
				log.Printf("Creating index %v. Error while parsing the expression (%v) : %v", indexName, indexField, err)
			}

			secExprs = append(secExprs, expression.NewStringer().Visit(expr))
		}
	}
	using := "gsi"
	exprType := "N1QL"
	partnExp := ""

	start := time.Now()
	defnID, err := client.CreateIndex(indexName, bucketName, using, exprType, partnExp, whereExpr, secExprs, isPrimary, with)
	if err == nil {
		log.Printf("Created the secondary index %v. Waiting for it become active", indexName)
		e := WaitTillIndexActive(defnID, client, indexActiveTimeoutSeconds)
		if e != nil {
			return e
		} else {
			elapsed := time.Since(start)
			tc.LogPerfStat("CreateAndBuildIndex", elapsed)
			return nil
		}
	}

	return err
}
开发者ID:jchris,项目名称:indexing,代码行数:49,代码来源:secondaryindexmanagement.go



注:本文中的github.com/couchbase/query/expression.NewStringer函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang expression.And类代码示例发布时间:2022-05-23
下一篇:
Golang expression.NewFormalizer函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap