Class BatchedImportRowBufferProcessor
java.lang.Object
com.illumon.iris.db.tables.dataimport.BatchedImportRowBufferProcessor
- All Implemented Interfaces:
BinaryStoreV2RowBufferProcessor
,TableListener
public abstract class BatchedImportRowBufferProcessor extends Object implements BinaryStoreV2RowBufferProcessor, TableListener
Base class for generated
BinaryStoreV2RowBufferProcessor
implementations that also support part of the
TableListener
interface for integration with the
BinaryStoreImportProcessor
and use a
RowBatch
to accumulate rows and enable vectorizable transformations and bulk writing.-
Nested Class Summary
Nested classes/interfaces inherited from interface com.illumon.iris.binarystore.BinaryStoreV2RowBufferProcessor
BinaryStoreV2RowBufferProcessor.Uninitialized
-
Field Summary
Fields Modifier and Type Field Description protected int[]
rowSizes
protected long
rxTimestamp
The receiving timestamp recorded locally at this destination, in nanoseconds.protected long
txTimestamp
The sending timestamp passed along from our source, in nanoseconds. -
Constructor Summary
Constructors Modifier Constructor Description protected
BatchedImportRowBufferProcessor(int rowBatchCapacity, boolean requiresInstrumentation)
Construct a BatchedImportRowBufferProcessor with no parallelism.protected
BatchedImportRowBufferProcessor(int rowBatchCapacity, int parallelism, boolean requiresInstrumentation)
Construct a BatchedImportRowBufferProcessor. -
Method Summary
Modifier and Type Method Description protected abstract void
assignRowBatchColumns(RowBatch rowBatch)
Implementations should use this as an opportunity to extract columns from the newRowBatch
for use inwriteRowBatch()
.void
close()
Close this listener when no further rows will be supplied.void
doDeferredProcessing()
Do any row processing previously deferred by this implementation'sBinaryStoreV2RowBufferProcessor.processRow(Row.Flags, int)
.protected long
getInstRxTime()
protected int
getInstSize(int vi)
protected long
getInstTxTime()
abstract TableDefinition
getTableDefinition()
Get theTableDefinition
that specifies the columns this table listener expects to supply to its writer.void
init(TableReader reader)
Specify the reader to be used for subsequent rows.protected void
invokeParallelTasks(ForkJoinTask<Void>[] tasks)
Tool for implementations to invoke parallel tasks.boolean
isDirty()
Check whether this buffer processor has any deferred row data to process viaBinaryStoreV2RowBufferProcessor.doDeferredProcessing()
.void
onNewRow()
Called by the driving application whenever a new row that is available from the reader.void
processRow(Row.Flags flags, int rowSize)
Process a binary row entry.void
setDataBuffer(ByteBuffer dataBuffer, long txTimestamp, long rxTimestamp)
Advise this buffer processor of the incoming data buffer and its associated timestamps to be used in subsequent calls toBinaryStoreV2RowBufferProcessor.processRow(Row.Flags, int)
.void
setDataImportProfiler(DataImportProfiler dataImportProfiler)
Set aDataImportProfiler
to use in instrumentation.void
setWriter(TableWriter writer, DbTableLocation tableLocation)
Supply the writer for output.protected abstract void
updateSetters(LocalTableWriter localTableWriter)
Implementations should use this as an opportunity to extract columns from the newLocalTableWriter
for use inwriteRowBatch()
and construct appropriate setters.protected abstract void
writeRowBatch()
Implementations should write the data accumulated inrowBatch
tolocalTableWriter
'sLocalAppendableColumn
s.protected abstract void
writeRowBatchParallel()
Implementations should write the data accumulated inrowBatch
tolocalTableWriter
'sLocalAppendableColumn
s, utilizinginvokeParallelTasks(ForkJoinTask[])
for parallelism.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.db.tables.dataimport.TableListener
resumeReading, setWriter
-
Field Details
-
txTimestamp
protected long txTimestampThe sending timestamp passed along from our source, in nanoseconds. -
rxTimestamp
protected long rxTimestampThe receiving timestamp recorded locally at this destination, in nanoseconds. -
rowSizes
protected final int[] rowSizes
-
-
Constructor Details
-
BatchedImportRowBufferProcessor
protected BatchedImportRowBufferProcessor(int rowBatchCapacity, int parallelism, boolean requiresInstrumentation)Construct a BatchedImportRowBufferProcessor.- Parameters:
rowBatchCapacity
- The capacity for row batchesparallelism
- The number of parallel writing threads to use, if> 1
-
BatchedImportRowBufferProcessor
protected BatchedImportRowBufferProcessor(int rowBatchCapacity, boolean requiresInstrumentation)Construct a BatchedImportRowBufferProcessor with no parallelism.- Parameters:
rowBatchCapacity
- The capacity for row batches
-
-
Method Details
-
setDataBuffer
public final void setDataBuffer(@NotNull ByteBuffer dataBuffer, long txTimestamp, long rxTimestamp)Description copied from interface:BinaryStoreV2RowBufferProcessor
Advise this buffer processor of the incoming data buffer and its associated timestamps to be used in subsequent calls toBinaryStoreV2RowBufferProcessor.processRow(Row.Flags, int)
. This buffer processor should record this information, and may need to clear cached objects (e.g. duplicate buffers) linked to the buffer.- Specified by:
setDataBuffer
in interfaceBinaryStoreV2RowBufferProcessor
- Parameters:
dataBuffer
- The data buffertxTimestamp
- The transmit timestamp from the sourcerxTimestamp
- The receive timestamp at this destination
-
processRow
Description copied from interface:BinaryStoreV2RowBufferProcessor
Process a binary row entry. Data is guaranteed to be complete and to have passed checksum verification if such verification is enabled. The data buffer will be positioned to begin reading variable columns.Implementations may internally "defer" part or all of this processing until a later time, for example in order to batch transformation or columnar writing tasks. They may assume that
BinaryStoreV2RowBufferProcessor.doDeferredProcessing()
will be called before the contents of the current data buffer are mutated.- Specified by:
processRow
in interfaceBinaryStoreV2RowBufferProcessor
- Parameters:
flags
- The flags for this row- Throws:
IOException
-
doDeferredProcessing
Description copied from interface:BinaryStoreV2RowBufferProcessor
Do any row processing previously deferred by this implementation'sBinaryStoreV2RowBufferProcessor.processRow(Row.Flags, int)
.This must be invoked explicitly:
- before changing the contents of the current data buffer
- before processing a record
- Specified by:
doDeferredProcessing
in interfaceBinaryStoreV2RowBufferProcessor
- Throws:
IOException
-
isDirty
public final boolean isDirty()Description copied from interface:BinaryStoreV2RowBufferProcessor
Check whether this buffer processor has any deferred row data to process viaBinaryStoreV2RowBufferProcessor.doDeferredProcessing()
.- Specified by:
isDirty
in interfaceBinaryStoreV2RowBufferProcessor
- Returns:
- Whether this buffer processor has any deferred row data to process
-
writeRowBatch
Implementations should write the data accumulated inrowBatch
tolocalTableWriter
'sLocalAppendableColumn
s.- Throws:
IOException
-
writeRowBatchParallel
protected abstract void writeRowBatchParallel()Implementations should write the data accumulated inrowBatch
tolocalTableWriter
'sLocalAppendableColumn
s, utilizinginvokeParallelTasks(ForkJoinTask[])
for parallelism. -
invokeParallelTasks
Tool for implementations to invoke parallel tasks. WillForkJoinTask.reinitialize()
all tasks upon completion.- Parameters:
tasks
- The tasks to execute and reinitialize
-
setDataImportProfiler
Set aDataImportProfiler
to use in instrumentation. This should be done before any calls toinit(TableReader)
orsetWriter(TableWriter, DbTableLocation)
.- Parameters:
dataImportProfiler
- TheDataImportProfiler
to use
-
init
Description copied from interface:TableListener
Specify the reader to be used for subsequent rows. Typically allows listeners to obtain RowGetters for each relevant column.- Specified by:
init
in interfaceTableListener
- Parameters:
reader
- The reader
-
assignRowBatchColumns
Implementations should use this as an opportunity to extract columns from the newRowBatch
for use inwriteRowBatch()
.- Parameters:
rowBatch
- The newRowBatch
-
onNewRow
public final void onNewRow()Description copied from interface:TableListener
Called by the driving application whenever a new row that is available from the reader.- Specified by:
onNewRow
in interfaceTableListener
-
setWriter
Description copied from interface:TableListener
Supply the writer for output. Typically allows listeners to obtain RowSetters for each relevant column.- Specified by:
setWriter
in interfaceTableListener
- Parameters:
writer
- The writertableLocation
- The table location object, typically used only for import details output on close
-
updateSetters
Implementations should use this as an opportunity to extract columns from the newLocalTableWriter
for use inwriteRowBatch()
and construct appropriate setters.assignRowBatchColumns(RowBatch)
must have been called at least once as a precondition.- Parameters:
localTableWriter
- The newLocalTableWriter
-
close
Description copied from interface:TableListener
Close this listener when no further rows will be supplied.- Specified by:
close
in interfaceTableListener
- Throws:
IOException
-
getTableDefinition
Description copied from interface:TableListener
Get theTableDefinition
that specifies the columns this table listener expects to supply to its writer.Note that this should only include writable columns, and that listener implementations are only required to accurately describe the column names (
DefaultColumnDefinition.getName()
) and data types (ColumnDefinition.getDataType()
) they expect to supply.- Specified by:
getTableDefinition
in interfaceTableListener
- Returns:
- The supported
TableDefinition
.
-
getInstRxTime
protected long getInstRxTime() -
getInstTxTime
protected long getInstTxTime() -
getInstSize
protected int getInstSize(int vi)
-