public interface HGIndexer<KeyType,ValueType>
An HGIndexer
represents an atom used internally
by HyperGraphDB to manage indices. All indexers apply to a
specific atom types.
Because indexers are stored as HyperGraphDB atoms, they must obey the Java Beans conventions of having a default constructor and getter/setter pair for each property that must be recorded into storage.
IMPORTANT:Instances of HGIndexer
are frequently used to perform lookup on
existing indices. For example, when trying to determine whether an atom of
a complex type is being indexed by some projection, one constructs a
ByPartIndexer
and performs a lookup in the index manager. Thus, it
is essential that implementation of HGIndexer
provide proper hashCode
and equals
methods.
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object other)
Declared to enforce implementation.
|
Comparator<byte[]> |
getComparator(HyperGraph graph)
Return a comparator used to compare key values return by this indexer.
|
ByteArrayConverter<KeyType> |
getConverter(HyperGraph graph)
Return a
ByteArrayConverter capable of translating keys
returned by this indexer to/from a byte[] . |
HGHandle |
getType()
Return the handle of the atom type all of whose instances should be indexed
by this indexer.
|
int |
hashCode()
Declared to enforce implementation.
|
void |
index(HyperGraph graph,
HGHandle atomHandle,
Object atom,
HGIndex<KeyType,ValueType> index)
Add a particular atom the the index.
|
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,ValueType> index)
Remove a particular from the index, assuming it is currently being indexed.
|
void index(HyperGraph graph, HGHandle atomHandle, Object atom, HGIndex<KeyType,ValueType> index)
Add a particular atom the the index. This method can safely assume that the atom hasn't been previously added to the index.
graph
- The HyperGraph
instance where the atom resides.atomHandle
- atom
- index
- The storage index where the atom should be added.void unindex(HyperGraph graph, HGHandle atomHandle, Object atom, HGIndex<KeyType,ValueType> index)
Remove a particular from the index, assuming it is currently being indexed.
graph
- The HyperGraph
instance where the atom resides.atomHandle
- atom
- index
- The storage index from the atom should be removed.ByteArrayConverter<KeyType> getConverter(HyperGraph graph)
Return a ByteArrayConverter
capable of translating keys
returned by this indexer to/from a byte[]
.
graph
- The current HyperGraph instance.ByteArrayConverter
for type of index keys
return by this indexer or null
if keys are of type byte[]
.Comparator<byte[]> getComparator(HyperGraph graph)
Return a comparator used to compare key values return by this indexer.
Note that the comparator's compare
method will be invoked
with byte[]
parameters. It is the comparator's responsibility
to convert them to the appropriate run-time type for performing the comparison
if need be.
The method may return null
if a default byte-by-byte comparator is to be
used.
graph
- The current HyperGraph instance.null
to use a default byte-by-byte comparison of keys.HGHandle getType()
Return the handle of the atom type all of whose instances should be indexed by this indexer.
void setType(HGHandle type)
Set the handle of the atom type all of whose instances should be indexed by this indexer.
Copyright © 2015. All rights reserved.