org.apache.giraph.examples
Class SimpleAggregatorWriter
java.lang.Object
org.apache.giraph.conf.DefaultImmutableClassesGiraphConfigurable
org.apache.giraph.examples.SimpleAggregatorWriter
- All Implemented Interfaces:
- AggregatorWriter, ImmutableClassesGiraphConfigurable
public class SimpleAggregatorWriter
- extends DefaultImmutableClassesGiraphConfigurable
- implements AggregatorWriter
This is a simple example for an aggregator writer. After each superstep
the writer will persist the aggregator values to disk, by use of the
Writable interface. The file will be created on the current working
directory.
|
Method Summary |
void |
close()
The method is called at the end of a successful computation. |
static String |
getFilename()
|
void |
initialize(org.apache.hadoop.mapreduce.Mapper.Context context,
long applicationAttempt)
The method is called at the initialization of the AggregatorWriter. |
void |
writeAggregator(Iterable<Map.Entry<String,org.apache.hadoop.io.Writable>> aggregatorMap,
long superstep)
The method is called at the end of each superstep. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SimpleAggregatorWriter
public SimpleAggregatorWriter()
getFilename
public static String getFilename()
initialize
public void initialize(org.apache.hadoop.mapreduce.Mapper.Context context,
long applicationAttempt)
throws IOException
- Description copied from interface:
AggregatorWriter
- The method is called at the initialization of the AggregatorWriter.
More precisely, the aggregatorWriter is initialized each time a new
master is elected.
- Specified by:
initialize in interface AggregatorWriter
- Parameters:
context - Mapper Context where the master is running onapplicationAttempt - ID of the applicationAttempt, used to
disambiguate aggregator writes for different attempts
- Throws:
IOException
writeAggregator
public void writeAggregator(Iterable<Map.Entry<String,org.apache.hadoop.io.Writable>> aggregatorMap,
long superstep)
throws IOException
- Description copied from interface:
AggregatorWriter
- The method is called at the end of each superstep. The user might decide
whether to write the aggregators values for the current superstep. For
the last superstep,
AggregatorWriter.LAST_SUPERSTEP is passed.
- Specified by:
writeAggregator in interface AggregatorWriter
- Parameters:
aggregatorMap - Map from aggregator name to aggregator valuesuperstep - Current superstep
- Throws:
IOException
close
public void close()
throws IOException
- Description copied from interface:
AggregatorWriter
- The method is called at the end of a successful computation. The method
is not called when the job fails and a new master is elected. For this
reason it's advised to flush data at the end of
AggregatorWriter.writeAggregator(Iterable, long).
- Specified by:
close in interface AggregatorWriter
- Throws:
IOException
Copyright © 2011-2013 The Apache Software Foundation. All Rights Reserved.