public class StatementPatternNode extends GroupMemberNodeBase<StatementPatternNode> implements IJoinNode, IStatementContainer, IReorderableNode
Note: The annotations on the class are mostly interpreted by the
toPredicate() method in AST2BOpUtility
and by the logic in
AST2BOpJoins
which handles the default and named graph access
patterns.
Note: If a variable is bound, then we bind that slot of the predicate. If a
variable can take some enumerated set of values, then we use an
#INLINE
access path to model that "IN" constraint. If the value for a
variable must lie within some key range, then we handle that case using
RangeBOp
. If we have no information about a variable, then we just
leave the variable unbound.
Modifier and Type | Class and Description |
---|---|
static interface |
StatementPatternNode.Annotations |
DEFAULT_INITIAL_CAPACITY
Constructor and Description |
---|
StatementPatternNode(BOp[] args,
Map<String,Object> anns)
Required shallow copy constructor.
|
StatementPatternNode(StatementPatternNode op)
Constructor required for
com.bigdata.bop.BOpUtility#deepCopy(FilterNode) . |
StatementPatternNode(TermNode s,
TermNode p,
TermNode o)
A triple pattern.
|
StatementPatternNode(TermNode s,
TermNode p,
TermNode o,
TermNode c,
org.openrdf.query.algebra.StatementPattern.Scope scope)
A quad pattern.
|
Modifier and Type | Method and Description |
---|---|
TermNode |
c()
The variable or constant for the context position (required iff in quads
mode).
|
TermNode |
get(int i)
Strengthen return type.
|
List<FilterNode> |
getAttachedJoinFilters()
Return the FILTER(s) associated with this
IJoinNode . |
Set<IVariable<?>> |
getDesiredBound(StaticAnalysis sa)
Get variables that are not required to be bound, but desired in the
sense that we want them to be bound when evaluating the construct.
|
VarNode |
getDistinctTermScanVar()
Return the variable that will be bound by the
DistinctTermAdvancer pattern. |
long |
getEstimatedCardinality(StaticOptimizer opt)
Return the estimated cardinality - either the range count of a
statement pattern or some computed estimated cardinality for a join
group.
|
VarNode |
getFastRangeCountVar()
Return the
VarNode associated with the optional
StatementPatternNode.Annotations.FAST_RANGE_COUNT_VAR property. |
Set<IVariable<?>> |
getProducedBindings()
Return the variables used by the predicate - i.e.
|
RangeNode |
getRange() |
Set<IVariable<?>> |
getRequiredBound(StaticAnalysis sa)
Return the variables used in the node that *must* be bound prior to
evaluating the node.
|
org.openrdf.query.algebra.StatementPattern.Scope |
getScope()
The scope for this statement pattern (either named graphs or default
graphs).
|
boolean |
isGround()
Return
true if none of s, p, o, or c is a variable. |
boolean |
isMinus()
Returns
false . |
boolean |
isOptional()
Return whether or not this is an join with "optional" semantics.
|
boolean |
isReorderable()
The decision about whether to re-order can no longer be made simply
by examining the type - individual instances of a particular type
may or may not be reorderable.
|
TermNode |
o()
The variable or constant for the object position (required).
|
TermNode |
p()
The variable or constant for the predicate position (required).
|
TermNode |
s()
The variable or constant for the subject position (required).
|
void |
setAttachedJoinFilters(List<FilterNode> filters) |
void |
setC(TermNode c) |
void |
setDistinctTermScanVar(VarNode var) |
void |
setFastRangeCount(VarNode var) |
void |
setOptional(boolean optional)
Mark this
StatementPatternNode as one which was lifted out of a
"simple optional" group and which therefore has "optional" semantics (we
will do an optional join for it). |
void |
setRange(RangeNode range)
Attach a
RangeNode that describes a range for the statement
pattern's O value. |
void |
setScope(org.openrdf.query.algebra.StatementPattern.Scope scope) |
void |
setSid(VarNode sid)
Set the SID variable.
|
VarNode |
sid()
The statement identifier variable for triples which match this statement
pattern (optional).
|
String |
toShortString()
General contract is a short (non-recursive) representation of the
BOp . |
String |
toString(int indent)
The contract of this method at this level is under-specified.
|
getContext, getParent, getParentGraphPatternGroup, getParentJoinGroup, setParent
getQueryHints, toString
addExplainHint, getExplainHints, getQueryHint, getQueryHint, getQueryHintAsBoolean, getQueryHintAsBoolean, getQueryHintAsInteger, replaceAllWith, setQueryHint, setQueryHints
addArg, addArg, addArgIfAbsent, annotations, annotationsEqual, argIterator, args, arity, clearProperty, copyAll, getProperty, indexOf, removeArg, replaceWith, setArg, setArgs, setId, setProperty, setUnboundProperty, toArray, toArray
annotationsEqual, annotationsToString, annotationsToString, annotationValueToString, checkArgs, clone, equals, getEvaluationContext, getId, getProperty, getRequiredProperty, hashCode, indent, isController, mutation, shortenName
finalize, getClass, notify, notifyAll, wait, wait, wait
getContext, getParent, getParentGraphPatternGroup, getParentJoinGroup, setParent
annotations, argIterator, args, arity, clone, getEvaluationContext, getId, getProperty, getRequiredProperty, isController, setProperty, toArray, toArray, toString
getProperty
public StatementPatternNode(StatementPatternNode op)
com.bigdata.bop.BOpUtility#deepCopy(FilterNode)
.public StatementPatternNode(BOp[] args, Map<String,Object> anns)
public StatementPatternNode(TermNode s, TermNode p, TermNode o)
StatementPattern.Scope
will be
StatementPattern.Scope.DEFAULT_CONTEXTS
, the context will be null
.s
- p
- o
- StatementPatternNode#StatementPatternNode(TermNode, TermNode,
TermNode, TermNode, Scope)
public StatementPatternNode(TermNode s, TermNode p, TermNode o, TermNode c, org.openrdf.query.algebra.StatementPattern.Scope scope)
Note: When a StatementPatternNode
appears in a WHERE clause, the
StatementPattern.Scope
should be marked as StatementPattern.Scope.DEFAULT_CONTEXTS
if it is
NOT embedded within a GRAPH clause and otherwise as
StatementPattern.Scope.NAMED_CONTEXTS
.
The context position of the statement should be null
unless
it is embedded within a GRAPH clause, in which case the context is the
context specified for the parent GRAPH clause.
The SPARQL UPDATE WITH uri
is a syntactic sugar for
GRAPH uri {...}
. Therefore, when present, any
StatementPatternNode
outside of an explicit GRAPH group is also
marked as StatementPattern.Scope.NAMED_CONTEXTS
and the context position will be
bound to the uri specified in the WITH
clause.
A null
context in StatementPattern.Scope.DEFAULT_CONTEXTS
is
interpreted as the RDF merge of the graphs in the defaultGraph (as
specified by the DatasetNode
). When non-null
(it can
be bound by the SPARQL UPDATE WITH clause), the defaultGraph
declared by the DatasetNode
is ignored and the context is bound
to the constant specified in that WITH clause.
Absent any other constraints on the query, an unbound variable context in
StatementPattern.Scope.NAMED_CONTEXTS
may be bound to any named graph specified by
the DatasetNode
.
s
- The subject (variable or constant; required).p
- The subject (variable or constant; required).o
- The subject (variable or constant; required).c
- The context (variable or constant; optional).scope
- Either StatementPattern.Scope.DEFAULT_CONTEXTS
or
StatementPattern.Scope.NAMED_CONTEXTS
(required).IllegalArgumentException
- if s, p, or o is null
.IllegalArgumentException
- if scope is null
.IllegalArgumentException
- if scope is StatementPattern.Scope.NAMED_CONTEXTS
and c
is null
.public final TermNode s()
public final TermNode p()
public final TermNode o()
public final TermNode c()
public TermNode get(int i)
get
in interface BOp
get
in class ModifiableBOpBase
i
- The argument index in [0:BOp.arity()
-1].public final void setC(TermNode c)
public final VarNode sid()
StatementPatternNode.Annotations.SID
public final void setSid(VarNode sid)
public final org.openrdf.query.algebra.StatementPattern.Scope getScope()
StatementPatternNode.Annotations.SCOPE
,
StatementPattern.Scope
public final void setScope(org.openrdf.query.algebra.StatementPattern.Scope scope)
public final VarNode getFastRangeCountVar()
VarNode
associated with the optional
StatementPatternNode.Annotations.FAST_RANGE_COUNT_VAR
property.VarNode
-or- null
if this triple pattern
is not associated with that annotation.public final void setFastRangeCount(VarNode var)
public final VarNode getDistinctTermScanVar()
DistinctTermAdvancer
pattern.null
if the
access path will not use a distinct term scan.StatementPatternNode.Annotations.DISTINCT_TERM_SCAN_VAR
public final void setDistinctTermScanVar(VarNode var)
public final boolean isOptional()
This returns true
iff the StatementPatternNode
was
lifted out of an optional JoinGroupNode
such that it has OPTIONAL
semantics.
isOptional
in interface IJoinNode
ASTSimpleOptionalOptimizer
public final void setOptional(boolean optional)
StatementPatternNode
as one which was lifted out of a
"simple optional" group and which therefore has "optional" semantics (we
will do an optional join for it).
Note: The need to maintain the correct semantics for the simple optional group (statement pattern plus filter(s)) is also the reason why the lifted FILTER(s) MUST NOT require the materialization of any variables which would not have been bound before that JOIN. Since variables bound by the JOIN for the optional statement pattern will not be materialized, filters attached to that JOIN can not require materialization of variables bound by the JOIN (though they can depend on variables already bound by the required joins in the parent group).
ASTSimpleOptionalOptimizer
public final void setRange(RangeNode range)
RangeNode
that describes a range for the statement
pattern's O value.range
- public final RangeNode getRange()
public final List<FilterNode> getAttachedJoinFilters()
IJoinNode
IJoinNode
. Such filters
will be run with the JOIN for this statement pattern. As such, they MUST
NOT rely on materialization of variables which would not have been bound
before that JOIN.getAttachedJoinFilters
in interface IJoinNode
null
(it may
return an empty list)(.ASTSimpleOptionalOptimizer
,
ASTAttachJoinFiltersOptimizer
public final void setAttachedJoinFilters(List<FilterNode> filters)
setAttachedJoinFilters
in interface IJoinNode
public boolean isGround()
true
if none of s, p, o, or c is a variable.public Set<IVariable<?>> getProducedBindings()
public String toString(int indent)
CoreBaseBOp
CoreBaseBOp.toString()
Or:
- return a pretty-print representation of the object with indent
Note that the former contract may or may not include recursive descent through a tree-like
object, whereas the latter almost certainly does.toString
in interface BOp
toString
in interface IQueryNode
toString
in class CoreBaseBOp
public String toShortString()
CoreBaseBOp
BOp
.toShortString
in interface BOp
toShortString
in class CoreBaseBOp
public boolean isReorderable()
IReorderableNode
isReorderable
in interface IReorderableNode
public long getEstimatedCardinality(StaticOptimizer opt)
IReorderableNode
getEstimatedCardinality
in interface IReorderableNode
opt
- This optimizer can be used to help work out the estimatepublic Set<IVariable<?>> getRequiredBound(StaticAnalysis sa)
IVariableBindingRequirements
IVariableBindingRequirements#getRequiredBound()
interface cannot be satisified, the query may still be valid and return
results (for the SPARQL 1.1 service example mentioned above, it may not,
for the FILTER it may).
The set of these variables must be disjoint from
IVariableBindingRequirements#getRequiredUnound()
.getRequiredBound
in interface IVariableBindingRequirements
public Set<IVariable<?>> getDesiredBound(StaticAnalysis sa)
IVariableBindingRequirements
IVariableBindingRequirements.getRequiredBound(StaticAnalysis)
.getDesiredBound
in interface IVariableBindingRequirements
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.