Interface IDataStore<K,V,VF extends ValueField,Q extends IQueryFilter>

Type Parameters:
K - Key type
V - Value type
VF - Value field type
Q - Query type
All Superinterfaces:
Map<K,V>
All Known Subinterfaces:
ICommandStatusStore, ICommandStore, ICommandStreamStore, IDataStreamStore, IDeploymentStore, IFeatureStore, IFeatureStoreBase<V,VF,F>, IFoiStore, IObsStore, IProcedureStore, IPropertyStore, IResourceStore<K,V,VF,F>, ISystemDescStore
All Known Implementing Classes:
EmptyCommandStatusStore, EmptyCommandStore, EmptyCommandStreamStore, org.sensorhub.impl.datastore.EmptyDataStore, EmptyDataStreamStore, EmptyDeploymentStore, EmptyFeatureBaseStore, EmptyFoiStore, EmptyObsStore, EmptyProcedureStore, EmptyPropertyStore, EmptyResourceStore, EmptySystemStore, org.sensorhub.impl.datastore.ReadOnlyDataStore

public interface IDataStore<K,V,VF extends ValueField,Q extends IQueryFilter> extends Map<K,V>

Base interface for all object data stores. This is an extension of the Map interface that adds support for:

  • Selecting, removing and counting elements matching a filter query
  • Backup/restore operations
  • Many operations return Stream objects allowing additional filtering, projecting and sorting using Java Stream API methods.

    Note that certain data store implementations may optimize execution by partitioning, parallelizing or distributing the Stream pipeline operations.

    • Method Details

      • getDatastoreName

        String getDatastoreName()
        Returns:
        Data store name
      • getNumRecords

        default long getNumRecords()
        Returns:
        Total number of records contained in this data store
      • selectEntries

        default Stream<Map.Entry<K,V>> selectEntries(Q query)
        Select all entries matching the query and return full entries
        Parameters:
        query - selection filter (datastore specific)
        Returns:
        Stream of matching entries (i.e. key/value pairs)
      • selectEntries

        Stream<Map.Entry<K,V>> selectEntries(Q query, Set<VF> fields)
        Select all entries matching the query and include selected fields only
        Parameters:
        query - selection filter (datastore specific)
        fields - List of value fields to read from datastore (or null to select all fields)
        Returns:
        Stream of value objects. Caller should not try to access fields of value objects that were not included in the fields parameter.
      • selectEntries

        default Stream<Map.Entry<K,V>> selectEntries(Q query, VF... fields)
      • select

        default Stream<V> select(Q query)
        Select all values matching the query
        Parameters:
        query - selection filter (datastore specific)
        Returns:
        Stream of value objects
      • select

        default Stream<V> select(Q query, Set<VF> fields)
        Select all values matching the query and include selected fields only
        Parameters:
        query - selection filter (datastore specific)
        fields - List of value fields to read from datastore
        Returns:
        Stream of value objects. Values returned by get methods corresponding to omitted fields may be invalid.
      • select

        default Stream<V> select(Q query, VF... fields)
      • selectKeys

        default Stream<K> selectKeys(Q query)
        Select all entries matching the query and return keys only
        Parameters:
        query - selection filter (datastore specific)
        Returns:
        Stream of key objects
      • removeEntries

        default long removeEntries(Q query)
        Batch remove all entries matching the query
        Parameters:
        query - selection filter (datastore specific)
        Returns:
        Number of deleted entries
      • countMatchingEntries

        default long countMatchingEntries(Q query)
        Count all entries matching the query
        Parameters:
        query - selection filter (datastore specific)
        Returns:
        number of matching entries, or the value of query limit if reached
      • commit

        void commit() throws DataStoreException
        Commit changes to storage
        Throws:
        DataStoreException - if an error occurred while committing changes
      • backup

        void backup(OutputStream is) throws IOException
        Backup datastore content to the specified output stream
        Parameters:
        is - target output stream
        Throws:
        IOException - if backup failed
      • restore

        void restore(InputStream os) throws IOException
        Restore datastore content from the specified input stream
        Parameters:
        os - source input stream
        Throws:
        IOException - if restoration failed
      • isReadOnly

        default boolean isReadOnly()
        Returns:
        true if the datastore is read-only, false otherwise
      • selectAllFilter

        Q selectAllFilter()
        Returns:
        The filter to use to select all records
      • size

        default int size()
        Specified by:
        size in interface Map<K,V>
      • isEmpty

        default boolean isEmpty()
        Specified by:
        isEmpty in interface Map<K,V>
      • containsKey

        default boolean containsKey(Object key)
        Specified by:
        containsKey in interface Map<K,V>
      • containsValue

        default boolean containsValue(Object value)
        Specified by:
        containsValue in interface Map<K,V>
      • entrySet

        default Set<Map.Entry<K,V>> entrySet()
        Specified by:
        entrySet in interface Map<K,V>
      • keySet

        default Set<K> keySet()
        Specified by:
        keySet in interface Map<K,V>
      • values

        default Collection<V> values()
        Specified by:
        values in interface Map<K,V>
      • putAll

        default void putAll(Map<? extends K,? extends V> map)
        Specified by:
        putAll in interface Map<K,V>