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

Golang datastore.GetKeyspace函数代码示例

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

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



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

示例1: 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


示例2: 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


示例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 *InferKeyspace) UnmarshalJSON(body []byte) error {
	var _unmarshalled struct {
		_      string                  `json:"#operator"`
		Keysp  string                  `json:"keyspace"`
		Namesp string                  `json:"namespace"`
		Using  datastore.InferenceType `json:"using"`
		With   json.RawMessage         `json:"with"`
	}

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

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

	ksref := algebra.NewKeyspaceRef(_unmarshalled.Namesp, _unmarshalled.Keysp, "")

	var with value.Value
	if len(_unmarshalled.With) > 0 {
		with = value.NewValue(_unmarshalled.With)
	}

	this.node = algebra.NewInferKeyspace(ksref, _unmarshalled.Using, with)
	return nil
}
开发者ID:pkdevboxy,项目名称:query,代码行数:29,代码来源:infer_keyspace.go


示例5: UnmarshalJSON

func (this *Join) UnmarshalJSON(body []byte) error {
	var _unmarshalled struct {
		_     string `json:"#operator"`
		Names string `json:"namespace"`
		Keys  string `json:"keyspace"`
		On    string `json:"on_keys"`
		Outer bool   `json:"outer"`
		As    string `json:"as"`
	}
	var keys_expr expression.Expression

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

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

	this.outer = _unmarshalled.Outer
	this.term = algebra.NewKeyspaceTerm(_unmarshalled.Names, _unmarshalled.Keys,
		nil, _unmarshalled.As, keys_expr, nil)
	this.keyspace, err = datastore.GetKeyspace(_unmarshalled.Names, _unmarshalled.Keys)
	return err
}
开发者ID:mschoch,项目名称:query,代码行数:29,代码来源:join.go


示例6: UnmarshalJSON

func (this *AlterIndex) UnmarshalJSON(body []byte) error {
	var _unmarshalled struct {
		_      string              `json:"#operator"`
		Index  string              `json:"index"`
		Keys   string              `json:"keyspace"`
		Names  string              `json:"namespace"`
		Rename string              `json:"rename"`
		Using  datastore.IndexType `json:"using"`
	}

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

	ksref := algebra.NewKeyspaceRef(_unmarshalled.Names, _unmarshalled.Keys, "")
	this.node = algebra.NewAlterIndex(ksref, _unmarshalled.Index, _unmarshalled.Using, _unmarshalled.Rename)

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

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

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


示例7: 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


示例8: 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


示例9: UnmarshalJSON

func (this *PrimaryScan) UnmarshalJSON(body []byte) error {
	var _unmarshalled struct {
		_     string              `json:"#operator"`
		Index string              `json:"index"`
		Names string              `json:"namespace"`
		Keys  string              `json:"keyspace"`
		Using datastore.IndexType `json:"using"`
		Limit string              `json:"limit"`
	}

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

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

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

	this.term = algebra.NewKeyspaceTerm(
		_unmarshalled.Names, _unmarshalled.Keys,
		nil, "", nil, nil)

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

	index, err := indexer.IndexByName(_unmarshalled.Index)
	if err != nil {
		return err
	}

	primary, ok := index.(datastore.PrimaryIndex)
	if ok {
		this.index = primary
		return nil
	}

	return fmt.Errorf("Unable to unmarshal %s as primary index.", _unmarshalled.Index)
}
开发者ID:pkdevboxy,项目名称:query,代码行数:49,代码来源:scan_primary.go


示例10: UnmarshalJSON

func (this *CreatePrimaryIndex) UnmarshalJSON(body []byte) error {
	var _unmarshalled struct {
		_     string                      `json:"#operator"`
		Keys  string                      `json:"keyspace"`
		Names string                      `json:"namespace"`
		Node  *algebra.CreatePrimaryIndex `json:"node"`
	}

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

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


示例11: UnmarshalJSON

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

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

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

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


示例12: UnmarshalJSON

func (this *BuildIndexes) UnmarshalJSON(body []byte) error {
	var _unmarshalled struct {
		_       string              `json:"#operator"`
		Keys    string              `json:"keyspace"`
		Names   string              `json:"namespace"`
		Using   datastore.IndexType `json:"using"`
		Indexes []string            `json:"indexes"`
	}

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

	ksref := algebra.NewKeyspaceRef(_unmarshalled.Names, _unmarshalled.Keys, "")
	this.node = algebra.NewBuildIndexes(ksref, _unmarshalled.Using, _unmarshalled.Indexes...)

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


示例13: UnmarshalJSON

func (this *IndexNest) UnmarshalJSON(body []byte) error {
	var _unmarshalled struct {
		_     string `json:"#operator"`
		Names string `json:"namespace"`
		Keys  string `json:"keyspace"`
		On    string `json:"on_key"`
		Outer bool   `json:"outer"`
		As    string `json:"as"`
		For   string `json:"for"`
		Scan  struct {
			Index  string              `json:"index"`
			Using  datastore.IndexType `json:"using"`
			Covers []string            `json:"covers"`
		} `json:"scan"`
	}

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

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

	this.outer = _unmarshalled.Outer
	this.keyFor = _unmarshalled.For
	this.idExpr = expression.NewField(
		expression.NewMeta(expression.NewIdentifier(this.keyFor)),
		expression.NewFieldName("id", false))
	this.term = algebra.NewKeyspaceTerm(_unmarshalled.Names, _unmarshalled.Keys,
		nil, _unmarshalled.As, keys_expr, nil)
	this.keyspace, err = datastore.GetKeyspace(_unmarshalled.Names, _unmarshalled.Keys)
	if err != nil {
		return err
	}

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

	this.index, err = indexer.IndexByName(_unmarshalled.Scan.Index)
	if err != nil {
		return err
	}

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

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

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


示例14: UnmarshalJSON

func (this *CreateIndex) UnmarshalJSON(body []byte) error {
	var _unmarshalled struct {
		_         string              `json:"#operator"`
		Keysp     string              `json:"keyspace"`
		Namesp    string              `json:"namespace"`
		Index     string              `json:"index"`
		Keys      []string            `json:"keys"`
		Using     datastore.IndexType `json:"using"`
		Partition []string            `json:"partition"`
		Where     string              `json:"where"`
		With      json.RawMessage     `json:"with"`
	}

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

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

	ksref := algebra.NewKeyspaceRef(_unmarshalled.Namesp, _unmarshalled.Keysp, "")

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

	var partition expression.Expressions
	if len(_unmarshalled.Partition) > 0 {
		partition = make(expression.Expressions, len(_unmarshalled.Partition))
		for i, p := range _unmarshalled.Partition {
			partition[i], err = parser.Parse(p)
			if err != nil {
				return err
			}
		}
	}

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

	var with value.Value
	if len(_unmarshalled.With) > 0 {
		with = value.NewValue(_unmarshalled.With)
	}

	this.node = algebra.NewCreateIndex(_unmarshalled.Index, ksref,
		keys, partition, where, _unmarshalled.Using, with)
	return nil
}
开发者ID:pkdevboxy,项目名称:query,代码行数:61,代码来源:index_create.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang datastore.IndexConnection类代码示例发布时间:2022-05-23
下一篇:
Golang algebra.Subselect类代码示例发布时间: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