StateStoreRecordOperations (Apache Hadoop HDFS-RBF 3.5.0 API)
Description: declaration: package: org.apache.hadoop.hdfs.server.federation.store.driver, interface: StateStoreRecordOperations

Package org.apache.hadoop.hdfs.server.federation.store.driver

# Interface StateStoreRecordOperations

All Known Implementing Classes:
  `StateStoreBaseImpl`, `StateStoreDriver`, `StateStoreFileBaseImpl`, `StateStoreFileImpl`, `StateStoreFileSystemImpl`, `StateStoreMySQLImpl`, `StateStoreSerializableImpl`, `StateStoreZooKeeperImpl`

@Private @Evolving public interface StateStoreRecordOperations
Operations for a driver to manage records in the State Store.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `<T extends BaseRecord>
  QueryResult<T>`
  `get(Class<T> clazz)`
  Get all records of the requested record class from the data store.
  `<T extends BaseRecord>
  T`
  `get(Class<T> clazz, Query<T> query)`
  Get a single record from the store that matches the query.
  `<T extends BaseRecord>
  List<T>`
  `getMultiple(Class<T> clazz, Query<T> query)`
  Get multiple records from the store that match a query.
  `<T extends BaseRecord>
  boolean`
  `put(T record, boolean allowUpdate, boolean errorIfExists)`
  Creates a single record.
  `<T extends BaseRecord>
  StateStoreOperationResult`
  `putAll(List<T> records, boolean allowUpdate, boolean errorIfExists)`
  Creates multiple records.
  `<T extends BaseRecord>
  Map<Query<T>,Integer>`
  `remove(Class<T> clazz, List<Query<T>> queries)`
  Remove all records of a specific class that match any query in a list of queries.
  `<T extends BaseRecord>
  int`
  `remove(Class<T> clazz, Query<T> query)`
  Remove multiple records of a specific class that match a query.
  `<T extends BaseRecord>
  boolean`
  `remove(T record)`
  Remove a single record.
  `<T extends BaseRecord>
  boolean`
  `removeAll(Class<T> clazz)`
  Remove all records of this class from the store.
  `<T extends BaseRecord>
  Map<T,Boolean>`
  `removeMultiple(List<T> records)`
  Remove multiple records.

- ## Method Details

  - ### get

    <T extends BaseRecord> QueryResult<T> get(Class<T> clazz) throws IOException
    Get all records of the requested record class from the data store. To use the default implementations in this class, getAll must return new instances of the records on each call. It is recommended to override the default implementations for better performance.
    Type Parameters:
      `T` - Record class of the records.
    Parameters:
      `clazz` - Class of record to fetch.
    Returns:
      List of all records that match the class.
    Throws:
      `IOException` - Throws exception if unable to query the data store.

  - ### get

    <T extends BaseRecord> T get(Class<T> clazz, Query<T> query) throws IOException
    Get a single record from the store that matches the query.
    Type Parameters:
      `T` - Record class of the records.
    Parameters:
      `clazz` - Class of record to fetch.
      `query` - Query to filter results.
    Returns:
      A single record matching the query. Null if there are no matching records.
    Throws:
      `IOException` - If multiple records match or if the data store cannot be queried.

  - ### getMultiple

    <T extends BaseRecord> List<T> getMultiple(Class<T> clazz, Query<T> query) throws IOException
    Get multiple records from the store that match a query. This method assumes the underlying driver does not support filtering. If the driver supports filtering it should overwrite this method.
    Type Parameters:
      `T` - Record class of the records.
    Parameters:
      `clazz` - Class of record to fetch.
      `query` - Query to filter results.
    Returns:
      Records of type class that match the query or empty list if none are found.
    Throws:
      `IOException` - Throws exception if unable to query the data store.

  - ### put

    <T extends BaseRecord> boolean put(T record, boolean allowUpdate, boolean errorIfExists) throws IOException
    Creates a single record. Optionally updates an existing record with same primary key.
    Type Parameters:
      `T` - Record class of the records.
    Parameters:
      `record` - The record to insert or update.
      `allowUpdate` - True if update of exiting record is allowed.
      `errorIfExists` - True if an error should be returned when inserting an existing record. Only used if allowUpdate = false.
    Returns:
      True if the operation was successful.
    Throws:
      `IOException` - Throws exception if unable to query the data store.

  - ### putAll

    <T extends BaseRecord> StateStoreOperationResult putAll(List<T> records, boolean allowUpdate, boolean errorIfExists) throws IOException
    Creates multiple records. Optionally updates existing records that have the same primary key.
    Type Parameters:
      `T` - Record class of the records.
    Parameters:
      `records` - List of data records to update or create. All records must be of class clazz.
      `allowUpdate` - True if update of exiting record is allowed.
      `errorIfExists` - True if an error should be returned when inserting an existing record. Only used if allowUpdate = false.
    Returns:
      The result of the putAll operation.
    Throws:
      `IOException` - Throws exception if unable to query the data store.

  - ### remove

    <T extends BaseRecord> boolean remove(T record) throws IOException
    Remove a single record.
    Type Parameters:
      `T` - Record class of the records.
    Parameters:
      `record` - Record to be removed.
    Returns:
      true If the record was successfully removed. False if the record could not be removed or not stored.
    Throws:
      `IOException` - Throws exception if unable to query the data store.

  - ### removeMultiple

    <T extends BaseRecord> Map<T,Boolean> removeMultiple(List<T> records) throws IOException
    Remove multiple records.
    Type Parameters:
      `T` - Record class of the records.
    Parameters:
      `records` - Records to be removed.
    Returns:
      Map of record to a boolean indicating if the record has being removed successfully.
    Throws:
      `IOException` - Throws exception if unable to query the data store.

  - ### removeAll

    <T extends BaseRecord> boolean removeAll(Class<T> clazz) throws IOException
    Remove all records of this class from the store.
    Type Parameters:
      `T` - Record class of the records.
    Parameters:
      `clazz` - Class of records to remove.
    Returns:
      True if successful.
    Throws:
      `IOException` - Throws exception if unable to query the data store.

  - ### remove

    <T extends BaseRecord> int remove(Class<T> clazz, Query<T> query) throws IOException
    Remove multiple records of a specific class that match a query. Requires the getAll implementation to fetch fresh records on each call.
    Type Parameters:
      `T` - Record class of the records.
    Parameters:
      `clazz` - The class to match the records with.
      `query` - Query to filter what to remove.
    Returns:
      The number of records removed.
    Throws:
      `IOException` - Throws exception if unable to query the data store.

  - ### remove

    <T extends BaseRecord> Map<Query<T>,Integer> remove(Class<T> clazz, List<Query<T>> queries) throws IOException
    Remove all records of a specific class that match any query in a list of queries. Requires the getAll implementation to fetch fresh records on each call.
    Type Parameters:
      `T` - Record class of the records.
    Parameters:
      `clazz` - The class to match the records with.
      `queries` - Queries (logical OR) to filter what to remove.
    Returns:
      Map of query to number of records removed by that query.
    Throws:
      `IOException` - Throws exception if unable to query the data store.