public interface HGIndex<KeyType,ValueType> extends HGSearchable<KeyType,ValueType>
The HGIndex
interface represents an user-created index in the HyperGraph
data structure.
Note that taking advantage of the fact that Java allows overriding methods to
further specialize on the return type (i.e. allowing contra-variant return types),
the find
method of the super-interface is redeclared to return a
HGRandomAccessResult
.
Modifier and Type | Method and Description |
---|---|
void |
addEntry(KeyType key,
ValueType value)
Add an entry to the index.
|
void |
close()
Close this index.
|
long |
count()
Return the number of keys in this index.
|
long |
count(KeyType key)
Return the number of values for the key.
|
HGRandomAccessResult<ValueType> |
find(KeyType key)
Retrieve all entries corresponding to the given key.
|
ValueType |
findFirst(KeyType key)
Find the first indexed entry corresponding to the given key.
|
String |
getName()
Return the unique name that identifies this index at the storage layer.
|
boolean |
isOpen()
Return
true if the index is currently opened and
false otherwise. |
void |
open()
Open the index for use.
|
void |
removeAllEntries(KeyType key)
Remove all entries in the index with a given key.
|
void |
removeEntry(KeyType key,
ValueType value)
Remove a specific entry in the index.
|
HGRandomAccessResult<KeyType> |
scanKeys()
Return a result set containing all keys in this index.
|
HGRandomAccessResult<ValueType> |
scanValues()
Return a result set containing all values in this index.
|
String getName()
void addEntry(KeyType key, ValueType value)
Add an entry to the index. If that entry is already present, calling this method should have no effect.
key
- The entry's key part.value
- The entry's value part.void removeEntry(KeyType key, ValueType value)
Remove a specific entry in the index. If an entry with this key and value does not exist, the method does not nothing.
key
- The key part of the entry.value
- The value part of the entry.void removeAllEntries(KeyType key)
Remove all entries in the index with a given key. If an entry with this key does not exist, the method does not nothing.
key
- The key all of whose corresponding entries will be removed.ValueType findFirst(KeyType key)
Find the first indexed entry corresponding to the given key. The first entry will generally be the one that was firstly added for that key. However, this is by no means guaranteed. This method is meant for indices where only a single value corresponds to a key. That is, in mathematical terms, indices that can be seen as functions.
key
- The key whose value is sought.HGRandomAccessResult<ValueType> find(KeyType key)
Retrieve all entries corresponding to the given key. The order in which the entries are returned is not necessarily the order in which they were originally added.
find
in interface HGSearchable<KeyType,ValueType>
key
- The key whose values are sought.HGRandomAccessResult
over all HGPersistentHandle
s under that key.void open()
Open the index for use. Entries may be added to the index only when it
has been explicitly opened. To determine whether an index is currently
opened, use the isOpen
method. Note that an index may be
temporarily opened by the HyperGraph querying mechanism.
void close()
Close this index. This method closes any run-time resources associated with the index, and invalidates it for use until reopened. It does not remove the index permanently from the database.
boolean isOpen()
Return true
if the index is currently opened and
false
otherwise.
HGRandomAccessResult<KeyType> scanKeys()
Return a result set containing all keys in this index.
HGRandomAccessResult<ValueType> scanValues()
Return a result set containing all values in this index.
long count()
Return the number of keys in this index. This operation must run in constant time, regardless of the number of keys.
long count(KeyType key)
Return the number of values for the key. This operation must run constant time regardless of the key or the number returned.
key
- The key whose values must be counted.Copyright © 2015. All rights reserved.