org.trippi.impl.base
Class PoolAwareTupleIterator

java.lang.Object
  extended by org.trippi.TupleIterator
      extended by org.trippi.impl.base.PoolAwareTupleIterator

public class PoolAwareTupleIterator
extends TupleIterator

Wraps an TupleIterator and automatically releases the associated session to the pool when closed.

Author:
cwilper@cs.cornell.edu

Field Summary
 
Fields inherited from class org.trippi.TupleIterator
INPUT_FORMATS, OUTPUT_FORMATS
 
Constructor Summary
PoolAwareTupleIterator(TupleIterator iter, TriplestoreSession session, TriplestoreSessionPool pool)
           
 
Method Summary
 void close()
          Close the wrapped iterator and release the session to the pool.
 void finalize()
          Ensure close() gets called at garbage collection time.
 boolean hasNext()
          Return true if there are more results.
 java.lang.String[] names()
          Get the names of the binding variables.
 java.util.Map next()
          Return the next result.
 java.util.List nextTriples(TriplePattern[] patterns)
          Return the next result as a List of Triple objects.
 
Methods inherited from class org.trippi.TupleIterator
count, fromStream, main, setAliasMap, toStream
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PoolAwareTupleIterator

public PoolAwareTupleIterator(TupleIterator iter,
                              TriplestoreSession session,
                              TriplestoreSessionPool pool)
Method Detail

hasNext

public boolean hasNext()
                throws TrippiException
Description copied from class: TupleIterator
Return true if there are more results.

Specified by:
hasNext in class TupleIterator
Throws:
TrippiException

next

public java.util.Map next()
                   throws TrippiException
Description copied from class: TupleIterator
Return the next result.

Specified by:
next in class TupleIterator
Throws:
TrippiException

nextTriples

public java.util.List nextTriples(TriplePattern[] patterns)
                           throws TrippiException
Description copied from class: TupleIterator
Return the next result as a List of Triple objects.

Overrides:
nextTriples in class TupleIterator
Throws:
TrippiException

names

public java.lang.String[] names()
                         throws TrippiException
Description copied from class: TupleIterator
Get the names of the binding variables. These will be the keys in the map for result.

Specified by:
names in class TupleIterator
Throws:
TrippiException

close

public void close()
           throws TrippiException
Close the wrapped iterator and release the session to the pool.

Specified by:
close in class TupleIterator
Throws:
TrippiException

finalize

public void finalize()
              throws TrippiException
Ensure close() gets called at garbage collection time.

Overrides:
finalize in class TupleIterator
Throws:
TrippiException