Interface IBmPersistentStringStore

All Superinterfaces:
AutoCloseable, Closeable

public interface IBmPersistentStringStore extends Closeable
String to byte array persistent key-value store.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes the store.
    long
    Gets the size of the store, in bytes.
    Gets all the keys in the store as Iterable.
    <T> T
    Reads data associated with the specified key.
    boolean
    Removes data assoicated with the specified key.
    boolean
    Checks if the store requires compacting.
    void
    Starts the store.
    void
    write(String key, byte[] data)
    Writes the specified data to store and associates with the specified key.
    void
    write(String key, byte[] data, int offset, int length)
    Writes the specified piece of binary data and associates it with the specified ID.
  • Method Details

    • start

      void start() throws IOException
      Starts the store.
      Throws:
      IOException - if any I/O error occurs.
    • close

      void close() throws IOException
      Closes the store. Once store closed, it cannot be started again.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException - if any I/O error occurs.
    • read

      <T> T read(String key, IBmPersistentStoreReaderCallback<T> callback) throws IOException
      Reads data associated with the specified key. If the data exist the callback is invoked.
      Parameters:
      key - The key. May not be null.
      callback - The callback. May not be null.
      Returns:
      the result returned by callback or null if there are no data associated with the specified key.
      Throws:
      IOException - if any I/O error occurs.
    • write

      void write(String key, byte[] data) throws IOException
      Writes the specified data to store and associates with the specified key.
      Parameters:
      key - The key. May not be null.
      data - The byte array containing the data. May not be null.
      Throws:
      IOException - if any I/O error occurs.
    • write

      void write(String key, byte[] data, int offset, int length) throws IOException
      Writes the specified piece of binary data and associates it with the specified ID.
      Parameters:
      key - The key. May not be null.
      data - The byte array containing the data. May not be null.
      offset - The offset of the data within the array.
      length - The length of the data.
      Throws:
      IOException - if any I/O error occurs.
    • remove

      boolean remove(String key) throws IOException
      Removes data assoicated with the specified key.
      Parameters:
      key - The key. May not be null.
      Returns:
      true if there were data associated with the specified key, false otherwise.
      Throws:
      IOException - if any I/O error occurs.
    • keys

      Iterable<String> keys()
      Gets all the keys in the store as Iterable.
      Returns:
      an instance of Iterable, never null.
    • getStoreSize

      long getStoreSize() throws IOException
      Gets the size of the store, in bytes.
      Returns:
      The size of the store, in bytes. Cannot be negative.
      Throws:
      IOException - if any I/O error occurs.
    • requiresCompacting

      boolean requiresCompacting() throws IOException
      Checks if the store requires compacting.
      Returns:
      true if the store requires compacting, false otherwise.
      Throws:
      IOException - if any I/O error occurs.