public class Program extends Object implements IProgram
Modifier and Type | Field and Description |
---|---|
protected static org.apache.log4j.Logger |
log |
Modifier | Constructor and Description |
---|---|
|
Program(String name,
boolean parallel)
An empty program.
|
protected |
Program(String name,
boolean parallel,
boolean closure)
An empty program.
|
|
Program(String name,
boolean parallel,
IQueryOptions queryOptions)
An empty program.
|
Modifier and Type | Method and Description |
---|---|
void |
addClosureOf(IRule rule)
Adds a sub-program consisting of the fixed point closure of the given
rule.
|
void |
addClosureOf(IRule[] rules)
Adds a sub-program consisting of the fixed point closure of the given
rules.
|
void |
addStep(IStep step)
Add another step in the program.
|
void |
addSteps(Iterator<? extends IStep> steps)
Adds the steps to the program.
|
String |
getName()
The name of the program.
|
IQueryOptions |
getQueryOptions()
Return additional constraints that must be imposed during query
evaluation.
|
boolean |
isClosure()
true iff the fixed point closure of the IProgram
should be computed. |
boolean |
isParallel()
true iff the IProgram.steps() MAY be executed in parallel. |
boolean |
isRule()
|
int |
stepCount()
The #of steps in the program (non-recursive).
|
Iterator<IStep> |
steps()
The sequence of sub-program
IStep s. |
IStep[] |
toArray()
An array containing the steps in the program (non-recursive).
|
String |
toString()
A human readable representation of the
IStep . |
protected StringBuilder |
toString(int depth) |
public Program(String name, boolean parallel)
name
- A label for the program.parallel
- true
iff the steps in the program are
parallelizable (this does not imply that they will be executed
in parallel, only that they do not have dependencies among the
steps and hence are in principle parallelizable).public Program(String name, boolean parallel, IQueryOptions queryOptions)
name
- A label for the program.parallel
- true
iff the steps in the program are
parallelizable (this does not imply that they will be executed
in parallel, only that they do not have dependencies among the
steps and hence are in principle parallelizable).queryOptions
- Options that will be imposed if the iprogram is evaluated as a
query.protected Program(String name, boolean parallel, boolean closure)
name
- A label for the program.parallel
- true
iff the steps in the program are
parallelizable (this does not imply that they will be executed
in parallel, only that they do not have dependencies among the
steps and hence are in principle parallelizable).closure
- true
iff the steps in the program must be run
until a fixed point is achieved.public final boolean isRule()
IStep
public boolean isParallel()
IProgram
true
iff the IProgram.steps()
MAY be executed in parallel.
When false
the steps WILL be executed sequentially and
(for mutation) the buffered writes will be flushed after each step.
Note: Sequential execution of a program makes a multi-IRule
program MUCH easier to debug as the rules are executed one by one and the
buffer is flushed after each rule so you can directly see the #of
elements consider by the IRule
for each IPredicate
in the
tail and the #of ISolution
s generated by the IRule
.
isParallel
in interface IProgram
public boolean isClosure()
IProgram
true
iff the fixed point closure of the IProgram
should be computed.
Note: Closure is computed in rounds. The rounds continue until the
IMutableRelation
(s) on which the steps are writing reach a fixed
point (no new solutions are added to the relation(s) within a given
round). If a program has a fixed point, then the same closure will be
obtained by either sequential or parallel execution of the steps within
each round and in general parallel execution of the steps is perferred as
it has better performance. However, the steps MAY be executed
sequentially to facilitate debugging.
public IQueryOptions getQueryOptions()
IStep
getQueryOptions
in interface IStep
public int stepCount()
IProgram
public Iterator<IStep> steps()
IProgram
IStep
s.public IStep[] toArray()
IProgram
public void addStep(IStep step)
step
- The step.public void addSteps(Iterator<? extends IStep> steps)
steps
- The steps.public void addClosureOf(IRule[] rules)
rules
- The rules.IllegalArgumentException
- if rules or any element of rules is
null
.IllegalStateException
- if this program is parallel.public void addClosureOf(IRule rule)
rule
- The rule.IllegalArgumentException
- if rule is null
.IllegalStateException
- if this program is parallel.protected StringBuilder toString(int depth)
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.