org.hypergraphdb.storage
Class DefaultBiIndexImpl<KeyType,ValueType>

java.lang.Object
  extended by org.hypergraphdb.storage.DefaultIndexImpl<KeyType,ValueType>
      extended by org.hypergraphdb.storage.DefaultBiIndexImpl<KeyType,ValueType>
All Implemented Interfaces:
HGBidirectionalIndex<KeyType,ValueType>, HGIndex<KeyType,ValueType>, HGOrderedSearchable<KeyType,ValueType>, HGSearchable<KeyType,ValueType>, HGSortIndex<KeyType,ValueType>

public class DefaultBiIndexImpl<KeyType,ValueType>
extends DefaultIndexImpl<KeyType,ValueType>
implements HGBidirectionalIndex<KeyType,ValueType>


Field Summary
 
Fields inherited from class org.hypergraphdb.storage.DefaultIndexImpl
DB_NAME_PREFIX
 
Constructor Summary
DefaultBiIndexImpl(java.lang.String indexName, com.sleepycat.db.Environment env, HGTransactionManager transactionManager, ByteArrayConverter<KeyType> keyConverter, ByteArrayConverter<ValueType> valueConverter, java.util.Comparator<?> comparator)
           
 
Method Summary
 void addEntry(KeyType key, ValueType value)
           Add an entry to the index.
 void close()
           Close this index.
 long countKeys(ValueType value)
          Return the number of keys pointing to the given values.
 HGRandomAccessResult<KeyType> findByValue(ValueType value)
          Return a HGSearchResult over all keys whose value is the value parameter.
 KeyType findFirstByValue(ValueType value)
          Return a key whose value is the value parameter.
 boolean isOpen()
          Return true if the index is currently opened and false otherwise.
 void open()
           Open the index for use.
 
Methods inherited from class org.hypergraphdb.storage.DefaultIndexImpl
count, count, find, findFirst, findGT, findGTE, findLast, findLT, findLTE, getComparator, getDatabaseName, getName, removeAllEntries, removeEntry, scanKeys, scanValues
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.hypergraphdb.HGIndex
count, count, find, findFirst, removeAllEntries, removeEntry, scanKeys, scanValues
 

Constructor Detail

DefaultBiIndexImpl

public DefaultBiIndexImpl(java.lang.String indexName,
                          com.sleepycat.db.Environment env,
                          HGTransactionManager transactionManager,
                          ByteArrayConverter<KeyType> keyConverter,
                          ByteArrayConverter<ValueType> valueConverter,
                          java.util.Comparator<?> comparator)
Method Detail

open

public void open()
Description copied from interface: HGIndex

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.

Specified by:
open in interface HGIndex<KeyType,ValueType>
Overrides:
open in class DefaultIndexImpl<KeyType,ValueType>

close

public void close()
Description copied from interface: HGIndex

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.

Specified by:
close in interface HGIndex<KeyType,ValueType>
Overrides:
close in class DefaultIndexImpl<KeyType,ValueType>

isOpen

public boolean isOpen()
Description copied from interface: HGIndex

Return true if the index is currently opened and false otherwise.

Specified by:
isOpen in interface HGIndex<KeyType,ValueType>
Overrides:
isOpen in class DefaultIndexImpl<KeyType,ValueType>

addEntry

public void addEntry(KeyType key,
                     ValueType value)
Description copied from interface: HGIndex

Add an entry to the index. If that entry is already present, calling this method should have no effect.

Specified by:
addEntry in interface HGIndex<KeyType,ValueType>
Overrides:
addEntry in class DefaultIndexImpl<KeyType,ValueType>
Parameters:
key - The entry's key part.
value - The entry's value part.

findByValue

public HGRandomAccessResult<KeyType> findByValue(ValueType value)
Description copied from interface: HGBidirectionalIndex

Return a HGSearchResult over all keys whose value is the value parameter.

Specified by:
findByValue in interface HGBidirectionalIndex<KeyType,ValueType>

findFirstByValue

public KeyType findFirstByValue(ValueType value)
Description copied from interface: HGBidirectionalIndex

Return a key whose value is the value parameter. If more than one index entry exists with that particular value, generally the one that was added first will be returned, but this is not guarantueed.

Specified by:
findFirstByValue in interface HGBidirectionalIndex<KeyType,ValueType>

countKeys

public long countKeys(ValueType value)
Description copied from interface: HGBidirectionalIndex

Return the number of keys pointing to the given values. This operation must execute in constant time, regardless of the data in the index.

Specified by:
countKeys in interface HGBidirectionalIndex<KeyType,ValueType>
Parameters:
value - The value.