Package com.illumon.iris.db.v2.utils
Class ArrayBackedTableWriter
java.lang.Object
com.illumon.iris.db.v2.utils.ArrayBackedTableWriter
- All Implemented Interfaces:
Entry,Record,Row,TableWriter
- Direct Known Subclasses:
RowOrientedArrayBackedTableWriter
The ArrayBackedTableWriter creates an in-memory table using ArrayBackedColumnSources of the type specified in the
constructor. You can retrieve the table using the
getTable function. It is designed to work with generated
loggers, and won't work with other row-oriented implementations.
It is recommended that startNewTable be called with an appropriate table size before logging through this TableWriter.
This class is not thread safe, you must synchronize externally.-
Nested Class Summary
Nested classes/interfaces inherited from interface com.illumon.iris.binarystore.Record
Record.RecordSetter<T extends RecordData> -
Field Summary
FieldsFields inherited from interface com.illumon.iris.binarystore.TableWriter
NULL_SETTER -
Constructor Summary
ConstructorsConstructorDescriptionArrayBackedTableWriter(TableDefinition definition) Create a TableWriter that produces an in-memory table using the provided TableDefinitionArrayBackedTableWriter(String[] columnNames, Class<?>[] columnTypes) Create a TableWriter that produces an in-memory table using the provided column names and types -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the writer.voidflush()Flushes data out.String[]Gets the column names for the table.Class[]Gets the column types for the table.Return the current Table being written to by this ArrayBackedTableWriterGet a writer for a Row entries.Gets a setter for a column.voidvoidsetNextRowIndex(int rowIndex) Sets the index where the next row will be written.voidsetUpdateIndex(boolean updateIndex) Sets whether or not the writer should update the index (defaults to true).voidstartNewTable(int expectedSize) Create a new table to be used for subsequent logging operationsvoidstartNewTable(int expectedSize, BiFunction<Index, Map<String, ColumnSource>, QueryTable> createTableFunction) Create a new table to be used for subsequent logging operationsbooleanTrue if all data types can be written out; false otherwise.voidwriteRow()Writes out a new row (values set using setters).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.illumon.iris.binarystore.Row
getColumnPartitionValue, setColumnPartitionValueMethods inherited from interface com.illumon.iris.binarystore.TableWriter
flushDeferredRows, getRecordSetter, getRecordSetter, getRecordWriter, getSetter, writeDeferredRow, writeRecord
-
Field Details
-
sources
-
-
Constructor Details
-
ArrayBackedTableWriter
Create a TableWriter that produces an in-memory table using the provided column names and types- Parameters:
columnNames- the names of the columns in the output table (and our input)columnTypes- the types of the columns in the output table (must be compatible with the input)
-
ArrayBackedTableWriter
Create a TableWriter that produces an in-memory table using the provided TableDefinition- Parameters:
definition- the Table definition
-
-
Method Details
-
setNextRowIndex
public void setNextRowIndex(int rowIndex) Sets the index where the next row will be written. This allows the caller to overwrite previously written rows. Note that once it is called, it is up to the caller to manage the row index as the Table Writer no longer knows what will be the last row.- Parameters:
rowIndex- the row index to write
-
setUpdateIndex
public void setUpdateIndex(boolean updateIndex) Sets whether or not the writer should update the index (defaults to true). Set this to false to update the index manually.- Parameters:
updateIndex- whether or not to update the index
-
startNewTable
public void startNewTable(int expectedSize) Create a new table to be used for subsequent logging operations- Parameters:
expectedSize- the expected maximum size of the table
-
startNewTable
public void startNewTable(int expectedSize, BiFunction<Index, Map<String, ColumnSource>, QueryTable> createTableFunction) Create a new table to be used for subsequent logging operations- Parameters:
expectedSize- the expected maximum size of the tablecreateTableFunction- a function that creates a query table
-
getQueryTable
Return the current Table being written to by this ArrayBackedTableWriter- Returns:
- the underlying Table
-
supportAllTypes
public boolean supportAllTypes()Description copied from interface:TableWriterTrue if all data types can be written out; false otherwise.- Specified by:
supportAllTypesin interfaceTableWriter- Returns:
- true if all data types can be written out; false otherwise.
-
close
Description copied from interface:TableWriterCloses the writer.- Specified by:
closein interfaceTableWriter- Throws:
IOException- problem closing the writer.
-
getColumnTypes
Description copied from interface:TableWriterGets the column types for the table.- Specified by:
getColumnTypesin interfaceTableWriter- Returns:
- column types for the table.
-
getColumnNames
Description copied from interface:TableWriterGets the column names for the table.- Specified by:
getColumnNamesin interfaceTableWriter- Returns:
- column names for the table.
-
setFlags
Description copied from interface:TableWriterThe implementation is likely to delegate to
Row.setFlags(Flags)in a default Row instance.- Specified by:
setFlagsin interfaceRow- Specified by:
setFlagsin interfaceTableWriter
-
writeRow
public void writeRow()Description copied from interface:TableWriterWrites out a new row (values set using setters).The implementation is likely to delegate to
Row.writeRow()in a default Row instance.- Specified by:
writeRowin interfaceRow- Specified by:
writeRowin interfaceTableWriter
-
flush
public void flush()Description copied from interface:TableWriterFlushes data out.- Specified by:
flushin interfaceTableWriter
-
getSetter
Description copied from interface:TableWriterGets a setter for a column.The implementation is likely to delegate to
Row.getSetter(String)in a default Row instance.- Specified by:
getSetterin interfaceRow- Specified by:
getSetterin interfaceTableWriter- Parameters:
name- column name- Returns:
- setter for the column.
-
getRowWriter
Description copied from interface:TableWriterGet 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.- Specified by:
getRowWriterin interfaceTableWriter- Returns:
- a Row, likely newly created
-