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>>
KeyValue
s 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, setContext
protected final Sharder sharder
public ShardingOutputWriter(Marshaller<K> keyMarshaller, Sharder sharder)
public void beginShard() throws IOException
OutputWriter
beginShard
in class OutputWriter<KeyValue<K,V>>
IOException
- in the event of failurepublic void endSlice() throws IOException
OutputWriter
endSlice
in class OutputWriter<KeyValue<K,V>>
IOException
- in the event of failurepublic void beginSlice() throws IOException
OutputWriter
beginSlice
in class OutputWriter<KeyValue<K,V>>
IOException
- in the event of failurepublic void write(KeyValue<K,V> value) throws IOException
OutputWriter
write
in class OutputWriter<KeyValue<K,V>>
IOException
protected abstract WriterT createWriter(int shardId)
shardId
- Implementations should not assume numbers provided are either in-order or
continuous.public void endShard() throws IOException
OutputWriter
endShard
in class OutputWriter<KeyValue<K,V>>
IOException
public abstract long estimateMemoryRequirement()
OutputWriter
estimateMemoryRequirement
in class OutputWriter<KeyValue<K,V>>
public boolean allowSliceRetry()
allowSliceRetry
in class OutputWriter<KeyValue<K,V>>
Copyright © 2015 Google. All rights reserved.