public abstract class HGKeyIndexer<KeyType> extends Object implements HGIndexer<KeyType,HGPersistentHandle>
An HGKeyIndexer
represents an atom used internally
by HyperGraphDB to manage key-based indices. All such indexers are
responsible for producing
a key for the given atom instance being indexed. In addition,
when the keys produced are NOT of type byte[]
, a key indexer
must provide a ByteArrayConverter
capable of translating
a key to/from a byte[]
.
Implementations may also provide a Comparator
for keys for
sorted indices and when the default byte[]
comparator is not
suitable.
Constructor and Description |
---|
HGKeyIndexer() |
HGKeyIndexer(HGHandle type) |
HGKeyIndexer(String name,
HGHandle type) |
Modifier and Type | Method and Description |
---|---|
abstract KeyType |
getKey(HyperGraph graph,
Object atom)
Returns an index key for the given atom.
|
String |
getName() |
HGHandle |
getType()
Return the handle of the atom type all of whose instances should be indexed
by this indexer.
|
void |
index(HyperGraph graph,
HGHandle atomHandle,
Object atom,
HGIndex<KeyType,HGPersistentHandle> index)
Add a particular atom the the index.
|
void |
setName(String name) |
void |
setType(HGHandle type)
Set the handle of the atom type all of whose instances should be indexed
by this indexer.
|
void |
unindex(HyperGraph graph,
HGHandle atomHandle,
Object atom,
HGIndex<KeyType,HGPersistentHandle> index)
Remove a particular from the index, assuming it is currently being indexed.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
equals, getComparator, getConverter, hashCode
public HGKeyIndexer()
public HGKeyIndexer(HGHandle type)
public String getName()
public void setName(String name)
public HGHandle getType()
HGIndexer
Return the handle of the atom type all of whose instances should be indexed by this indexer.
getType
in interface HGIndexer<KeyType,HGPersistentHandle>
public void setType(HGHandle type)
HGIndexer
Set the handle of the atom type all of whose instances should be indexed by this indexer.
setType
in interface HGIndexer<KeyType,HGPersistentHandle>
public void index(HyperGraph graph, HGHandle atomHandle, Object atom, HGIndex<KeyType,HGPersistentHandle> index)
HGIndexer
Add a particular atom the the index. This method can safely assume that the atom hasn't been previously added to the index.
index
in interface HGIndexer<KeyType,HGPersistentHandle>
graph
- The HyperGraph
instance where the atom resides.index
- The storage index where the atom should be added.public void unindex(HyperGraph graph, HGHandle atomHandle, Object atom, HGIndex<KeyType,HGPersistentHandle> index)
HGIndexer
Remove a particular from the index, assuming it is currently being indexed.
unindex
in interface HGIndexer<KeyType,HGPersistentHandle>
graph
- The HyperGraph
instance where the atom resides.index
- The storage index from the atom should be removed.public abstract KeyType getKey(HyperGraph graph, Object atom)
Returns an index key for the given atom.
graph
- The current HyperGraph
instance.atom
- The atom being indexed.byte[]
,
a non-null ByteArrayConverter
must be provided by the
getConverter
method.Copyright © 2015. All rights reserved.