O
- type of values accepted by this outputpublic abstract class OutputWriter<O> extends Object implements Serializable
Created by Output
to write input for a given shard. Writers output for a shard as a
number of slices, where the slicing is up to the caller.
beginShard()
is called before any calls to beginSlice()
or write(O)
to setup the writer.
Each slice is written by calling beginSlice()
, then write(O)
any number of times,
then endSlice()
. Before the first slice, in between two slices, or after the final slice,
the OutputWriter
may go through serialization and deserialization.
At the end of the final slice, endShard()
will be called after endSlice()
.
If a slice is aborted, there is no guarantee whether endSlice()
will be called; however,
if it is not called, the OutputWriter
will not be serialized. If the slice is retried
later, the OutputWriter
serialized after the previous slice will be deserialized again.
Constructor and Description |
---|
OutputWriter() |
Modifier and Type | Method and Description |
---|---|
boolean |
allowSliceRetry() |
void |
beginShard()
Will be called once before any calls to write.
|
void |
beginSlice()
Prepares the writer for writing after possibly having gone through
serialization or deserialization.
|
void |
cleanup()
called after shards completes for any necessary cleanup.
|
void |
close()
Deprecated.
Override endShard instead.
|
void |
endShard()
Called when no more output will be written to this writer.
|
void |
endSlice()
Prepares the writer for possible serialization.
|
long |
estimateMemoryRequirement()
Returns the estimated memory that will be used by this writer in bytes.
|
ShardContext |
getContext()
Returns the current context, or null if none.
|
void |
open()
Deprecated.
Override beginShard instead.
|
void |
setContext(ShardContext context)
Used internally to sets the context to be used for the processing that follows.
|
abstract void |
write(O value)
Writes a value to the output.
|
public void setContext(ShardContext context)
public ShardContext getContext()
public void beginSlice() throws IOException
IOException
- in the event of failurepublic abstract void write(O value) throws IOException
IOException
public void endSlice() throws IOException
IOException
- in the event of failure@Deprecated public void open() throws IOException
IOException
- in the event of failurepublic void beginShard() throws IOException
IOException
- in the event of failurepublic long estimateMemoryRequirement()
@Deprecated public void close() throws IOException
IOException
- in the event of failurepublic void endShard() throws IOException
IOException
public boolean allowSliceRetry()
public void cleanup()
Copyright © 2015 Google. All rights reserved.