Class BinaryStoreWriterV2
- All Implemented Interfaces:
Entry
,Record
,Row
,TableWriter<BinaryRowV2>
- Direct Known Subclasses:
BinaryStoreAggregatorWriterMultiPartition
,BinaryStoreAggregatorWriterStandard
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
A container for binningWritableRowContainer
s by column partition in order to enable write batching.Nested classes/interfaces inherited from interface com.illumon.iris.binarystore.Record
Record.RecordSetter<T extends RecordData>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final com.fishlib.io.logger.Logger
protected BinaryRecordV2
protected Row
Fields inherited from interface com.illumon.iris.binarystore.TableWriter
NULL_SETTER
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
BinaryStoreWriterV2
(String[] columnNames, SupportedType[] columnTypes, Object[] typeMetadata, Map<String, Object> constantColumnValues, int applicationVersion, int targetWriteSize, com.fishlib.io.logger.Logger log) protected
BinaryStoreWriterV2
(String[] columnNames, SupportedType[] columnTypes, Object[] typeMetadata, Map<String, Object> constantColumnValues, int applicationVersion, com.fishlib.io.logger.Logger log) Note: this is for internal use, and does not call setChannelManager or init().BinaryStoreWriterV2
(String path, String[] columnNames, SupportedType[] columnTypes, Object[] typeMetadata, com.fishlib.io.logger.Logger log) BinaryStoreWriterV2
(String path, String[] columnNames, SupportedType[] columnTypes, Object[] typeMetadata, DateFormat rollFormat, com.fishlib.io.logger.Logger log) BinaryStoreWriterV2
(String path, String[] columnNames, SupportedType[] columnTypes, Object[] typeMetadata, DateFormat rollFormat, Map<String, Object> constantColumnValues, int applicationVersion, int targetWriteSize, com.fishlib.io.logger.Logger log) BinaryStoreWriterV2
(String path, String[] columnNames, SupportedType[] columnTypes, Object[] typeMetadata, DateFormat rollFormat, Map<String, Object> constantColumnValues, int applicationVersion, com.fishlib.io.logger.Logger log) BinaryStoreWriterV2
(String path, String[] columnNames, SupportedType[] columnTypes, Object[] typeMetadata, DateFormat rollFormat, Map<String, Object> constantColumnValues, com.fishlib.io.logger.Logger log) BinaryStoreWriterV2
(String path, String[] columnNames, SupportedType[] columnTypes, Object[] typeMetadata, Map<String, Object> constantColumnValues, int applicationVersion, com.fishlib.io.logger.Logger log) BinaryStoreWriterV2
(String path, String[] columnNames, SupportedType[] columnTypes, Object[] typeMetadata, Map<String, Object> constantColumnValues, com.fishlib.io.logger.Logger log) -
Method Summary
Modifier and TypeMethodDescriptionCompute the header buffer for this writer and return it in a new buffer (direct).protected BinaryRecordV2
Implementation point for creating a binary record writer (BinaryRecordV2
).protected BinaryRowV2
createBinaryRow
(String[] columnNames, SupportedType[] columnTypes, Object[] typeMetadata) void
Write any rows buffered byTableWriter.writeDeferredRow(WritableRowContainer)
to storage.protected void
Flush all of the deferred rows in the input collection to the underlying stream.String[]
Gets the column names for the table.For rows that are to be used with file managers that allow dynamic column partition selection, retrieve the column partition value.Class[]
Gets the column types for the table.Gets a record setter for an entry.<T extends RecordData>
Record.RecordSetter<T>getRecordSetter
(Class<T> tClass) Gets a typed record setter for an entry.Get new writer for Record entries.Get a writer for a Row entries.Gets a setter for a column.protected void
init()
static BinaryStoreWriterV2
makeCurrentDatePartitionedBinaryStoreWriter
(com.fishlib.io.logger.Logger log, String logDir, String namespace, String tablename, TableIdentifier.NamespaceSet namespaceSet, String internalPartition, String[] columnNames, SupportedType[] columnTypes, Object[] typeMetadata, Map<String, Object> constantColumnValues, int applicationVersion, ZoneId zoneId) Make a BinaryStoreWriterV2 instance that changes the column partition value based on the current time, by changing the name of the rolling output file.static BinaryStoreWriterV2
makeMultiPartitionFileManagerBinaryStoreWriter
(com.fishlib.io.logger.Logger log, String logDir, String namespace, String tablename, TableIdentifier.NamespaceSet namespaceSet, String internalPartition, String[] columnNames, SupportedType[] columnTypes, Object[] typeMetadata, Map<String, Object> constantColumnValues, int applicationVersion) Make a BinaryStoreWriterV2 instance that uses dynamic (per-row) column partition values.static BinaryStoreWriterV2
makeSpecifiedPartitionBinaryStoreWriter
(com.fishlib.io.logger.Logger log, String logDir, String namespace, String tablename, TableIdentifier.NamespaceSet namespaceSet, String internalPartition, String columnPartition, String[] columnNames, SupportedType[] columnTypes, Object[] typeMetadata, Map<String, Object> constantColumnValues, int applicationVersion, ZoneId zoneId) Make a BinaryStoreWriterV2 with the specified values, including an unchanging column partition value.void
setColumnPartitionValue
(String columnPartitionValue) For rows that are to be used with file managers that allow dynamic column partition selection, set the column partition value.void
void
setRecordData
(RecordData recordData) void
Write the row to disk.protected void
writeMulti
(ByteBuffer[] buffs, int count, GatheringByteChannel channel) Perform a gathering write to the writer's channel.void
writeRecord
(WritableByteChannel channel) Write a record entry to the provided output channel.void
writeRow()
Writes out a new row (values set using setters).Methods inherited from class com.illumon.iris.binarystore.AbstractBinaryStoreWriter
close, flush, setChannelManager, supportAllTypes
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.illumon.iris.binarystore.TableWriter
getSetter
-
Field Details
-
-
primaryRecordWriter
-
log
protected final com.fishlib.io.logger.Logger log
-
-
Constructor Details
-
BinaryStoreWriterV2
public BinaryStoreWriterV2(String path, String[] columnNames, SupportedType[] columnTypes, Object[] typeMetadata, com.fishlib.io.logger.Logger log) throws IOException - Throws:
IOException
-
BinaryStoreWriterV2
public BinaryStoreWriterV2(String path, String[] columnNames, SupportedType[] columnTypes, Object[] typeMetadata, DateFormat rollFormat, com.fishlib.io.logger.Logger log) throws IOException - Throws:
IOException
-
BinaryStoreWriterV2
public BinaryStoreWriterV2(String path, String[] columnNames, SupportedType[] columnTypes, Object[] typeMetadata, Map<String, Object> constantColumnValues, com.fishlib.io.logger.Logger log) throws IOException- Throws:
IOException
-
BinaryStoreWriterV2
public BinaryStoreWriterV2(String path, String[] columnNames, SupportedType[] columnTypes, Object[] typeMetadata, Map<String, Object> constantColumnValues, int applicationVersion, com.fishlib.io.logger.Logger log) throws IOException- Throws:
IOException
-
BinaryStoreWriterV2
public BinaryStoreWriterV2(String path, String[] columnNames, SupportedType[] columnTypes, Object[] typeMetadata, DateFormat rollFormat, Map<String, Object> constantColumnValues, com.fishlib.io.logger.Logger log) throws IOException- Throws:
IOException
-
BinaryStoreWriterV2
public BinaryStoreWriterV2(String path, String[] columnNames, SupportedType[] columnTypes, Object[] typeMetadata, DateFormat rollFormat, Map<String, Object> constantColumnValues, int applicationVersion, com.fishlib.io.logger.Logger log) throws IOException- Throws:
IOException
-
BinaryStoreWriterV2
public BinaryStoreWriterV2(String path, String[] columnNames, SupportedType[] columnTypes, Object[] typeMetadata, DateFormat rollFormat, Map<String, Object> constantColumnValues, int applicationVersion, int targetWriteSize, com.fishlib.io.logger.Logger log) throws IOException- Throws:
IOException
-
BinaryStoreWriterV2
protected BinaryStoreWriterV2(String[] columnNames, SupportedType[] columnTypes, Object[] typeMetadata, Map<String, Object> constantColumnValues, int applicationVersion, com.fishlib.io.logger.Logger log) Note: this is for internal use, and does not call setChannelManager or init(). -
BinaryStoreWriterV2
-
-
Method Details
-
computeHeaderBuffer
Compute the header buffer for this writer and return it in a new buffer (direct). Callers of this method should cache the result if possible.- Returns:
- a new buffer containing the binary header.
- Throws:
IOException
- pass through
-
makeCurrentDatePartitionedBinaryStoreWriter
public static BinaryStoreWriterV2 makeCurrentDatePartitionedBinaryStoreWriter(com.fishlib.io.logger.Logger log, String logDir, String namespace, String tablename, TableIdentifier.NamespaceSet namespaceSet, String internalPartition, String[] columnNames, SupportedType[] columnTypes, Object[] typeMetadata, Map<String, Object> constantColumnValues, int applicationVersion, ZoneId zoneId) throws IOExceptionMake a BinaryStoreWriterV2 instance that changes the column partition value based on the current time, by changing the name of the rolling output file.- Parameters:
log
- the Logger instancelogDir
- the directory into which binary logs will be writtennamespace
- the namespacetablename
- the table namenamespaceSet
- the NamespaceSetinternalPartition
- the internal partition valuecolumnNames
- the names of the columns being loggedcolumnTypes
- the types of the columns being loggedtypeMetadata
- the type metadataconstantColumnValues
- any constant column valuesapplicationVersion
- the application logger versionzoneId
- the time zone ZoneId- Throws:
IOException
- from the initialization
-
makeSpecifiedPartitionBinaryStoreWriter
public static BinaryStoreWriterV2 makeSpecifiedPartitionBinaryStoreWriter(com.fishlib.io.logger.Logger log, String logDir, String namespace, String tablename, TableIdentifier.NamespaceSet namespaceSet, String internalPartition, String columnPartition, String[] columnNames, SupportedType[] columnTypes, Object[] typeMetadata, Map<String, Object> constantColumnValues, int applicationVersion, ZoneId zoneId) throws IOExceptionMake a BinaryStoreWriterV2 with the specified values, including an unchanging column partition value.- Parameters:
log
- the Logger instancelogDir
- the directory in which the logs will be writtennamespace
- the namespace (used to construct the file name)tablename
- the table name (used to construct the file name)namespaceSet
- the namespaceSet (used to construct the file name)internalPartition
- the internal partition value (used to construct the file name)columnPartition
- the column partition value (used to construct the file name)columnNames
- the names of the columns being loggedcolumnTypes
- the types of the columns being loggedtypeMetadata
- the type metadataconstantColumnValues
- any constant column valuesapplicationVersion
- the application logger versionzoneId
- the time zone, used to generate the date-time stamp at the end of the file name- Returns:
- the BinaryStoreWriterV2 instance
- Throws:
IOException
- from the initialization
-
makeMultiPartitionFileManagerBinaryStoreWriter
public static BinaryStoreWriterV2 makeMultiPartitionFileManagerBinaryStoreWriter(com.fishlib.io.logger.Logger log, String logDir, String namespace, String tablename, TableIdentifier.NamespaceSet namespaceSet, String internalPartition, String[] columnNames, SupportedType[] columnTypes, Object[] typeMetadata, Map<String, Object> constantColumnValues, int applicationVersion) throws IOExceptionMake a BinaryStoreWriterV2 instance that uses dynamic (per-row) column partition values.- Parameters:
log
- the Logger instancelogDir
- the directory into which binary logs will be writtennamespace
- the namespacetablename
- the table namenamespaceSet
- the NamespaceSetinternalPartition
- the internal partition valuecolumnNames
- the names of the columns being loggedcolumnTypes
- the types of the columns being loggedtypeMetadata
- the type metadataconstantColumnValues
- any constant column valuesapplicationVersion
- the application logger version- Throws:
IOException
- from the initialization
-
init
- Throws:
IOException
-
getRowWriter
Description copied from interface:TableWriter
Get a writer for a Row entries. This is likely to be newly created, so callers should cache this value. In practice, TableWriter implementations generally cache the result of the first call to this method as a primary writer.- Returns:
- a Row, likely newly created
-
createBinaryRow
protected BinaryRowV2 createBinaryRow(String[] columnNames, SupportedType[] columnTypes, Object[] typeMetadata) -
getSetter
Description copied from interface:TableWriter
Gets a setter for a column.The implementation is likely to delegate to
Row.getSetter(String)
in a default Row instance.- Parameters:
name
- column name- Returns:
- setter for the column.
-
setFlags
Description copied from interface:TableWriter
The implementation is likely to delegate to
Row.setFlags(Flags)
in a default Row instance. -
writeRow
Description copied from interface:TableWriter
Writes out a new row (values set using setters).The implementation is likely to delegate to
Row.writeRow()
in a default Row instance.- Throws:
IOException
- problem writing the row
-
setColumnPartitionValue
Description copied from interface:Row
For rows that are to be used with file managers that allow dynamic column partition selection, set the column partition value.- Parameters:
columnPartitionValue
- the column partition value
-
getColumnPartitionValue
Description copied from interface:Row
For rows that are to be used with file managers that allow dynamic column partition selection, retrieve the column partition value.- Returns:
- the previously-set column partition value
-
writeDeferredRow
Description copied from interface:TableWriter
Write the row to disk.
Implementations of this method may choose to buffer rows for more efficient use of the underlying storage. Users should invoke
TableWriter.flushDeferredRows()
to tell the implementation to write any buffered rows.- Parameters:
row
- The row to write (or potentially buffer)- Throws:
IOException
- if an error occurs during write.
-
flushDeferredRows
protected void flushDeferredRows(BinaryStoreWriterV2.DeferrableRowPartition part) throws IOException Flush all of the deferred rows in the input collection to the underlying stream.- Parameters:
part
- The collection of deferred rows for the partitionVlaue- Throws:
IOException
- if an error occurs during writing. Rows may be partially written, however there are no guarantees that the rows were written completely.
-
flushDeferredRows
Description copied from interface:TableWriter
Write any rows buffered byTableWriter.writeDeferredRow(WritableRowContainer)
to storage.- Throws:
IOException
- if an error occurs during write. Implementations that may write to more than one channel will write through to each channel and throw aMultiException
wrapped in anIOException
that contains the details on errors that occurred per channel.
-
writeMulti
protected void writeMulti(ByteBuffer[] buffs, int count, GatheringByteChannel channel) throws IOException Perform a gathering write to the writer's channel. This method will not return until all buffers have been written or an error occurs.- Parameters:
buffs
- The buffers to writecount
- The number of buffers to write.- Throws:
IOException
-
getColumnTypes
Description copied from interface:TableWriter
Gets the column types for the table.- Returns:
- column types for the table.
-
getColumnNames
Description copied from interface:TableWriter
Gets the column names for the table.- Returns:
- column names for the table.
-
setRecordData
-
getRecordSetter
Description copied from interface:TableWriter
Gets a typed record setter for an entry.The implementation is likely to delegate to
Record.getRecordSetter(Class)
in a default Record instance.- Returns:
- setter for the record.
-
getRecordSetter
Description copied from interface:TableWriter
Gets a record setter for an entry.The implementation is likely to delegate to
Record.getRecordSetter()
in a default Record instance.- Returns:
- setter for the record.
-
writeRecord
Description copied from interface:TableWriter
Write a record entry to the provided output channel. The implementor is responsible for providing the data buffer.The
TableWriter
implementation is likely to delegate toRecord.writeRecord(WritableByteChannel)
in a default Record instance.- Throws:
IOException
-
getRecordWriter
Description copied from interface:TableWriter
Get new writer for Record entries. This is likely to be newly created, so callers should cache this value. In practice, implementers generally cache the result of the first call to this method as a primary writer.- Returns:
- a Record, likely newly created
-
createBinaryRecord
Implementation point for creating a binary record writer (BinaryRecordV2
). Derived classes can override to change the details or type.- Returns:
- a new BinaryRecordV2 record writer
-