Class WritableLocalTableLocation
- All Implemented Interfaces:
com.fishlib.base.log.LogOutputAppendable
,DeephavenFormatTableLocation
,IWritableLocalTableLocation
,TableLocation
,TableLocationKey
,TableLocationState
,NamedImplementation
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.illumon.iris.db.v2.locations.TableLocation
TableLocation.Format, TableLocation.Listener
Nested classes/interfaces inherited from interface com.illumon.iris.db.v2.locations.TableLocationKey
TableLocationKey.ComparatorImpl, TableLocationKey.KeyedObjectKeyImpl<VALUE_TYPE>, TableLocationKey.SelfKeyedObjectKeyImpl<VALUE_TYPE extends TableLocationKey>
-
Field Summary
Fields inherited from class com.illumon.iris.db.v2.locations.local.LocalTableLocation
CHECKPOINT_RECORD_FILE_NAME
Fields inherited from class com.illumon.iris.db.v2.locations.AbstractTableLocation
cachedGroupings, NO_GROUPING_SENTINEL
Fields inherited from class com.illumon.iris.db.v2.locations.SubscriptionAggregator
subscriptions
Fields inherited from interface com.illumon.iris.db.v2.locations.TableLocationKey
COMPARATOR, NULL_PARTITION
Fields inherited from interface com.illumon.iris.db.v2.locations.TableLocationState
NULL_SIZE, NULL_TIME, REMOVE_SIZE
-
Constructor Summary
ConstructorsConstructorDescriptionWritableLocalTableLocation
(TableKey tableKey, TableLocationKey tableLocationKey, File directory, TableDataRefreshService refreshService) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Refresh and activate update pushing from the implementing class.protected void
Deactivate pushed updates from the implementing class.Get a name for the implementing class.Access the checkpoint record in use by writers of this location.void
getWriterCheckpointRecordSnapshot
(ByteArrayOutputStream snapshotOutput) Read the current state of this location's writer checkpoint record into a snapshot buffer.boolean
protected <T> boolean
matchSubscriptionToken
(T token) Verify that a notification pertains to a currently-active subscription.void
refresh()
Initialize or refresh state information.void
Force a re-initialization of the reader checkpoint, after upgrading the checkpoint file.void
Read the concurrent consumer fields from the checkpoint record file into the internal reader checkpoint record.Clear and refresh the writer checkpoint record from the persistent checkpoint record file.final void
truncate()
Truncate this location's data and metadata, and advertise the change.final void
truncate
(CheckpointRecord.SourceFileSizeRecord sourceFileSizeRecord, CheckpointRecord.Flag truncationFlag, String... excludeFiles) Truncate this location's data and reset metadata to NULL_SIZE size and unknown table definition, and advertise the change.void
For simple callers that don't already have snapshot buffers, fill and write a newly-allocated snapshot buffer from this location's checkpoint record to this location's checkpoint record file.void
writeCheckpointRecordSnapshot
(ByteArrayOutputStream snapshotInput) Write a snapshot buffer to this location's checkpoint record file.Methods inherited from class com.illumon.iris.db.v2.locations.local.LocalTableLocation
ensureReaderCheckpointInitialized, getCheckpointRecordFile, getCheckpointRecordFile, getColumnVersion, getDataIndexImpl, getDirectory, getReaderCheckpointRecord, getSortedColumns, getTableDefinition, hasDataIndexFor, makeColumnLocation, readCheckpointRecordForImporters, readCheckpointRecordForImporters, readCheckpointRecordForImporters, readCheckpointRecordForImportersFromFile, readCheckpointRecordForImportersFromFile, readCheckpointRecordForImportersFromFile, readCheckpointRecordForSerialConsumers, setSnapshot, writeCheckpointRecord
Methods inherited from class com.illumon.iris.db.v2.locations.AbstractTableLocation
clearColumnLocations, deliverInitialSnapshot, getColumnLocation, getColumnPartition, getDataIndex, getInternalPartition, getLastModifiedTimeMillis, getSize, getStateLock, getTableKey, getVisit, handleUpdate, handleUpdate, toString, visit
Methods inherited from class com.illumon.iris.db.v2.locations.SubscriptionAggregator
activationFailed, activationSuccessful, checkHasSubscribers, postActivationHook, subscribe, supportsSubscriptions, unsubscribe
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.DeephavenFormatTableLocation
getColumnVersion, getFormat
Methods inherited from interface com.illumon.iris.db.v2.locations.local.IWritableLocalTableLocation
getDirectory
Methods inherited from interface com.illumon.iris.db.v2.locations.TableLocation
append, as, clearColumnLocations, getColumnLocation, getColumnLocation, getDataIndex, getSortedColumns, getTableKey, getVisit, handleUpdate, hasDataIndexFor, subscribe, supportsSubscriptions, toGenericString, toStringDetailed, toStringHelper, unsubscribe, visit
Methods inherited from interface com.illumon.iris.db.v2.locations.TableLocationKey
getColumnPartition, getInternalPartition, writeTo
Methods inherited from interface com.illumon.iris.db.v2.locations.TableLocationState
copyStateValuesTo, getLastModifiedTimeMillis, getSize, getSizeStr, getStateLock, writeStateValuesTo
-
Constructor Details
-
WritableLocalTableLocation
public WritableLocalTableLocation(@NotNull TableKey tableKey, @NotNull TableLocationKey tableLocationKey, @NotNull File directory, @NotNull TableDataRefreshService refreshService)
-
-
Method Details
-
truncate
public final void truncate()Truncate this location's data and metadata, and advertise the change. This is disruptive for concurrent data readers and/or writers.- Specified by:
truncate
in interfaceIWritableLocalTableLocation
-
truncate
public final void truncate(@Nullable CheckpointRecord.SourceFileSizeRecord sourceFileSizeRecord, CheckpointRecord.Flag truncationFlag, String... excludeFiles) Truncate this location's data and reset metadata to NULL_SIZE size and unknown table definition, and advertise the change. This is disruptive for concurrent data readers and/or writers.- Specified by:
truncate
in interfaceIWritableLocalTableLocation
- Parameters:
sourceFileSizeRecord
- use this to keep track of the binary file location that triggered the truncatetruncationFlag
- flag indicating the type of truncation to write in the checkpoint recordexcludeFiles
- files to leave on disk when deleting data from this location
-
refreshAfterUpgrade
public void refreshAfterUpgrade()Force a re-initialization of the reader checkpoint, after upgrading the checkpoint file. It is expected that this happens only if there is no column data and the size is 0. -
getImplementationName
Description copied from interface:NamedImplementation
Get a name for the implementing class. Useful for abstract classes that implement
LogOutputAppendable
or overridetoString
.The default implementation is correct, but not suitable for high-frequency usage.
- Specified by:
getImplementationName
in interfaceIWritableLocalTableLocation
- Specified by:
getImplementationName
in interfaceNamedImplementation
- Returns:
- A name for the implementing class
-
isWritable
public boolean isWritable()- Specified by:
isWritable
in interfaceIWritableLocalTableLocation
-
refresh
public void refresh()Description copied from interface:TableLocation
Initialize or refresh state information.- Specified by:
refresh
in interfaceIWritableLocalTableLocation
- Specified by:
refresh
in interfaceTableLocation
-
activateUnderlyingDataSource
protected void activateUnderlyingDataSource()Description copied from class:SubscriptionAggregator
Refresh and activate update pushing from the implementing class.
If the implementation will deliver notifications in a different thread than the one that calls this method, then this method must be asynchronous - that is, it must not block pending delivery of results. This requirement holds even if that other thread has nothing to do with the initial activation request!
Listeners should guard against duplicate notifications, especially if the implementation delivers synchronous notifications.
The implementation should call activationSuccessful() when done activating and delivering initial refresh results, unless activationFailed() was called instead.
Must be called under the subscription lock.
- Overrides:
activateUnderlyingDataSource
in classSubscriptionAggregator<TableLocation.Listener>
-
deactivateUnderlyingDataSource
protected void deactivateUnderlyingDataSource()Description copied from class:SubscriptionAggregator
Deactivate pushed updates from the implementing class. Must be called under the subscription lock.- Overrides:
deactivateUnderlyingDataSource
in classSubscriptionAggregator<TableLocation.Listener>
-
matchSubscriptionToken
protected <T> boolean matchSubscriptionToken(T token) Description copied from class:SubscriptionAggregator
Verify that a notification pertains to a currently-active subscription. Must be called under the subscription lock.- Overrides:
matchSubscriptionToken
in classSubscriptionAggregator<TableLocation.Listener>
- Parameters:
token
- A subscription-related object that the subclass can use to match a notification- Returns:
- True iff notification delivery should proceed
-
refreshReaderCheckpointRecord
public void refreshReaderCheckpointRecord()Read the concurrent consumer fields from the checkpoint record file into the internal reader checkpoint record. Note that the record is cleared before read. If the file no longer exists, the record will remain cleared.- Overrides:
refreshReaderCheckpointRecord
in classLocalTableLocation
-
getWriterCheckpointRecord
Access the checkpoint record in use by writers of this location. This is for advanced use only.- Specified by:
getWriterCheckpointRecord
in interfaceIWritableLocalTableLocation
- Returns:
- The checkpoint record used for writing data to this location
-
resetWriterCheckpointRecord
Clear and refresh the writer checkpoint record from the persistent checkpoint record file.- Specified by:
resetWriterCheckpointRecord
in interfaceIWritableLocalTableLocation
- Returns:
- The writer checkpoint record
-
getWriterCheckpointRecordSnapshot
Read the current state of this location's writer checkpoint record into a snapshot buffer.- Specified by:
getWriterCheckpointRecordSnapshot
in interfaceIWritableLocalTableLocation
- Parameters:
snapshotOutput
- The snapshot buffer to write to
-
writeCheckpointRecordSnapshot
Write a snapshot buffer to this location's checkpoint record file.- Specified by:
writeCheckpointRecordSnapshot
in interfaceIWritableLocalTableLocation
- Parameters:
snapshotInput
- The snapshot buffer to read from
-
writeCheckpointRecord
public void writeCheckpointRecord()For simple callers that don't already have snapshot buffers, fill and write a newly-allocated snapshot buffer from this location's checkpoint record to this location's checkpoint record file.- Specified by:
writeCheckpointRecord
in interfaceIWritableLocalTableLocation
-