Class StateStoreSerializableImpl

All Implemented Interfaces:
StateStoreRecordOperations
Direct Known Subclasses:
StateStoreFileBaseImpl, StateStoreMySQLImpl, StateStoreZooKeeperImpl

@Public @Evolving public abstract class StateStoreSerializableImpl extends StateStoreBaseImpl
State Store driver that stores a serialization of the records. The serializer is pluggable.
  • Field Details

  • Constructor Details

    • StateStoreSerializableImpl

      public StateStoreSerializableImpl()
  • Method Details

    • init

      public boolean init(org.apache.hadoop.conf.Configuration config, String id, Collection<Class<? extends BaseRecord>> records, StateStoreMetrics metrics)
      Description copied from class: StateStoreDriver
      Initialize the state store connection.
      Overrides:
      init in class StateStoreDriver
      Parameters:
      config - Configuration for the driver.
      id - Identifier for the driver.
      records - Records that are supported.
      metrics - State store metrics.
      Returns:
      If initialized and ready, false if failed to initialize driver.
    • serialize

      protected <T extends BaseRecord> byte[] serialize(T record)
      Serialize a record using the serializer.
      Type Parameters:
      T - Type of the state store record.
      Parameters:
      record - Record to serialize.
      Returns:
      Byte array with the serialization of the record.
    • serializeString

      protected <T extends BaseRecord> String serializeString(T record)
      Serialize a record using the serializer.
      Type Parameters:
      T - Type of the state store record.
      Parameters:
      record - Record to serialize.
      Returns:
      String with the serialization of the record.
    • newRecord

      protected <T extends BaseRecord> T newRecord(String data, Class<T> clazz, boolean includeDates) throws IOException
      Creates a record from an input data string.
      Type Parameters:
      T - Type of the state store record.
      Parameters:
      data - Serialized text of the record.
      clazz - Record class.
      includeDates - If dateModified and dateCreated are serialized.
      Returns:
      The created record by deserializing the input text.
      Throws:
      IOException - If the record deserialization fails.
    • getPrimaryKey

      protected static String getPrimaryKey(BaseRecord record)
      Get the primary key for a record. If we don't want to store in folders, we need to remove / from the name.
      Parameters:
      record - Record to get the primary key for.
      Returns:
      Primary key for the record.
    • getOriginalPrimaryKey

      protected static String getOriginalPrimaryKey(String stateStoreRecordKey)
      Get the original primary key for the given state store record key. The returned key is readable as it is the original key.
      Parameters:
      stateStoreRecordKey - The record primary key stored by the state store implementations.
      Returns:
      The original primary key for the given record key.