Infinispan Distribution 5.2.6.Final-redhat-2

org.infinispan.query.impl
Class CacheQueryImpl

java.lang.Object
  extended by org.infinispan.query.impl.CacheQueryImpl
All Implemented Interfaces:
Iterable<Object>, CacheQuery
Direct Known Subclasses:
ClusteredCacheQueryImpl

public class CacheQueryImpl
extends Object
implements CacheQuery

Implementation class of the CacheQuery interface.

Author:
Navin Surtani, Sanne Grinovero (C) 2011 Red Hat Inc., Marko Luksa

Field Summary
protected  AdvancedCache<?,?> cache
           
protected  org.hibernate.search.query.engine.spi.HSQuery hSearchQuery
           
protected  KeyTransformationHandler keyTransformationHandler
           
 
Constructor Summary
CacheQueryImpl(org.apache.lucene.search.Query luceneQuery, org.hibernate.search.spi.SearchFactoryIntegrator searchFactory, AdvancedCache<?,?> cache, KeyTransformationHandler keyTransformationHandler, Class<?>... classes)
           
CacheQueryImpl(org.apache.lucene.search.Query luceneQuery, org.hibernate.search.spi.SearchFactoryIntegrator searchFactory, AdvancedCache<?,?> cache, KeyTransformationHandler keyTransformationHandler, org.hibernate.search.query.engine.spi.TimeoutExceptionFactory timeoutExceptionFactory, Class<?>... classes)
           
 
Method Summary
 CacheQuery disableFullTextFilter(String name)
          Disable a given filter by its name.
 org.hibernate.search.FullTextFilter enableFullTextFilter(String name)
          Enable a given filter by its name.
 org.apache.lucene.search.Explanation explain(int documentId)
          Return the Lucene Explanation object describing the score computation for the matching object/document in the current query
 CacheQuery filter(org.apache.lucene.search.Filter filter)
          Takes in a lucene filter and sets it to the filter field in the class.
 CacheQuery firstResult(int firstResult)
          Sets the the result of the given integer value to the first result.
 org.hibernate.search.query.engine.spi.FacetManager getFacetManager()
           
 int getResultSize()
          Gets the integer number of results.
 ResultIterator iterator()
          Returns the results of a search as a ResultIterator.
 ResultIterator iterator(FetchOptions fetchOptions)
          Returns the results of a search as a ResultIterator.
 List<Object> list()
          Returns the results of a search as a list.
 CacheQuery maxResults(int maxResults)
          Sets the maximum number of results to the number passed in as a parameter.
 CacheQuery projection(String... fields)
          Defines the Lucene field names projected and returned in a query result Each field is converted back to it's object representation, an Object[] being returned for each "row"

A projectable field must be stored in the Lucene index and use a TwoWayFieldBridge Unless notified in their JavaDoc, all built-in bridges are two-way.

 CacheQuery sort(org.apache.lucene.search.Sort sort)
          Allows lucene to sort the results.
 CacheQuery timeout(long timeout, TimeUnit timeUnit)
          Set the timeout for this query.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cache

protected final AdvancedCache<?,?> cache

keyTransformationHandler

protected final KeyTransformationHandler keyTransformationHandler

hSearchQuery

protected org.hibernate.search.query.engine.spi.HSQuery hSearchQuery
Constructor Detail

CacheQueryImpl

public CacheQueryImpl(org.apache.lucene.search.Query luceneQuery,
                      org.hibernate.search.spi.SearchFactoryIntegrator searchFactory,
                      AdvancedCache<?,?> cache,
                      KeyTransformationHandler keyTransformationHandler,
                      Class<?>... classes)

CacheQueryImpl

public CacheQueryImpl(org.apache.lucene.search.Query luceneQuery,
                      org.hibernate.search.spi.SearchFactoryIntegrator searchFactory,
                      AdvancedCache<?,?> cache,
                      KeyTransformationHandler keyTransformationHandler,
                      org.hibernate.search.query.engine.spi.TimeoutExceptionFactory timeoutExceptionFactory,
                      Class<?>... classes)
Method Detail

filter

public CacheQuery filter(org.apache.lucene.search.Filter filter)
Takes in a lucene filter and sets it to the filter field in the class.

Specified by:
filter in interface CacheQuery
Parameters:
filter - - lucene filter

getResultSize

public int getResultSize()
Description copied from interface: CacheQuery
Gets the integer number of results.

Specified by:
getResultSize in interface CacheQuery
Returns:
The result size of the query.

sort

public CacheQuery sort(org.apache.lucene.search.Sort sort)
Description copied from interface: CacheQuery
Allows lucene to sort the results. Integers are sorted in descending order.

Specified by:
sort in interface CacheQuery
Parameters:
sort - - lucene sort object

enableFullTextFilter

public org.hibernate.search.FullTextFilter enableFullTextFilter(String name)
Enable a given filter by its name.

Specified by:
enableFullTextFilter in interface CacheQuery
Parameters:
name - of filter.
Returns:
a FullTextFilter object.

disableFullTextFilter

public CacheQuery disableFullTextFilter(String name)
Disable a given filter by its name.

Specified by:
disableFullTextFilter in interface CacheQuery
Parameters:
name - of filter.

firstResult

public CacheQuery firstResult(int firstResult)
Sets the the result of the given integer value to the first result.

Specified by:
firstResult in interface CacheQuery
Parameters:
firstResult - index to be set.
Throws:
IllegalArgumentException - if the index given is less than zero.

maxResults

public CacheQuery maxResults(int maxResults)
Description copied from interface: CacheQuery
Sets the maximum number of results to the number passed in as a parameter.

Specified by:
maxResults in interface CacheQuery
Parameters:
maxResults - that are to be set to the maxResults.

iterator

public ResultIterator iterator()
                        throws org.hibernate.search.SearchException
Description copied from interface: CacheQuery
Returns the results of a search as a ResultIterator. This calls CacheQuery.iterator(FetchOptions fetchOptions) with default FetchOptions; this implies eager loading of all results.

Specified by:
iterator in interface Iterable<Object>
Specified by:
iterator in interface CacheQuery
Returns:
a ResultIterator which can be used to iterate through the results that were found.
Throws:
org.hibernate.search.SearchException

iterator

public ResultIterator iterator(FetchOptions fetchOptions)
                        throws org.hibernate.search.SearchException
Description copied from interface: CacheQuery
Returns the results of a search as a ResultIterator. Warning: the return type is an extension of Iterator which introduces a ResultIterator.close() method. This close method needs to be invoked when the iteration is complete to avoid resource leakage.

Specified by:
iterator in interface CacheQuery
Parameters:
fetchOptions - how to fetch results (see @link FetchOptions)
Returns:
a QueryResultIterator which can be used to iterate through the results that were found.
Throws:
org.hibernate.search.SearchException

list

public List<Object> list()
                  throws org.hibernate.search.SearchException
Description copied from interface: CacheQuery
Returns the results of a search as a list.

Specified by:
list in interface CacheQuery
Returns:
list of objects that were found from the search.
Throws:
org.hibernate.search.SearchException

getFacetManager

public org.hibernate.search.query.engine.spi.FacetManager getFacetManager()
Specified by:
getFacetManager in interface CacheQuery
Returns:
return the manager for all faceting related operations

explain

public org.apache.lucene.search.Explanation explain(int documentId)
Description copied from interface: CacheQuery
Return the Lucene Explanation object describing the score computation for the matching object/document in the current query

Specified by:
explain in interface CacheQuery
Parameters:
documentId - Lucene Document id to be explain. This is NOT the object key
Returns:
Lucene Explanation

projection

public CacheQuery projection(String... fields)
Description copied from interface: CacheQuery
Defines the Lucene field names projected and returned in a query result Each field is converted back to it's object representation, an Object[] being returned for each "row"

A projectable field must be stored in the Lucene index and use a TwoWayFieldBridge Unless notified in their JavaDoc, all built-in bridges are two-way. All @DocumentId fields are projectable by design.

If the projected field is not a projectable field, null is returned in the object[]

Specified by:
projection in interface CacheQuery
Parameters:
fields - the projected field names
Returns:
this to allow for method chaining

timeout

public CacheQuery timeout(long timeout,
                          TimeUnit timeUnit)
Description copied from interface: CacheQuery
Set the timeout for this query. If the query hasn't finished processing before the timeout, an exception will be thrown.

Specified by:
timeout in interface CacheQuery
Parameters:
timeout - the timeout duration
timeUnit - the time unit of the timeout parameter
Returns:

Infinispan Distribution 5.2.6.Final-redhat-2

Copyright © 2013 JBoss, a division of Red Hat. All Rights Reserved.