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[]rowSizesprotected longrxTimestampThe receiving timestamp recorded locally at this destination, in nanoseconds.protected longtxTimestampThe sending timestamp passed along from our source, in nanoseconds. -
Constructor Summary
Constructors Modifier Constructor Description protectedBatchedImportRowBufferProcessor(int rowBatchCapacity, boolean requiresInstrumentation)Construct a BatchedImportRowBufferProcessor with no parallelism.protectedBatchedImportRowBufferProcessor(int rowBatchCapacity, int parallelism, boolean requiresInstrumentation)Construct a BatchedImportRowBufferProcessor. -
Method Summary
Modifier and Type Method Description protected abstract voidassignRowBatchColumns(RowBatch rowBatch)Implementations should use this as an opportunity to extract columns from the newRowBatchfor use inwriteRowBatch().voidclose()Close this listener when no further rows will be supplied.voiddoDeferredProcessing()Do any row processing previously deferred by this implementation'sBinaryStoreV2RowBufferProcessor.processRow(Row.Flags, int).protected longgetInstRxTime()protected intgetInstSize(int vi)protected longgetInstTxTime()abstract TableDefinitiongetTableDefinition()Get theTableDefinitionthat specifies the columns this table listener expects to supply to its writer.voidinit(TableReader reader)Specify the reader to be used for subsequent rows.protected voidinvokeParallelTasks(ForkJoinTask<Void>[] tasks)Tool for implementations to invoke parallel tasks.booleanisDirty()Check whether this buffer processor has any deferred row data to process viaBinaryStoreV2RowBufferProcessor.doDeferredProcessing().voidonNewRow()Called by the driving application whenever a new row that is available from the reader.voidprocessRow(Row.Flags flags, int rowSize)Process a binary row entry.voidsetDataBuffer(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).voidsetDataImportProfiler(DataImportProfiler dataImportProfiler)Set aDataImportProfilerto use in instrumentation.voidsetWriter(TableWriter writer, DbTableLocation tableLocation)Supply the writer for output.protected abstract voidupdateSetters(LocalTableWriter localTableWriter)Implementations should use this as an opportunity to extract columns from the newLocalTableWriterfor use inwriteRowBatch()and construct appropriate setters.protected abstract voidwriteRowBatch()Implementations should write the data accumulated inrowBatchtolocalTableWriter'sLocalAppendableColumns.protected abstract voidwriteRowBatchParallel()Implementations should write the data accumulated inrowBatchtolocalTableWriter'sLocalAppendableColumns, utilizinginvokeParallelTasks(ForkJoinTask[])for parallelism.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:BinaryStoreV2RowBufferProcessorAdvise 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:
setDataBufferin interfaceBinaryStoreV2RowBufferProcessor- Parameters:
dataBuffer- The data buffertxTimestamp- The transmit timestamp from the sourcerxTimestamp- The receive timestamp at this destination
-
processRow
Description copied from interface:BinaryStoreV2RowBufferProcessorProcess 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:
processRowin interfaceBinaryStoreV2RowBufferProcessor- Parameters:
flags- The flags for this row- Throws:
IOException
-
doDeferredProcessing
Description copied from interface:BinaryStoreV2RowBufferProcessorDo 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:
doDeferredProcessingin interfaceBinaryStoreV2RowBufferProcessor- Throws:
IOException
-
isDirty
public final boolean isDirty()Description copied from interface:BinaryStoreV2RowBufferProcessorCheck whether this buffer processor has any deferred row data to process viaBinaryStoreV2RowBufferProcessor.doDeferredProcessing().- Specified by:
isDirtyin interfaceBinaryStoreV2RowBufferProcessor- Returns:
- Whether this buffer processor has any deferred row data to process
-
writeRowBatch
Implementations should write the data accumulated inrowBatchtolocalTableWriter'sLocalAppendableColumns.- Throws:
IOException
-
writeRowBatchParallel
protected abstract void writeRowBatchParallel()Implementations should write the data accumulated inrowBatchtolocalTableWriter'sLocalAppendableColumns, 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 aDataImportProfilerto use in instrumentation. This should be done before any calls toinit(TableReader)orsetWriter(TableWriter, DbTableLocation).- Parameters:
dataImportProfiler- TheDataImportProfilerto use
-
init
Description copied from interface:TableListenerSpecify the reader to be used for subsequent rows. Typically allows listeners to obtain RowGetters for each relevant column.- Specified by:
initin interfaceTableListener- Parameters:
reader- The reader
-
assignRowBatchColumns
Implementations should use this as an opportunity to extract columns from the newRowBatchfor use inwriteRowBatch().- Parameters:
rowBatch- The newRowBatch
-
onNewRow
public final void onNewRow()Description copied from interface:TableListenerCalled by the driving application whenever a new row that is available from the reader.- Specified by:
onNewRowin interfaceTableListener
-
setWriter
Description copied from interface:TableListenerSupply the writer for output. Typically allows listeners to obtain RowSetters for each relevant column.- Specified by:
setWriterin 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 newLocalTableWriterfor 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:TableListenerClose this listener when no further rows will be supplied.- Specified by:
closein interfaceTableListener- Throws:
IOException
-
getTableDefinition
Description copied from interface:TableListenerGet theTableDefinitionthat 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:
getTableDefinitionin interfaceTableListener- Returns:
- The supported
TableDefinition.
-
getInstRxTime
protected long getInstRxTime() -
getInstTxTime
protected long getInstTxTime() -
getInstSize
protected int getInstSize(int vi)
-