Package org.sensorhub.api.datastore
Interface IDataStore<K,V,VF extends ValueField,Q extends IQueryFilter>
- Type Parameters:
K
- Key typeV
- Value typeVF
- Value field typeQ
- 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
Base interface for all object data stores. This is an extension of the
Map
interface that adds support for:
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.
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
backup
(OutputStream is) Backup datastore content to the specified output streamvoid
commit()
Commit changes to storagedefault boolean
containsKey
(Object key) default boolean
containsValue
(Object value) default long
countMatchingEntries
(Q query) Count all entries matching the queryentrySet()
default long
default boolean
isEmpty()
default boolean
keySet()
default void
default long
removeEntries
(Q query) Batch remove all entries matching the queryvoid
restore
(InputStream os) Restore datastore content from the specified input streamSelect all values matching the querySelect all values matching the query and include selected fields onlyselectEntries
(Q query) Select all entries matching the query and return full entriesselectEntries
(Q query, Set<VF> fields) Select all entries matching the query and include selected fields onlyselectEntries
(Q query, VF... fields) selectKeys
(Q query) Select all entries matching the query and return keys onlydefault int
size()
default Collection<V>
values()
Methods inherited from interface java.util.Map
clear, compute, computeIfAbsent, computeIfPresent, equals, forEach, get, getOrDefault, hashCode, merge, put, putIfAbsent, remove, remove, replace, replace, replaceAll
-
Method Details
-
getDatastoreName
String getDatastoreName()- Returns:
- Data store name
-
getNumRecords
default long getNumRecords()- Returns:
- Total number of records contained in this data store
-
selectEntries
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
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
-
select
Select all values matching the query- Parameters:
query
- selection filter (datastore specific)- Returns:
- Stream of value objects
-
select
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
-
selectKeys
Select all entries matching the query and return keys only- Parameters:
query
- selection filter (datastore specific)- Returns:
- Stream of key objects
-
removeEntries
Batch remove all entries matching the query- Parameters:
query
- selection filter (datastore specific)- Returns:
- Number of deleted entries
-
countMatchingEntries
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
Commit changes to storage- Throws:
DataStoreException
- if an error occurred while committing changes
-
backup
Backup datastore content to the specified output stream- Parameters:
is
- target output stream- Throws:
IOException
- if backup failed
-
restore
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() -
isEmpty
default boolean isEmpty() -
containsKey
- Specified by:
containsKey
in interfaceMap<K,
V>
-
containsValue
- Specified by:
containsValue
in interfaceMap<K,
V>
-
entrySet
-
keySet
-
values
-
putAll
-