K - key typeV - value typeWriterT - type of the output writer being written topublic abstract class ShardingOutputWriter<K,V,WriterT extends OutputWriter<KeyValue<K,V>>> extends OutputWriter<KeyValue<K,V>>
KeyValues out to a number of output writers each corresponding to a different
shard A sharder and an Output object are provided in the constructor. The output object will be
used to create the writers that will be written to. The sharder will determine which writer any
given record will be written to based on the key.| Constructor and Description |
|---|
ShardingOutputWriter(Marshaller<K> keyMarshaller,
Sharder sharder) |
| 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.
|
protected abstract WriterT |
createWriter(int shardId)
Creates a new writer.
|
void |
endShard()
Called when no more output will be written to this writer.
|
void |
endSlice()
Prepares the writer for possible serialization.
|
abstract long |
estimateMemoryRequirement()
Returns the estimated memory that will be used by this writer in bytes.
|
protected Map<Integer,WriterT> |
getShardsToWriterMap() |
void |
write(KeyValue<K,V> value)
Writes a value to the output.
|
cleanup, close, getContext, open, setContextprotected final Sharder sharder
public ShardingOutputWriter(Marshaller<K> keyMarshaller, Sharder sharder)
public void beginShard()
throws IOException
OutputWriterbeginShard in class OutputWriter<KeyValue<K,V>>IOException - in the event of failurepublic void endSlice()
throws IOException
OutputWriterendSlice in class OutputWriter<KeyValue<K,V>>IOException - in the event of failurepublic void beginSlice()
throws IOException
OutputWriterbeginSlice in class OutputWriter<KeyValue<K,V>>IOException - in the event of failurepublic void write(KeyValue<K,V> value) throws IOException
OutputWriterwrite in class OutputWriter<KeyValue<K,V>>IOExceptionprotected abstract WriterT createWriter(int shardId)
shardId - Implementations should not assume numbers provided are either in-order or
continuous.public void endShard()
throws IOException
OutputWriterendShard in class OutputWriter<KeyValue<K,V>>IOExceptionpublic abstract long estimateMemoryRequirement()
OutputWriterestimateMemoryRequirement in class OutputWriter<KeyValue<K,V>>public boolean allowSliceRetry()
allowSliceRetry in class OutputWriter<KeyValue<K,V>>Copyright © 2015 Google. All rights reserved.