at.dms.kjc.slicegraph
Class InputSliceNode

java.lang.Object
  extended by at.dms.kjc.slicegraph.SliceNode
      extended by at.dms.kjc.slicegraph.InputSliceNode

public class InputSliceNode
extends SliceNode

Each Slice is started by an InputSlice Node that is either a joiner connecting several other slices, or a connection to a single other slice. Has an array of weights and corresponding InterSliceEdges.


Constructor Summary
InputSliceNode()
          Constructor: no edges, no weights
InputSliceNode(int[] weights)
          Constructor: weights, edges to be set later.
InputSliceNode(int[] weights, InterSliceEdge[] sources)
          Creator
InputSliceNode(int[] weights, OutputSliceNode[] sources)
          Constructor
 
Method Summary
 void canonicalize()
          Merge neighboring edges and weights if the neighboring edges are actually the same Edge object.
 String debugString(boolean escape)
          Return a string that gives some information for this input slice node.
 String getIdent()
          Returns unique string identifying slice.
 int getItems(InterSliceEdge edge)
          Return the number of items that traverse this edge on one iteration of this input slice node, remember that a single edge can appear multiple times in the joining pattern.
 FilterSliceNode getNextFilter()
          Get the following FilterSliceNode.
 InterSliceEdge getSingleEdge()
          Get the singleton edge.
 LinkedList<InterSliceEdge> getSourceList()
          Return a linked list of the sources pattern.
 InterSliceEdge[] getSources()
           
 LinkedList<InterSliceEdge> getSourceSequence()
          Return a list of the edges with each edge appearing once and ordered by the order in which each edge appears in the join pattern.
 Set<InterSliceEdge> getSourceSet()
           
 CType getType()
           
 int getWeight(Edge out)
           
 int[] getWeights()
           
 int getWidth()
          Return the number of unique inputs (Edges) to this join.
 boolean hasFileInput()
           
 boolean isFileOutput()
          InputSliceNode is FileOutput if FilterSliceNode is FileOutput.
 boolean isJoiner()
          Is a joiner if there are at least 2 sources (even if same Edge object).
 boolean noInputs()
          Are there no inputs?
 boolean oneInput()
          Does sources have a single element.
 double ratio(Edge edge)
          return ratio of weight of edge to totalWeights().
 void replaceEdge(InterSliceEdge oldEdge, InterSliceEdge newEdge)
          In the sources array for the input, replace all instances of oldEdge with newEdge.
 void set(LinkedList<Integer> weights, LinkedList<InterSliceEdge> edges)
          Set the weights and sources array of this input slice node to the weights list and the edges list.
 void setSources(InterSliceEdge[] sources)
          Set the source edges.
 void setWeights(int[] newWeights)
          Set the weights to newWeights.
 int totalWeights()
           
 
Methods inherited from class at.dms.kjc.slicegraph.SliceNode
getAsFilter, getAsInput, getAsOutput, getEdgeToNext, getNext, getParent, getPrevious, isFilterSlice, isInputSlice, isOutputSlice, setNext, setParent, setPrevious
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InputSliceNode

public InputSliceNode(int[] weights,
                      InterSliceEdge[] sources)
Creator


InputSliceNode

public InputSliceNode(int[] weights,
                      OutputSliceNode[] sources)
Constructor


InputSliceNode

public InputSliceNode(int[] weights)
Constructor: weights, edges to be set later.


InputSliceNode

public InputSliceNode()
Constructor: no edges, no weights

Method Detail

canonicalize

public void canonicalize()
Merge neighboring edges and weights if the neighboring edges are actually the same Edge object. This operation exists as a cleanup operation for synch removal. Code generation for Edges may rely on OutputSliceNode.canonicalize() being run on all output nodes whose edges are combined by canonicalize.


isFileOutput

public boolean isFileOutput()
InputSliceNode is FileOutput if FilterSliceNode is FileOutput.


getIdent

public String getIdent()
Returns unique string identifying slice.


getWidth

public int getWidth()
Return the number of unique inputs (Edges) to this join.

Returns:
The width of the join.

getItems

public int getItems(InterSliceEdge edge)
Return the number of items that traverse this edge on one iteration of this input slice node, remember that a single edge can appear multiple times in the joining pattern.

Parameters:
edge - The edge to query.
Returns:
The number of items passing on the edge.

getWeights

public int[] getWeights()
Returns:
array of edge weights

getSources

public InterSliceEdge[] getSources()
Returns:
array of edges

set

public void set(LinkedList<Integer> weights,
                LinkedList<InterSliceEdge> edges)
Set the weights and sources array of this input slice node to the weights list and the edges list.

Parameters:
weights - The list of weights (Integer).
edges - The list of edges.

setWeights

public void setWeights(int[] newWeights)
Set the weights to newWeights.

Parameters:
newWeights -

setSources

public void setSources(InterSliceEdge[] sources)
Set the source edges. (shares, does not copy.)


totalWeights

public int totalWeights()
Returns:
total weight of all edges

getWeight

public int getWeight(Edge out)
Parameters:
out - The Edge that we are interested in
Returns:
total weight on all connections to a single Edge.

oneInput

public boolean oneInput()
Does sources have a single element.

Returns:
true if there is a single element in sources.

isJoiner

public boolean isJoiner()
Is a joiner if there are at least 2 sources (even if same Edge object).

Returns:
is a joiner.

getSingleEdge

public InterSliceEdge getSingleEdge()
Get the singleton edge. Must have only one input in sources.

Returns:
the edge, or throw AssertionError

getNextFilter

public FilterSliceNode getNextFilter()
Get the following FilterSliceNode.

Returns:

noInputs

public boolean noInputs()
Are there no inputs?

Returns:

ratio

public double ratio(Edge edge)
return ratio of weight of edge to totalWeights().

Parameters:
edge -
Returns:
0.0 if totalWeights() == 0, else ratio.

getSourceSequence

public LinkedList<InterSliceEdge> getSourceSequence()
Return a list of the edges with each edge appearing once and ordered by the order in which each edge appears in the join pattern.

Returns:
The list.

getSourceList

public LinkedList<InterSliceEdge> getSourceList()
Return a linked list of the sources pattern.

Returns:
The linked list of the sources pattern.

getSourceSet

public Set<InterSliceEdge> getSourceSet()

debugString

public String debugString(boolean escape)
Return a string that gives some information for this input slice node. If escape is true, then escape the new lines "\\n".

Parameters:
escape - Should we escape the new lines?
Returns:
The string.

hasFileInput

public boolean hasFileInput()

replaceEdge

public void replaceEdge(InterSliceEdge oldEdge,
                        InterSliceEdge newEdge)
In the sources array for the input, replace all instances of oldEdge with newEdge.

Parameters:
oldEdge - The edge to replace.
newEdge - The edge to install.

getType

public CType getType()