org.garret.jsql
Class HashMapIterator

java.lang.Object
  extended byorg.garret.jsql.HashMapIterator
All Implemented Interfaces:
java.lang.Cloneable, QueryIterator

public class HashMapIterator
extends java.lang.Object
implements QueryIterator, java.lang.Cloneable

Query iterator using hash table


Constructor Summary
HashMapIterator(java.lang.String key)
          Constructor of hash iterator
 
Method Summary
 void add(java.lang.Object obj, java.lang.Object keyValue)
          Add new object
 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 key, 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.
 void remove(java.lang.Object keyValue)
          Remove object with specified key
 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).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HashMapIterator

public HashMapIterator(java.lang.String key)
Constructor of hash iterator

Parameters:
key - primary key name
Method Detail

getByPrimaryKey

public java.lang.Object getByPrimaryKey(java.lang.String key,
                                        java.lang.Object keyValue)
Description copied from interface: QueryIterator
Try to use index to locate object by unique primary key.

Specified by:
getByPrimaryKey in interface QueryIterator
Parameters:
key - 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.

getFirst

public java.lang.Object getFirst()
Description copied from interface: QueryIterator
Get first object.

Specified by:
getFirst in interface QueryIterator
Returns:
first object or null if there are no object to search.

getNext

public java.lang.Object getNext(java.lang.Object prevObj,
                                int prevIndex)
Description copied from interface: QueryIterator
Get next object.

Specified by:
getNext in interface QueryIterator
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

getByKeyRange

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

Specified by:
getByKeyRange in interface QueryIterator
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()
Description copied from interface: QueryIterator
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.

Specified by:
concurrentIterator in interface QueryIterator
Returns:
this if iterator is reentrant or clone of iterator

isThreadSafe

public boolean isThreadSafe()
Description copied from interface: QueryIterator
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.

Specified by:
isThreadSafe in interface QueryIterator
Returns:
true is iterator can be use in parallel search, false otherwise

useNormalizedKeys

public boolean useNormalizedKeys()
Description copied from interface: QueryIterator
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.

Specified by:
useNormalizedKeys in interface QueryIterator
Returns:
true if key values are stored in the index in normalized form

add

public void add(java.lang.Object obj,
                java.lang.Object keyValue)
Add new object

Parameters:
obj - new object
keyValue - value of primary key for this object

remove

public void remove(java.lang.Object keyValue)
Remove object with specified key

Parameters:
keyValue - value of the primary key for removed object