nenok.lc
Class JoinTree

java.lang.Object
  extended by nenok.lc.JoinTree
All Implemented Interfaces:
Iterable<Node>
Direct Known Subclasses:
HJoinTree, IDJoinTree, LSJoinTree, SSJoinTree

public abstract class JoinTree
extends Object
implements Iterable<Node>

This is the base class for the various join tree implementations. Each join tree class is equivalent to an architecture of local computation.

Version:
1.1
Author:
Marc Pouly

Nested Class Summary
 class JoinTree.Construction
          Inner class wrapping all necessary data for the join tree construction process.
 
Field Summary
protected  Allocator allocator
           
protected  TaskFactory factory
           
protected  Node root
           
 
Constructor Summary
protected JoinTree(Knowledgebase kb, Collection<Domain> queries, Algorithm algo, Processor proc)
          Constructor:
 
Method Summary
 Valuation answer(Domain query)
          Method to answer a given query represented by a domain.
 void collect()
          Executes the collect propagation.
 int countNodes()
           
abstract  Node createNode()
           
 void distribute(boolean... args)
          Executes the distribute propagation.
 Allocator getAllocator()
           
abstract  String getArchitecture()
           
 double getCollectTime()
           
 int getCommunicationCosts()
           
 Algorithm getConstructionAlgorithm()
           
 double getDistributeTime()
           
 Domain getLargestDomain()
           
 Set<Processor> getProcessorSet()
           
 double getPropagationTime()
           
 Collection<Domain> getQueries()
           
 Node getRoot()
           
 TaskFactory getTaskFactory()
           
 Domain getTreeDomain()
           
 boolean isBinary()
           
 boolean isCollected()
           
 boolean isDistributed()
           
 Iterator<Node> iterator()
          Jointrees can iterate over their nodes.
 void makeBinary()
          Transforms this join tree to a binary join tree.
 void propagate(boolean... args)
          Executes collect & distribute propagation.
abstract  void scale()
          Performs the scaling operations for this architecture.
 void setAllocator(Allocator allocator)
          Sets the jointree's processor allocation model.
 String toASCII(boolean content)
          Prints the jointree as ASCII string.
 String toString()
           
abstract  boolean verify(Class type)
          Verifies that the given knowledgebase can indeed be used with this architecture.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

root

protected Node root

allocator

protected Allocator allocator

factory

protected TaskFactory factory
Constructor Detail

JoinTree

protected JoinTree(Knowledgebase kb,
                   Collection<Domain> queries,
                   Algorithm algo,
                   Processor proc)
            throws ConstrException,
                   RemoteException
Constructor:

Parameters:
kb - The knowledgebase covered by this join tree.
queries - The set of queries that are covered by this join tree.
algo - The construction algorithm.
proc - The processor assigned to query nodes.
Throws:
ConstrException - Exceptions thrown during the construction process.
RemoteException - Exceptions caused by communication problems when accessing the query processor.
Method Detail

scale

public abstract void scale()
                    throws VAException,
                           RemoteException
Performs the scaling operations for this architecture. This method is executed, if the valuations are type Scalability.

Throws:
VAException - Exception thrown while executing the scaling operation.
RemoteException - Exceptions caused by communication problems when accessing the query processor.

getArchitecture

public abstract String getArchitecture()
Returns:
The join tree's architecture type.

verify

public abstract boolean verify(Class type)
Verifies that the given knowledgebase can indeed be used with this architecture.

Parameters:
type - The type of the locators that are contained in the knowledgebase.
Returns:
true, if the knowledgebase satifies the mathematical restrictions for this architecture.

createNode

public abstract Node createNode()
Returns:
Returns a new node instance corresponding to the architecture type of this jointree.

getQueries

public Collection<Domain> getQueries()
Returns:
The set of queries that are guarantueed to be covered by this jointree.

propagate

public void propagate(boolean... args)
               throws LCException,
                      RemoteException
Executes collect & distribute propagation.

Parameters:
args - args[0] = false averts scaling if the valuation algebra instance is of type Scalability.
Throws:
LCException - Exception thrown during join tree propagation.
RemoteException - Exceptions caused by communication problems when accessing processors.

collect

public void collect()
             throws LCException,
                    RemoteException
Executes the collect propagation.

Throws:
LCException - Exception thrown during join tree propagation.
RemoteException - Exceptions caused by communication problems when accessing processors.

distribute

public void distribute(boolean... args)
                throws LCException,
                       RemoteException
Executes the distribute propagation.

Parameters:
args - args[0] = false averts scaling if the valuation algebra instance is of type Scalability.
Throws:
LCException - Exception thrown when trying to execute distribute before collect has been terminated.
RemoteException - Exceptions caused by communication problems when accessing processors.

answer

public Valuation answer(Domain query)
                 throws RemoteException
Method to answer a given query represented by a domain.

Parameters:
query - The query to answer.
Returns:
The valuation of an (arbitrary) node in the tree with the query's domain.
Throws:
RemoteException - Exceptions caused when trying to access the processor hosting the query answer.

getCollectTime

public double getCollectTime()
Returns:
The time elapsed while executing collect. -1, if collect has not yet been executed.

getDistributeTime

public double getDistributeTime()
Returns:
The time elapsed while executing distribute. -1, if distribute has not yet been executed.

getPropagationTime

public double getPropagationTime()
Returns:
The time elapsed while executing collect and distribute. -1, if the propagation has not yet been executed.

getTaskFactory

public TaskFactory getTaskFactory()
Returns:
The task factory of this jointree.

setAllocator

public void setAllocator(Allocator allocator)
Sets the jointree's processor allocation model.

Parameters:
allocator - The new processor allocation model.

getAllocator

public Allocator getAllocator()
Returns:
The processor allocation model of this jointree.

getCommunicationCosts

public int getCommunicationCosts()
Returns:
Returns the total communication costs caused by local computation messages.

getConstructionAlgorithm

public Algorithm getConstructionAlgorithm()
Returns:
The construction algorithm having built this join tree.

getProcessorSet

public Set<Processor> getProcessorSet()
Returns:
A set of all processors that are assigned to at least one node on this join tree. Note that the null elements will never occur in this set.

getRoot

public Node getRoot()
Returns:
The root node of this join tree.

iterator

public Iterator<Node> iterator()
Jointrees can iterate over their nodes.

Specified by:
iterator in interface Iterable<Node>
Returns:
The jointree's node iterator.
See Also:
Iterable.iterator()

getLargestDomain

public Domain getLargestDomain()
Returns:
The largest domain in this join tree.

getTreeDomain

public Domain getTreeDomain()
Returns:
The union of all node domains within the tree.

countNodes

public int countNodes()
Returns:
Counts the number of nodes within the join tree.

toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()

toASCII

public String toASCII(boolean content)
Prints the jointree as ASCII string.

Parameters:
content - true to print the content of each node.
Returns:
The current jointree as ASCII string.

isCollected

public boolean isCollected()
Returns:
true, if the collect algorithm has been executed.

isDistributed

public boolean isDistributed()
Returns:
true, if the distribute algorithm has been executed.

isBinary

public boolean isBinary()
Returns:
true, if this join tree is binary.

makeBinary

public void makeBinary()
Transforms this join tree to a binary join tree.