Package org.dizitart.no2.store
Interface NitriteStore<Config extends StoreConfig>
-
- Type Parameters:
Config
- the type parameter
- All Superinterfaces:
AutoCloseable
,NitritePlugin
- All Known Implementing Classes:
AbstractNitriteStore
public interface NitriteStore<Config extends StoreConfig> extends NitritePlugin
Represents a storage interface for Nitrite database.- Since:
- 1.0
- Author:
- Anindya Chatterjee
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
beforeClose()
This method is called before closing the store.void
closeMap(String mapName)
Closes aNitriteMap
with the specified name in the store.void
closeRTree(String rTreeName)
Closes aNitriteRTree
with the specified name in the store.void
commit()
Commits the changes.StoreCatalog
getCatalog()
Gets the store catalog.Set<String>
getCollectionNames()
Returns a set of all collection names in the store.Map<String,Set<String>>
getKeyedRepositoryRegistry()
Returns a set of all the keyed-repository names registered in the Nitrite store.Set<String>
getRepositoryRegistry()
Returns a set of all the repository names registered in the Nitrite store.Config
getStoreConfig()
Gets the store configuration.String
getStoreVersion()
Gets the underlying storage engine version.boolean
hasMap(String mapName)
Checks if aNitriteMap
with the given name exists in the store.boolean
hasUnsavedChanges()
Checks if the store has any unsaved changes.boolean
isClosed()
Checks whether this store is closed.boolean
isReadOnly()
Checks if the store is opened in read-only mode.<Key,Value>
NitriteMap<Key,Value>openMap(String mapName, Class<?> keyType, Class<?> valueType)
Opens aNitriteMap
.void
openOrCreate()
Opens the store if it exists, or creates a new one if it doesn't.<Key extends BoundingBox,Value>
NitriteRTree<Key,Value>openRTree(String rTreeName, Class<?> keyType, Class<?> valueType)
Opens aNitriteRTree
with the given key and value types.void
removeMap(String mapName)
Removes aNitriteMap
with the specified name from the store.void
removeRTree(String rTreeName)
Removes aNitriteRTree
with the specified name from the store.void
subscribe(StoreEventListener listener)
Subscribes aStoreEventListener
to this store.void
unsubscribe(StoreEventListener listener)
Unsubscribes aStoreEventListener
from this store.-
Methods inherited from interface org.dizitart.no2.common.module.NitritePlugin
close, initialize
-
-
-
-
Method Detail
-
openOrCreate
void openOrCreate()
Opens the store if it exists, or creates a new one if it doesn't.
-
isClosed
boolean isClosed()
Checks whether this store is closed.- Returns:
true
if closed;false
otherwise.
-
getCollectionNames
Set<String> getCollectionNames()
Returns a set of all collection names in the store.- Returns:
- a set of all collection names in the store
-
getRepositoryRegistry
Set<String> getRepositoryRegistry()
Returns a set of all the repository names registered in the Nitrite store.- Returns:
- a set of all the repository names registered in the Nitrite store
-
getKeyedRepositoryRegistry
Map<String,Set<String>> getKeyedRepositoryRegistry()
Returns a set of all the keyed-repository names registered in the Nitrite store.- Returns:
- a set of all the keyed-repository names registered in the Nitrite store
-
hasUnsavedChanges
boolean hasUnsavedChanges()
Checks if the store has any unsaved changes.- Returns:
true
if the store has unsaved changes;false
otherwise.
-
isReadOnly
boolean isReadOnly()
Checks if the store is opened in read-only mode.- Returns:
true
if the store is read-only;false
otherwise.
-
commit
void commit()
Commits the changes. For persistent stores, it also writes changes to disk. It does nothing if there are no unsaved changes.
-
beforeClose
void beforeClose()
This method is called before closing the store. Any cleanup or finalization tasks should be performed in this method.
-
hasMap
boolean hasMap(String mapName)
Checks if aNitriteMap
with the given name exists in the store.- Parameters:
mapName
- the name of the map to check- Returns:
- true if the map exists, false otherwise
-
openMap
<Key,Value> NitriteMap<Key,Value> openMap(String mapName, Class<?> keyType, Class<?> valueType)
Opens aNitriteMap
. The map is automatically created if it does not yet exist. If a map with this name is already opened, this map is returned.- Type Parameters:
Key
- the key typeValue
- the value type- Parameters:
mapName
- the map namekeyType
- the key typevalueType
- the value type- Returns:
- the map.
-
closeMap
void closeMap(String mapName)
Closes aNitriteMap
with the specified name in the store.- Parameters:
mapName
- the map name
-
removeMap
void removeMap(String mapName)
Removes aNitriteMap
with the specified name from the store.- Parameters:
mapName
- the map name to remove.
-
openRTree
<Key extends BoundingBox,Value> NitriteRTree<Key,Value> openRTree(String rTreeName, Class<?> keyType, Class<?> valueType)
Opens aNitriteRTree
with the given key and value types. The key type must extend theBoundingBox
class. Returns aNitriteRTree
instance that can be used to perform R-Tree operations on the data.RTree is automatically created if it does not yet exist. If a RTree with this name is already open, this RTree is returned.
- Type Parameters:
Key
- the key typeValue
- the value type- Parameters:
rTreeName
- the RTree namekeyType
- the key typevalueType
- the value type- Returns:
- the map.
-
closeRTree
void closeRTree(String rTreeName)
Closes aNitriteRTree
with the specified name in the store.- Parameters:
rTreeName
- the RTree name
-
removeRTree
void removeRTree(String rTreeName)
Removes aNitriteRTree
with the specified name from the store.- Parameters:
rTreeName
- the RTree name to remove.
-
subscribe
void subscribe(StoreEventListener listener)
Subscribes aStoreEventListener
to this store. The listener will be notified of any changes made to the store.- Parameters:
listener
- the listener to subscribe
-
unsubscribe
void unsubscribe(StoreEventListener listener)
Unsubscribes aStoreEventListener
from this store.- Parameters:
listener
- the listener to unsubscribe
-
getStoreVersion
String getStoreVersion()
Gets the underlying storage engine version.- Returns:
- the store version
-
getStoreConfig
Config getStoreConfig()
Gets the store configuration.- Returns:
- the store config
-
getCatalog
StoreCatalog getCatalog()
Gets the store catalog.- Returns:
- the catalog
-
-