|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.hypergraphdb.HGIndexManager
public class HGIndexManager
The HGIndexManager allows you to create atom indices. Such indices
allow quick lookup of atoms depending on their value and/or target sets.
Atom indexing in HyperGraph relies on the concept of a HGIndexer. Indexers
are always bound to an atom type. They are mainly responsible for producing an index key
given an atom instance. The index manager interacts with the HGStore to create
and update indices at the storage level based on an implementation of the HGIndexer
interface.
When an implementation of a HGIndexer does not produce keys of byte[]
type, it is required to return a non-null ByteArrayConverter from its
getConverter method. In addition, if a regular byte ordering is not appropriate
for a given key type, the HGIndexer implementation must return a non-null
Comparator from its getComparator method.
To create a new index for a given atom type, call the register(HGIndexer) method.
To later remove it, call the unregister(HGIndexer) method. Registering an
indexer will store the indexer as a HyperGraph atom and it will request a low-level storage
index from the HGStore. All atom instance of the type for which a new indexer
is being registered will be automatically indexed. Naturally, this may be a very long operation.
Therefore it is recommended that indexer be registered at a time where there's no other activity
on the HyperGraph database.
| Constructor Summary | |
|---|---|
HGIndexManager(HyperGraph graph)
|
|
| Method Summary | ||
|---|---|---|
void |
close()
Cleanup reference to external resources for this indexer. |
|
void |
deleteIndex(HGIndexer indexer)
|
|
|
getIndex(HGIndexer indexer)
Retrieve the storage HGIndex associated to the passed-in
HGIndexer. |
|
HGIndex<HGPersistentHandle,HGPersistentHandle> |
getIndexByType()
Return the predefined index from types to atoms. |
|
HGIndex<HGPersistentHandle,HGPersistentHandle> |
getIndexByValue()
Return the predefined index from values to atoms. |
|
java.util.List<HGIndexer> |
getIndexersForType(HGHandle type)
Return all registered HGIndexers for a given HyperGraph type. |
|
boolean |
isRegistered(HGIndexer indexer)
Return true if the given HGIndexer is registered
with the index manager and false otherwise. |
|
|
register(HGIndexer indexer)
Possibly create a new index based on the specified IndexDescriptor. |
|
boolean |
unregister(HGIndexer indexer)
Remove an existing index. |
|
void |
unregisterAll(HGHandle typeHandle)
Remove all indexers for the given type. |
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public HGIndexManager(HyperGraph graph)
| Method Detail |
|---|
public void deleteIndex(HGIndexer indexer)
public void close()
Cleanup reference to external resources for this indexer.
public boolean unregister(HGIndexer indexer)
Remove an existing index. If there's no index as specified by
the indexer parameter, nothing is done.
indexer - The indexer to be removed.
true if the indexer was removed and
false if it didn't exist.public void unregisterAll(HGHandle typeHandle)
Remove all indexers for the given type. This is normally called only when the type is being from the HyperGraph instance.
typeHandle - The handle of the atom type whose indexers are to be
deleted.public boolean isRegistered(HGIndexer indexer)
Return true if the given HGIndexer is registered
with the index manager and false otherwise.
indexer - The possibly registered HGIndexer.public <KeyType,ValueType> HGIndex<KeyType,ValueType> register(HGIndexer indexer)
Possibly create a new index based on the specified IndexDescriptor.
If an index corresponding to the descriptor already exists, the method
does nothing and returns false. Otherwise it creates a new index,
which triggers the automatic indexing of all atoms of the type specified in
the descriptor and returns true at the end.
desc - The descriptor of the index to be created.
true if a new index was created and false
otherwise.public <KeyType,ValueType> HGIndex<KeyType,ValueType> getIndex(HGIndexer indexer)
Retrieve the storage HGIndex associated to the passed-in
HGIndexer.
indexer - The HGIndexer whose associated HGIndex
is desired.
null if the passed in HGIndexer
hasn't been registered with the index manager.public java.util.List<HGIndexer> getIndexersForType(HGHandle type)
Return all registered HGIndexers for a given HyperGraph type.
type - The HGHandle of the HyperGraph type whose indexers
are desired.
null if no indexer is
currently registered for that type.public HGIndex<HGPersistentHandle,HGPersistentHandle> getIndexByType()
Return the predefined index from types to atoms. That is, each key in this index is a type handle and its values are all atoms with that type.
public HGIndex<HGPersistentHandle,HGPersistentHandle> getIndexByValue()
Return the predefined index from values to atoms. That is, each key in this index is a value handle and its index values are all atoms with that value handle.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||