public interface IJoinNexus
IPredicate
s,
IBindingSet
s, and ISolution
s for the evaluation of an
IRule
and is responsible for resolving the relation symbol to the
IRelation
object. Instances of this interface may be type-specific
and allow you to control various implementation classes used during
IRule
execution.
Note: This interface is NOT Serializable
. Use an
IJoinNexusFactory
to create instances of this interface.
Modifier and Type | Field and Description |
---|---|
static int |
ALL
|
static int |
BINDINGS
Bit flag indicating that
newSolution(IRule, IBindingSet) should
clone the IBindingSet and make it available via
ISolution.getBindingSet() . |
static int |
ELEMENT
Bit flag indicating that
newSolution(IRule, IBindingSet) should
materialize an element from the IRule and IBindingSet and
make it available via ISolution.get() . |
static int |
RULE
Bit flag indicating that
newSolution(IRule, IBindingSet) make
the IRule that generated the ISolution available via
ISolution.getRule() . |
Modifier and Type | Method and Description |
---|---|
boolean |
bind(IPredicate<?> pred,
IConstraint[] constraints,
Object e,
IBindingSet bindings)
Binds variables from a visited element.
|
boolean |
bind(IRule rule,
int index,
Object e,
IBindingSet bindings)
Deprecated.
by
#bind(IPredicate, Object, IBindingSet) |
IConstant |
fakeBinding(IPredicate predicate,
Var var)
Return a 'fake' binding for the given variable in the specified
predicate.
|
boolean |
forceSerialExecution()
Deprecated.
by bop annotations.
|
ActionEnum |
getAction()
The kind of operation that is being executed (Query, Insert, or Delete).
|
IStreamSerializer<IBindingSet[]> |
getBindingSetSerializer()
Return the object that is responsible for (de-)serializing chunks of
IBindingSet s. |
int |
getChunkCapacity()
Deprecated.
by bop annotations.
|
int |
getChunkOfChunksCapacity()
Deprecated.
by bop annotations.
|
int |
getFullyBufferedReadThreshold()
Deprecated.
by bop annotations.
|
IRelation |
getHeadRelationView(IPredicate pred)
Locate and return the view of the relation identified by the
IPredicate . |
IIndexManager |
getIndexManager()
Used to locate indices, relations and relation containers.
|
IJoinNexusFactory |
getJoinNexusFactory()
The factory object is used to materialize appropriate
IJoinNexus
instances when the rule execution crosses an RMI boundary. |
int |
getMaxParallelSubqueries()
Deprecated.
by bop annotations.
|
IEvaluationPlanFactory |
getPlanFactory()
Return the factory for
IEvaluationPlan s. |
String |
getProperty(String name,
String defaultValue)
Resolve the property value using the
IIndexManager , the namespace
of the resource, and the Properties instance to be tested as
hidden parameters. |
<T> T |
getProperty(String name,
String defaultValue,
IValidator<T> validator)
Resolves, parses, and validates the property value.
|
IRangeCountFactory |
getRangeCountFactory()
The factory object for range counts used by
IEvaluationPlan s. |
long |
getReadTimestamp()
Equivalent to
IJoinNexusFactory.getReadTimestamp() . |
IRuleStatisticsFactory |
getRuleStatisticsFactory()
The factory for rule statistics objects.
|
IRuleTaskFactory |
getRuleTaskFactory(boolean parallel,
IRule rule)
Deprecated.
by annotations on individual
BOp s which specify which
join operator is to be used on a join by join basis. |
IElementFilter<ISolution> |
getSolutionFilter()
Return the
IElementFilter that will be used to reject solutions
based on the bindings for the head of the rule -or- null
if no filter will be imposed. |
IStreamSerializer<ISolution[]> |
getSolutionSerializer()
Return the object that is responsible for (de-)serializing chunks of
ISolution s. |
IAccessPath |
getTailAccessPath(IRelation relation,
IPredicate pred)
Obtain an access path reading from relation for the specified predicate
(from the tail of some rule).
|
IRelation |
getTailRelationView(IPredicate pred)
Locate and return the view of the relation(s) identified by the
IPredicate . |
long |
getWriteTimestamp()
Equivalent to
IJoinNexusFactory.getWriteTimestamp() . |
Iterator<PartitionLocator> |
locatorScan(AbstractScaleOutFederation<?> fed,
IPredicate<?> predicate)
Return an iterator visiting the
PartitionLocator for the index
partitions from which an IAccessPath must read in order to
materialize all elements which would be visited for that predicate. |
IBindingSet |
newBindingSet(IRule rule)
Factory for
IBindingSet implementations. |
ISortKeyBuilder<IBindingSet> |
newBindingSetSortKeyBuilder(IRule rule)
Return an
ISortKeyBuilder for an IBindingSet . |
IBuffer<ISolution[]> |
newDeleteBuffer(IMutableRelation relation)
Return a thread-safe buffer onto which chunks of computed
ISolution s will be written. |
IBuffer<ISolution[]> |
newInsertBuffer(IMutableRelation relation)
Return a thread-safe buffer onto which chunks of computed
ISolution s will be written. |
IBlockingBuffer<ISolution[]> |
newQueryBuffer()
Return a thread-safe buffer onto which chunks of computed
ISolution s will be written. |
ISolution |
newSolution(IRule rule,
IBindingSet bindingSet)
Create a new
ISolution . |
IBuffer<ISolution> |
newUnsynchronizedBuffer(IBuffer<ISolution[]> targetBuffer,
int chunkCapacity)
Return a buffer suitable for a single-threaded writer that flushes onto
the specified targetBuffer.
|
long |
runMutation(IStep step)
Run as mutation operation (it will write any solutions onto the relations
named in the head of the various
IRule s). |
IChunkedOrderedIterator<ISolution> |
runQuery(IStep step)
Run as a query.
|
int |
solutionFlags()
The flags that effect the behavior of
newSolution(IRule, IBindingSet) . |
static final int ELEMENT
newSolution(IRule, IBindingSet)
should
materialize an element from the IRule
and IBindingSet
and
make it available via ISolution.get()
.static final int BINDINGS
newSolution(IRule, IBindingSet)
should
clone the IBindingSet
and make it available via
ISolution.getBindingSet()
.static final int RULE
newSolution(IRule, IBindingSet)
make
the IRule
that generated the ISolution
available via
ISolution.getRule()
.static final int ALL
IRuleStatisticsFactory getRuleStatisticsFactory()
IJoinNexusFactory getJoinNexusFactory()
IJoinNexus
instances when the rule execution crosses an RMI boundary.IRangeCountFactory getRangeCountFactory()
IEvaluationPlan
s.ActionEnum getAction()
boolean forceSerialExecution()
int getMaxParallelSubqueries()
ExecutorService
entirely and ONE (1) to submit a single task at a
time to the ExecutorService
.int getChunkCapacity()
10,000
or better.int getChunkOfChunksCapacity()
IBuffer
that is the target
or one or more UnsynchronizedArrayBuffer
s. This is generally a
small value on the order of the #of parallel producers that might be
writing on the IBuffer
since the capacity of the
UnsynchronizedArrayBuffer
s is already quite large (10k or better
elements, defining a single "chunk" from a single producer).getMaxParallelSubqueries()
,
getChunkCapacity()
int getFullyBufferedReadThreshold()
IAccessPath
. When this threshold is exceeded the
IAccessPath
will use an IAsynchronousIterator
instead.
This value should on the order of getChunkCapacity()
.IAccessPath.iterator(long,long, int)
,
AbstractResource.Options#FULLY_BUFFERED_READ_THRESHOLD
String getProperty(String name, String defaultValue)
IIndexManager
, the namespace
of the resource, and the Properties
instance to be tested as
hidden parameters.name
- The property name.defaultValue
- The default.Configuration
<T> T getProperty(String name, String defaultValue, IValidator<T> validator)
name
- The property name.defaultValue
- The default value.boolean bind(IRule rule, int index, Object e, IBindingSet bindings)
#bind(IPredicate, Object, IBindingSet)
Note: The bindings are propagated before the constraints are verified so this method will have a side-effect on the bindings even if the constraints were not satisfied. Therefore you should clone the bindings before calling this method.
rule
- The rule.index
- The index of the IPredicate
in the body of the
Rule
.e
- An element materialized by the IAccessPath
for that
IPredicate
.bindingSet
- the bindings to which new bindings from the element will be
applied.true
unless the new bindings would violate any of
the IConstraint
s declared for the Rule
).NullPointerException
- if an argument is null
.IndexOutOfBoundsException
- if the index is out of bounds.boolean bind(IPredicate<?> pred, IConstraint[] constraints, Object e, IBindingSet bindings)
Note: The bindings are propagated before the constraints are verified so this method will have a side-effect on the bindings even if the constraints were not satisfied. Therefore you should clone the bindings before calling this method.
pred
- The IPredicate
from which the element was read.constraints
- An array of constraints which must be satisfied (optional).e
- An element materialized by the IAccessPath
for that
IPredicate
.bindingSet
- the bindings to which new bindings from the element will be
applied.true
unless the new bindings would violate any of
the optional IConstraint
.NullPointerException
- if an argument is null
.IConstant fakeBinding(IPredicate predicate, Var var)
IKeyOrder
associated with the IAccessPath
that will be used to evaluate the predicate when it appears in the tail
of an IRule
for a given IEvaluationPlan
.predicate
- The predicate.var
- A variable appearing in that predicate.ISolution newSolution(IRule rule, IBindingSet bindingSet)
ISolution
. The behavior of this method generally
depends on bit flags specified when the IJoinNexus
was created.
Note: For many purposes, it is only the computed ELEMENT
s that
are of interest. For high-level query, you will generally specify only
the BINDINGS
. The BINDINGS
are also useful for some
truth maintenance applications. The RULE
is generally only of
interest for inspecting the behavior of some rule set.
rule
- The rule.bindingSet
- The bindings (the implementation MUST clone the bindings if
they will be saved with the ISolution
).ISolution
.IllegalArgumentException
- if any parameter is null
.ELEMENT
,
BINDINGS
,
RULE
,
solutionFlags()
,
Solution
ISortKeyBuilder<IBindingSet> newBindingSetSortKeyBuilder(IRule rule)
ISortKeyBuilder
for an IBindingSet
. The sort
key may be used to SORT IBindingSet
s or to impose a DISTINCT
filter on ISolution
s, etc.rule
- The rule that will determine the order imposed amoung the
bound variables (which variable is 1st, 2nd, 3rd, etc.).int solutionFlags()
newSolution(IRule, IBindingSet)
.IBindingSet newBindingSet(IRule rule)
IBindingSet
implementations.
Note: The factory MUST apply any bound
constants
for the IRule
before
returning the IBindingSet
.
rule
- The rule whose bindings will be stored in the binding set.IRuleTaskFactory getRuleTaskFactory(boolean parallel, IRule rule)
BOp
s which specify which
join operator is to be used on a join by join basis.IRuleTaskFactory
for the rule. When the rule
is a step of a sequential program writing on one or more
IMutableRelation
s, then the returned IStepTask
must
automatically flush the buffer after the rule executes in order to ensure
that the state of the IMutableRelation
(s) are updated before the
next IRule
is executed.parallel
- true
unless the rule is a step is a sequential
IProgram
. Note that a sequential step MUST flush its
buffer since steps are run in sequence precisely because they
have a dependency!rule
- A rule that is a step in some program. If the program is just
a rule then the value of parallel does not matter. The
buffer will is cleared when it flushed so a re-flushed is
always a NOP.IStepTask
to execute for that rule.RunRuleAndFlushBufferTaskFactory
,
RunRuleAndFlushBufferTask
IEvaluationPlanFactory getPlanFactory()
IEvaluationPlan
s.long getWriteTimestamp()
IJoinNexusFactory.getWriteTimestamp()
.long getReadTimestamp()
IJoinNexusFactory.getReadTimestamp()
.IRelation getHeadRelationView(IPredicate pred)
IPredicate
. The implementation must choose a view that will
accept writes iff this is a mutation operation and which is associated
with an appropriate timestamp.pred
- The IPredicate
, which MUST be the head of some
IRule
.IRelation
, which will never be a fused view and
which will accept writes iff the rules are being executed as a
mutation operation.IRelation getTailRelationView(IPredicate pred)
IPredicate
.
Note: This method is responsible for returning a fused view when more
than one relation name was specified for the IPredicate
. It
SHOULD be used whenever the IRelation
is selected based on a
predicate in the tail of an IRule
and could therefore be a fused
view of more than one relation instance. (The head of the IRule
must be a simple IRelation
and not a view.)
Note: The implementation should choose the read timestamp for each
relation in the view using #getReadTimestamp(String)
.
pred
- The IPredicate
, which MUST be a tail from some IRule
.IRelation
, which might be a
RelationFusedView
.IAccessPath getTailAccessPath(IRelation relation, IPredicate pred)
Note that passing in the IRelation
is important since it
otherwise must be discovered using the IResourceLocator
. By
requiring the caller to resolve it before hand and pass it into this
method the contention and demand on the IResourceLocator
cache is
reduced.
relation
- The relation.pred
- The predicate. When IPredicate.getPartitionId()
is
set, the returned IAccessPath
MUST read on the
identified local index partition (directly, not via RMI).Iterator<PartitionLocator> locatorScan(AbstractScaleOutFederation<?> fed, IPredicate<?> predicate)
PartitionLocator
for the index
partitions from which an IAccessPath
must read in order to
materialize all elements which would be visited for that predicate.
Note: You can use an IDataServiceCallable
to obtain the
reference of the IDataService
and pass that into your
AbstractTask
in order to have the federation reference available
when running under the ConcurrencyManager
.
predicate
- The predicate, with whatever bindings already applied.fed
- The federation, which is required in order to access the
IMetadataIndex
for a scale-out index.joinNexus
- The IJoinNexus
.IIndexManager getIndexManager()
IChunkedOrderedIterator<ISolution> runQuery(IStep step) throws Exception
step
- The IRule
or IProgram
.IllegalStateException
- unless this is an ActionEnum.Query
.IllegalArgumentException
- if either argument is null
.Exception
long runMutation(IStep step) throws Exception
IRule
s).step
- The IRule
or IProgram
.IllegalArgumentException
- unless ActionEnum.isMutation()
is true
.IllegalArgumentException
- if either argument is null
.Exception
IBlockingBuffer<ISolution[]> newQueryBuffer()
ISolution
s will be written. The client will drain
ISolution
s from buffer using IBlockingBuffer.iterator()
.IBuffer<ISolution[]> newInsertBuffer(IMutableRelation relation)
ISolution
s will be written. When the buffer is
flushed
the chunked ISolution
s will be
inserted into the IMutableRelation
.relation
- The relation.IBuffer<ISolution[]> newDeleteBuffer(IMutableRelation relation)
ISolution
s will be written. When the buffer is
flushed
the chunks of ISolution
s will be
deleted from the IMutableRelation
.relation
- The relation.IBuffer<ISolution> newUnsynchronizedBuffer(IBuffer<ISolution[]> targetBuffer, int chunkCapacity)
The returned buffer MUST apply the optional filter value returned by
getSolutionFilter()
in order to keep individual
ISolution
s out of the buffer. Filtering is done at this level
since the targetBuffer contains chunks of solutions.
targetBuffer
- A thread-safe buffer for chunks of ISolution
s that
was allocated with newQueryBuffer()
,
newInsertBuffer(IMutableRelation)
, or
newDeleteBuffer(IMutableRelation)
.chunkCapacity
- The capacity of the new buffer. This should be maximum chunk
size that will be produced or getChunkCapacity()
if
you do not have better information.IElementFilter<ISolution> getSolutionFilter()
IElementFilter
that will be used to reject solutions
based on the bindings for the head of the rule -or- null
if no filter will be imposed. This may be used for query or mutation.IStreamSerializer<ISolution[]> getSolutionSerializer()
IStreamSerializer<IBindingSet[]> getBindingSetSerializer()
IBindingSet
s. This is used by JoinTask
s to transfer
intermediate IBindingSet
s from one join dimension to the next.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.