本文整理汇总了Golang中github.com/couchbase/query/algebra.Subselect.From方法的典型用法代码示例。如果您正苦于以下问题:Golang Subselect.From方法的具体用法?Golang Subselect.From怎么用?Golang Subselect.From使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/couchbase/query/algebra.Subselect
的用法示例。
在下文中一共展示了Subselect.From方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: visitFrom
func (this *builder) visitFrom(node *algebra.Subselect, group *algebra.Group) error {
count, err := this.fastCount(node)
if err != nil {
return err
}
if count {
this.maxParallelism = 1
} else if node.From() != nil {
if this.where != nil || group != nil {
this.limit = nil
}
_, err := node.From().Accept(this)
if err != nil {
return err
}
} else {
// No FROM clause
scan := plan.NewDummyScan()
this.children = append(this.children, scan)
this.maxParallelism = 1
}
return nil
}
示例2: fastCount
func (this *builder) fastCount(node *algebra.Subselect) (bool, error) {
if node.From() == nil ||
node.Where() != nil ||
node.Group() != nil {
return false, nil
}
from, ok := node.From().(*algebra.KeyspaceTerm)
if !ok ||
from.Projection() != nil ||
from.Keys() != nil {
return false, nil
}
from.SetDefaultNamespace(this.namespace)
keyspace, err := this.getTermKeyspace(from)
if err != nil {
return false, err
}
for _, term := range node.Projection().Terms() {
count, ok := term.Expression().(*algebra.Count)
if !ok || count.Operand() != nil {
return false, nil
}
}
scan := plan.NewCountScan(keyspace, from)
this.children = append(this.children, scan)
return true, nil
}
示例3: VisitSubselect
func (this *builder) VisitSubselect(node *algebra.Subselect) (interface{}, error) {
aggs, err := allAggregates(node, this.order)
if err != nil {
return nil, err
}
this.where = node.Where()
group := node.Group()
if group == nil && len(aggs) > 0 {
group = algebra.NewGroup(nil, nil, nil)
this.where = constrainAggregate(this.where, aggs)
}
this.children = make([]plan.Operator, 0, 16) // top-level children, executed sequentially
this.subChildren = make([]plan.Operator, 0, 16) // sub-children, executed across data-parallel streams
count, err := this.fastCount(node)
if err != nil {
return nil, err
}
if count {
this.maxParallelism = 1
} else if node.From() != nil {
if this.where != nil || group != nil {
this.limit = nil
}
_, err := node.From().Accept(this)
if err != nil {
return nil, err
}
} else {
// No FROM clause
scan := plan.NewDummyScan()
this.children = append(this.children, scan)
this.maxParallelism = 1
}
if this.coveringScan != nil {
coverer := expression.NewCoverer(this.coveringScan.Covers())
err = this.cover.MapExpressions(coverer)
if err != nil {
return nil, err
}
if this.where != nil {
this.where, err = coverer.Map(this.where)
if err != nil {
return nil, err
}
}
}
if node.Let() != nil {
this.subChildren = append(this.subChildren, plan.NewLet(node.Let()))
}
if node.Where() != nil {
this.subChildren = append(this.subChildren, plan.NewFilter(node.Where()))
}
if group != nil {
this.visitGroup(group, aggs)
}
projection := node.Projection()
this.subChildren = append(this.subChildren, plan.NewInitialProject(projection))
// Initial DISTINCT (parallel)
if projection.Distinct() || this.distinct {
this.subChildren = append(this.subChildren, plan.NewDistinct())
}
if !this.delayProjection {
// Perform the final projection if there is no subsequent ORDER BY
this.subChildren = append(this.subChildren, plan.NewFinalProject())
}
// Parallelize the subChildren
this.children = append(this.children, plan.NewParallel(plan.NewSequence(this.subChildren...), this.maxParallelism))
// Final DISTINCT (serial)
if projection.Distinct() || this.distinct {
this.children = append(this.children, plan.NewDistinct())
}
// Serialize the top-level children
return plan.NewSequence(this.children...), nil
}