I
- Vertex idV
- Vertex dataE
- Edge datapublic class SimplePartitionStore<I extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable,E extends org.apache.hadoop.io.Writable> extends Object implements PartitionStore<I,V,E>
Constructor and Description |
---|
SimplePartitionStore(ImmutableClassesGiraphConfiguration<I,V,E> conf,
org.apache.hadoop.mapreduce.Mapper.Context context)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addPartition(Partition<I,V,E> partition)
Add a *new* partition to the store.
|
void |
addPartitionVertices(Integer partitionId,
ExtendedDataOutput extendedDataOutput)
Add vertices to a given partition from a given DataOutput instance.
|
Partition<I,V,E> |
getNextPartition()
Return the next partition in iteration for the current superstep.
|
int |
getNumPartitions()
Return the number of stored partitions.
|
long |
getPartitionEdgeCount(Integer partitionId)
Return the number of edges in a partition.
|
Iterable<Integer> |
getPartitionIds()
Return the ids of all the stored partitions as an Iterable.
|
long |
getPartitionVertexCount(Integer partitionId)
Return the number of vertices in a partition.
|
boolean |
hasPartition(Integer partitionId)
Whether a specific partition is present in the store.
|
void |
initialize()
Called at the beginning of the computation.
|
boolean |
isEmpty()
Whether the partition store is empty.
|
void |
putPartition(Partition<I,V,E> partition)
Put a partition back to the store.
|
Partition<I,V,E> |
removePartition(Integer partitionId)
Remove a partition and return it.
|
void |
shutdown()
Called at the end of the computation.
|
void |
startIteration()
Start the iteration cycle to iterate over partitions.
|
public SimplePartitionStore(ImmutableClassesGiraphConfiguration<I,V,E> conf, org.apache.hadoop.mapreduce.Mapper.Context context)
conf
- Configurationcontext
- Mapper contextpublic boolean addPartition(Partition<I,V,E> partition)
PartitionStore
addPartition
in interface PartitionStore<I extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable,E extends org.apache.hadoop.io.Writable>
partition
- Partition to addpublic Partition<I,V,E> removePartition(Integer partitionId)
PartitionStore
removePartition
in interface PartitionStore<I extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable,E extends org.apache.hadoop.io.Writable>
partitionId
- Partition idpublic boolean hasPartition(Integer partitionId)
PartitionStore
hasPartition
in interface PartitionStore<I extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable,E extends org.apache.hadoop.io.Writable>
partitionId
- Partition idpublic Iterable<Integer> getPartitionIds()
PartitionStore
getPartitionIds
in interface PartitionStore<I extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable,E extends org.apache.hadoop.io.Writable>
public int getNumPartitions()
PartitionStore
getNumPartitions
in interface PartitionStore<I extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable,E extends org.apache.hadoop.io.Writable>
public long getPartitionVertexCount(Integer partitionId)
PartitionStore
getPartitionVertexCount
in interface PartitionStore<I extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable,E extends org.apache.hadoop.io.Writable>
partitionId
- Partition idpublic long getPartitionEdgeCount(Integer partitionId)
PartitionStore
getPartitionEdgeCount
in interface PartitionStore<I extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable,E extends org.apache.hadoop.io.Writable>
partitionId
- Partition idpublic boolean isEmpty()
PartitionStore
isEmpty
in interface PartitionStore<I extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable,E extends org.apache.hadoop.io.Writable>
public void startIteration()
PartitionStore
PartitionStore.getNextPartition()
to iterate over the partitions.
Each time PartitionStore.getNextPartition()
is called an unprocessed partition in
the current iteration is returned. After processing of the partition is
done, partition should be put back in the store using
PartitionStore.putPartition(Partition)
. Here is an example of the entire
workflow:
In the main thread:
partitionStore.startIteration();
In multiple threads iterating over the partitions:
Partition partition = partitionStore.getNextPartition();
... do stuff with partition ...
partitionStore.putPartition(partition);
Called from a single thread.startIteration
in interface PartitionStore<I extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable,E extends org.apache.hadoop.io.Writable>
public Partition<I,V,E> getNextPartition()
PartitionStore
PartitionStore.putPartition(Partition)
after use. Look at comments on
PartitionStore.startIteration()
for more detail.getNextPartition
in interface PartitionStore<I extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable,E extends org.apache.hadoop.io.Writable>
public void putPartition(Partition<I,V,E> partition)
PartitionStore
PartitionStore.getNextPartition()
.
Look at comments on PartitionStore.startIteration()
for more detail.putPartition
in interface PartitionStore<I extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable,E extends org.apache.hadoop.io.Writable>
partition
- Partitionpublic void addPartitionVertices(Integer partitionId, ExtendedDataOutput extendedDataOutput)
PartitionStore
addPartitionVertices
in interface PartitionStore<I extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable,E extends org.apache.hadoop.io.Writable>
partitionId
- Partition idextendedDataOutput
- Output containing serialized vertex datapublic void shutdown()
PartitionStore
shutdown
in interface PartitionStore<I extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable,E extends org.apache.hadoop.io.Writable>
public void initialize()
PartitionStore
initialize
in interface PartitionStore<I extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable,E extends org.apache.hadoop.io.Writable>
Copyright © 2011-2020 The Apache Software Foundation. All Rights Reserved.