本文整理汇总了Golang中github.com/couchbase/query/algebra.KeyspaceTerm.Keys方法的典型用法代码示例。如果您正苦于以下问题:Golang KeyspaceTerm.Keys方法的具体用法?Golang KeyspaceTerm.Keys怎么用?Golang KeyspaceTerm.Keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/couchbase/query/algebra.KeyspaceTerm
的用法示例。
在下文中一共展示了KeyspaceTerm.Keys方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: selectScan
func (this *builder) selectScan(keyspace datastore.Keyspace, node *algebra.KeyspaceTerm,
limit expression.Expression) (op plan.Operator, err error) {
keys := node.Keys()
if keys != nil {
switch keys := keys.(type) {
case *expression.ArrayConstruct:
this.maxParallelism = util.MaxInt(1, len(keys.Operands()))
case *algebra.NamedParameter, *algebra.PositionalParameter:
this.maxParallelism = 0
default:
this.maxParallelism = 1
}
return plan.NewKeyScan(keys), nil
}
this.maxParallelism = 0 // Use default parallelism for index scans
secondary, primary, err := this.buildScan(keyspace, node, limit)
if err != nil {
return nil, err
}
if secondary != nil {
return secondary, nil
} else {
return primary, nil
}
}
示例2: VisitKeyspaceTerm
func (this *builder) VisitKeyspaceTerm(node *algebra.KeyspaceTerm) (interface{}, error) {
node.SetDefaultNamespace(this.namespace)
keyspace, err := this.getTermKeyspace(node)
if err != nil {
return nil, err
}
if this.subquery && this.correlated && node.Keys() == nil {
return nil, errors.NewSubqueryMissingKeysError(node.Keyspace())
}
scan, err := this.selectScan(keyspace, node, this.limit)
if err != nil {
return nil, err
}
this.children = append(this.children, scan)
if this.coveringScan == nil {
fetch := plan.NewFetch(keyspace, node)
this.subChildren = append(this.subChildren, fetch)
}
return nil, nil
}
示例3: buildJoinScan
func (this *builder) buildJoinScan(keyspace datastore.Keyspace, node *algebra.KeyspaceTerm, op string) (
datastore.Index, expression.Covers, error) {
indexes, err := allIndexes(keyspace)
if err != nil {
return nil, nil, err
}
var pred expression.Expression
pred = expression.NewIsNotNull(node.Keys().Copy())
dnf := NewDNF()
pred, err = dnf.Map(pred)
if err != nil {
return nil, nil, err
}
subset := pred
if this.where != nil {
subset = expression.NewAnd(subset, this.where.Copy())
subset, err = dnf.Map(subset)
if err != nil {
return nil, nil, err
}
}
formalizer := expression.NewFormalizer()
formalizer.Keyspace = node.Alias()
primaryKey := expression.Expressions{
expression.NewField(
expression.NewMeta(expression.NewConstant(node.Alias())),
expression.NewFieldName("id", false)),
}
sargables, err := sargableIndexes(indexes, pred, subset, primaryKey, dnf, formalizer)
if err != nil {
return nil, nil, err
}
minimals, err := minimalIndexes(sargables, pred)
if err != nil {
return nil, nil, err
}
if len(minimals) == 0 {
return nil, nil, errors.NewNoIndexJoinError(node.Alias(), op)
}
return this.buildCoveringJoinScan(minimals, node, op)
}