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
public class ArrayBackedTableWriter extends Object implements TableWriter
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
Fields Modifier and Type Field Description protected Map<String,ColumnSource>
sources
-
Constructor Summary
Constructors Constructor Description ArrayBackedTableWriter(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 Type Method Description void
close()
Closes the writer.void
flush()
Flushes data out.String[]
getColumnNames()
Gets the column names for the table.Class[]
getColumnTypes()
Gets the column types for the table.QueryTable
getQueryTable()
Return the current Table being written to by this ArrayBackedTableWriterRow
getRowWriter()
Get a writer for a Row entries.RowSetter
getSetter(String name)
Gets a setter for a column.void
setFlags(Row.Flags flags)
void
setNextRowIndex(int rowIndex)
Sets the index where the next row will be written.void
setUpdateIndex(boolean updateIndex)
Sets whether or not the writer should update the index (defaults to true).void
startNewTable(int expectedSize)
Create a new table to be used for subsequent logging operationsvoid
startNewTable(int expectedSize, BiFunction<Index,Map<String,ColumnSource>,QueryTable> createTableFunction)
Create a new table to be used for subsequent logging operationsboolean
supportAllTypes()
True if all data types can be written out; false otherwise.void
writeRow()
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, wait
Methods inherited from interface com.illumon.iris.binarystore.Row
getColumnPartitionValue, setColumnPartitionValue
Methods inherited from interface com.illumon.iris.binarystore.TableWriter
flushDeferredRows, getRecordSetter, getRecordSetter, getRecordWriter, getSetter, writeDeferredRow, writeRecord
-
Field Details
-
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:TableWriter
True if all data types can be written out; false otherwise.- Specified by:
supportAllTypes
in interfaceTableWriter
- Returns:
- true if all data types can be written out; false otherwise.
-
close
Description copied from interface:TableWriter
Closes the writer.- Specified by:
close
in interfaceTableWriter
- Throws:
IOException
- problem closing the writer.
-
getColumnTypes
Description copied from interface:TableWriter
Gets the column types for the table.- Specified by:
getColumnTypes
in interfaceTableWriter
- Returns:
- column types for the table.
-
getColumnNames
Description copied from interface:TableWriter
Gets the column names for the table.- Specified by:
getColumnNames
in interfaceTableWriter
- Returns:
- column names for the table.
-
setFlags
Description copied from interface:TableWriter
The implementation is likely to delegate to
Row.setFlags(Flags)
in a default Row instance.- Specified by:
setFlags
in interfaceRow
- Specified by:
setFlags
in interfaceTableWriter
-
writeRow
public void 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.- Specified by:
writeRow
in interfaceRow
- Specified by:
writeRow
in interfaceTableWriter
-
flush
public void flush()Description copied from interface:TableWriter
Flushes data out.- Specified by:
flush
in interfaceTableWriter
-
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.- Specified by:
getSetter
in interfaceRow
- Specified by:
getSetter
in interfaceTableWriter
- Parameters:
name
- column name- Returns:
- setter for the column.
-
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.- Specified by:
getRowWriter
in interfaceTableWriter
- Returns:
- a Row, likely newly created
-