Class InMemoryMetastoreTable

java.lang.Object
org.apache.bookkeeper.metastore.InMemoryMetastoreTable
All Implemented Interfaces:
MetastoreScannableTable, MetastoreTable

public class InMemoryMetastoreTable extends Object implements MetastoreScannableTable
An in-memory implementation of a Metastore table.
  • Constructor Details

  • Method Details

    • getName

      public String getName()
      Description copied from interface: MetastoreTable
      Get table name.
      Specified by:
      getName in interface MetastoreTable
      Returns:
      table name
    • cloneValue

      static Versioned<Value> cloneValue(Value value, Version version, Set<String> fields)
    • get

      public void get(String key, MetastoreCallback<Versioned<Value>> cb, Object ctx)
      Description copied from interface: MetastoreTable
      Get all fields of a key.

      Return Code:

      • MSException.Code.OK: success returning the key
      • MSException.Code.NoKey: no key found
      • MSException.Code.IllegalOp/MSException.Code.ServiceDown: other issues

      Specified by:
      get in interface MetastoreTable
      Parameters:
      key - Key Name
      cb - Callback to return all fields of the key
      ctx - Callback context
    • get

      public void get(String key, MetastoreWatcher watcher, MetastoreCallback<Versioned<Value>> cb, Object ctx)
      Description copied from interface: MetastoreTable
      Get all fields of a key.

      Return Code:

      • MSException.Code.OK: success returning the key
      • MSException.Code.NoKey: no key found
      • MSException.Code.IllegalOp/MSException.Code.ServiceDown: other issues

      Specified by:
      get in interface MetastoreTable
      Parameters:
      key - Key Name
      watcher - Watcher object to receive notifications
      cb - Callback to return all fields of the key
      ctx - Callback context
    • get

      public void get(String key, Set<String> fields, MetastoreCallback<Versioned<Value>> cb, Object ctx)
      Description copied from interface: MetastoreTable
      Get specified fields of a key.

      Return Code:

      • MSException.Code.OK: success returning the key
      • MSException.Code.NoKey: no key found
      • MSException.Code.IllegalOp/MSException.Code.ServiceDown: other issues

      Specified by:
      get in interface MetastoreTable
      Parameters:
      key - Key Name
      fields - Fields to return
      cb - Callback to return specified fields of the key
      ctx - Callback context
    • scheduleGet

      public void scheduleGet(String key, Set<String> fields, MetastoreCallback<Versioned<Value>> cb, Object ctx)
    • put

      public void put(String key, Value value, Version version, MetastoreCallback<Version> cb, Object ctx)
      Description copied from interface: MetastoreTable
      Update a key according to its version.

      Return Code:

      • MSException.Code.OK: success updating the key
      • MSException.Code.BadVersion: failed to update the key due to bad version
      • MSException.Code.NoKey: no key found to update data, if not provided Version.NEW
      • MSException.Code.KeyExists: entry exists providing Version.NEW
      • MSException.Code.IllegalOp/MSException.Code.ServiceDown: other issues

      The key is updated only when the version matches its current version. In particular, if the provided version is:

      • Version.ANY: update the data without comparing its version. Note this usage is not encouraged since it may mess up data consistency.
      • Version.NEW: create the entry if it doesn't exist before; Otherwise return MSException.Code.KeyExists.
      Specified by:
      put in interface MetastoreTable
      Parameters:
      key - Key Name
      value - Value to update.
      version - Version specified to update.
      cb - Callback to return new version after updated.
      ctx - Callback context
    • remove

      public void remove(String key, Version version, MetastoreCallback<Void> cb, Object ctx)
      Description copied from interface: MetastoreTable
      Remove a key by its version.

      The key is removed only when the version matches its current version. If version is Version.ANY, the key would be removed directly.

      Return Code:

      • MSException.Code.OK: success updating the key
      • MSException.Code.NoKey: if the key doesn't exist.
      • MSException.Code.BadVersion: failed to delete the key due to bad version
      • MSException.Code.IllegalOp/MSException.Code.ServiceDown: other issues

      Specified by:
      remove in interface MetastoreTable
      Parameters:
      key - Key Name.
      version - Version specified to remove.
      cb - Callback to return all fields of the key
      ctx - Callback context
    • openCursor

      public void openCursor(MetastoreCallback<MetastoreCursor> cb, Object ctx)
      Description copied from interface: MetastoreTable
      Open a cursor to loop over all the entries of the table, which returns all fields for each entry. The returned cursor doesn't need to guarantee any order, since the underlying might be a hash table or an order table.
      Specified by:
      openCursor in interface MetastoreTable
      Parameters:
      cb - Callback to return an opened cursor
      ctx - Callback context
    • openCursor

      public void openCursor(Set<String> fields, MetastoreCallback<MetastoreCursor> cb, Object ctx)
      Description copied from interface: MetastoreTable
      Open a cursor to loop over all the entries of the table, which returns the specified fields for each entry. The returned cursor doesn't need to guarantee any order, since the underlying might be a hash table or an order table.
      Specified by:
      openCursor in interface MetastoreTable
      Parameters:
      fields - Fields to select
      cb - Callback to return an opened cursor
      ctx - Callback context
    • openCursor

      public void openCursor(String firstKey, boolean firstInclusive, String lastKey, boolean lastInclusive, MetastoreScannableTable.Order order, MetastoreCallback<MetastoreCursor> cb, Object ctx)
      Description copied from interface: MetastoreScannableTable
      Open a cursor to loop over the entries belonging to a key range, which returns all fields for each entry.

      Return Code:
      MSException.Code.OK: an opened cursor
      MSException.Code.IllegalOp/MSException.Code.ServiceDown: other issues

      Specified by:
      openCursor in interface MetastoreScannableTable
      Parameters:
      firstKey - Key to start scanning. If it is MetastoreScannableTable.EMPTY_START_KEY, it starts from first key (inclusive).
      firstInclusive - true if firstKey is to be included in the returned view.
      lastKey - Key to stop scanning. If it is MetastoreScannableTable.EMPTY_END_KEY, scan ends at the lastKey of the table (inclusive).
      lastInclusive - true if lastKey is to be included in the returned view.
      order - the order to loop over the entries
      cb - Callback to return an opened cursor.
      ctx - Callback context
    • openCursor

      public void openCursor(String firstKey, boolean firstInclusive, String lastKey, boolean lastInclusive, MetastoreScannableTable.Order order, Set<String> fields, MetastoreCallback<MetastoreCursor> cb, Object ctx)
      Description copied from interface: MetastoreScannableTable
      Open a cursor to loop over the entries belonging to a key range, which returns the specified fields for each entry.

      Return Code:
      MSException.Code.OK: an opened cursor
      MSException.Code.IllegalOp/MSException.Code.ServiceDown: other issues

      Specified by:
      openCursor in interface MetastoreScannableTable
      Parameters:
      firstKey - Key to start scanning. If it is MetastoreScannableTable.EMPTY_START_KEY, it starts from first key (inclusive).
      firstInclusive - true if firstKey is to be included in the returned view.
      lastKey - Key to stop scanning. If it is MetastoreScannableTable.EMPTY_END_KEY, scan ends at the lastKey of the table (inclusive).
      lastInclusive - true if lastKey is to be included in the returned view.
      order - the order to loop over the entries
      fields - Fields to select
      cb - Callback to return an opened cursor.
      ctx - Callback context
    • close

      public void close()
      Description copied from interface: MetastoreTable
      Close the table.
      Specified by:
      close in interface MetastoreTable