Class CheckpointRecord
- All Implemented Interfaces:
com.fishlib.base.log.LogOutputAppendable
,TableLocationState
Checkpoint record to group information for a table writer to safely resume after a process or system crash. Concurrent accesses should be externally synchronized.
Currently stores:
- The table location's state (see
TableLocationState
) - The corresponding size (in bytes) of the data region of all data files, e.g. column .dat, .sym, .bytes, and .sym.bytes files
- Current source file name and position (optional)
- Import state (optional)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Marker interface for data file size records.static enum
Enumeration of flags that can be set on a checkpoint record.static class
Simple, immutable FileSizeRecord implementation.static interface
Marker interface for source file size records. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Version 1 columns contain a 128KB header on .dat and .sym files, and stored grouping as serialized hashmaps in the metadata of .dat files.static final int
Version 2 eliminates the column file headers and stores groupings as adjacent tables per columnstatic final int
The current column format version for newly written tablesstatic final int
The current version that will be output.static final ByteOrder
static final int
Null version number/static final int
Version "0" only had an int table location size, and no other metadata.static final int
Version "1" has modification time, data file sizes, source file state, and import state, all updated atomically.static final int
Version "2" uses a null size when truncating a location via data-driven command.static final int
Version "3" adds a "truncated location" marker.static final int
Version "4" eliminates the 128k header bytes in column files and writes Grouping / Indexes as tables adjacent to the historical tables.static final int
Version "5" adds the concept of a Data Index, which can be thought of as traditional database indexes.Fields inherited from interface com.illumon.iris.db.v2.locations.TableLocationState
NULL_SIZE, NULL_TIME, REMOVE_SIZE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.fishlib.base.log.LogOutput
append
(com.fishlib.base.log.LogOutput logOutput) void
clear()
Clear the checkpoint record, forgetting any externally set/put data providers.void
Clear all flags on this checkpoint record.Get the byte order of the data stored in this location.int
Get the column version for the table at this location.getDataFileSizeRecord
(String name) Get the file size record for a given file name, or null if not put or read since the checkpoint record was last cleared.getFlags()
return the flags set on this checkpoint record as a set.Get the import details derived from the import state, or null if the import state is null.Get the import state, or null if not set or read since the checkpoint record was last cleared.Get the ordered list of sorted columns for this location.Get the file size record for the source file, or null if not set or read since the checkpoint record was last cleared.Get the table location state, or null if not set or read since the checkpoint record was last cleared.int
Get the version this checkpoint record was written with, orNULL_VERSION
if not or read since the checkpoint record was last cleared.boolean
Test whether this record contains any column data.boolean
Determine whether the version this checkpoint record was written is the current version.boolean
Determine whether this checkpoint record has a null version.static void
Main - print the specified checkpoint record files to standard out.void
putDataFileSizeRecord
(CheckpointRecord.DataFileSizeRecord dataFileSizeRecord) Put a file size record.void
Read all fields of interest to concurrent consumer applications into this record from a DataInputStream.void
Read all fields of interest to importers (i.e.void
Read all fields of interest to serial consumer applications (i.e.void
setByteOrder
(ByteOrder order) Set the byte order for data that will be stored in this location.void
setColumnVersion
(int columnVersion) Set the column version.void
setDataIndexes
(List<String[]> dataIndexes) void
setFlags
(EnumSet<CheckpointRecord.Flag> flags) Set the flags on this checkpoint record.void
setImportState
(ImportState importState) Set the import state.void
setSortedColumns
(List<SortPair> sortedColumns) Set the sorted columns for this table location.void
setSourceFileSizeRecord
(CheckpointRecord.SourceFileSizeRecord sourceFileSizeRecord) Set the source file size record.void
setTableLocationState
(TableLocationState tableLocationState) Set the table location state.toString()
void
Write all fields out from this record to a DataOutputStream.Methods inherited from class com.illumon.iris.db.v2.locations.TableLocationStateHolder
clearValues, getLastModifiedTimeMillis, getSize, getStateLock, readValuesFrom, setValues
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.illumon.iris.db.v2.locations.TableLocationState
copyStateValuesTo, getSizeStr, writeStateValuesTo
-
Field Details
-
NEW_COLUMN_BYTE_ORDER
-
NULL_VERSION
public static final int NULL_VERSIONNull version number/- See Also:
-
VERSION_0_TABLE_LOCATION_SIZE_ONLY
public static final int VERSION_0_TABLE_LOCATION_SIZE_ONLYVersion "0" only had an int table location size, and no other metadata.- See Also:
-
VERSION_1_ATOMIC_STATE
public static final int VERSION_1_ATOMIC_STATEVersion "1" has modification time, data file sizes, source file state, and import state, all updated atomically.- See Also:
-
VERSION_2_NULL_SIZE_ON_TRUNCATE
public static final int VERSION_2_NULL_SIZE_ON_TRUNCATEVersion "2" uses a null size when truncating a location via data-driven command.- See Also:
-
VERSION_3_TRUNCATE_MARKER
public static final int VERSION_3_TRUNCATE_MARKERVersion "3" adds a "truncated location" marker.- See Also:
-
VERSION_4_GROUPING_TABLES
public static final int VERSION_4_GROUPING_TABLESVersion "4" eliminates the 128k header bytes in column files and writes Grouping / Indexes as tables adjacent to the historical tables.- See Also:
-
VERSION_5_DATA_INDEX
public static final int VERSION_5_DATA_INDEXVersion "5" adds the concept of a Data Index, which can be thought of as traditional database indexes. Unlike Groupings they are not necessarily contiguous.- See Also:
-
CURRENT_VERSION
public static final int CURRENT_VERSIONThe current version that will be output.- See Also:
-
COLUMN_FORMAT_1_HEADERS
public static final int COLUMN_FORMAT_1_HEADERSVersion 1 columns contain a 128KB header on .dat and .sym files, and stored grouping as serialized hashmaps in the metadata of .dat files.- See Also:
-
COLUMN_FORMAT_2_HEADERLESS
public static final int COLUMN_FORMAT_2_HEADERLESSVersion 2 eliminates the column file headers and stores groupings as adjacent tables per column- See Also:
-
CURRENT_COLUMN_FORMAT
public static final int CURRENT_COLUMN_FORMATThe current column format version for newly written tables- See Also:
-
-
Constructor Details
-
CheckpointRecord
public CheckpointRecord()Construct a new, cleared checkpoint record.
-
-
Method Details
-
getVersion
public int getVersion()Get the version this checkpoint record was written with, orNULL_VERSION
if not or read since the checkpoint record was last cleared.- Returns:
- The version
-
hasCurrentVersion
public boolean hasCurrentVersion()Determine whether the version this checkpoint record was written is the current version. Non-current records may require updating before data can be read or appended to.
Should only be called on a record that was just re-read from persistent storage.
- Returns:
- Whether this record was written with the current version
-
hasNullVersion
public boolean hasNullVersion()Determine whether this checkpoint record has a null version. Records with a null version are generally empty and should be treated as non-existent for purposes of appending or reading.
Should only be called on a record that was just re-read from persistent storage.
- Returns:
- Whether this record has the null version
-
getFlags
return the flags set on this checkpoint record as a set.- Returns:
- the set of flags set.
-
setFlags
Set the flags on this checkpoint record. The new set replaces any existing flags. -
clearFlags
public void clearFlags()Clear all flags on this checkpoint record. -
getTableLocationState
Get the table location state, or null if not set or read since the checkpoint record was last cleared.- Returns:
- The table location state
-
setTableLocationState
Set the table location state.- Parameters:
tableLocationState
- The table location state
-
getDataFileSizeRecord
Get the file size record for a given file name, or null if not put or read since the checkpoint record was last cleared.- Parameters:
name
- The file name- Returns:
- The data file size record
-
putDataFileSizeRecord
Put a file size record.- Parameters:
dataFileSizeRecord
- The data file size record
-
hasColumnData
public boolean hasColumnData()Test whether this record contains any column data.- Returns:
- True if this record contains any column data, i.e. if it has at least one column data file with non-zero size
-
getSourceFileSizeRecord
Get the file size record for the source file, or null if not set or read since the checkpoint record was last cleared.- Returns:
- The source file size record
-
setSourceFileSizeRecord
public void setSourceFileSizeRecord(@NotNull CheckpointRecord.SourceFileSizeRecord sourceFileSizeRecord) Set the source file size record.- Parameters:
sourceFileSizeRecord
- The source file size record
-
getImportState
Get the import state, or null if not set or read since the checkpoint record was last cleared.- Returns:
- The import state
-
setImportState
Set the import state.- Parameters:
importState
- The import state
-
getImportDetails
Get the import details derived from the import state, or null if the import state is null.- Returns:
- The import details
-
getByteOrder
Get the byte order of the data stored in this location.- Returns:
- the byte order
-
setByteOrder
Set the byte order for data that will be stored in this location.- Parameters:
order
- the new byte order
-
getColumnVersion
public int getColumnVersion()Get the column version for the table at this location.- Returns:
- the column format version for this location
-
setColumnVersion
public void setColumnVersion(int columnVersion) Set the column version.- Parameters:
columnVersion
- the column version
-
setSortedColumns
Set the sorted columns for this table location. The input is copied internally and is expected to be in the same order in which the columns are sorted.- Parameters:
sortedColumns
- the set of sorted columns
-
getSortedColumns
Get the ordered list of sorted columns for this location.- Returns:
- an unmodifiable list of the sorted columns.
-
setDataIndexes
-
getDataIndexes
-
clear
public void clear()Clear the checkpoint record, forgetting any externally set/put data providers. -
append
public com.fishlib.base.log.LogOutput append(@NotNull com.fishlib.base.log.LogOutput logOutput) - Specified by:
append
in interfacecom.fishlib.base.log.LogOutputAppendable
-
toString
-
writeRecord
Write all fields out from this record to a DataOutputStream. This is only called by importer applications.- Parameters:
out
- The output stream- Throws:
IOException
-
readRecordForSerialConsumers
Read all fields of interest to serial consumer applications (i.e. those that don't concurrently import data) into this record from a DataInputStream.
It's expected that this will be called on a
clear()
ed record.- Parameters:
in
- The input stream- Throws:
IOException
-
readRecordForConcurrentConsumers
Read all fields of interest to concurrent consumer applications into this record from a DataInputStream.
It's expected that this will be called on a
clear()
ed record.- Parameters:
in
- The input stream- Throws:
IOException
-
readRecordForImporters
public void readRecordForImporters(@NotNull DataInputStream in) throws IOException, ClassNotFoundException Read all fields of interest to importers (i.e. all fields) into this record from a DataInputStream.
It's expected that this will be called on a
clear()
ed record.- Parameters:
in
- The input stream- Throws:
IOException
ClassNotFoundException
-
main
Main - print the specified checkpoint record files to standard out.- Parameters:
args
- Array of checkpoint record directories or file names
-