org.hypergraphdb.storage
Class IndexResultSet<T>

java.lang.Object
  extended by org.hypergraphdb.storage.IndexResultSet<T>
All Implemented Interfaces:
java.util.Iterator<T>, HGRandomAccessResult<T>, HGSearchResult<T>, TwoWayIterator<T>, CloseMe
Direct Known Subclasses:
KeyScanResultSet, SingleKeyResultSet, SingleValueResultSet

public abstract class IndexResultSet<T>
extends java.lang.Object
implements HGRandomAccessResult<T>

An IndexResultSet is based on a cursor over an indexed set of values. Implementation of complex query execution may move the cursor position based on some index key to speed up query processing.

Author:
Borislav Iordanov

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.hypergraphdb.HGRandomAccessResult
HGRandomAccessResult.GotoResult
 
Field Summary
 
Fields inherited from interface org.hypergraphdb.HGSearchResult
EMPTY
 
Constructor Summary
IndexResultSet()
          Construct an empty result set.
IndexResultSet(BDBTxCursor cursor, com.sleepycat.db.DatabaseEntry keyIn, ByteArrayConverter<T> converter)
          Construct a result set matching a specific key.
 
Method Summary
 void close()
          Free all system resources held up by the result set and invalidate it for further use.
 int count()
           
 T current()
          Returns the current element in the result set.
 HGRandomAccessResult.GotoResult goTo(T value, boolean exactMatch)
          Position the result set at a particular value if that value is indeed part of the result set.
 boolean hasNext()
           
 boolean hasPrev()
           Return true if there is a previous element in the current iteration state and false otherwise.
 T next()
           
 T prev()
           Returns the previous element in this iteration.
 void remove()
           
 void removeCurrent()
          Remove current element.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.hypergraphdb.HGSearchResult
isOrdered
 

Constructor Detail

IndexResultSet

public IndexResultSet()

Construct an empty result set.


IndexResultSet

public IndexResultSet(BDBTxCursor cursor,
                      com.sleepycat.db.DatabaseEntry keyIn,
                      ByteArrayConverter<T> converter)

Construct a result set matching a specific key.

Parameters:
cursor -
key -
Method Detail

goTo

public HGRandomAccessResult.GotoResult goTo(T value,
                                            boolean exactMatch)
Description copied from interface: HGRandomAccessResult

Position the result set at a particular value if that value is indeed part of the result set.

Specified by:
goTo in interface HGRandomAccessResult<T>
Parameters:
value - The value where this result set should be positioned.
exactMatch - A flag indicating whether the passed in value should match exactly a value in the result set, or whether the cursor should be positioned to the closest value. Here "closest" means "smallest greater than the value parameter.
Returns:
A GotoResult.

close

public final void close()
Description copied from interface: HGSearchResult

Free all system resources held up by the result set and invalidate it for further use.

Specified by:
close in interface HGSearchResult<T>
Specified by:
close in interface CloseMe

current

public final T current()
Description copied from interface: HGSearchResult

Returns the current element in the result set. If there is no current element, java.util.NoSuchElementException is thrown. There is no current element in one of two cases: either the result set is empty or the next method was never invoked.

Specified by:
current in interface HGSearchResult<T>
Returns:
The current element in a HGSearchResult.

hasPrev

public final boolean hasPrev()
Description copied from interface: TwoWayIterator

Return true if there is a previous element in the current iteration state and false otherwise. After the iterator has been initialized, the value of hasPrev will always be false.

Specified by:
hasPrev in interface TwoWayIterator<T>

hasNext

public final boolean hasNext()
Specified by:
hasNext in interface java.util.Iterator<T>

prev

public final T prev()
Description copied from interface: TwoWayIterator

Returns the previous element in this iteration.

Specified by:
prev in interface TwoWayIterator<T>

next

public final T next()
Specified by:
next in interface java.util.Iterator<T>

remove

public final void remove()
Specified by:
remove in interface java.util.Iterator<T>

count

public int count()

removeCurrent

public void removeCurrent()
Remove current element. After that cursor becomes invalid, so next(), prev() operations will fail. However, a goTo operation should work.