com.intel.hadoop.graphbuilder.graph.glgraph
Class EdgeListStorage<EdgeData>

java.lang.Object
  extended by com.intel.hadoop.graphbuilder.graph.glgraph.EdgeListStorage<EdgeData>
Type Parameters:
EdgeData -

public class EdgeListStorage<EdgeData>
extends java.lang.Object

Stores a list of edges as 3 separate arrays of source id, target id and edge data respectively. This class is used as a temporary storage for edges in the GLGraph before finalization.

See Also:
GLGraph.addEdge(Object, Object, Object), GLGraph.finalize()

Field Summary
 java.util.ArrayList<EdgeData> edata
          A list of edge data.
 java.util.ArrayList<java.lang.Integer> sources
          A list of source vertex ids.
 java.util.ArrayList<java.lang.Integer> targets
          A list of target vertex ids.
 
Constructor Summary
EdgeListStorage()
          Default constructor of an empty EdgeListStorage.
EdgeListStorage(int size)
          Creates an empty EdgeListStorage with expected size.
 
Method Summary
 void addEdge(java.lang.Integer source, java.lang.Integer target, EdgeData data)
          Add an edge with source, target and edata to the storage.
 void addEdges(java.util.List<java.lang.Integer> sourceList, java.util.List<java.lang.Integer> targetList, java.util.List<EdgeData> dataList)
          Add a list of edges.
 void clear()
          Removing all edges from the storage.
 void inplace_shuffle(java.util.List<java.lang.Integer> permute)
          Inplace shuffle the edges in the storage by a permutation array.
 void reserve(int n)
          Reserves the space for n edges.
 int size()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

edata

public java.util.ArrayList<EdgeData> edata
A list of edge data.


sources

public java.util.ArrayList<java.lang.Integer> sources
A list of source vertex ids.


targets

public java.util.ArrayList<java.lang.Integer> targets
A list of target vertex ids.

Constructor Detail

EdgeListStorage

public EdgeListStorage()
Default constructor of an empty EdgeListStorage.


EdgeListStorage

public EdgeListStorage(int size)
Creates an empty EdgeListStorage with expected size.

Parameters:
size -
Method Detail

reserve

public void reserve(int n)
Reserves the space for n edges.

Parameters:
n - the number of edges to be added.

addEdge

public void addEdge(java.lang.Integer source,
                    java.lang.Integer target,
                    EdgeData data)
Add an edge with source, target and edata to the storage. Thread safe.

Parameters:
source -
target -
data -

addEdges

public void addEdges(java.util.List<java.lang.Integer> sourceList,
                     java.util.List<java.lang.Integer> targetList,
                     java.util.List<EdgeData> dataList)
              throws java.lang.Exception
Add a list of edges. Thread safe.

Parameters:
sourceList -
targetList -
dataList -
Throws:
java.lang.Exception

size

public int size()
Returns:
the number of edges in the storage.

clear

public void clear()
Removing all edges from the storage.


inplace_shuffle

public void inplace_shuffle(java.util.List<java.lang.Integer> permute)
                     throws java.lang.Exception
Inplace shuffle the edges in the storage by a permutation array.

Throws:
java.lang.Exception