org.garret.jsql
Interface QueryIterator

All Known Implementing Classes:
ArrayIterator, HashMapIterator, ListIterator, RecursiveIterator, ResultSetIterator

public interface QueryIterator

Interface for query iterator. Query iterator provides sequential or (and) direct access to the records in the table


Method Summary
 QueryIterator concurrentIterator()
          JSQL is able to perform sequential search in parallel.
 boolean getByKeyRange(java.lang.String key, java.lang.Object minValue, java.lang.Object maxValue, boolean inclusive, Query result)
          Try to use index to select objects belonginh to the specified range
 java.lang.Object getByPrimaryKey(java.lang.String primaryKey, java.lang.Object keyValue)
          Try to use index to locate object by unique primary key.
 java.lang.Object getFirst()
          Get first object.
 java.lang.Object getNext(java.lang.Object prevObj, int prevIndex)
          Get next object.
 boolean isThreadSafe()
          Check if it is possible to use iterator concurrently.
 boolean useNormalizedKeys()
          Check if iterator supporting direct access by key stores key values in normalized form (all integer types as Long, all real types as Double, other types as it is).
 

Method Detail

getFirst

public java.lang.Object getFirst()
Get first object.

Returns:
first object or null if there are no object to search.

getNext

public java.lang.Object getNext(java.lang.Object prevObj,
                                int prevIndex)
Get next object.

Parameters:
prevObj - reference returned by previous call of getNext or getFirst
prevIndex - index of previous object (starting from 0 for first object)
Returns:
next object or null if there are no more objects

getByPrimaryKey

public java.lang.Object getByPrimaryKey(java.lang.String primaryKey,
                                        java.lang.Object keyValue)
                                 throws NoIndexException
Try to use index to locate object by unique primary key.

Parameters:
primaryKey - name of primary key field. This files should be unique among all searched object.
keyValue - key value
Returns:
object with specified value of primary key or null if object was not found.
Throws:
NoIndexException - if there is no index for this field

getByKeyRange

public boolean getByKeyRange(java.lang.String key,
                             java.lang.Object minValue,
                             java.lang.Object maxValue,
                             boolean inclusive,
                             Query result)
Try to use index to select objects belonginh to the specified range

Parameters:
key - name of key field.
minValue - low bound for key value (if null, then there is no low bound
maxValue - high bound for key value (if null, then there is no high bound
inclusive - whether bounds are inclusive or exclusive
result - query to which records belongin to the specified range should be added using add method
Returns:
true if index is applicable, false otherwise

concurrentIterator

public QueryIterator concurrentIterator()
JSQL is able to perform sequential search in parallel. To be able to achive it, query iterator should is either reentrant either cloneable. The method concurrentIterator should either return this if iterator is reentrant, or clone the iterator. This method will be called prior any other access to the iterator by JSQL.

Returns:
this if iterator is reentrant or clone of iterator

isThreadSafe

public boolean isThreadSafe()
Check if it is possible to use iterator concurrently. JQSl is able to perform sequential search in parallel. Iterator should be reentrant or supports clone method to be use in multiple concurrent threads.

Returns:
true is iterator can be use in parallel search, false otherwise

useNormalizedKeys

public boolean useNormalizedKeys()
Check if iterator supporting direct access by key stores key values in normalized form (all integer types as Long, all real types as Double, other types as it is). Normalization of key value should be performed using Query.normilizeKeyValue method.
If this method returns false then JSQL will try to convert search literals to the type of the indexed field. But it is possible only if type of the field is known at query compilation time. Otherwise in case of using dynamic binding such covertsion should be performed by iterator itself using Query.castLiteral method.

Returns:
true if key values are stored in the index in normalized form