Class LocalTableWriter
java.lang.Object
com.illumon.iris.db.tables.appendable.local.LocalTableWriter
- All Implemented Interfaces:
Entry
,Record
,Row
,TableWriter
,BufferedAppendable
- Direct Known Subclasses:
DiskTableWriter
TableWriter for concurrently-readable table writing to a local table location.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.illumon.iris.binarystore.Record
Record.RecordSetter<T extends RecordData>
-
Field Summary
Fields inherited from interface com.illumon.iris.binarystore.TableWriter
NULL_SETTER
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a writer for the supplied table.LocalTableWriter
(LocalAppendableTable table, boolean needRowSupport) Construct a writer for the supplied table. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
Abort a transaction.final void
adviseRowsWritten
(long count) Update accounting for rows were written.void
close()
Closes the writer.boolean
dirty()
Test if there is data to flush.final void
End a transaction.void
flush()
Flushes data out.void
force()
Force all flushed data to be persisted to permanent storage.<CT extends LocalAppendableColumn<?>>
CTGet aLocalAppendableColumn
for use by writing code that doesn't useRowSetter
s.String[]
Gets the column names for the table.Class[]
Gets the column types for the table.Get a writer for a Row entries.Gets a setter for a column.final boolean
Check whether an invalid transaction (which will never succeed) is in progress.final boolean
Check whether a transaction is in progress.final void
Abort a transaction if one is in progress.final void
End a transaction if one is in progress.boolean
Perform aBufferedAppendable.force()
if there is data pending persistence.void
If we're not currently in a transaction, begin one.void
Optional operation.void
release()
Release any resources held.void
void
setImportDetails
(Properties importDetails) Set a trivial import state object wrapping the supplied import details to be part of checkpoints for the output table.void
setImportState
(ImportState importState) Set an import state object to be part of checkpoints for the output table.final void
Begin a transaction that is guaranteed to never succeed.final void
Begin a transaction.boolean
True if all data types can be written out; false otherwise.void
updateImportState
(UnaryOperator<ImportState> updater) Set the import state object (as insetImportState(ImportState)
) after applying the supplied updater function to the existing import state object.final 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
-
Constructor Details
-
LocalTableWriter
Construct a writer for the supplied table.- Parameters:
table
- The table to write to
-
LocalTableWriter
Construct a writer for the supplied table.- Parameters:
table
- The table to write toneedRowSupport
- Should this local table writer allocate aRow
for traditional row-by-row ingest
-
-
Method Details
-
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.
-
getColumnNames
Description copied from interface:TableWriter
Gets the column names for the table.- Specified by:
getColumnNames
in interfaceTableWriter
- Returns:
- column names for the table.
-
getColumnTypes
Description copied from interface:TableWriter
Gets the column types for the table.- Specified by:
getColumnTypes
in interfaceTableWriter
- Returns:
- column types for the table.
-
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
-
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:
columnName
- column name- Returns:
- setter for the column.
-
getColumn
public <CT extends LocalAppendableColumn<?>> CT getColumn(@NotNull String name, @NotNull Class<CT> clazz) Get aLocalAppendableColumn
for use by writing code that doesn't useRowSetter
s.- Parameters:
name
- The column nameclazz
- The expected column class- Returns:
- The column
-
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
-
inTransaction
public final boolean inTransaction()Check whether a transaction is in progress.- Returns:
- Whether a transaction is in progress
-
inInvalidTransaction
public final boolean inInvalidTransaction()Check whether an invalid transaction (which will never succeed) is in progress.- Returns:
- Whether an invalid transaction is in progress
-
startTransaction
public final void startTransaction()Begin a transaction. It is an error to call this method if a transaction is already in progress. -
maybeStartTransaction
public void maybeStartTransaction()If we're not currently in a transaction, begin one. -
startInvalidTransaction
public final void startInvalidTransaction()Begin a transaction that is guaranteed to never succeed. It is an error to call this method if a transaction is already in progress. -
abortTransaction
public final void abortTransaction()Abort a transaction. It is an error to call this method if a transaction is not in progress. -
maybeAbortTransaction
public final void maybeAbortTransaction()Abort a transaction if one is in progress. -
endTransaction
public final void endTransaction()End a transaction. It is an error to call this method if a transaction is not in progress or the current transaction is invalid. -
maybeEndTransaction
public final void maybeEndTransaction()End a transaction if one is in progress. -
adviseRowsWritten
public final void adviseRowsWritten(long count) Update accounting for rows were written.- Parameters:
count
- The number of rows that were written
-
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
- Throws:
IOException
- problem writing the row
-
dirty
public boolean dirty()Test if there is data to flush.- Returns:
- Whether there is data to flush
-
flush
public void flush()Description copied from interface:TableWriter
Flushes data out.- Specified by:
flush
in interfaceBufferedAppendable
- Specified by:
flush
in interfaceTableWriter
-
prepareCheckpoint
public void prepareCheckpoint()Description copied from interface:BufferedAppendable
Optional operation. Prepare a checkpoint snapshot for the next call toBufferedAppendable.force()
. Should be called directly afterBufferedAppendable.flush()
, with no intervening modification operations.- Specified by:
prepareCheckpoint
in interfaceBufferedAppendable
-
force
public void force()Description copied from interface:BufferedAppendable
Force all flushed data to be persisted to permanent storage. Will consistently and atomically persist the last prepared checkpoint in implementations that implementBufferedAppendable.prepareCheckpoint()
. Does not implyBufferedAppendable.flush()
, as this is a distinct operation in all implementations. May be called concurrently by threads other than the "writing thread".- Specified by:
force
in interfaceBufferedAppendable
-
maybeForce
public boolean maybeForce()Description copied from interface:BufferedAppendable
Perform aBufferedAppendable.force()
if there is data pending persistence. Implementations that don't keep track of pending data explicitly will always invokeBufferedAppendable.force()
pessimistically.- Specified by:
maybeForce
in interfaceBufferedAppendable
- Returns:
- Whether this call may have done any actual work (i.e. there was data pending or assumed to be pending)
-
close
public void close()Description copied from interface:TableWriter
Closes the writer.- Specified by:
close
in interfaceBufferedAppendable
- Specified by:
close
in interfaceTableWriter
-
release
public void release()Description copied from interface:BufferedAppendable
Release any resources held. Called after an error in preparation for termination. For external callers, this should be done as the final access to this column with the exception of any asynchronousBufferedAppendable.force()
operations.- Specified by:
release
in interfaceBufferedAppendable
-
updateImportState
Set the import state object (as insetImportState(ImportState)
) after applying the supplied updater function to the existing import state object.- Parameters:
updater
- The import state updater
-
setImportState
Set an import state object to be part of checkpoints for the output table.- Parameters:
importState
- The import state
-
setImportDetails
Set a trivial import state object wrapping the supplied import details to be part of checkpoints for the output table.- Parameters:
importDetails
- The import details
-