Class WritableLocalTableLocation

All Implemented Interfaces:
com.fishlib.base.log.LogOutputAppendable, DeephavenFormatTableLocation, IWritableLocalTableLocation, TableLocation, TableLocationKey, TableLocationState, NamedImplementation

public class WritableLocalTableLocation extends LocalTableLocation implements IWritableLocalTableLocation
Writable local table location.
  • Constructor Details

  • 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 interface IWritableLocalTableLocation
    • 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 interface IWritableLocalTableLocation
      Parameters:
      sourceFileSizeRecord - use this to keep track of the binary file location that triggered the truncate
      truncationFlag - flag indicating the type of truncation to write in the checkpoint record
      excludeFiles - 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

      public String getImplementationName()
      Description copied from interface: NamedImplementation

      Get a name for the implementing class. Useful for abstract classes that implement LogOutputAppendable or override toString.

      The default implementation is correct, but not suitable for high-frequency usage.

      Specified by:
      getImplementationName in interface IWritableLocalTableLocation
      Specified by:
      getImplementationName in interface NamedImplementation
      Returns:
      A name for the implementing class
    • isWritable

      public boolean isWritable()
      Specified by:
      isWritable in interface IWritableLocalTableLocation
    • refresh

      public void refresh()
      Description copied from interface: TableLocation
      Initialize or refresh state information.
      Specified by:
      refresh in interface IWritableLocalTableLocation
      Specified by:
      refresh in interface TableLocation
    • 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 class SubscriptionAggregator<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 class SubscriptionAggregator<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 class SubscriptionAggregator<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 class LocalTableLocation
    • getWriterCheckpointRecord

      public CheckpointRecord getWriterCheckpointRecord()
      Access the checkpoint record in use by writers of this location. This is for advanced use only.
      Specified by:
      getWriterCheckpointRecord in interface IWritableLocalTableLocation
      Returns:
      The checkpoint record used for writing data to this location
    • resetWriterCheckpointRecord

      public CheckpointRecord resetWriterCheckpointRecord()
      Clear and refresh the writer checkpoint record from the persistent checkpoint record file.
      Specified by:
      resetWriterCheckpointRecord in interface IWritableLocalTableLocation
      Returns:
      The writer checkpoint record
    • getWriterCheckpointRecordSnapshot

      public void getWriterCheckpointRecordSnapshot(@NotNull ByteArrayOutputStream snapshotOutput)
      Read the current state of this location's writer checkpoint record into a snapshot buffer.
      Specified by:
      getWriterCheckpointRecordSnapshot in interface IWritableLocalTableLocation
      Parameters:
      snapshotOutput - The snapshot buffer to write to
    • writeCheckpointRecordSnapshot

      public void writeCheckpointRecordSnapshot(@NotNull ByteArrayOutputStream snapshotInput)
      Write a snapshot buffer to this location's checkpoint record file.
      Specified by:
      writeCheckpointRecordSnapshot in interface IWritableLocalTableLocation
      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 interface IWritableLocalTableLocation