public interface HGStoreImplementation
A HGStoreImplementation
provides the crucial storage layer for a
HyperGraphDB instance. This interface allows one to plug different storage layers
based on different lower-level stores and thus obtain various performance characteristics
or transaction guarantees. Implementing this interface is not trivial and some
core assumption must be carefully observed.
Note that this interface is an SPI (Service Provider Interface) and it
is not intended to be used by an application. Instead, applications should use
the HGStore
class which offers the same functionality, but in
the context of a HyperGraphDB instance. All methods here are intended for use
by HyperGraphDB itself.
Modifier and Type | Method and Description |
---|---|
void |
addIncidenceLink(HGPersistentHandle handle,
HGPersistentHandle newLink)
And an element to the incidence set of a given atom (as identified by the
handle
parameter). |
boolean |
containsData(HGPersistentHandle handle)
Return
true if the data space contains data with the given
handle and false otherwise. |
boolean |
containsLink(HGPersistentHandle handle)
Return
true if there is a primitive link for the given handle. |
Object |
getConfiguration()
Each different storage mechanism provides its own configuration object
with parameters that can be set before storage is initialized.
|
byte[] |
getData(HGPersistentHandle handle)
Return the data corresponding to a given handle or
null if it is not found. |
HGRandomAccessResult<HGPersistentHandle> |
getIncidenceResultSet(HGPersistentHandle handle)
Return the incidence set associate with the given handle.
|
long |
getIncidenceSetCardinality(HGPersistentHandle handle)
Return the number of elements of the incidence set for the given handle or 0
if no such set exists.
|
<KeyType,ValueType> |
getIndex(String name)
Get the HyperGraphDB index with the given name.
|
<KeyType,ValueType> |
getIndex(String name,
ByteArrayConverter<KeyType> keyConverter,
ByteArrayConverter<ValueType> valueConverter,
Comparator<?> comparator,
boolean isBidirectional,
boolean createIfNecessary)
Retrieve the index with the given name, or create a new index if no index with
that name exists.
|
HGPersistentHandle[] |
getLink(HGPersistentHandle handle)
Return the link corresponding to a given handle or
null if it is not found. |
HGTransactionFactory |
getTransactionFactory()
Return the transaction factory associated with this storage instance.
|
void |
removeData(HGPersistentHandle handle)
Remove the data corresponding to a given handle.
|
void |
removeIncidenceLink(HGPersistentHandle handle,
HGPersistentHandle oldLink)
Remove a specifiec element from the incidence set of a given atom (as identified by
the
handle parameter). |
void |
removeIncidenceSet(HGPersistentHandle handle)
Remove the incidence set associated with the given handle.
|
void |
removeIndex(String name)
Remove the index with the given name.
|
void |
removeLink(HGPersistentHandle handle)
Remove the link corresponding to a given handle.
|
void |
shutdown()
Stops the storage engine.
|
void |
startup(HGStore store,
HGConfiguration configuration)
Starts the storage engine.
|
HGPersistentHandle |
store(HGPersistentHandle handle,
byte[] data)
Store a raw data buffer and return its handle.
|
HGPersistentHandle |
store(HGPersistentHandle handle,
HGPersistentHandle[] link)
Store a primitive link and return its handle.
|
Object getConfiguration()
void startup(HGStore store, HGConfiguration configuration)
Starts the storage engine.
This method is invoked after storage configuration parameters have been set and its purpose is to perform complete initialization for the underlying storage layer, possibly creating a new database instance. When this method returns, the storage should be ready for use.
void shutdown()
Stops the storage engine.
This method is invoked when the database instance is closed. It is expected to perform all necessary cleanup and closing of resources of the storage layer.
HGTransactionFactory getTransactionFactory()
Return the transaction factory associated with this storage instance. Storage implementations in HyperGraphDB are expected to be transactional and support snapshot isolation semantics.
HGPersistentHandle store(HGPersistentHandle handle, HGPersistentHandle[] link)
handle
- The handle to use as the identifier of the link.link
- The primitive link. Neither the array nor any of its element can
be null
.handle
argument.HGPersistentHandle[] getLink(HGPersistentHandle handle)
null
if it is not found.void removeLink(HGPersistentHandle handle)
boolean containsLink(HGPersistentHandle handle)
true
if there is a primitive link for the given handle.HGPersistentHandle store(HGPersistentHandle handle, byte[] data)
handle
- The handle to use as identifier within the data space.data
- The buffer to store. There is no limit to the size of this buffer, but it can't be null.handle
argument.byte[] getData(HGPersistentHandle handle)
null
if it is not found.void removeData(HGPersistentHandle handle)
boolean containsData(HGPersistentHandle handle)
true
if the data space contains data with the given
handle and false
otherwise.HGRandomAccessResult<HGPersistentHandle> getIncidenceResultSet(HGPersistentHandle handle)
void removeIncidenceSet(HGPersistentHandle handle)
long getIncidenceSetCardinality(HGPersistentHandle handle)
void addIncidenceLink(HGPersistentHandle handle, HGPersistentHandle newLink)
handle
parameter).void removeIncidenceLink(HGPersistentHandle handle, HGPersistentHandle oldLink)
handle
parameter).<KeyType,ValueType> HGIndex<KeyType,ValueType> getIndex(String name)
null
if no
index with that name exists.<KeyType,ValueType> HGIndex<KeyType,ValueType> getIndex(String name, ByteArrayConverter<KeyType> keyConverter, ByteArrayConverter<ValueType> valueConverter, Comparator<?> comparator, boolean isBidirectional, boolean createIfNecessary)
name
- The name of the index. It must be unique for the storage layer.keyConverter
- Converter to byte [] for the keys in this index. Necessary when creating
a new index. If null
, a default converter should be used.valueConverter
- Converter to byte [] for the values in this index. Necessary when creating
a new index. If null
, a default converter should be used.void removeIndex(String name)
Copyright © 2015. All rights reserved.