org.apache.gora.query.impl
Class ResultBase<K,T extends Persistent>

java.lang.Object
  extended by org.apache.gora.query.impl.ResultBase<K,T>
All Implemented Interfaces:
Closeable, Result<K,T>
Direct Known Subclasses:
AccumuloResult, AvroResult, CassandraResult, DataFileAvroResult, HBaseResult, MemStore.MemResult, SqlResult

public abstract class ResultBase<K,T extends Persistent>
extends Object
implements Result<K,T>

Base class for Result implementations.


Field Summary
protected  DataStore<K,T> dataStore
           
protected  K key
           
protected  long limit
          Query limit
protected  long offset
          How far we have proceeded
protected  T persistent
           
protected  Query<K,T> query
           
 
Constructor Summary
ResultBase(DataStore<K,T> dataStore, Query<K,T> query)
           
 
Method Summary
protected  void clear()
           
 T get()
          Returns the current object.
 DataStore<K,T> getDataStore()
          Returns the DataStore, that this Result is associated with.
 K getKey()
          Returns the current key.
 Class<K> getKeyClass()
          Returns the class of the keys
 long getOffset()
          Returns the number of times next() is called with return value true.
protected  T getOrCreatePersistent(T persistent)
           
 Class<T> getPersistentClass()
          Returns the class of the persistent objects
 Query<K,T> getQuery()
          Returns the Query object for this Result.
protected  boolean isLimitReached()
          Returns whether the limit for the query is reached.
 boolean next()
          Advances to the next element and returns false if at end.
protected abstract  boolean nextInner()
          next() calls this function to read the actual results.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.gora.query.Result
close, getProgress
 

Field Detail

dataStore

protected final DataStore<K,T extends Persistent> dataStore

query

protected final Query<K,T extends Persistent> query

key

protected K key

persistent

protected T extends Persistent persistent

limit

protected long limit
Query limit


offset

protected long offset
How far we have proceeded

Constructor Detail

ResultBase

public ResultBase(DataStore<K,T> dataStore,
                  Query<K,T> query)
Method Detail

getDataStore

public DataStore<K,T> getDataStore()
Description copied from interface: Result
Returns the DataStore, that this Result is associated with.

Specified by:
getDataStore in interface Result<K,T extends Persistent>
Returns:
the DataStore of the Result

getQuery

public Query<K,T> getQuery()
Description copied from interface: Result
Returns the Query object for this Result.

Specified by:
getQuery in interface Result<K,T extends Persistent>
Returns:
the Query object for this Result.

get

public T get()
Description copied from interface: Result
Returns the current object.

Specified by:
get in interface Result<K,T extends Persistent>
Returns:
current object

getKey

public K getKey()
Description copied from interface: Result
Returns the current key.

Specified by:
getKey in interface Result<K,T extends Persistent>
Returns:
current key

getKeyClass

public Class<K> getKeyClass()
Description copied from interface: Result
Returns the class of the keys

Specified by:
getKeyClass in interface Result<K,T extends Persistent>
Returns:
class of the keys

getPersistentClass

public Class<T> getPersistentClass()
Description copied from interface: Result
Returns the class of the persistent objects

Specified by:
getPersistentClass in interface Result<K,T extends Persistent>
Returns:
class of the persistent objects

isLimitReached

protected boolean isLimitReached()
Returns whether the limit for the query is reached.


clear

protected void clear()

next

public final boolean next()
                   throws IOException
Description copied from interface: Result
Advances to the next element and returns false if at end.

Specified by:
next in interface Result<K,T extends Persistent>
Returns:
true if end is not reached yet
Throws:
IOException

getOffset

public long getOffset()
Description copied from interface: Result
Returns the number of times next() is called with return value true.

Specified by:
getOffset in interface Result<K,T extends Persistent>
Returns:
the number of results so far

nextInner

protected abstract boolean nextInner()
                              throws IOException
next() calls this function to read the actual results.

Throws:
IOException

getOrCreatePersistent

protected T getOrCreatePersistent(T persistent)
                                              throws IOException
Throws:
IOException


Copyright © 2010-2012 The Apache Software Foundation. All Rights Reserved.