O
- type of values accepted by this outputR
- type returned by finish(java.util.Collection<? extends com.google.appengine.tools.mapreduce.OutputWriter<O>>)
public abstract class Output<O,R> extends Object implements Serializable
OutputWriter
s and may
produce a result to be returned in MapReduceResult
(see
finish(java.util.Collection<? extends com.google.appengine.tools.mapreduce.OutputWriter<O>>)
).
This class is really an interface that might be evolving. In order to avoid breaking users when we change the interface, we made it an abstract class.
Constructor and Description |
---|
Output() |
Modifier and Type | Method and Description |
---|---|
abstract List<? extends OutputWriter<O>> |
createWriters(int numShards)
Returns a list of writers, one for each shard, for this output.
|
abstract R |
finish(Collection<? extends OutputWriter<O>> writers)
Returns a result to be made available through
MapReduceResult.getOutputResult() . |
Context |
getContext()
Returns the current context, or null if none.
|
void |
setContext(Context context)
Used internally to sets the context to be used for the processing that follows.
|
public void setContext(Context context)
public Context getContext()
public abstract List<? extends OutputWriter<O>> createWriters(int numShards)
numShards
- The number of shards which should be equal to the number of
OutputWriter
s returned.public abstract R finish(Collection<? extends OutputWriter<O>> writers) throws IOException
MapReduceResult.getOutputResult()
.
This method allows the Output
to inspect the final state of its OutputWriter
s
to produce a final result object. For example, if the OutputWriter
s produce blobs in
blobstore, finish
could collect and return a list of blob IDs.
Should return null if no such result makes sense for this kind of output.
Called after all OutputWriter
s have been closed (with OutputWriter.close()
). It
is possible for this method to be called more than once with the same writers
collection. It is also possible for the job to fail after this is invoked.
The writers
argument will contain the same writers that createWriters(int)
returned
in the same order. Writers may be serialized and deserialized multiple times. typically,
getWriter
will have been called in a different JVM.
IOException
Copyright © 2015 Google. All rights reserved.