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

Golang parser.Parse函数代码示例

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

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



在下文中一共展示了Parse函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: UnmarshalJSON

func (this *InitialGroup) UnmarshalJSON(body []byte) error {
	var _unmarshalled struct {
		_    string   "#operator"
		Keys []string "group_keys"
		Aggs []string "aggregates"
	}

	err := json.Unmarshal(body, &_unmarshalled)
	if err != nil {
		return err
	}

	this.keys = make(expression.Expressions, len(_unmarshalled.Keys))
	for i, key := range _unmarshalled.Keys {
		key_expr, err := parser.Parse(key)
		if err != nil {
			return err
		}
		this.keys[i] = key_expr
	}

	this.aggregates = make(algebra.Aggregates, len(_unmarshalled.Aggs))
	for i, agg := range _unmarshalled.Aggs {
		agg_expr, err := parser.Parse(agg)
		if err != nil {
			return err
		}
		this.aggregates[i], _ = agg_expr.(algebra.Aggregate)
	}

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


示例2: init

func init() {
	qpServer = startQueryport("localhost:9998", serverCallb)

	ns := &namespace{
		name:          "default",
		keyspaceCache: make(map[string]datastore.Keyspace),
	}
	ks := &keyspace{
		namespace: ns,
		name:      "default",
		indexes:   make(map[string]datastore.Index),
	}
	expr, err := parser.Parse(`gender`)
	if err != nil {
		log.Fatal(err)
	}
	equalKey := expression.Expressions{expr}
	expr, err = parser.Parse(`name`)
	if err != nil {
		log.Fatal(err)
	}
	rangeKey := expression.Expressions{expr}
	whereKey, err := parser.Parse("(30 < `age`)")
	if err != nil {
		log.Fatal(err)
	}
	index, _ = new2iIndex(
		"testindex", equalKey, rangeKey, whereKey, "gsi", ks)
	index.setHost([]string{"localhost:9998"})
}
开发者ID:pkdevboxy,项目名称:query,代码行数:30,代码来源:secondary_index_test.go


示例3: UnmarshalJSON

func (this *SendUpsert) UnmarshalJSON(body []byte) error {
	var _unmarshalled struct {
		_         string `json:"#operator"`
		KeyExpr   string `json:"key"`
		ValueExpr string `json:"value"`
		Keys      string `json:"keyspace"`
		Names     string `json:"namespace"`
		Alias     string `json:"alias"`
	}

	err := json.Unmarshal(body, &_unmarshalled)
	if err != nil {
		return err
	}

	if _unmarshalled.KeyExpr != "" {
		this.key, err = parser.Parse(_unmarshalled.KeyExpr)
		if err != nil {
			return err
		}
	}

	if _unmarshalled.ValueExpr != "" {
		this.value, err = parser.Parse(_unmarshalled.ValueExpr)
		if err != nil {
			return err
		}
	}

	this.alias = _unmarshalled.Alias
	this.keyspace, err = datastore.GetKeyspace(_unmarshalled.Names, _unmarshalled.Keys)
	return nil
}
开发者ID:pkdevboxy,项目名称:query,代码行数:33,代码来源:upsert.go


示例4: UnmarshalJSON

func (this *Range) UnmarshalJSON(body []byte) error {
	var _unmarshalled struct {
		Low       []string
		High      []string
		Inclusion datastore.Inclusion
	}

	err := json.Unmarshal(body, &_unmarshalled)
	if err != nil {
		return err
	}

	if _unmarshalled.Low != nil {
		this.Low = make(expression.Expressions, len(_unmarshalled.Low))
		for l, lowExpr := range _unmarshalled.Low {
			this.Low[l], err = parser.Parse(lowExpr)
			if err != nil {
				return err
			}
		}
	}

	if _unmarshalled.High != nil {
		this.High = make(expression.Expressions, len(_unmarshalled.High))
		for h, hiExpr := range _unmarshalled.High {
			this.High[h], err = parser.Parse(hiExpr)
			if err != nil {
				return err
			}
		}
	}

	this.Inclusion = _unmarshalled.Inclusion
	return nil
}
开发者ID:pkdevboxy,项目名称:query,代码行数:35,代码来源:span.go


示例5: UnmarshalJSON

func (this *IndexScan) UnmarshalJSON(body []byte) error {
	var _unmarshalled struct {
		_         string              `json:"#operator"`
		Index     string              `json:"index"`
		Namespace string              `json:"namespace"`
		Keyspace  string              `json:"keyspace"`
		Using     datastore.IndexType `json:"using"`
		Spans     Spans               `json:"spans"`
		Distinct  bool                `json:"distinct"`
		Limit     string              `json:"limit"`
		Covers    []string            `json:"covers"`
	}

	err := json.Unmarshal(body, &_unmarshalled)
	if err != nil {
		return err
	}

	k, err := datastore.GetKeyspace(_unmarshalled.Namespace, _unmarshalled.Keyspace)
	if err != nil {
		return err
	}

	this.term = algebra.NewKeyspaceTerm(
		_unmarshalled.Namespace, _unmarshalled.Keyspace,
		nil, "", nil, nil)

	this.spans = _unmarshalled.Spans
	this.distinct = _unmarshalled.Distinct

	if _unmarshalled.Limit != "" {
		this.limit, err = parser.Parse(_unmarshalled.Limit)
		if err != nil {
			return err
		}
	}

	if _unmarshalled.Covers != nil {
		this.covers = make(expression.Covers, len(_unmarshalled.Covers))
		for i, c := range _unmarshalled.Covers {
			expr, err := parser.Parse(c)
			if err != nil {
				return err
			}

			this.covers[i] = expression.NewCover(expr)
		}
	}

	indexer, err := k.Indexer(_unmarshalled.Using)
	if err != nil {
		return err
	}

	this.index, err = indexer.IndexByName(_unmarshalled.Index)
	return err
}
开发者ID:pkdevboxy,项目名称:query,代码行数:57,代码来源:scan_index.go


示例6: Condition

// Condition implement Index{} interface.
func (si *secondaryIndex) Condition() expression.Expression {
	if si != nil && si.whereExpr != "" {
		expr, _ := parser.Parse(si.whereExpr)
		return expr
	}
	return nil
}
开发者ID:prataprc,项目名称:indexing,代码行数:8,代码来源:secondary_index.go


示例7: UnmarshalJSON

func (this *SendUpdate) UnmarshalJSON(body []byte) error {
	var _unmarshalled struct {
		_     string `json:"#operator"`
		Keys  string `json:"keyspace"`
		Names string `json:"namespace"`
		Alias string `json:"alias"`
		Limit string `json:"limit"`
	}

	err := json.Unmarshal(body, &_unmarshalled)
	if err != nil {
		return err
	}

	this.alias = _unmarshalled.Alias

	if _unmarshalled.Limit != "" {
		this.limit, err = parser.Parse(_unmarshalled.Limit)
		if err != nil {
			return err
		}
	}

	this.keyspace, err = datastore.GetKeyspace(_unmarshalled.Names, _unmarshalled.Keys)
	return err
}
开发者ID:pkdevboxy,项目名称:query,代码行数:26,代码来源:update.go


示例8: UnmarshalJSON

func (this *Let) UnmarshalJSON(body []byte) error {
	var _unmarshalled struct {
		_        string `json:"#operator"`
		Bindings []struct {
			_    string `json:"type"`
			Var  string `json:"variable"`
			Expr string `json:"variable"`
			Desc bool   `json:"descend"`
		} `json:"bindings"`
	}

	err := json.Unmarshal(body, &_unmarshalled)
	if err != nil {
		return err
	}

	this.bindings = make(expression.Bindings, len(_unmarshalled.Bindings))
	for i, binding := range _unmarshalled.Bindings {
		expr, err := parser.Parse(binding.Expr)
		if err != nil {
			return err
		}
		if binding.Desc {
			this.bindings[i] = expression.NewDescendantBinding(binding.Var, expr)
		} else {
			this.bindings[i] = expression.NewBinding(binding.Var, expr)
		}
	}

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


示例9: UnmarshalUpdateFor

/*
Unmarshals byte array.
*/
func UnmarshalUpdateFor(body []byte) (*algebra.UpdateFor, error) {
	var _unmarshalled struct {
		Bindings json.RawMessage `json:"bindings"`
		When     string          `json:"when"`
	}

	err := json.Unmarshal(body, &_unmarshalled)
	if err != nil {
		return nil, err
	}

	bindings, err := unmarshal.UnmarshalBindings(_unmarshalled.Bindings)
	if err != nil {
		return nil, err
	}

	var when expression.Expression
	if _unmarshalled.When != "" {
		when, err = parser.Parse(_unmarshalled.When)
		if err != nil {
			return nil, err
		}
	}

	return algebra.NewUpdateFor(bindings, when), nil
}
开发者ID:pkdevboxy,项目名称:query,代码行数:29,代码来源:update.go


示例10: UnmarshalJSON

func (this *Unnest) UnmarshalJSON(body []byte) error {
	var _unmarshalled struct {
		_     string `json:"#operator"`
		Outer bool   `json:"outer"`
		Expr  string `json:"expr"`
		As    string `json:"as"`
	}
	var expr expression.Expression

	err := json.Unmarshal(body, &_unmarshalled)
	if err != nil {
		return err
	}

	if _unmarshalled.Expr != "" {
		expr, err = parser.Parse(_unmarshalled.Expr)
		if err != nil {
			return err
		}
	}

	this.term = algebra.NewUnnest(nil, _unmarshalled.Outer, expr, _unmarshalled.As)
	this.alias = _unmarshalled.As
	return err
}
开发者ID:mschoch,项目名称:query,代码行数:25,代码来源:join.go


示例11: UnmarshalJSON

func (this *ValueScan) UnmarshalJSON(body []byte) error {
	var _unmarshalled struct {
		_      string `json:"#operator"`
		Values string `json:"values"`
	}

	err := json.Unmarshal(body, &_unmarshalled)
	if err != nil {
		return err
	}

	if _unmarshalled.Values == "" {
		return nil
	}

	expr, err := parser.Parse(_unmarshalled.Values)
	if err != nil {
		return err
	}

	array, ok := expr.(*expression.ArrayConstruct)
	if !ok {
		return fmt.Errorf("Invalid VALUES expression %s", _unmarshalled.Values)
	}

	this.values, err = algebra.NewPairs(array)
	return err
}
开发者ID:pkdevboxy,项目名称:query,代码行数:28,代码来源:scan_value.go


示例12: UnmarshalBindings

func UnmarshalBindings(body []byte) (expression.Bindings, error) {
	var _unmarshalled []struct {
		Var  string `json:"variable"`
		Expr string `json:"expr"`
		Desc bool   `json:"descend"`
	}

	err := json.Unmarshal(body, &_unmarshalled)
	if err != nil {
		return nil, err
	}

	bindings := make(expression.Bindings, len(_unmarshalled))
	for i, binding := range _unmarshalled {
		expr, err := parser.Parse(binding.Expr)
		if err != nil {
			return nil, err
		}

		if binding.Desc {
			bindings[i] = expression.NewDescendantBinding(binding.Var, expr)
		} else {
			bindings[i] = expression.NewBinding(binding.Var, expr)
		}
	}

	return bindings, nil
}
开发者ID:pkdevboxy,项目名称:query,代码行数:28,代码来源:binding.go


示例13: UnmarshalJSON

func (this *Fetch) UnmarshalJSON(body []byte) error {
	var _unmarshalled struct {
		_     string `json:"#operator"`
		Proj  string `json:"projection"`
		Names string `json:"namespace"`
		Keys  string `json:"keyspace"`
		As    string `json:"as"`
	}
	var proj_expr expression.Path

	err := json.Unmarshal(body, &_unmarshalled)
	if err != nil {
		return err
	}

	if _unmarshalled.Proj != "" {
		expr, err := parser.Parse(_unmarshalled.Proj)
		if err != nil {
			return err
		}

		_proj_expr, is_path := expr.(expression.Path)
		if !is_path {
			return fmt.Errorf("Fetch.UnmarshalJSON: cannot resolve path expression from %s", _unmarshalled.Proj)
		}
		proj_expr = _proj_expr
	}
	this.term = algebra.NewKeyspaceTerm(_unmarshalled.Names, _unmarshalled.Keys,
		proj_expr, _unmarshalled.As, nil, nil)

	this.keyspace, err = datastore.GetKeyspace(_unmarshalled.Names, _unmarshalled.Keys)

	return err
}
开发者ID:pkdevboxy,项目名称:query,代码行数:34,代码来源:fetch.go


示例14: SeekKey

// SeekKey implement Index{} interface.
func (si *secondaryIndex) SeekKey() expression.Expressions {
	if si != nil && si.partnExpr != "" {
		expr, _ := parser.Parse(si.partnExpr)
		return expression.Expressions{expr}
	}
	return nil
}
开发者ID:prataprc,项目名称:indexing,代码行数:8,代码来源:secondary_index.go


示例15: UnmarshalUnsetTerm

/*
Unmarshals byte array.
*/
func UnmarshalUnsetTerm(body []byte) (*algebra.UnsetTerm, error) {
	var _unmarshalled struct {
		Path string          `json:"path"`
		For  json.RawMessage `json:"path_for"`
	}

	err := json.Unmarshal(body, &_unmarshalled)
	if err != nil {
		return nil, err
	}

	path_expr, err := parser.Parse(_unmarshalled.Path)
	if err != nil {
		return nil, err
	}

	path, is_path := path_expr.(expression.Path)
	if !is_path {
		return nil, fmt.Errorf("UnmarshalUnsetTerm: cannot resolve path expression from %s",
			_unmarshalled.Path)
	}

	var updateFor *algebra.UpdateFor
	if len(_unmarshalled.For) > 0 {
		updateFor, err = UnmarshalUpdateFor(_unmarshalled.For)
		if err != nil {
			return nil, err
		}
	}

	return algebra.NewUnsetTerm(path, updateFor), nil
}
开发者ID:pkdevboxy,项目名称:query,代码行数:35,代码来源:update.go


示例16: UnmarshalJSON

func (this *Merge) UnmarshalJSON(body []byte) error {
	var _unmarshalled struct {
		_      string               `json:"#operator"`
		Keys   string               `json:"keyspace"`
		Names  string               `json:"namespace"`
		KRef   *algebra.KeyspaceRef `json:"keyspaceRef"`
		Key    string               `json:"key"`
		Update json.RawMessage      `json:"update"`
		Delete json.RawMessage      `json:"delete"`
		Insert json.RawMessage      `json:"insert"`
	}

	err := json.Unmarshal(body, &_unmarshalled)
	if err != nil {
		return err
	}

	this.keyspace, err = datastore.GetKeyspace(_unmarshalled.Names, _unmarshalled.Keys)
	if err != nil {
		return err
	}

	if _unmarshalled.Key != "" {
		this.key, err = parser.Parse(_unmarshalled.Key)
		if err != nil {
			return err
		}
	}

	ops := []json.RawMessage{
		_unmarshalled.Update,
		_unmarshalled.Delete,
		_unmarshalled.Insert,
	}

	for i, child := range ops {
		var op_type struct {
			Operator string `json:"#operator"`
		}

		err = json.Unmarshal(child, &op_type)
		if err != nil {
			return err
		}

		switch i {
		case 0:
			this.update, err = MakeOperator(op_type.Operator, child)
		case 1:
			this.delete, err = MakeOperator(op_type.Operator, child)
		case 2:
			this.insert, err = MakeOperator(op_type.Operator, child)
		}
		return err
	}

	return err
}
开发者ID:jmptrader,项目名称:query,代码行数:58,代码来源:merge.go


示例17: UnmarshalSetTerms

/*
Unmarshals byte array.
*/
func UnmarshalSetTerms(body []byte) (algebra.SetTerms, error) {
	var _unmarshalled []struct {
		Path  string          `json:"path"`
		Value string          `json:"value"`
		For   json.RawMessage `json:"path_for"`
	}

	err := json.Unmarshal(body, &_unmarshalled)
	if err != nil {
		return nil, err
	}

	terms := make(algebra.SetTerms, len(_unmarshalled))
	for i, term := range _unmarshalled {
		path_expr, err := parser.Parse(term.Path)
		if err != nil {
			return nil, err
		}

		path, is_path := path_expr.(expression.Path)
		if !is_path {
			return nil, fmt.Errorf("UnmarshalSetTerms: cannot resolve path expression from %s",
				term.Path)
		}

		value, err := parser.Parse(term.Value)
		if err != nil {
			return nil, err
		}

		var updateFor *algebra.UpdateFor
		if len(term.For) > 0 {
			updateFor, err = UnmarshalUpdateFor(term.For)
			if err != nil {
				return nil, err
			}
		}

		terms[i] = algebra.NewSetTerm(path, value, updateFor)
	}

	return terms, nil
}
开发者ID:pkdevboxy,项目名称:query,代码行数:46,代码来源:update.go


示例18: RangeKey

// RangeKey implement Index{} interface.
func (si *secondaryIndex) RangeKey() expression.Expressions {
	if si != nil && si.secExprs != nil {
		exprs := make(expression.Expressions, 0, len(si.secExprs))
		for _, exprS := range si.secExprs {
			expr, _ := parser.Parse(exprS)
			exprs = append(exprs, expr)
		}
		return exprs
	}
	return nil
}
开发者ID:prataprc,项目名称:indexing,代码行数:12,代码来源:secondary_index.go


示例19: CompileN1QLExpression

// CompileN1QLExpression will take expressions defined in N1QL's DDL statement
// and compile them for evaluation.
func CompileN1QLExpression(expressions []string) ([]interface{}, error) {
	cExprs := make([]interface{}, 0, len(expressions))
	for _, expr := range expressions {
		cExpr, err := qparser.Parse(expr)
		if err != nil {
			logging.Errorf("CompileN1QLExpression() %v: %v\n", expr, err)
			return nil, err
		}
		cExprs = append(cExprs, cExpr)
	}
	return cExprs, nil
}
开发者ID:jchris,项目名称:indexing,代码行数:14,代码来源:n1ql_evaluate.go


示例20: UnmarshalJSON

func (this *Order) UnmarshalJSON(body []byte) error {
	var _unmarshalled struct {
		_     string `json:"#operator"`
		Terms []struct {
			Expr string `json:"expr"`
			Desc bool   `json:"desc"`
		} `json:"sort_terms"`
		offsetExpr string `json:"offset"`
		limitExpr  string `json:"limit"`
	}

	err := json.Unmarshal(body, &_unmarshalled)
	if err != nil {
		return err
	}

	this.terms = make(algebra.SortTerms, len(_unmarshalled.Terms))
	for i, term := range _unmarshalled.Terms {
		expr, err := parser.Parse(term.Expr)
		if err != nil {
			return err
		}
		this.terms[i] = algebra.NewSortTerm(expr, term.Desc)
	}
	if offsetExprStr := _unmarshalled.offsetExpr; offsetExprStr != "" {
		offsetExpr, err := parser.Parse(offsetExprStr)
		if err != nil {
			return err
		}
		this.offset = NewOffset(offsetExpr)
	}
	if limitExprStr := _unmarshalled.limitExpr; limitExprStr != "" {
		limitExpr, err := parser.Parse(limitExprStr)
		if err != nil {
			return err
		}
		this.limit = NewLimit(limitExpr)
	}
	return nil
}
开发者ID:pkdevboxy,项目名称:query,代码行数:40,代码来源:order.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang logging.Debugf函数代码示例发布时间:2022-05-23
下一篇:
Golang expression.Visitor类代码示例发布时间: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