org.compass.gps.device.hibernate.indexer
Class ScrollableHibernateIndexEntitiesIndexer

java.lang.Object
  extended by org.compass.gps.device.hibernate.indexer.ScrollableHibernateIndexEntitiesIndexer
All Implemented Interfaces:
HibernateIndexEntitiesIndexer, IndexEntitiesIndexer

public class ScrollableHibernateIndexEntitiesIndexer
extends Object
implements HibernateIndexEntitiesIndexer

A Hibernate indexer uses Hibernate ScrollableResults to index the database instead of using setFirstResult and setMaxResults. Using scrollable results yields better performance especially for large result set.

First tries to call HibernateQueryProvider.createCriteria(org.hibernate.Session, org.compass.gps.device.hibernate.entities.EntityInformation) in order to use Hibernate Criteria to construct the cursor. If no criteria is returned (null is returned), Hibernate Query is used by calling HibernateQueryProvider.createQuery(org.hibernate.Session, org.compass.gps.device.hibernate.entities.EntityInformation).

When using Criteria, by default, orders the results by entity id. This can be turned off either globablly using setPerformOrderById(boolean), or per entity using setPerformOrderById(String, boolean).

Author:
kimchy

Constructor Summary
ScrollableHibernateIndexEntitiesIndexer()
           
 
Method Summary
 void performIndex(CompassSession session, IndexEntity[] entities)
          Performs the actual indexing of the list of index entities.
 void setHibernateGpsDevice(HibernateGpsDevice device)
          Sets the Hibernate gps device for the given indexer.
 void setPerformOrderById(boolean performOrderById)
          Should this indxer order by the ids when Criteria is available.
 void setPerformOrderById(String entity, boolean performOrderById)
          Should this indxer order by the ids when Criteria is available for the given entity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScrollableHibernateIndexEntitiesIndexer

public ScrollableHibernateIndexEntitiesIndexer()
Method Detail

setHibernateGpsDevice

public void setHibernateGpsDevice(HibernateGpsDevice device)
Description copied from interface: HibernateIndexEntitiesIndexer
Sets the Hibernate gps device for the given indexer. Called once when the device starts up.

Specified by:
setHibernateGpsDevice in interface HibernateIndexEntitiesIndexer

setPerformOrderById

public void setPerformOrderById(boolean performOrderById)
Should this indxer order by the ids when Criteria is available. Defaults to true.


setPerformOrderById

public void setPerformOrderById(String entity,
                                boolean performOrderById)
Should this indxer order by the ids when Criteria is available for the given entity. Defaults to setPerformOrderById(boolean).


performIndex

public void performIndex(CompassSession session,
                         IndexEntity[] entities)
Description copied from interface: IndexEntitiesIndexer
Performs the actual indexing of the list of index entities. Usually, an index entity represent a group of indexable content (like a certain class when using ORM, or a select statement). This method perform the fetching of the data and indexing it in Compass using the provided Compass session.

Specified by:
performIndex in interface IndexEntitiesIndexer
Parameters:
session - The compass session to index the data with
entities - A list of entities to perform the indexing by


Copyright (c) 2004-2009 The Compass Project.