T - Type of event.P - Type of partition.@NotThreadSafe public abstract class PartitionedFileWriter<T,P> extends Object implements FileWriter<T>
FileWriter.| Modifier and Type | Class and Description |
|---|---|
protected static interface |
PartitionedFileWriter.PartitionedFileWriterFactory<T,P> |
| Modifier | Constructor and Description |
|---|---|
protected |
PartitionedFileWriter(PartitionedFileWriter.PartitionedFileWriterFactory<T,P> fileWriterFactory)
Constructs with the given file writer factory.
|
| Modifier and Type | Method and Description |
|---|---|
void |
append(T event)
Appends an event to the file.
|
void |
appendAll(Iterator<? extends T> events)
Appends multiple events to the file.
|
void |
close() |
protected void |
closePartitionWriter(P partition)
Closes the
FileWriter for the given partition. |
void |
flush() |
protected abstract P |
getPartition(T event)
Returns the partition ID for the given event.
|
protected void |
partitionChanged(P oldPartition,
P newPartition)
Invoked when partition changed (different from the last event get appended).
|
protected PartitionedFileWriter(PartitionedFileWriter.PartitionedFileWriterFactory<T,P> fileWriterFactory)
public void append(T event) throws IOException
FileWriterappend in interface FileWriter<T>event - event to appendIOException - if fail to appendpublic void appendAll(Iterator<? extends T> events) throws IOException
FileWriterappendAll in interface FileWriter<T>events - an Iterator that provides events to appendIOException - if fail to appendpublic void flush()
throws IOException
flush in interface FlushableIOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionprotected final void closePartitionWriter(P partition) throws IOException
FileWriter for the given partition.IOExceptionprotected void partitionChanged(P oldPartition, P newPartition) throws IOException
IOExceptionCopyright © 2016 Cask Data, Inc. Licensed under the Apache License, Version 2.0.