com.bigdata.relation.rule
Class Program

java.lang.Object
  extended by com.bigdata.relation.rule.Program
All Implemented Interfaces:
IProgram, IStep, Serializable
Direct Known Subclasses:
MappedProgram

public class Program
extends Object
implements IProgram

Mutable program may be used to create a variety of rule executions.

Version:
$Id: Program.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson
See Also:
Serialized Form

Field Summary
protected static org.apache.log4j.Logger log
           
 
Constructor Summary
  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.
 
Method Summary
 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()
          true iff the step is an IRule and false iff the step is an IProgram.
 int stepCount()
          The #of steps in the program (non-recursive).
 Iterator<IStep> steps()
          The sequence of sub-program ISteps.
 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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected static final transient org.apache.log4j.Logger log
Constructor Detail

Program

public Program(String name,
               boolean parallel)
An empty program.

Parameters:
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).

Program

public Program(String name,
               boolean parallel,
               IQueryOptions queryOptions)
An empty program.

Parameters:
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.

Program

protected Program(String name,
                  boolean parallel,
                  boolean closure)
An empty program.

Parameters:
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.
Method Detail

getName

public String getName()
Description copied from interface: IStep
The name of the program.

Specified by:
getName in interface IStep

isRule

public final boolean isRule()
Description copied from interface: IStep
true iff the step is an IRule and false iff the step is an IProgram.

Specified by:
isRule in interface IStep

isParallel

public boolean isParallel()
Description copied from interface: 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 ISolutions generated by the IRule.

Specified by:
isParallel in interface IProgram

isClosure

public boolean isClosure()
Description copied from interface: 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.

Specified by:
isClosure in interface IProgram

getQueryOptions

public IQueryOptions getQueryOptions()
Description copied from interface: IStep
Return additional constraints that must be imposed during query evaluation.

Specified by:
getQueryOptions in interface IStep

stepCount

public int stepCount()
Description copied from interface: IProgram
The #of steps in the program (non-recursive).

Specified by:
stepCount in interface IProgram

steps

public Iterator<IStep> steps()
Description copied from interface: IProgram
The sequence of sub-program ISteps.

Specified by:
steps in interface IProgram

toArray

public IStep[] toArray()
Description copied from interface: IProgram
An array containing the steps in the program (non-recursive).

Specified by:
toArray in interface IProgram

addStep

public void addStep(IStep step)
Add another step in the program.

Parameters:
step - The step.

addSteps

public void addSteps(Iterator<? extends IStep> steps)
Adds the steps to the program.

Parameters:
steps - The steps.

addClosureOf

public void addClosureOf(IRule[] rules)
Adds a sub-program consisting of the fixed point closure of the given rules.

Parameters:
rules - The rules.
Throws:
IllegalArgumentException - if rules or any element of rules is null.
IllegalStateException - if this program is parallel.

addClosureOf

public void addClosureOf(IRule rule)
Adds a sub-program consisting of the fixed point closure of the given rule.

Parameters:
rule - The rule.
Throws:
IllegalArgumentException - if rule is null.
IllegalStateException - if this program is parallel.

toString

protected StringBuilder toString(int depth)

toString

public String toString()
Description copied from interface: IStep
A human readable representation of the IStep.

Specified by:
toString in interface IStep
Overrides:
toString in class Object


Copyright © 2006-2009 SYSTAP, LLC. All Rights Reserved.