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 SummaryNested ClassesModifier and TypeClassDescriptionstatic interfaceMarker interface for data file size records.static enumEnumeration of flags that can be set on a checkpoint record.static classSimple, immutable FileSizeRecord implementation.static interfaceMarker interface for source file size records.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final intVersion 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 intVersion 2 eliminates the column file headers and stores groupings as adjacent tables per columnstatic final intThe current column format version for newly written tablesstatic final intThe current version that will be output.static final ByteOrderstatic final intNull version number/static final intVersion "0" only had an int table location size, and no other metadata.static final intVersion "1" has modification time, data file sizes, source file state, and import state, all updated atomically.static final intVersion "2" uses a null size when truncating a location via data-driven command.static final intVersion "3" adds a "truncated location" marker.static final intVersion "4" eliminates the 128k header bytes in column files and writes Grouping / Indexes as tables adjacent to the historical tables.static final intVersion "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.TableLocationStateNULL_SIZE, NULL_TIME, REMOVE_SIZE
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptioncom.fishlib.base.log.LogOutputappend(com.fishlib.base.log.LogOutput logOutput) voidclear()Clear the checkpoint record, forgetting any externally set/put data providers.voidClear all flags on this checkpoint record.Get the byte order of the data stored in this location.intGet 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.intGet the version this checkpoint record was written with, orNULL_VERSIONif not or read since the checkpoint record was last cleared.booleanTest whether this record contains any column data.booleanDetermine whether the version this checkpoint record was written is the current version.booleanDetermine whether this checkpoint record has a null version.static voidMain - print the specified checkpoint record files to standard out.voidputDataFileSizeRecord(CheckpointRecord.DataFileSizeRecord dataFileSizeRecord) Put a file size record.voidRead all fields of interest to concurrent consumer applications into this record from a DataInputStream.voidRead all fields of interest to importers (i.e.voidRead all fields of interest to serial consumer applications (i.e.voidsetByteOrder(ByteOrder order) Set the byte order for data that will be stored in this location.voidsetColumnVersion(int columnVersion) Set the column version.voidsetDataIndexes(List<String[]> dataIndexes) voidsetFlags(EnumSet<CheckpointRecord.Flag> flags) Set the flags on this checkpoint record.voidsetImportState(ImportState importState) Set the import state.voidsetSortedColumns(List<SortPair> sortedColumns) Set the sorted columns for this table location.voidsetSourceFileSizeRecord(CheckpointRecord.SourceFileSizeRecord sourceFileSizeRecord) Set the source file size record.voidsetTableLocationState(TableLocationState tableLocationState) Set the table location state.toString()voidWrite all fields out from this record to a DataOutputStream.Methods inherited from class com.illumon.iris.db.v2.locations.TableLocationStateHolderclearValues, getLastModifiedTimeMillis, getSize, getStateLock, readValuesFrom, setValuesMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.illumon.iris.db.v2.locations.TableLocationStatecopyStateValuesTo, getSizeStr, writeStateValuesTo
- 
Field Details- 
NEW_COLUMN_BYTE_ORDER
- 
NULL_VERSIONpublic static final int NULL_VERSIONNull version number/- See Also:
 
- 
VERSION_0_TABLE_LOCATION_SIZE_ONLYpublic 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_STATEpublic 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_TRUNCATEpublic 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_MARKERpublic static final int VERSION_3_TRUNCATE_MARKERVersion "3" adds a "truncated location" marker.- See Also:
 
- 
VERSION_4_GROUPING_TABLESpublic 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_INDEXpublic 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_VERSIONpublic static final int CURRENT_VERSIONThe current version that will be output.- See Also:
 
- 
COLUMN_FORMAT_1_HEADERSpublic 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_HEADERLESSpublic 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_FORMATpublic static final int CURRENT_COLUMN_FORMATThe current column format version for newly written tables- See Also:
 
 
- 
- 
Constructor Details- 
CheckpointRecordpublic CheckpointRecord()Construct a new, cleared checkpoint record.
 
- 
- 
Method Details- 
getVersionpublic int getVersion()Get the version this checkpoint record was written with, orNULL_VERSIONif not or read since the checkpoint record was last cleared.- Returns:
- The version
 
- 
hasCurrentVersionpublic 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
 
- 
hasNullVersionpublic 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
 
- 
getFlagsreturn the flags set on this checkpoint record as a set.- Returns:
- the set of flags set.
 
- 
setFlagsSet the flags on this checkpoint record. The new set replaces any existing flags.
- 
clearFlagspublic void clearFlags()Clear all flags on this checkpoint record.
- 
getTableLocationStateGet the table location state, or null if not set or read since the checkpoint record was last cleared.- Returns:
- The table location state
 
- 
setTableLocationStateSet the table location state.- Parameters:
- tableLocationState- The table location state
 
- 
getDataFileSizeRecordGet 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
 
- 
putDataFileSizeRecordPut a file size record.- Parameters:
- dataFileSizeRecord- The data file size record
 
- 
hasColumnDatapublic 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
 
- 
getSourceFileSizeRecordGet 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
 
- 
setSourceFileSizeRecordpublic void setSourceFileSizeRecord(@NotNull CheckpointRecord.SourceFileSizeRecord sourceFileSizeRecord) Set the source file size record.- Parameters:
- sourceFileSizeRecord- The source file size record
 
- 
getImportStateGet the import state, or null if not set or read since the checkpoint record was last cleared.- Returns:
- The import state
 
- 
setImportStateSet the import state.- Parameters:
- importState- The import state
 
- 
getImportDetailsGet the import details derived from the import state, or null if the import state is null.- Returns:
- The import details
 
- 
getByteOrderGet the byte order of the data stored in this location.- Returns:
- the byte order
 
- 
setByteOrderSet the byte order for data that will be stored in this location.- Parameters:
- order- the new byte order
 
- 
getColumnVersionpublic int getColumnVersion()Get the column version for the table at this location.- Returns:
- the column format version for this location
 
- 
setColumnVersionpublic void setColumnVersion(int columnVersion) Set the column version.- Parameters:
- columnVersion- the column version
 
- 
setSortedColumnsSet 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
 
- 
getSortedColumnsGet the ordered list of sorted columns for this location.- Returns:
- an unmodifiable list of the sorted columns.
 
- 
setDataIndexes
- 
getDataIndexes
- 
clearpublic void clear()Clear the checkpoint record, forgetting any externally set/put data providers.
- 
appendpublic com.fishlib.base.log.LogOutput append(@NotNull com.fishlib.base.log.LogOutput logOutput) - Specified by:
- appendin interface- com.fishlib.base.log.LogOutputAppendable
 
- 
toString
- 
writeRecordWrite all fields out from this record to a DataOutputStream. This is only called by importer applications.- Parameters:
- out- The output stream
- Throws:
- IOException
 
- 
readRecordForSerialConsumersRead 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
 
- 
readRecordForConcurrentConsumersRead 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
 
- 
readRecordForImporterspublic 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
 
- 
mainMain - print the specified checkpoint record files to standard out.- Parameters:
- args- Array of checkpoint record directories or file names
 
 
-