|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bigdata.bop.CoreBaseBOp
com.bigdata.bop.BOpBase
public class BOpBase
Abstract base class for copy-on-write BOps. The BOpBase class
is used for query evaluation operators. The copy-on-write contract provides a
safety margin during concurrent evaluation of query plans by ensuring that
all references are fully published.
Instances of this class are effectively immutable (mutation APIs always
return a deep copy of the operator to which the mutation has been applied),
Serializable to facilitate distributed computing, and
Cloneable to facilitate non-destructive tree rewrites.
BOps should define the following public constructors
public Class(BOp[] args, Map<String,Object> anns)BOp
from the caller's data or when generated a query plan from Prolog. There are
some exceptions to this rule. For example, Constant does not define a
shallow copy constructor because that would not provide a means to set the
constant's value.public Class(Class src)BOp, apply the mutation to the copy, and then return the copy. This
is the "effectively immutable" contract. Again, there are some exceptions.
For example, Var provides a canonicalized mapping such that reference
tests may be used to determine if two Vars are the same. In order to
support that contract it overrides Var.clone().
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.bigdata.bop.BOp |
|---|
BOp.Annotations |
| Field Summary |
|---|
| Fields inherited from class com.bigdata.bop.CoreBaseBOp |
|---|
DEFAULT_INITIAL_CAPACITY |
| Fields inherited from interface com.bigdata.bop.BOp |
|---|
NOANNS, NOARGS |
| Constructor Summary | |
|---|---|
BOpBase(BOp[] args,
Map<String,Object> annotations)
Shallow copy constructor (required). |
|
BOpBase(BOpBase op)
Deep copy constructor (required). |
|
| Method Summary | ||
|---|---|---|
protected void |
_clearProperty(String name)
Clear an annotation. |
|
protected void |
_set(int index,
BOp op)
Set the value of an operand. |
|
protected Object |
_setProperty(String name,
Object value)
Set an annotation. |
|
Map<String,Object> |
annotations()
The operator's annotations. |
|
protected Map<String,Object> |
annotationsCopy()
A copy of the annotations. |
|
protected boolean |
annotationsEqual(BOp o)
Return true iff the annotations of this BOp and the
other BOp are equals. |
|
protected Map<String,Object> |
annotationsRef()
A reference to the actual annotations map object. |
|
Iterator<BOp> |
argIterator()
An iterator visiting the operator's arguments. |
|
List<BOp> |
args()
The operator's arguments as list. |
|
protected BOp[] |
argsCopy()
A copy of the args[] array. |
|
int |
arity()
The #of arguments to the operation. |
|
BOp |
clearAnnotations(String[] names)
Strips off the named annotations. |
|
BOpBase |
clearProperty(String name)
Clear the named annotation. |
|
protected static BOp[] |
deepCopy(BOp[] a)
Deep copy the arguments. |
|
protected static Map<String,Object> |
deepCopy(Map<String,Object> a)
Deep copy the annotations. |
|
BOp |
get(int index)
Return an argument to the operation. |
|
Object |
getProperty(String name)
Return the value of a named property. |
|
BOpBase |
setArg(int index,
BOp newArg)
Return a new BOpBase in which the child operand has been replaced
by the given expression. |
|
BOpBase |
setProperty(String name,
Object value)
Unconditionally sets the property. |
|
BOpBase |
setUnboundProperty(String name,
Object value)
Conditionally sets the property. |
|
BOp[] |
toArray()
A shallow copy of the operator's arguments. |
|
|
toArray(T[] a)
A shallow copy of the operator's arguments using the generic type of the caller's array. |
|
| Methods inherited from class com.bigdata.bop.CoreBaseBOp |
|---|
annotationsEqual, annotationsToString, checkArgs, clone, equals, getEvaluationContext, getId, getProperty, getRequiredProperty, hashCode, indent, isController, toShortString, toString |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public BOpBase(BOpBase op)
Each BOp MUST implement a public copy constructor with the
signature:
public Foo(Foo)This construct is invoked by
CoreBaseBOp.clone() using reflection and is
responsible for the deep copy semantics for the BOp.
The default implementation makes a deep copy of args() and
annotations() but DOES NOT perform field-by-field copying.
Subclasses may simply delegate the constructor to their super class
unless they have additional fields which need to be copied.
This design pattern was selected because it preserves the immutable
contract of the BOp which gives us our thread safety and
visibility guarantees. Since the deep copy is realized by the BOp
implementation classes, it is important that each class take
responsibility for the deep copy semantics of any fields it may declare.
op - A deep copy will be made of this BOp.
NullPointerException - if the argument is null.
public BOpBase(BOp[] args,
Map<String,Object> annotations)
args - The arguments to the operator.annotations - The annotations for the operator (optional).| Method Detail |
|---|
public final Map<String,Object> annotations()
BOp
protected boolean annotationsEqual(BOp o)
CoreBaseBOptrue iff the annotations of this BOp and the
other BOp are equals.
Note: This method permits override by subclasses with direct access to the maps to be compared.
annotationsEqual in class CoreBaseBOpCoreBaseBOp.annotationsEqual(Map, Map)protected final BOp[] argsCopy()
protected final Map<String,Object> annotationsCopy()
protected final Map<String,Object> annotationsRef()
BOpBase instance is created so we can know
this locally by inspection of the code).
public BOp get(int index)
BOp
index - The argument index in [0:BOp.arity()-1].
protected final void _set(int index,
BOp op)
Note: This is protected to facilitate copy-on-write patterns. It is not
public to prevent arbitrary changes to operators outside of methods which
clone the operator and return the modified version. This is part of the
effectively immutable contract for BOps.
index - The index.op - The operand.
public BOpBase setArg(int index,
BOp newArg)
BOpBase in which the child operand has been replaced
by the given expression.
index - The index of the child expression to be replaced.newArg - The new child expression.
BOpBase in which the child operand has
been replaced.public int arity()
BOp
public final List<BOp> args()
Note: This is much less efficient than argIterator().
public final Iterator<BOp> argIterator()
The iterator does not support removal. (This is more efficient than #args()).
public BOp[] toArray()
BOp
public <T> T[] toArray(T[] a)
BOpnull is appended to mark the end of the data.
protected static BOp[] deepCopy(BOp[] a)
Note: As long as we stick to the immutable semantics for bops, we can just make a shallow copy of the arguments in the "copy" constructor and then modify them within the specific operator constructor before returning control to the caller. This would result in less heap churn.
protected static Map<String,Object> deepCopy(Map<String,Object> a)
Note: This does not know how to deep copy annotations which are not
BOps or immutable objects such as Strings or
Numbers. Such objects should not be used as annotations.
public Object getProperty(String name)
IPropertySet
name - The property name.
protected Object _setProperty(String name,
Object value)
Note: This is protected to facilitate copy-on-write patterns. It is not
public to prevent arbitrary changes to operators outside of methods which
clone the operator and return the modified version. This is part of the
effectively immutable contract for BOps.
name - The name.value - The value.
protected void _clearProperty(String name)
Note: This is protected to facilitate copy-on-write patterns. It is not
public to prevent arbitrary changes to operators outside of methods which
clone the operator and return the modified version. This is part of the
effectively immutable contract for BOps.
name - The name.
public BOpBase setProperty(String name,
Object value)
BOp
name - The name.value - The value.
BOp on which the property has been set.
public BOpBase setUnboundProperty(String name,
Object value)
name - The name.value - The value.
BOp on which the property has been set.
IllegalStateException - if the property is already set.public BOpBase clearProperty(String name)
name - The annotation.
BOp in which the named annotation has been
removed.public BOp clearAnnotations(String[] names)
names - The annotations to be removed.
BOp in which the specified annotations do
not appear.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||