StaticAnalysis_CanJoin
which is a port of this code to
the AST mode.public class PartitionedJoinGroup extends Object
A join group consists of an ordered collection of IPredicate
s and an
unordered collection of IConstraint
s. IPredicate
representing
non-optional joins are extracted into a JoinGraph
along with any
IConstraint
s whose variables are guaranteed to be bound by the
implied joins.
The remainder of the IPredicate
s and IConstraint
s form a
"tail plan". IConstraint
s in the tail plan are attached to the last
IPredicate
at which their variable(s) MIGHT have become bound.
Constructor and Description |
---|
PartitionedJoinGroup(IPredicate<?>[] sourcePreds,
IConstraint[] constraints)
Deprecated.
Analyze a set of
IPredicate s representing "runFirst", optional
joins, and non-optional joins which may be freely reordered together with
a collection of IConstraint s and partition them into a join graph
and a tail plan. |
Modifier and Type | Method and Description |
---|---|
static boolean |
canJoin(IPredicate<?> p1,
IPredicate<?> p2)
Deprecated.
Return
true iff two predicates can join on the basis of at
least one variable which is shared directly by those predicates. |
static boolean |
canJoinUsingConstraints(IPredicate<?>[] path,
IPredicate<?> vertex,
IConstraint[] constraints)
Deprecated.
Return
true iff a predicate may be used to extend a join
path on the basis of at least one variable which is shared either
directly or via one or more constraints which may be attached to the
predicate when it is added to the join path. |
IPredicate<?>[] |
getJoinGraph()
Deprecated.
The
IPredicate s in the join graph (required joins). |
IConstraint[] |
getJoinGraphConstraints()
Deprecated.
The
IConstraint s to be applied to the IPredicate s in the
join graph. |
IConstraint[] |
getJoinGraphConstraints(int[] pathIds,
boolean pathIsComplete)
Deprecated.
Return the set of constraints which should be attached to the last join
in the given the join path.
|
static IConstraint[][] |
getJoinGraphConstraints(IPredicate<?>[] path,
IConstraint[] joinGraphConstraints,
IVariable<?>[] knownBoundVars,
boolean pathIsComplete)
Deprecated.
Given a join path, return the set of constraints to be associated with
each join in that join path.
|
Set<IVariable<?>> |
getJoinGraphVars()
Deprecated.
The set of variables bound by the non-optional predicates (either the
head plan or the join graph).
|
IPredicate<?>[] |
getTailPlan()
Deprecated.
The
IPredicate s representing optional joins. |
IConstraint[] |
getTailPlanConstraints(int bopId)
Deprecated.
Return the set of
IConstraint s which should be evaluated when an
identified predicate having SPARQL optional semantics is evaluated. |
public PartitionedJoinGroup(IPredicate<?>[] sourcePreds, IConstraint[] constraints)
IPredicate
s representing "runFirst", optional
joins, and non-optional joins which may be freely reordered together with
a collection of IConstraint
s and partition them into a join graph
and a tail plan. The resulting data structure can efficiently answer a
variety of queries regarding joins, join paths, and constraints and can
be used to formulate a complete query when combined with a desired join
ordering.knownBound
- A set of variables which are known to be bound on entry.sourcePreds
- The predicates.constraints
- The constraints.IllegalArgumentException
- if the source predicates array is null
.IllegalArgumentException
- if the source predicates array is empty.IllegalArgumentException
- if any element of the source predicates array is
null
.public Set<IVariable<?>> getJoinGraphVars()
public IPredicate<?>[] getJoinGraph()
IPredicate
s in the join graph (required joins).public IConstraint[] getJoinGraphConstraints()
IConstraint
s to be applied to the IPredicate
s in the
join graph. Each IConstraint
should be applied as soon as all of
its variable(s) are known to be bound. The constraints are not attached
to the IPredicate
s in the join graph because the evaluation order
of those IPredicate
s is not yet known (it will be determined by a
query optimizer when it decides on an evaluation order for those joins).public IConstraint[] getJoinGraphConstraints(int[] pathIds, boolean pathIsComplete)
The rule followed by this method is that each constraint will be attached to the first non-optional join at which all of its variables are known to be bound. It is assumed that constraints are attached to each join in the join path by a consistent logic, e.g., as dictated by this method.
joinPath
- An ordered array of predicate identifiers representing a
specific sequence of non-optional joins.pathIsComplete
- true
iff the path represents a complete
join path. When true
, any constraints which have
not already been attached will be attached to the last
predicate in the join path.IllegalArgumentException
- if the join path is null
.IllegalArgumentException
- if the join path is empty.IllegalArgumentException
- if any element of the join path is null
.IllegalArgumentException
- if any predicate specified in the join path is not known to
this class.IllegalArgumentException
- if any predicate specified in the join path is optional.public static IConstraint[][] getJoinGraphConstraints(IPredicate<?>[] path, IConstraint[] joinGraphConstraints, IVariable<?>[] knownBoundVars, boolean pathIsComplete)
path
- The join path.joinGraphConstraints
- The constraints to be applied to the join path (optional).knownBoundVars
- Variables that are known to be bound as inputs to this join
graph (parent queries).pathIsComplete
- true
iff the path represents a complete
join path. When true
, any constraints which have
not already been attached will be attached to the last predicate
in the join path.IllegalArgumentException
- if the join path is null
.IllegalArgumentException
- if the join path is empty.IllegalArgumentException
- if any element of the join path is null
.IllegalArgumentException
- if any element of the join graph constraints is
null
.public IPredicate<?>[] getTailPlan()
IPredicate
s representing optional joins. Any
IConstraint
s having variable(s) NOT bound by the required joins
will already have been attached to the last IPredicate
in the
tail plan in which their variable(S) MIGHT have been bound.public IConstraint[] getTailPlanConstraints(int bopId)
IConstraint
s which should be evaluated when an
identified predicate having SPARQL optional semantics is evaluated. For
constraints whose variables are not known to be bound when entering the
tail plan, the constraint should be evaluated at the last predicate for
which its variables MIGHT become bound.bopId
- The identifier for an IPredicate
appearing in the tail
plan.IllegalArgumentException
- if there is no such predicate in the tail plan.public static boolean canJoin(IPredicate<?> p1, IPredicate<?> p2)
true
iff two predicates can join on the basis of at
least one variable which is shared directly by those predicates. Only the
operands of the predicates are considered.
Note: This method will only identify joins where the predicates directly
share at least one variable. However, joins are also possible when the
predicates share variables via one or more constraint(s). Use
canJoinUsingConstraints
to identify such joins.
Note: Any two predicates may join regardless of the presence of shared
variables. However, such joins will produce the full cross product of the
binding sets selected by each predicate. As such, they should be run last
and this method will not return true
for such predicates.
Note: This method is more efficient than
BOpUtility.getSharedVars(BOp, BOp)
because it does not
materialize the sets of shared variables. However, it only considers the
operands of the IPredicate
s and is thus more restricted than
BOpUtility.getSharedVars(BOp, BOp)
as well.
p1
- A predicate.p2
- Another predicate.true
iff the predicates share at least one variable
as an operand.IllegalArgumentException
- if the two either reference is null
.public static boolean canJoinUsingConstraints(IPredicate<?>[] path, IPredicate<?> vertex, IConstraint[] constraints)
true
iff a predicate may be used to extend a join
path on the basis of at least one variable which is shared either
directly or via one or more constraints which may be attached to the
predicate when it is added to the join path. The join path is used to
decide which variables are known to be bound, which in turn decides which
constraints may be run. Unlike the case when the variable is directly
shared between the two predicates, a join involving a constraint requires
us to know which variables are already bound so we can know when the
constraint may be attached.
Note: Use canJoin(IPredicate, IPredicate)
instead to identify joins based on a variable which is directly shared.
Note: Any two predicates may join regardless of the presence of shared
variables. However, such joins will produce the full cross product of the
binding sets selected by each predicate. As such, they should be run last
and this method will not return true
for such predicates.
path
- A join path containing at least one predicate.vertex
- A predicate which is being considered as an extension of that
join path.constraints
- A set of zero or more constraints (optional). Constraints are
attached dynamically once the variables which they use are
bound. Hence, a constraint will always share a variable with
any predicate to which it is attached. If any constraints are
attached to the given vertex and they share a variable which
has already been bound by the join path, then the vertex may
join with the join path even if it does not directly bind that
variable.true
iff the vertex can join with the join path via
a shared variable.IllegalArgumentException
- if the join path is null
.IllegalArgumentException
- if the join path is empty.IllegalArgumentException
- if any element in the join path is null
.IllegalArgumentException
- if the vertex is null
.IllegalArgumentException
- if the vertex is already part of the join path.IllegalArgumentException
- if any element in the optional constraints array is
null
.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.