public class Predicate<E> extends AbstractAccessPathOp<E> implements IPredicate<E>
IPredicate
.Modifier and Type | Class and Description |
---|---|
static interface |
Predicate.Annotations |
DEFAULT_INITIAL_CAPACITY
Constructor and Description |
---|
Predicate(BOp[] args,
Map<String,Object> annotations)
Required shallow copy constructor.
|
Predicate(BOp[] args,
NV... annotations)
Variable argument version of the shallow constructor.
|
Predicate(IVariableOrConstant<?>[] values,
String relationName,
int partitionId,
boolean optional,
IElementFilter<E> constraint,
IAccessPathExpander<E> expander,
long timestamp) |
Predicate(IVariableOrConstant<?>[] values,
String relationName,
long timestamp)
Simplified ctor (for lex predicates).
|
Predicate(Predicate<E> op)
Constructor required for
com.bigdata.bop.BOpUtility#deepCopy(FilterNode) . |
Modifier and Type | Method and Description |
---|---|
protected Predicate<E> |
_asBound(IBindingSet bindingSet)
Override any unbound variables for which we were giving bindings.
|
Predicate<E> |
addAccessPathFilter(IFilter filter)
|
Predicate<E> |
addIndexLocalFilter(IFilter filter)
|
Predicate<E> |
asBound(IBindingSet bindingSet)
Fast path for as-bound.
|
Object |
asBound(int index,
IBindingSet bindingSet)
Extract the as bound value from the predicate.
|
Predicate<E> |
asBound(IVariable<?> var,
IConstant<?> val)
Return a new instance in which all occurrences of the given variable have
been replaced by the specified constant.
|
protected void |
checkArgs(BOp[] args)
Disallows
null in any position. |
Predicate<E> |
clearAnnotations(String[] names)
Strengthened return type.
|
Predicate<E> |
clone()
Overridden to provide a fast path clone().
|
IConstant<?> |
get(E e,
int index)
Return the asBound value at the specified index for the given element.
|
IVariableOrConstant |
get(int index)
Return an argument to the operation.
|
IAccessPathExpander<E> |
getAccessPathExpander()
Returns the object that may be used to selectively override the
evaluation of the predicate.
|
IFilter |
getAccessPathFilter()
Return the optional filter to be evaluated once tuples have been
converted into relation elements by the access path (local to the
caller).
|
IFilter |
getIndexLocalFilter()
Return the optional filter to be evaluated local to the index.
|
IKeyOrder<E> |
getKeyOrder()
Return the
IKeyOrder override for this IPredicate by the
query optimizer. |
String |
getOnlyRelationName()
Resource identifier (aka namespace) identifies the
IRelation
associated with this IPredicate . |
int |
getPartitionId()
The index partition identifier and
-1 if no partition
identifier was specified. |
int |
getRelationCount()
The #of elements in the relation view.
|
String |
getRelationName(int index)
Return the ith element of the relation view.
|
long |
getTimestamp()
The timestamp or transaction identifier on which the operator will read
or write.
|
int |
getVariableCount() |
int |
getVariableCount(IKeyOrder<E> keyOrder)
The #of arguments in the predicate required for the specified
IKeyOrder which are unbound. |
boolean |
isFullyBound(IKeyOrder<E> keyOrder)
Figure out if all positions in the predicate which are required to form
the key for this access path are bound in the predicate.
|
boolean |
isOptional()
true iff the predicate is optional when evaluated as the
right-hand side of a join. |
boolean |
isRemoteAccessPath()
Return
true if this is a remote access path. |
RangeBOp |
range() |
Predicate<E> |
setArg(int index,
IVariableOrConstant arg)
Return a copy of this predicate with a different
IVariableOrConstant
for the arg specified by the supplied index parameter. |
Predicate<E> |
setBOpId(int bopId)
Sets the
BOp.Annotations.BOP_ID annotation. |
Predicate<E> |
setPartitionId(int partitionId)
Sets the index partition identifier constraint.
|
Predicate<E> |
setRelationName(String[] relationName)
A copy of this
IPredicate in which the relationName(s)
replace the existing set of relation name(s). |
Predicate<E> |
setTimestamp(long timestamp) |
String |
toString()
Return a non-recursive representation of the arguments and annotations
for this
BOp . |
String |
toString(IBindingSet bindingSet)
Representation of the predicate with variable bindings.
|
__replaceArg, _clearProperty, _set, _setProperty, annotations, annotationsCopy, annotationsEqual, annotationsRef, argIterator, args, argsCopy, arity, clearProperty, deepCopy, deepCopy, getProperty, setArg, setProperty, setUnboundProperty, toArray, toArray
annotationsEqual, annotationsToString, annotationsToString, annotationValueToString, equals, getEvaluationContext, getId, getProperty, getRequiredProperty, hashCode, indent, isController, mutation, shortenName, toShortString, toString
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
equals, hashCode
annotations, argIterator, args, arity, getEvaluationContext, getId, getProperty, getRequiredProperty, isController, setProperty, toArray, toArray, toShortString, toString
getProperty
public Predicate(BOp[] args, Map<String,Object> annotations)
public Predicate(Predicate<E> op)
com.bigdata.bop.BOpUtility#deepCopy(FilterNode)
.public Predicate(BOp[] args, NV... annotations)
vars
- annotations
- public Predicate(IVariableOrConstant<?>[] values, String relationName, long timestamp)
values
- The values (order is important!).relationName
- Identifies the relation to be queried.public Predicate(IVariableOrConstant<?>[] values, String relationName, int partitionId, boolean optional, IElementFilter<E> constraint, IAccessPathExpander<E> expander, long timestamp)
relationName
- The namespace of the relation.partitionId
- The index partition constraint -or- -1
if there
is no index partition constraint.values
- The values (order is important!).optional
- true iff the predicate is optional when evaluated in a JOIN.constraint
- An optional constraint.expander
- Allows selective override of the predicate evaluation.protected void checkArgs(BOp[] args)
null
in any position.checkArgs
in class CoreBaseBOp
args
- public String getOnlyRelationName()
IPredicate
IRelation
associated with this IPredicate
.getOnlyRelationName
in interface IPredicate<E>
ILocatableResourceAnnotations.RELATION_NAME
public String getRelationName(int index)
IPredicate
getRelationName
in interface IPredicate<E>
index
- The index into the array of relation names in the view.public int getRelationCount()
IPredicate
getRelationCount
in interface IPredicate<E>
public Predicate<E> setRelationName(String[] relationName)
IPredicate
IPredicate
in which the relationName(s)
replace the existing set of relation name(s).setRelationName
in interface IPredicate<E>
relationName
- The relation name(s).public int getPartitionId()
IPredicate
-1
if no partition
identifier was specified.getPartitionId
in interface IPredicate<E>
-1
if the
predicate is not locked to a specific index partition.IPredicate.Annotations.PARTITION_ID
,
PartitionLocator
,
AccessPath
,
JoinMasterTask
public IVariableOrConstant get(int index)
BOp
get
in interface BOp
get
in interface IPredicate<E>
get
in class BOpBase
index
- The argument index in [0:BOp.arity()
-1].public IConstant<?> get(E e, int index)
IPredicate
Note: there is no general means available to implement this method of an awareness of the internal structure of the element type. General purpose record types, such as GOM or relation records, can generally implement this method in the context of the "schema" imposed by the predicate.
get
in interface IPredicate<E>
e
- The element, which must implement IElement
.index
- The index.public final boolean isOptional()
IPredicate
true
iff the predicate is optional when evaluated as the
right-hand side of a join. An optional predicate will match once after
all matches in the data have been exhausted. By default, the match will
NOT bind any variables that have been determined to be bound by the
predicate based on the computed IEvaluationPlan
.
For mutation, some IRelation
s may require that all variables
appearing in the head are bound. This and similar constraints can be
enforced using IConstraint
s on the IRule
.
isOptional
in interface IPredicate<E>
true
iff this predicate is optional when evaluating
a JOIN.public final IFilter getIndexLocalFilter()
IPredicate
getIndexLocalFilter
in interface IPredicate<E>
IPredicate.Annotations.INDEX_LOCAL_FILTER
public final IFilter getAccessPathFilter()
IPredicate
getAccessPathFilter
in interface IPredicate<E>
IPredicate.Annotations.ACCESS_PATH_FILTER
public final IAccessPathExpander<E> getAccessPathExpander()
IPredicate
getAccessPathExpander
in interface IPredicate<E>
IAccessPathExpander
.IPredicate.Annotations.ACCESS_PATH_EXPANDER
public final int getVariableCount()
getVariableCount
in interface IPredicate<E>
public final boolean isFullyBound(IKeyOrder<E> keyOrder)
IPredicate
isFullyBound
in interface IPredicate<E>
public final int getVariableCount(IKeyOrder<E> keyOrder)
IPredicate
IKeyOrder
which are unbound.getVariableCount
in interface IPredicate<E>
keyOrder
- The key order.IKeyOrder
.public final boolean isRemoteAccessPath()
IPredicate
true
if this is a remote access path.isRemoteAccessPath
in interface IPredicate<E>
IPredicate.Annotations.REMOTE_ACCESS_PATH
public Predicate<E> asBound(IVariable<?> var, IConstant<?> val)
IPredicate
Note: The optimal IKeyOrder
often changes when binding a variable
on a predicate.
asBound
in interface IPredicate<E>
var
- The variable.val
- The constant.public Predicate<E> asBound(IBindingSet bindingSet)
This reuses the annotations map since we know that the annotations will
not be changed by asBound(IBindingSet)
. That provides a
significant reduction in heap churn.
asBound
in interface IPredicate<E>
bindingSet
- The binding set.IPredicate
-or- null
if the
IPredicate
can not be unified with the
IBindingSet
.(RDR query does too much work)
protected final Predicate<E> _asBound(IBindingSet bindingSet)
public Object asBound(int index, IBindingSet bindingSet)
IPredicate
asBound
in interface IPredicate<E>
index
- The index into that predicate.bindingSet
- The binding set.null
if no binding is available
(the predicate is not bound at that index and the variable at
that index in the predicate is not bound in the binding set).public final RangeBOp range()
public IKeyOrder<E> getKeyOrder()
IPredicate
IKeyOrder
override for this IPredicate
by the
query optimizer.getKeyOrder
in interface IPredicate<E>
IKeyOrder
or null
if the
IKeyOrder
was not overridden.IPredicate.Annotations.KEY_ORDER
public Predicate<E> clone()
Predicate
instance. However, subclasses MUST override this method. This change was
introduced on 11/17/2011 when a profiler showed a 13% of all time related
to a join intensive process in CoreBaseBOp.clone()
using
reflection to make a copy of an asBound(IBindingSet)
predicate.clone
in interface BOp
clone
in class CoreBaseBOp
public Predicate<E> setPartitionId(int partitionId)
IPredicate
setPartitionId
in interface IPredicate<E>
partitionId
- The index partition identifier.IPredicate
.IPredicate.Annotations.PARTITION_ID
public Predicate<E> setBOpId(int bopId)
IPredicate
BOp.Annotations.BOP_ID
annotation.setBOpId
in interface IPredicate<E>
bopId
- The bop id.IPredicate
.public Predicate<E> setArg(int index, IVariableOrConstant arg)
IPredicate
IVariableOrConstant
for the arg specified by the supplied index parameter.setArg
in interface IPredicate<E>
public Predicate<E> addIndexLocalFilter(IFilter filter)
IPredicate.Annotations.INDEX_LOCAL_FILTER
. When there is a filter for
the named property, the filters are combined. Otherwise the filter is
set.filter
- The filter.public Predicate<E> addAccessPathFilter(IFilter filter)
IPredicate.Annotations.INDEX_LOCAL_FILTER
. When there is a filter for
the named property, the filters are combined. Otherwise the filter is
set.filter
- The filter.public Predicate<E> clearAnnotations(String[] names)
Strips off the named annotations.
clearAnnotations
in class BOpBase
names
- The annotations to be removed.BOp
in which the specified annotations do
not appear.public String toString()
CoreBaseBOp
BOp
.toString
in interface BOp
toString
in interface IPredicate<E>
toString
in class CoreBaseBOp
public String toString(IBindingSet bindingSet)
IPredicate
toString
in interface IPredicate<E>
bindingSet
- The variable bindingspublic final long getTimestamp()
IPredicate
getTimestamp
in interface IPredicate<E>
ITimestampAnnotations.TIMESTAMP
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.