public class ModifiableBOpBase extends CoreBaseBOp
BOp
s. Unlike BOpBase
, this
class supports destructive mutation. This is the base class for the bigdata
AST nodes. ASTs are destructively rewritten by optimizers before they are
turned into a query plan.
ModifiableBOpBase
s 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.Annotations
DEFAULT_INITIAL_CAPACITY
Constructor and Description |
---|
ModifiableBOpBase(BOp[] args,
Map<String,Object> annotations)
Shallow copy constructor (required).
|
ModifiableBOpBase(ModifiableBOpBase op)
Deep copy constructor (required).
|
Modifier and Type | Method and Description |
---|---|
void |
addArg(BOp newArg)
Add a new argument (core mutation method).
|
void |
addArg(int index,
BOp newArg)
Add a new argument (core mutation method) at the specified index.
|
void |
addArgIfAbsent(BOp arg)
Add an argument iff it is not already present.
|
Map<String,Object> |
annotations()
The operator's annotations.
|
protected boolean |
annotationsEqual(BOp o)
|
Iterator<BOp> |
argIterator()
An iterator visiting the operator's arguments.
|
List<BOp> |
args()
An unmodifiable view of the list of arguments (aka children) of this
node.
|
int |
arity()
The #of arguments to the operation.
|
ModifiableBOpBase |
clearProperty(String name)
Clear the named annotation (destructive mutation).
|
ModifiableBOpBase |
copyAll(Map<String,Object> anns)
Copy all annotations from the caller's map.
|
BOp |
get(int index)
Return an argument to the operation.
|
Object |
getProperty(String name)
Return the value of a named property.
|
int |
indexOf(BOp bop)
Return the index of the bop in the args.
|
boolean |
removeArg(BOp arg)
Remove the 1st occurrence of the argument (core mutation method).
|
int |
replaceWith(BOp oldChild,
BOp newChild)
Replace a child of a node with another reference (destructive
modification).
|
ModifiableBOpBase |
setArg(int index,
BOp newArg)
Replace the value of the argument at the specified index (core mutation
method).
|
ModifiableBOpBase |
setArgs(BOp[] args)
Replace the arguments.
|
void |
setId(int id)
Unconditionally set the
Annotations#BOP_ID . |
ModifiableBOpBase |
setProperty(String name,
Object value)
Set the named property value (destructive mutation).
|
ModifiableBOpBase |
setUnboundProperty(String name,
Object value)
Conditionally set the named property iff it is not bound (destructive
mutation).
|
BOp[] |
toArray()
A shallow copy of the operator's arguments.
|
<T> T[] |
toArray(T[] a)
A shallow copy of the operator's arguments using the generic type of the
caller's array.
|
annotationsEqual, annotationsToString, annotationsToString, annotationValueToString, checkArgs, clone, equals, getEvaluationContext, getId, getProperty, getRequiredProperty, hashCode, indent, isController, mutation, shortenName, toShortString, toString, toString
public ModifiableBOpBase(ModifiableBOpBase op)
Each BOp
MUST implement a public copy constructor with the
signature:
public Foo(Foo)This construct is invoked by
CoreBaseBOp.clone()
using reflection.
The default implementation makes a shallow 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.
op
- A deep copy will be made of this BOp
.NullPointerException
- if the argument is null
.public ModifiableBOpBase(BOp[] args, Map<String,Object> annotations)
args
- The arguments to the operator.annotations
- The annotations for the operator (optional). When
null
, a mutable map with a default capacity of
is allocated. Do
NOT specify an immutable map.public final Map<String,Object> annotations()
BOp
protected boolean annotationsEqual(BOp o)
CoreBaseBOp
true
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 CoreBaseBOp
CoreBaseBOp.annotationsEqual(Map, Map)
public BOp get(int index)
BOp
index
- The argument index in [0:BOp.arity()
-1].public int indexOf(BOp bop)
public ModifiableBOpBase setArgs(BOp[] args)
args
- The new arguments.public ModifiableBOpBase setArg(int index, BOp newArg)
index
- The index of the child expression to be replaced.newArg
- The new child expression.ModifiableBOpBase
.IllegalArgumentException
- if the argument is null
.IllegalArgumentException
- if the argument is this.public void addArg(BOp newArg)
newArg
- The argument.IllegalArgumentException
- if the argument is null
.IllegalArgumentException
- if the argument is this.public void addArg(int index, BOp newArg)
index
- The index at which the child expression is to be inserted.newArg
- The argument.IllegalArgumentException
- if the argument is null
.IllegalArgumentException
- if the argument is this.public void addArgIfAbsent(BOp arg)
arg
- The argument.IllegalArgumentException
- if the argument is null
.IllegalArgumentException
- if the argument is this.public boolean removeArg(BOp arg)
arg
- The argument.true
iff the argument was removed.IllegalArgumentException
- if the argument is null
.IllegalArgumentException
- if the argument is this.public int replaceWith(BOp oldChild, BOp newChild)
oldChild
- newChild
- public int arity()
BOp
public final List<BOp> args()
Note: The view is not modifiable in order to preserve the contract that
CoreBaseBOp.mutation()
will be invoked if there is change in the state of
this BOp
.
public final Iterator<BOp> argIterator()
Note: This Iterator
supports removal.
public BOp[] toArray()
BOp
public <T> T[] toArray(T[] a)
BOp
null
is appended to mark the end of the data.public Object getProperty(String name)
IPropertySet
name
- The property name.public ModifiableBOpBase copyAll(Map<String,Object> anns)
anns
- The annotations to be copied.public ModifiableBOpBase setProperty(String name, Object value)
name
- The name.value
- The new value.public ModifiableBOpBase setUnboundProperty(String name, Object value)
name
- The name.value
- The value.IllegalStateException
- if the property is already set.public ModifiableBOpBase clearProperty(String name)
name
- The annotation.public void setId(int id)
Annotations#BOP_ID
.id
- The id.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.