com.bigdata.relation.rule
Interface IBindingSet

All Superinterfaces:
Cloneable, Serializable
All Known Implementing Classes:
ArrayBindingSet, EmptyBindingSet, HashBindingSet

public interface IBindingSet
extends Cloneable, Serializable

Interface for a set of bindings. The set of variables values is extensible and the bound values are loosely typed.

Version:
$Id: IBindingSet.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson
TODO:
The variable positions in a binding set can be assigned an index by the order in which they are encountered across the predicates when the predicates are considered in execution order. This gives us a dense index in [0:nvars-1]. The index can be into an array. When the bindings are of a primitive type, as they are for the RDF DB, that array can be an array of the primitive type, e.g., long[nvars].

This change would require that the singleton factory for a variable was on the Rule (different rules would have different index assignments), it would require predicates to be cloned into a Rule so that the variables possessed the necessary index assignment, and that index assignment would have to be late - once the evaluation order was determined, so maybe the Rule is cloned into the RuleState once we have the evaluation order.

There would also need to be a type-specific means for copying bindings from a visited element into a bindingSet if a want to avoid autoboxing.

The IConstant interface might have to disappear for this as well. I am not convinced that it adds much.

To obtain a Var you MUST go to the IVariable factory on the IRule. (It is easy to find violators since all vars are currently assigned by a single factory.)

Since we sometimes do not have access to the rule that generated the bindings, we would also require the ability to retrieve a binding by the name of the variable (this case arises when the rule is generated dynamically in a manner that is not visible to the consumer of the bindings, e.g., the match rule of the RDF DB).


Method Summary
 void clear(IVariable var)
          Clear any binding for the variable.
 void clearAll()
          Clear all bindings.
 IBindingSet clone()
          Return a shallow copy of the binding set.
 boolean equals(IBindingSet o)
          True iff the variables and their bound values are the same for the two binding sets.
 IConstant get(IVariable var)
          Return the binding for the variable.
 boolean isBound(IVariable var)
          Return true iff the variable is bound.
 Iterator<Map.Entry<IVariable,IConstant>> iterator()
          Visits the bindings.
 void set(IVariable var, IConstant val)
          Bind the variable to the value.
 int size()
          The #of bound variables.
 Iterator<IVariable> vars()
          Visits the bound variables.
 

Method Detail

isBound

boolean isBound(IVariable var)
Return true iff the variable is bound.

Parameters:
var - The variable.
Returns:
true if the variable is bound.
Throws:
IllegalArgumentException - if var is null.

set

void set(IVariable var,
         IConstant val)
Bind the variable to the value.

Parameters:
var - The variable.
val - The value (MAY NOT be null).
Throws:
IllegalArgumentException - if var is null.
IllegalArgumentException - if val is null.

get

IConstant get(IVariable var)
Return the binding for the variable.

Parameters:
var - The variable.
Returns:
the binding for the variable -or- null iff the variable is not bound.
Throws:
IllegalArgumentException - if var is null.

clear

void clear(IVariable var)
Clear any binding for the variable.

Parameters:
var - The variable.
Throws:
IllegalArgumentException - if var is null.

clearAll

void clearAll()
Clear all bindings.


size

int size()
The #of bound variables.


iterator

Iterator<Map.Entry<IVariable,IConstant>> iterator()
Visits the bindings.


vars

Iterator<IVariable> vars()
Visits the bound variables.


clone

IBindingSet clone()
Return a shallow copy of the binding set.


equals

boolean equals(IBindingSet o)
True iff the variables and their bound values are the same for the two binding sets.

Parameters:
o - Another binding set.


Copyright © 2006-2009 SYSTAP, LLC. All Rights Reserved.