示例#1
0
func (this *builder) VisitIndexNest(node *algebra.IndexNest) (interface{}, error) {
	_, err := node.Left().Accept(this)
	if err != nil {
		return nil, err
	}

	right := node.Right()
	right.SetDefaultNamespace(this.namespace)
	namespace, err := this.datastore.NamespaceByName(right.Namespace())
	if err != nil {
		return nil, err
	}

	keyspace, err := namespace.KeyspaceByName(right.Keyspace())
	if err != nil {
		return nil, err
	}

	nest, err := this.buildIndexNest(keyspace, node)
	if err != nil {
		return nil, err
	}

	this.subChildren = append(this.subChildren, nest)
	return nil, nil
}
示例#2
0
func (this *builder) buildIndexNest(keyspace datastore.Keyspace,
	node *algebra.IndexNest) (op *plan.IndexNest, err error) {
	index, covers, err := this.buildJoinScan(keyspace, node.Right(), "nest")
	if err != nil {
		return nil, err
	}

	return plan.NewIndexNest(keyspace, node, index, covers), nil
}
示例#3
0
func NewIndexNest(keyspace datastore.Keyspace, nest *algebra.IndexNest,
	index datastore.Index, covers expression.Covers) *IndexNest {
	rv := &IndexNest{
		keyspace: keyspace,
		term:     nest.Right(),
		outer:    nest.Outer(),
		keyFor:   nest.For(),
		index:    index,
		covers:   covers,
	}

	rv.idExpr = expression.NewField(
		expression.NewMeta(expression.NewIdentifier(rv.keyFor)),
		expression.NewFieldName("id", false))
	return rv
}