Beispiel #1
0
func (this *builder) VisitIndexJoin(node *algebra.IndexJoin) (interface{}, error) {
	this.limit = nil

	_, 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
	}

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

	this.subChildren = append(this.subChildren, join)
	return nil, nil
}
Beispiel #2
0
func (this *builder) buildIndexJoin(keyspace datastore.Keyspace,
	node *algebra.IndexJoin) (op *plan.IndexJoin, err error) {
	index, covers, err := this.buildJoinScan(keyspace, node.Right(), "join")
	if err != nil {
		return nil, err
	}

	return plan.NewIndexJoin(keyspace, node, index, covers), nil
}
Beispiel #3
0
func NewIndexJoin(keyspace datastore.Keyspace, join *algebra.IndexJoin,
	index datastore.Index, covers expression.Covers) *IndexJoin {
	rv := &IndexJoin{
		keyspace: keyspace,
		term:     join.Right(),
		outer:    join.Outer(),
		keyFor:   join.For(),
		index:    index,
		covers:   covers,
	}

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