[infinispan-commits] Infinispan SVN: r846 - in trunk/query/src: main/java/org/infinispan/query/backend and 5 other directories.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Wed Sep 23 12:16:54 EDT 2009
Author: manik.surtani at jboss.com
Date: 2009-09-23 12:16:53 -0400 (Wed, 23 Sep 2009)
New Revision: 846
Added:
trunk/query/src/test/java/org/infinispan/query/helper/TestQueryHelperFactory.java
Removed:
trunk/query/src/test/java/org/infinispan/query/helper/IndexCleanUp.java
Modified:
trunk/query/src/main/java/org/infinispan/query/CacheQuery.java
trunk/query/src/main/java/org/infinispan/query/QueryFactory.java
trunk/query/src/main/java/org/infinispan/query/QueryIterator.java
trunk/query/src/main/java/org/infinispan/query/Version.java
trunk/query/src/main/java/org/infinispan/query/backend/IndexSearcherCloser.java
trunk/query/src/main/java/org/infinispan/query/backend/LocalQueryInterceptor.java
trunk/query/src/main/java/org/infinispan/query/backend/QueryHelper.java
trunk/query/src/main/java/org/infinispan/query/backend/QueryInterceptor.java
trunk/query/src/main/java/org/infinispan/query/backend/SearchableCacheConfiguration.java
trunk/query/src/main/java/org/infinispan/query/backend/TransactionalEventTransactionContext.java
trunk/query/src/main/java/org/infinispan/query/impl/AbstractIterator.java
trunk/query/src/main/java/org/infinispan/query/impl/CacheQueryImpl.java
trunk/query/src/main/java/org/infinispan/query/impl/EagerIterator.java
trunk/query/src/main/java/org/infinispan/query/impl/LazyIterator.java
trunk/query/src/test/java/org/infinispan/query/blackbox/BrokenAnnotationTest.java
trunk/query/src/test/java/org/infinispan/query/blackbox/ClusteredCacheTest.java
trunk/query/src/test/java/org/infinispan/query/blackbox/LocalCacheProfilerTest.java
trunk/query/src/test/java/org/infinispan/query/blackbox/LocalCacheTest.java
trunk/query/src/test/java/org/infinispan/query/impl/EagerIteratorTest.java
trunk/query/src/test/java/org/infinispan/query/impl/LazyIteratorTest.java
trunk/query/src/test/java/org/infinispan/query/test/BrokenDocumentId.java
trunk/query/src/test/java/org/infinispan/query/test/BrokenProvided.java
trunk/query/src/test/java/org/infinispan/query/test/Person.java
Log:
* Reformatted code
* Updated tests to use a RAM based index store
* Other minor tweaks to tests to make them more reliable
Modified: trunk/query/src/main/java/org/infinispan/query/CacheQuery.java
===================================================================
--- trunk/query/src/main/java/org/infinispan/query/CacheQuery.java 2009-09-23 15:39:26 UTC (rev 845)
+++ trunk/query/src/main/java/org/infinispan/query/CacheQuery.java 2009-09-23 16:16:53 UTC (rev 846)
@@ -29,17 +29,17 @@
import java.util.List;
/**
- * A cache-query is what will be returned when the getQuery() method is run on {@link QueryFactory}. This object can have methods such
- * as list, setFirstResult,setMaxResults, setFetchSize, getResultSize and setSort.
- *
+ * A cache-query is what will be returned when the getQuery() method is run on {@link QueryFactory}. This object can
+ * have methods such as list, setFirstResult,setMaxResults, setFetchSize, getResultSize and setSort.
* <p/>
+ * <p/>
+ *
* @author Manik Surtani
* @author Navin Surtani
* @see QueryFactory#getQuery(org.apache.lucene.search.Query)
- * @see QueryFactory#getBasicQuery(String, String)
+ * @see QueryFactory#getBasicQuery(String, String)
*/
-public interface CacheQuery extends Iterable
-{
+public interface CacheQuery extends Iterable {
/**
* Returns the results of a search as a list.
*
@@ -49,8 +49,7 @@
List<Object> list();
/**
- * Returns the results of a search as a {@link QueryIterator} with a given
- * integer parameter - the fetchSize.
+ * Returns the results of a search as a {@link QueryIterator} with a given integer parameter - the fetchSize.
*
* @param fetchSize integer to be given to the implementation constructor.
* @return a QueryResultIterator which can be used to iterate through the results that were found.
@@ -60,7 +59,7 @@
/**
* Returns the results of a search as a {@link QueryIterator}. This calls {@link CacheQuery#iterator(int fetchSize)}
- * but uses a default fetchSize of 1.
+ * but uses a default fetchSize of 1.
*
* @return a QueryResultIterator which can be used to iterate through the results that were found.
*/
@@ -68,8 +67,8 @@
QueryIterator iterator();
/**
- * Lazily loads the results from the Query as a {@link QueryIterator} with a given
- * integer parameter - the fetchSize.
+ * Lazily loads the results from the Query as a {@link QueryIterator} with a given integer parameter - the
+ * fetchSize.
*
* @param fetchSize integer to be passed into the lazy implementation of {@link QueryIterator}
* @return a QueryResultIterator which can be used to <B>lazily</B> iterate through results.
@@ -144,6 +143,4 @@
public void setFilter(Filter f);
-
-
}
Modified: trunk/query/src/main/java/org/infinispan/query/QueryFactory.java
===================================================================
--- trunk/query/src/main/java/org/infinispan/query/QueryFactory.java 2009-09-23 15:39:26 UTC (rev 845)
+++ trunk/query/src/main/java/org/infinispan/query/QueryFactory.java 2009-09-23 16:16:53 UTC (rev 846)
@@ -5,14 +5,12 @@
import org.apache.lucene.search.Query;
import org.hibernate.search.engine.SearchFactoryImplementor;
import org.infinispan.Cache;
-import org.infinispan.query.impl.CacheQueryImpl;
import org.infinispan.query.backend.QueryHelper;
+import org.infinispan.query.impl.CacheQueryImpl;
/**
* Class that is used to build {@link org.infinispan.query.CacheQuery}
*
- *
- *
* @author Navin Surtani
* @since 4.0
*/
@@ -23,7 +21,7 @@
private Cache cache;
private SearchFactoryImplementor searchFactory;
- public QueryFactory(Cache cache, QueryHelper qh){
+ public QueryFactory(Cache cache, QueryHelper qh) {
this.cache = cache;
searchFactory = qh.getSearchFactory();
}
@@ -35,28 +33,29 @@
* @return the query result
*/
- public CacheQuery getQuery(Query luceneQuery){
+ public CacheQuery getQuery(Query luceneQuery) {
return new CacheQueryImpl(luceneQuery, searchFactory, cache);
}
/**
- * This method is a basic query. The user provides 2 strings and internally the {@link org.apache.lucene.search.Query} is built.
- *
+ * This method is a basic query. The user provides 2 strings and internally the {@link
+ * org.apache.lucene.search.Query} is built.
+ * <p/>
* The first string is the field that they are searching and the second one is the search that they want to run.
- *
+ * <p/>
* For example: -
- *
+ * <p/>
* {@link org.infinispan.query.CacheQuery} cq = new QueryFactory
+ * <p/>
+ * The query is built by use of a {@link org.apache.lucene.queryParser.QueryParser} and a {@link
+ * org.apache.lucene.analysis.standard.StandardAnalyzer} </p>
*
- * The query is built by use of a {@link org.apache.lucene.queryParser.QueryParser} and a {@link org.apache.lucene.analysis.standard.StandardAnalyzer}
- * </p>
- *
- * @param field - the field on the class that you are searching
+ * @param field - the field on the class that you are searching
* @param search - the String that you want to be using to search
* @return {@link org.infinispan.query.CacheQuery} result
*/
- public CacheQuery getBasicQuery(String field, String search) throws org.apache.lucene.queryParser.ParseException{
+ public CacheQuery getBasicQuery(String field, String search) throws org.apache.lucene.queryParser.ParseException {
QueryParser parser = new QueryParser(field, new StandardAnalyzer());
org.apache.lucene.search.Query luceneQuery = parser.parse(search);
Modified: trunk/query/src/main/java/org/infinispan/query/QueryIterator.java
===================================================================
--- trunk/query/src/main/java/org/infinispan/query/QueryIterator.java 2009-09-23 15:39:26 UTC (rev 845)
+++ trunk/query/src/main/java/org/infinispan/query/QueryIterator.java 2009-09-23 16:16:53 UTC (rev 846)
@@ -18,7 +18,7 @@
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
+ */
package org.infinispan.query;
@@ -27,11 +27,11 @@
/**
* Iterates over query results
* <p/>
+ *
* @author Manik Surtani
- * @author Navin Surtani
+ * @author Navin Surtani
*/
-public interface QueryIterator extends ListIterator
-{
+public interface QueryIterator extends ListIterator {
/**
* Jumps to a specific index in the iterator.
*
@@ -81,7 +81,7 @@
boolean isBeforeLast();
/**
- * This method must be called on your iterator once you have finished so that Lucene resources can be freed up.
+ * This method must be called on your iterator once you have finished so that Lucene resources can be freed up.
*/
void close();
Modified: trunk/query/src/main/java/org/infinispan/query/Version.java
===================================================================
--- trunk/query/src/main/java/org/infinispan/query/Version.java 2009-09-23 15:39:26 UTC (rev 845)
+++ trunk/query/src/main/java/org/infinispan/query/Version.java 2009-09-23 16:16:53 UTC (rev 846)
@@ -5,12 +5,11 @@
*
* @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
*/
-public class Version
-{
+public class Version {
//version string - should correspond with the version in the pom
private static final String version = "1.0.0-SNAPSHOT";
- public static void main(String[] args)
- {
+
+ public static void main(String[] args) {
System.out.println("\nJBoss Cache Searchable Edition\nVersion:\t" + version + "\n\n");
}
}
Modified: trunk/query/src/main/java/org/infinispan/query/backend/IndexSearcherCloser.java
===================================================================
--- trunk/query/src/main/java/org/infinispan/query/backend/IndexSearcherCloser.java 2009-09-23 15:39:26 UTC (rev 845)
+++ trunk/query/src/main/java/org/infinispan/query/backend/IndexSearcherCloser.java 2009-09-23 16:16:53 UTC (rev 846)
@@ -30,20 +30,19 @@
import java.util.Set;
/**
- * Class with static method that is called by {@link org.infinispan.query.impl.CacheQueryImpl} and {@link org.infinispan.query.impl.EagerIterator}
- * <p />
- *
+ * Class with static method that is called by {@link org.infinispan.query.impl.CacheQueryImpl} and {@link
+ * org.infinispan.query.impl.EagerIterator}
+ * <p/>
+ * <p/>
* Simply an abstraction for one method to reduce unneccesary code replication.
+ *
* @author Navin Surtani
*/
- public class IndexSearcherCloser
-{
- public static void closeSearcher(Searcher searcher, ReaderProvider readerProvider)
- {
+public class IndexSearcherCloser {
+ public static void closeSearcher(Searcher searcher, ReaderProvider readerProvider) {
Set<IndexReader> indexReaders = getIndexReaders(searcher);
- for (IndexReader indexReader : indexReaders)
- {
+ for (IndexReader indexReader : indexReaders) {
readerProvider.closeReader(indexReader);
}
}
Modified: trunk/query/src/main/java/org/infinispan/query/backend/LocalQueryInterceptor.java
===================================================================
--- trunk/query/src/main/java/org/infinispan/query/backend/LocalQueryInterceptor.java 2009-09-23 15:39:26 UTC (rev 845)
+++ trunk/query/src/main/java/org/infinispan/query/backend/LocalQueryInterceptor.java 2009-09-23 16:16:53 UTC (rev 846)
@@ -1,12 +1,12 @@
package org.infinispan.query.backend;
import org.hibernate.search.engine.SearchFactoryImplementor;
-import org.infinispan.factories.annotations.Inject;
-import org.infinispan.context.InvocationContext;
import org.infinispan.commands.write.PutKeyValueCommand;
+import org.infinispan.commands.write.PutMapCommand;
import org.infinispan.commands.write.RemoveCommand;
import org.infinispan.commands.write.ReplaceCommand;
-import org.infinispan.commands.write.PutMapCommand;
+import org.infinispan.context.InvocationContext;
+import org.infinispan.factories.annotations.Inject;
import javax.transaction.TransactionManager;
import java.util.Map;
@@ -15,7 +15,8 @@
* <p/>
* This class is an interceptor that will index data only if it has come from a local source.
* <p/>
- * Currently, this is a property that is determined by setting "infinispan.query.indexLocalOnly" as a System property to "true".
+ * Currently, this is a property that is determined by setting "infinispan.query.indexLocalOnly" as a System property to
+ * "true".
*
* @author Navin Surtani
* @since 4.0
Modified: trunk/query/src/main/java/org/infinispan/query/backend/QueryHelper.java
===================================================================
--- trunk/query/src/main/java/org/infinispan/query/backend/QueryHelper.java 2009-09-23 15:39:26 UTC (rev 845)
+++ trunk/query/src/main/java/org/infinispan/query/backend/QueryHelper.java 2009-09-23 16:16:53 UTC (rev 846)
@@ -4,10 +4,11 @@
import org.hibernate.search.engine.SearchFactoryImplementor;
import org.hibernate.search.impl.SearchFactoryImpl;
import org.infinispan.Cache;
+import org.infinispan.CacheException;
import org.infinispan.factories.ComponentRegistry;
import org.infinispan.factories.InterceptorChainFactory;
+import org.infinispan.interceptors.LockingInterceptor;
import org.infinispan.interceptors.base.CommandInterceptor;
-import org.infinispan.interceptors.LockingInterceptor;
import org.infinispan.util.logging.Log;
import org.infinispan.util.logging.LogFactory;
@@ -18,10 +19,10 @@
* <p/>
* This is a TEMPORARY helper class that will be used to add the QueryInterceptor to the chain and provide Classes to
* Hibernate Search.
+ * <p/>
+ * This class needs to be instantiated and then have applyProperties() called on it. This class WILL be removed once
+ * other hooks come into Infinispan for versions 4.1 etc.
*
- * This class needs to be instantiated and then have applyProperties() called on it. This class WILL be removed once other hooks come into Infinispan
- * for versions 4.1 etc.
- *
* @author Navin Surtani
* @since 4.0
*/
@@ -30,7 +31,7 @@
public class QueryHelper {
public static final String QUERY_ENABLED_PROPERTY = "infinispan.query.enabled";
- public static final String QUERY_INDEX_LOCAL_ONLY_PROPERTY = "infinispan.query.indexLocalOnly";
+ public static final String QUERY_INDEX_LOCAL_ONLY_PROPERTY = "infinispan.query.indexLocalOnly";
private Cache cache;
private Properties properties;
@@ -77,7 +78,7 @@
SearchConfiguration cfg = new SearchableCacheConfiguration(classes, properties);
searchFactory = new SearchFactoryImpl(cfg);
-
+ applyProperties();
}
/**
@@ -93,14 +94,9 @@
* <p/>
* Anything put before calling this method will NOT not be picked up by the {@link QueryInterceptor} and hence not be
* indexed.
- *
- * @throws Exception
*/
- public void applyProperties()
- throws Exception {
-
-
+ private void applyProperties() {
if (log.isDebugEnabled()) log.debug("Entered QueryHelper.applyProperties()");
// If the query property is set to true, i.e. we want to query objects in the cache, then we need to add the QueryInterceptor.
@@ -110,15 +106,19 @@
boolean indexLocal = Boolean.getBoolean(QUERY_INDEX_LOCAL_ONLY_PROPERTY);
- if (indexLocal) {
- // Add a LocalQueryInterceptor to the chain
- addInterceptor(LocalQueryInterceptor.class);
- }
- // We're indexing data even if it comes from other sources
+ try {
+ if (indexLocal) {
+ // Add a LocalQueryInterceptor to the chain
+ addInterceptor(LocalQueryInterceptor.class);
+ }
+ // We're indexing data even if it comes from other sources
- else {
- // Add in a QueryInterceptor to the chain
- addInterceptor(QueryInterceptor.class);
+ else {
+ // Add in a QueryInterceptor to the chain
+ addInterceptor(QueryInterceptor.class);
+ }
+ } catch (Exception e) {
+ throw new CacheException("Unable to add interceptor", e);
}
}
}
@@ -164,7 +164,7 @@
// get the component registry and then register the searchFactory.
ComponentRegistry cr = cache.getAdvancedCache().getComponentRegistry();
cr.registerComponent(searchFactory, SearchFactoryImplementor.class);
-
+
// Get the interceptor chain factory so I can create my interceptor.
InterceptorChainFactory icf = cr.getComponent(InterceptorChainFactory.class);
Modified: trunk/query/src/main/java/org/infinispan/query/backend/QueryInterceptor.java
===================================================================
--- trunk/query/src/main/java/org/infinispan/query/backend/QueryInterceptor.java 2009-09-23 15:39:26 UTC (rev 845)
+++ trunk/query/src/main/java/org/infinispan/query/backend/QueryInterceptor.java 2009-09-23 16:16:53 UTC (rev 846)
@@ -17,9 +17,9 @@
/**
* This interceptor will be created when the System Property "infinispan.query.indexLocalOnly" is "false"
- *
+ * <p/>
* This type of interceptor will allow the indexing of data even when it comes from other caches within a cluster.
- *
+ * <p/>
* However, if the a cache would not be putting the data locally, the interceptor will not index it.
*
* @author Navin Surtani
@@ -46,7 +46,7 @@
// This method will get the put() calls on the cache and then send them into Lucene once it's successful.
- if (log.isDebugEnabled())log.debug("Entered the searchable core interceptor visitPutKeyValueCommand()");
+ if (log.isDebugEnabled()) log.debug("Entered the searchable core interceptor visitPutKeyValueCommand()");
// do the actual put first.
Object toReturn = invokeNextInterceptor(ctx, command);
Modified: trunk/query/src/main/java/org/infinispan/query/backend/SearchableCacheConfiguration.java
===================================================================
--- trunk/query/src/main/java/org/infinispan/query/backend/SearchableCacheConfiguration.java 2009-09-23 15:39:26 UTC (rev 845)
+++ trunk/query/src/main/java/org/infinispan/query/backend/SearchableCacheConfiguration.java 2009-09-23 16:16:53 UTC (rev 846)
@@ -22,13 +22,13 @@
package org.infinispan.query.backend;
+import org.hibernate.annotations.common.reflection.ReflectionManager;
import org.hibernate.search.cfg.SearchConfiguration;
-import org.hibernate.annotations.common.reflection.ReflectionManager;
+import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
import java.util.Properties;
-import java.util.Map;
-import java.util.HashMap;
/**
* Class that implements {@link org.hibernate.search.cfg.SearchConfiguration} so that within Infinispan-Query, there is
Modified: trunk/query/src/main/java/org/infinispan/query/backend/TransactionalEventTransactionContext.java
===================================================================
--- trunk/query/src/main/java/org/infinispan/query/backend/TransactionalEventTransactionContext.java 2009-09-23 15:39:26 UTC (rev 845)
+++ trunk/query/src/main/java/org/infinispan/query/backend/TransactionalEventTransactionContext.java 2009-09-23 16:16:53 UTC (rev 846)
@@ -35,8 +35,8 @@
* transaction context information from the {@link javax.transaction.TransactionManager} that gets passed in as a
* parameter upon instantiation.
* <p/>
- * It is used by the {@link QueryInterceptor} to pass transaction information to a
- * Hibernate Search {@link org.hibernate.search.backend.Work} object.
+ * It is used by the {@link QueryInterceptor} to pass transaction information to a Hibernate Search {@link
+ * org.hibernate.search.backend.Work} object.
* <p/>
* <p/>
*
Modified: trunk/query/src/main/java/org/infinispan/query/impl/AbstractIterator.java
===================================================================
--- trunk/query/src/main/java/org/infinispan/query/impl/AbstractIterator.java 2009-09-23 15:39:26 UTC (rev 845)
+++ trunk/query/src/main/java/org/infinispan/query/impl/AbstractIterator.java 2009-09-23 16:16:53 UTC (rev 846)
@@ -66,5 +66,5 @@
public boolean hasNext() {
return index <= max;
}
-
+
}
Modified: trunk/query/src/main/java/org/infinispan/query/impl/CacheQueryImpl.java
===================================================================
--- trunk/query/src/main/java/org/infinispan/query/impl/CacheQueryImpl.java 2009-09-23 15:39:26 UTC (rev 845)
+++ trunk/query/src/main/java/org/infinispan/query/impl/CacheQueryImpl.java 2009-09-23 16:16:53 UTC (rev 846)
@@ -65,8 +65,7 @@
*
* @author Navin Surtani
*/
-public class CacheQueryImpl implements CacheQuery
-{
+public class CacheQueryImpl implements CacheQuery {
private Sort sort;
private Filter filter;
private Map<String, FullTextFilterImpl> filterDefinitions;
@@ -87,15 +86,12 @@
public org.infinispan.util.logging.Log log;
-
-
- public CacheQueryImpl(Query luceneQuery, SearchFactoryImplementor searchFactory, Cache cache, Class... classes)
- {
+ public CacheQueryImpl(Query luceneQuery, SearchFactoryImplementor searchFactory, Cache cache, Class... classes) {
this.luceneQuery = luceneQuery;
this.cache = cache;
this.searchFactory = searchFactory;
this.targetedEntities = this.searchFactory.getIndexedTypesPolymorphic(classes);
-
+
}
@@ -105,8 +101,7 @@
* @param f - lucene filter
*/
- public void setFilter(Filter f)
- {
+ public void setFilter(Filter f) {
filter = f;
}
@@ -114,38 +109,28 @@
/**
* @return The result size of the query.
*/
- public int getResultSize()
- {
- if (resultSize == null)
- {
+ public int getResultSize() {
+ if (resultSize == null) {
//get result size without object initialization
IndexSearcher searcher = buildSearcher(searchFactory);
- if (searcher == null)
- {
+ if (searcher == null) {
resultSize = 0;
- }
- else
- {
+ } else {
TopDocs hits;
- try
- {
+ try {
hits = getQueryHits(searcher, 1).topDocs; // Lucene enforces that at least one top doc will be retrieved.
resultSize = hits.totalHits;
}
- catch (IOException e)
- {
+ catch (IOException e) {
throw new HibernateException("Unable to query Lucene index", e);
}
- finally
- {
+ finally {
//searcher cannot be null
- try
- {
+ try {
closeSearcher(searcher, searchFactory.getReaderProvider());
//searchFactoryImplementor.getReaderProvider().closeReader( searcher.getIndexReader() );
}
- catch (SearchException e)
- {
+ catch (SearchException e) {
log.warn("Unable to properly close searcher during lucene query: " + e);
}
}
@@ -154,19 +139,16 @@
return this.resultSize;
}
- private void closeSearcher(Searcher searcher, ReaderProvider readerProvider)
- {
+ private void closeSearcher(Searcher searcher, ReaderProvider readerProvider) {
Set<IndexReader> indexReaders = getIndexReaders(searcher);
- for (IndexReader indexReader : indexReaders)
- {
+ for (IndexReader indexReader : indexReaders) {
readerProvider.closeReader(indexReader);
}
}
- public void setSort(Sort s)
- {
+ public void setSort(Sort s) {
sort = s;
}
@@ -177,10 +159,8 @@
* @param name of filter.
* @return a FullTextFilter object.
*/
- public FullTextFilter enableFullTextFilter(String name)
- {
- if (filterDefinitions == null)
- {
+ public FullTextFilter enableFullTextFilter(String name) {
+ if (filterDefinitions == null) {
filterDefinitions = new HashMap<String, FullTextFilterImpl>();
}
FullTextFilterImpl filterDefinition = filterDefinitions.get(name);
@@ -189,8 +169,7 @@
filterDefinition = new FullTextFilterImpl();
filterDefinition.setName(name);
FilterDef filterDef = searchFactory.getFilterDefinition(name);
- if (filterDef == null)
- {
+ if (filterDef == null) {
throw new SearchException("Unkown @FullTextFilter: " + name);
}
filterDefinitions.put(name, filterDefinition);
@@ -202,8 +181,7 @@
*
* @param name of filter.
*/
- public void disableFullTextFilter(String name)
- {
+ public void disableFullTextFilter(String name) {
filterDefinitions.remove(name);
}
@@ -213,32 +191,26 @@
* @param firstResult index to be set.
* @throws IllegalArgumentException if the index given is less than zero.
*/
- public void setFirstResult(int firstResult)
- {
- if (firstResult < 0)
- {
+ public void setFirstResult(int firstResult) {
+ if (firstResult < 0) {
throw new IllegalArgumentException("'first' pagination parameter less than 0");
}
this.firstResult = firstResult;
}
- public QueryIterator iterator() throws HibernateException
- {
+ public QueryIterator iterator() throws HibernateException {
return iterator(1);
}
- public QueryIterator iterator(int fetchSize) throws HibernateException
- {
+ public QueryIterator iterator(int fetchSize) throws HibernateException {
List<Object> keyList = null;
IndexSearcher searcher = buildSearcher(searchFactory);
- if (searcher == null)
- {
+ if (searcher == null) {
throw new NullPointerException("IndexSearcher instance is null.");
}
- try
- {
+ try {
QueryHits queryHits = getQueryHits(searcher, calculateTopDocsRetrievalSize());
int first = first();
int max = max(first, queryHits.totalHits);
@@ -246,8 +218,7 @@
keyList = new ArrayList<Object>(size);
DocumentExtractor extractor = new DocumentExtractor(queryHits, searchFactory, indexProjection, idFieldNames, allowFieldSelectionInProjection);
- for (int index = first; index <= max; index++)
- {
+ for (int index = first; index <= max; index++) {
// Since the documentId is same thing as the key in each key, value pairing. We can just get the documentId
// from Lucene and then get it from the cache.
@@ -259,14 +230,12 @@
}
}
- catch (IOException e)
- {
+ catch (IOException e) {
throw new HibernateException("Unable to query Lucene index", e);
}
- finally
- {
+ finally {
IndexSearcherCloser.closeSearcher(searcher, searchFactory.getReaderProvider());
@@ -275,17 +244,14 @@
return new EagerIterator(keyList, cache, fetchSize);
}
- public QueryIterator lazyIterator()
- {
+ public QueryIterator lazyIterator() {
return lazyIterator(1);
}
- public QueryIterator lazyIterator(int fetchSize)
- {
+ public QueryIterator lazyIterator(int fetchSize) {
IndexSearcher searcher = buildSearcher(searchFactory);
- try
- {
+ try {
QueryHits queryHits = getQueryHits(searcher, calculateTopDocsRetrievalSize());
int first = first();
int max = max(first, queryHits.totalHits);
@@ -294,14 +260,11 @@
return new LazyIterator(extractor, cache, searcher, searchFactory, first, max, fetchSize);
}
- catch (IOException e)
- {
- try
- {
+ catch (IOException e) {
+ try {
IndexSearcherCloser.closeSearcher(searcher, searchFactory.getReaderProvider());
}
- catch (SearchException ee)
- {
+ catch (SearchException ee) {
//we have the initial issue already
}
throw new HibernateException("Unable to query Lucene index", e);
@@ -310,15 +273,13 @@
}
- public List<Object> list() throws HibernateException
- {
+ public List<Object> list() throws HibernateException {
IndexSearcher searcher = buildSearcher(searchFactory);
if (searcher == null) return Collections.EMPTY_LIST;
- try
- {
+ try {
QueryHits queryHits = getQueryHits(searcher, calculateTopDocsRetrievalSize());
@@ -330,8 +291,7 @@
DocumentExtractor extractor = new DocumentExtractor(queryHits, searchFactory, indexProjection, idFieldNames, allowFieldSelectionInProjection);
List<Object> keysForCache = new ArrayList<Object>(size);
- for (int index = first; index <= max; index++)
- {
+ for (int index = first; index <= max; index++) {
// Since the documentId is same thing as the key in each key, value pairing. We can just get the documentId
// from Lucene and then get it from the cache.
@@ -343,155 +303,123 @@
// Loop through my list of keys and get it from the cache. Put each object that I get into a separate list.
List<Object> listToReturn = new ArrayList<Object>(size);
- for (Object key : keysForCache){
+ for (Object key : keysForCache) {
listToReturn.add(cache.get(key));
}
// TODO: navssurtani --> Speak with EB or HF about what a resultTransformer is and what it does etc etc.
- if (resultTransformer == null)
- {
+ if (resultTransformer == null) {
return listToReturn;
- }
- else
- {
+ } else {
return resultTransformer.transformList(listToReturn);
}
}
- catch (IOException e)
- {
+ catch (IOException e) {
throw new HibernateException("Unable to query Lucene index", e);
}
- finally
- {
+ finally {
IndexSearcherCloser.closeSearcher(searcher, searchFactory.getReaderProvider());
}
}
- private int max(int first, int totalHits)
- {
- if (maxResults == null)
- {
+ private int max(int first, int totalHits) {
+ if (maxResults == null) {
return totalHits - 1;
- }
- else
- {
+ } else {
return maxResults + first < totalHits ?
- first + maxResults - 1 :
- totalHits - 1;
+ first + maxResults - 1 :
+ totalHits - 1;
}
}
- private int first()
- {
+ private int first() {
return firstResult != null ?
- firstResult :
- 0;
+ firstResult :
+ 0;
}
- private QueryHits getQueryHits(Searcher searcher, Integer n) throws IOException
- {
+ private QueryHits getQueryHits(Searcher searcher, Integer n) throws IOException {
org.apache.lucene.search.Query query = filterQueryByClasses(luceneQuery);
buildFilters();
QueryHits queryHits;
- if (n == null)
- { // try to make sure that we get the right amount of top docs
+ if (n == null) { // try to make sure that we get the right amount of top docs
queryHits = new QueryHits(searcher, query, filter, sort);
- }
- else
- {
+ } else {
queryHits = new QueryHits(searcher, query, filter, sort, n);
}
resultSize = queryHits.totalHits;
return queryHits;
}
- private Integer calculateTopDocsRetrievalSize()
- {
- if (maxResults == null)
- {
+ private Integer calculateTopDocsRetrievalSize() {
+ if (maxResults == null) {
return null;
- }
- else
- {
+ } else {
return first() + maxResults;
}
}
- public void setMaxResults(int maxResults)
- {
- if (maxResults < 0)
- {
+ public void setMaxResults(int maxResults) {
+ if (maxResults < 0) {
throw new IllegalArgumentException("'max' pagination parameter less than 0");
}
this.maxResults = maxResults;
}
- private IndexSearcher buildSearcher(SearchFactoryImplementor searchFactoryImplementor)
- {
+ private IndexSearcher buildSearcher(SearchFactoryImplementor searchFactoryImplementor) {
Map<Class<?>, DocumentBuilderIndexedEntity<?>> builders = searchFactoryImplementor.getDocumentBuildersIndexedEntities();
List<DirectoryProvider> directories = new ArrayList<DirectoryProvider>();
Set<String> idFieldNames = new HashSet<String>();
Similarity searcherSimilarity = null;
- if (targetedEntities.size() == 0)
- {
+ if (targetedEntities.size() == 0) {
// empty targetedEntities array means search over all indexed enities,
// but we have to make sure there is at least one
- if (builders.isEmpty())
- {
+ if (builders.isEmpty()) {
throw new HibernateException(
- "There are no mapped entities. Don't forget to add @Indexed to at least one class."
+ "There are no mapped entities. Don't forget to add @Indexed to at least one class."
);
}
- for (DocumentBuilderIndexedEntity builder : builders.values())
- {
+ for (DocumentBuilderIndexedEntity builder : builders.values()) {
searcherSimilarity = checkSimilarity(searcherSimilarity, builder);
- if (builder.getIdKeywordName() != null)
- {
+ if (builder.getIdKeywordName() != null) {
idFieldNames.add(builder.getIdKeywordName());
allowFieldSelectionInProjection = allowFieldSelectionInProjection && builder.allowFieldSelectionInProjection();
}
final DirectoryProvider[] directoryProviders = builder.getDirectoryProviderSelectionStrategy()
- .getDirectoryProvidersForAllShards();
+ .getDirectoryProvidersForAllShards();
populateDirectories(directories, directoryProviders);
}
classesAndSubclasses = null;
- }
- else
- {
+ } else {
Set<Class<?>> involvedClasses = new HashSet<Class<?>>(targetedEntities.size());
involvedClasses.addAll(targetedEntities);
- for (Class<?> clazz : targetedEntities)
- {
+ for (Class<?> clazz : targetedEntities) {
DocumentBuilderIndexedEntity<?> builder = builders.get(clazz);
- if (builder != null)
- {
+ if (builder != null) {
involvedClasses.addAll(builder.getMappedSubclasses());
}
}
- for (Class clazz : involvedClasses)
- {
+ for (Class clazz : involvedClasses) {
DocumentBuilderIndexedEntity builder = builders.get(clazz);
- if (builder == null)
- {
+ if (builder == null) {
throw new HibernateException("Not a mapped entity (don't forget to add @Indexed): " + clazz);
}
- if (builder.getIdKeywordName() != null)
- {
+ if (builder.getIdKeywordName() != null) {
idFieldNames.add(builder.getIdKeywordName());
allowFieldSelectionInProjection = allowFieldSelectionInProjection && builder.allowFieldSelectionInProjection();
}
final DirectoryProvider[] directoryProviders = builder.getDirectoryProviderSelectionStrategy()
- .getDirectoryProvidersForAllShards();
+ .getDirectoryProvidersForAllShards();
searcherSimilarity = checkSimilarity(searcherSimilarity, builder);
populateDirectories(directories, directoryProviders);
}
@@ -501,28 +429,22 @@
//compute optimization needClassFilterClause
//if at least one DP contains one class that is not part of the targeted classesAndSubclasses we can't optimize
- if (classesAndSubclasses != null)
- {
- for (DirectoryProvider dp : directories)
- {
+ if (classesAndSubclasses != null) {
+ for (DirectoryProvider dp : directories) {
final Set<Class<?>> classesInDirectoryProvider = searchFactoryImplementor.getClassesInDirectoryProvider(
- dp
+ dp
);
// if a DP contains only one class, we know for sure it's part of classesAndSubclasses
- if (classesInDirectoryProvider.size() > 1)
- {
+ if (classesInDirectoryProvider.size() > 1) {
//risk of needClassFilterClause
- for (Class clazz : classesInDirectoryProvider)
- {
- if (!classesAndSubclasses.contains(clazz))
- {
+ for (Class clazz : classesInDirectoryProvider) {
+ if (!classesAndSubclasses.contains(clazz)) {
this.needClassFilterClause = true;
break;
}
}
}
- if (this.needClassFilterClause)
- {
+ if (this.needClassFilterClause) {
break;
}
}
@@ -531,23 +453,19 @@
//set up the searcher
final DirectoryProvider[] directoryProviders = directories.toArray(new DirectoryProvider[directories.size()]);
IndexSearcher is = new IndexSearcher(
- searchFactoryImplementor.getReaderProvider().openReader(
- directoryProviders
- )
+ searchFactoryImplementor.getReaderProvider().openReader(
+ directoryProviders
+ )
);
is.setSimilarity(searcherSimilarity);
return is;
}
- private Similarity checkSimilarity(Similarity similarity, DocumentBuilderIndexedEntity builder)
- {
- if (similarity == null)
- {
+ private Similarity checkSimilarity(Similarity similarity, DocumentBuilderIndexedEntity builder) {
+ if (similarity == null) {
similarity = builder.getSimilarity();
- }
- else if (!similarity.getClass().equals(builder.getSimilarity().getClass()))
- {
+ } else if (!similarity.getClass().equals(builder.getSimilarity().getClass())) {
throw new HibernateException("Cannot perform search on two entities with differing Similarity implementations (" + similarity.getClass().getName() + " & " + builder.getSimilarity().getClass().getName() + ")");
}
@@ -557,31 +475,24 @@
private void populateDirectories(List<DirectoryProvider> directories, DirectoryProvider[] directoryProviders)
{
- for (DirectoryProvider provider : directoryProviders)
- {
- if (!directories.contains(provider))
- {
+ for (DirectoryProvider provider : directoryProviders) {
+ if (!directories.contains(provider)) {
directories.add(provider);
}
}
}
- private org.apache.lucene.search.Query filterQueryByClasses(org.apache.lucene.search.Query luceneQuery)
- {
- if (!needClassFilterClause)
- {
+ private org.apache.lucene.search.Query filterQueryByClasses(org.apache.lucene.search.Query luceneQuery) {
+ if (!needClassFilterClause) {
return luceneQuery;
- }
- else
- {
+ } else {
//A query filter is more practical than a manual class filtering post query (esp on scrollable resultsets)
//it also probably minimise the memory footprint
BooleanQuery classFilter = new BooleanQuery();
//annihilate the scoring impact of DocumentBuilder.CLASS_FIELDNAME
classFilter.setBoost(0);
- for (Class clazz : classesAndSubclasses)
- {
+ for (Class clazz : classesAndSubclasses) {
Term t = new Term(DocumentBuilder.CLASS_FIELDNAME, clazz.getName());
TermQuery termQuery = new TermQuery(t);
classFilter.add(termQuery, BooleanClause.Occur.SHOULD);
@@ -597,29 +508,24 @@
// Method changed by Navin Surtani on Dec 16th 2008. Copied out from FullTextQueryImpl from Hibernate Search code like
// previously done. Also copied in methods like buildLuceneFilter(), createFilter() and those methods that follow down
// until the end of the class.
- private void buildFilters()
- {
- if (filterDefinitions == null || filterDefinitions.size() == 0)
- {
+ private void buildFilters() {
+ if (filterDefinitions == null || filterDefinitions.size() == 0) {
return; // there is nothing to do if we don't have any filter definitions
}
ChainedFilter chainedFilter = new ChainedFilter();
- for (FullTextFilterImpl fullTextFilter : filterDefinitions.values())
- {
+ for (FullTextFilterImpl fullTextFilter : filterDefinitions.values()) {
Filter filter = buildLuceneFilter(fullTextFilter);
chainedFilter.addFilter(filter);
}
- if (filter != null)
- {
+ if (filter != null) {
chainedFilter.addFilter(filter);
}
filter = chainedFilter;
}
- private Filter buildLuceneFilter(FullTextFilterImpl fullTextFilter)
- {
+ private Filter buildLuceneFilter(FullTextFilterImpl fullTextFilter) {
/*
* FilterKey implementations and Filter(Factory) do not have to be threadsafe wrt their parameter injection
@@ -631,65 +537,53 @@
// try to get the filter out of the cache
Filter filter = cacheInstance(def.getCacheMode()) ?
- searchFactory.getFilterCachingStrategy().getCachedFilter(key) :
- null;
+ searchFactory.getFilterCachingStrategy().getCachedFilter(key) :
+ null;
- if (filter == null)
- {
+ if (filter == null) {
filter = createFilter(def, instance);
// add filter to cache if we have to
- if (cacheInstance(def.getCacheMode()))
- {
+ if (cacheInstance(def.getCacheMode())) {
searchFactory.getFilterCachingStrategy().addCachedFilter(key, filter);
}
}
return filter;
}
- private Filter createFilter(FilterDef def, Object instance)
- {
+ private Filter createFilter(FilterDef def, Object instance) {
Filter filter;
- if (def.getFactoryMethod() != null)
- {
- try
- {
+ if (def.getFactoryMethod() != null) {
+ try {
filter = (Filter) def.getFactoryMethod().invoke(instance);
}
- catch (IllegalAccessException e)
- {
+ catch (IllegalAccessException e) {
throw new SearchException(
- "Unable to access @Factory method: "
- + def.getImpl().getName() + "." + def.getFactoryMethod().getName()
+ "Unable to access @Factory method: "
+ + def.getImpl().getName() + "." + def.getFactoryMethod().getName()
);
}
- catch (InvocationTargetException e)
- {
+ catch (InvocationTargetException e) {
throw new SearchException(
- "Unable to access @Factory method: "
- + def.getImpl().getName() + "." + def.getFactoryMethod().getName()
+ "Unable to access @Factory method: "
+ + def.getImpl().getName() + "." + def.getFactoryMethod().getName()
);
}
- catch (ClassCastException e)
- {
+ catch (ClassCastException e) {
throw new SearchException(
- "@Key method does not return a org.apache.lucene.search.Filter class: "
- + def.getImpl().getName() + "." + def.getFactoryMethod().getName()
+ "@Key method does not return a org.apache.lucene.search.Filter class: "
+ + def.getImpl().getName() + "." + def.getFactoryMethod().getName()
);
}
- }
- else
- {
- try
- {
+ } else {
+ try {
filter = (Filter) instance;
}
- catch (ClassCastException e)
- {
+ catch (ClassCastException e) {
throw new SearchException(
- "Filter implementation does not implement the Filter interface: "
- + def.getImpl().getName() + ". "
- + (def.getFactoryMethod() != null ? def.getFactoryMethod().getName() : ""), e
+ "Filter implementation does not implement the Filter interface: "
+ + def.getImpl().getName() + ". "
+ + (def.getFactoryMethod() != null ? def.getFactoryMethod().getName() : ""), e
);
}
}
@@ -699,87 +593,68 @@
}
private Object createFilterInstance(FullTextFilterImpl fullTextFilter,
- FilterDef def)
- {
+ FilterDef def) {
Object instance;
- try
- {
+ try {
instance = def.getImpl().newInstance();
}
- catch (InstantiationException e)
- {
+ catch (InstantiationException e) {
throw new SearchException("Unable to create @FullTextFilterDef: " + def.getImpl(), e);
}
- catch (IllegalAccessException e)
- {
+ catch (IllegalAccessException e) {
throw new SearchException("Unable to create @FullTextFilterDef: " + def.getImpl(), e);
}
- for (Map.Entry<String, Object> entry : fullTextFilter.getParameters().entrySet())
- {
+ for (Map.Entry<String, Object> entry : fullTextFilter.getParameters().entrySet()) {
def.invoke(entry.getKey(), instance, entry.getValue());
}
if (cacheInstance(def.getCacheMode()) && def.getKeyMethod() == null && fullTextFilter.getParameters()
- .size() > 0)
- {
+ .size() > 0) {
throw new SearchException("Filter with parameters and no @Key method: " + fullTextFilter.getName());
}
return instance;
}
- private FilterKey createFilterKey(FilterDef def, Object instance)
- {
+ private FilterKey createFilterKey(FilterDef def, Object instance) {
FilterKey key = null;
- if (!cacheInstance(def.getCacheMode()))
- {
+ if (!cacheInstance(def.getCacheMode())) {
return key; // if the filter is not cached there is no key!
}
- if (def.getKeyMethod() == null)
- {
- key = new FilterKey()
- {
- public int hashCode()
- {
+ if (def.getKeyMethod() == null) {
+ key = new FilterKey() {
+ public int hashCode() {
return getImpl().hashCode();
}
- public boolean equals(Object obj)
- {
- if (!(obj instanceof FilterKey))
- {
+ public boolean equals(Object obj) {
+ if (!(obj instanceof FilterKey)) {
return false;
}
FilterKey that = (FilterKey) obj;
return this.getImpl().equals(that.getImpl());
}
};
- }
- else
- {
- try
- {
+ } else {
+ try {
key = (FilterKey) def.getKeyMethod().invoke(instance);
}
- catch (IllegalAccessException e)
- {
+ catch (IllegalAccessException e) {
throw new SearchException(
- "Unable to access @Key method: "
- + def.getImpl().getName() + "." + def.getKeyMethod().getName()
+ "Unable to access @Key method: "
+ + def.getImpl().getName() + "." + def.getKeyMethod().getName()
);
}
- catch (InvocationTargetException e)
- {
+ catch (InvocationTargetException e) {
throw new SearchException(
- "Unable to access @Key method: "
- + def.getImpl().getName() + "." + def.getKeyMethod().getName()
+ "Unable to access @Key method: "
+ + def.getImpl().getName() + "." + def.getKeyMethod().getName()
);
}
- catch (ClassCastException e)
- {
+ catch (ClassCastException e) {
throw new SearchException(
- "@Key method does not return FilterKey: "
- + def.getImpl().getName() + "." + def.getKeyMethod().getName()
+ "@Key method does not return FilterKey: "
+ + def.getImpl().getName() + "." + def.getKeyMethod().getName()
);
}
}
@@ -792,16 +667,14 @@
return wrapperKey;
}
- private Filter addCachingWrapperFilter(Filter filter, FilterDef def)
- {
- if (cacheResults(def.getCacheMode()))
- {
+ private Filter addCachingWrapperFilter(Filter filter, FilterDef def) {
+ if (cacheResults(def.getCacheMode())) {
int cachingWrapperFilterSize = searchFactory.getFilterCacheBitResultsSize();
filter = new org.hibernate.search.filter.CachingWrapperFilter(filter, cachingWrapperFilterSize);
}
return filter;
}
-
+
}
Modified: trunk/query/src/main/java/org/infinispan/query/impl/EagerIterator.java
===================================================================
--- trunk/query/src/main/java/org/infinispan/query/impl/EagerIterator.java 2009-09-23 15:39:26 UTC (rev 845)
+++ trunk/query/src/main/java/org/infinispan/query/impl/EagerIterator.java 2009-09-23 16:16:53 UTC (rev 846)
@@ -38,7 +38,6 @@
* <p/>
* <p/>
*
- *
* @author Navin Surtani
*/
@@ -50,10 +49,8 @@
private static final Log log = LogFactory.getLog(EagerIterator.class);
- public EagerIterator(List<Object> idList, Cache cache, int fetchSize)
- {
- if (fetchSize < 1)
- {
+ public EagerIterator(List<Object> idList, Cache cache, int fetchSize) {
+ if (fetchSize < 1) {
throw new IllegalArgumentException("Incorrect value for fetchsize passed. Your fetchSize is less than 1");
}
@@ -81,17 +78,14 @@
* @throws IndexOutOfBoundsException
*/
- public void jumpToResult(int index) throws IndexOutOfBoundsException
- {
- if (index > idList.size() || index < 0)
- {
+ public void jumpToResult(int index) throws IndexOutOfBoundsException {
+ if (index > idList.size() || index < 0) {
throw new IndexOutOfBoundsException("The index you entered is either greater than the size of the list or negative");
}
this.index = index;
}
- public void close()
- {
+ public void close() {
// This method does not need to do anything for this type of iterator as when an instace of it is
// created, the iterator() method in CacheQueryImpl closes everything that needs to be closed.
}
@@ -101,8 +95,7 @@
*
* @return The next element in the list.
*/
- public Object next()
- {
+ public Object next() {
if (!hasNext()) throw new IndexOutOfBoundsException("Out of boundaries. There is no next");
Object toReturn;
@@ -110,16 +103,13 @@
// make sure the index we are after is in the buffer. If it is, then index >= bufferIndex and index <= (bufferIndex + bufferSize).
if (bufferIndex >= 0 // buffer init check
- && index >= bufferIndex // lower boundary
- && index < (bufferIndex + bufferSize)) // upper boundary
+ && index >= bufferIndex // lower boundary
+ && index < (bufferIndex + bufferSize)) // upper boundary
{
// now we can get this from the buffer. Sweet!
int indexToReturn = index - bufferIndex;
toReturn = buffer[indexToReturn];
- }
-
- else
- {
+ } else {
// We need to populate the buffer.
toReturn = cache.get(idList.get(index));
@@ -132,12 +122,9 @@
// we now need to buffer item at index "index", as well as the next "fetchsize - 1" elements. I.e., a total of fetchsize elements will be buffered.
//now loop through bufferSize times to add the rest of the objects into the list.
- for (int i = 1; i < bufferSize; i++)
- {
- if (index + i > max)
- {
- if (log.isDebugEnabled())
- {
+ for (int i = 1; i < bufferSize; i++) {
+ if (index + i > max) {
+ if (log.isDebugEnabled()) {
log.debug("Your current index + bufferSize exceeds the size of your number of hits");
}
break;
@@ -161,8 +148,7 @@
* @return The previous element in the list.
*/
- public Object previous()
- {
+ public Object previous() {
if (!hasPrevious()) throw new IndexOutOfBoundsException("Index is out of bounds. There is no previous");
Object toReturn;
@@ -171,15 +157,13 @@
// make sure the index we are after is in the buffer. If it is, then index >= bufferIndex and index <= (bufferIndex + bufferSize).
if (bufferIndex >= 0 // buffer init check
- && index <= bufferIndex // lower boundary
- && index >= (bufferIndex + bufferSize)) // upper boundary
+ && index <= bufferIndex // lower boundary
+ && index >= (bufferIndex + bufferSize)) // upper boundary
{
// now we can get this from the buffer. Sweet!
int indexToReturn = bufferIndex - index; // Unlike next() we have to make sure that we are subtracting index from bufferIndex
toReturn = buffer[indexToReturn];
- }
- else
- {
+ } else {
toReturn = cache.get(idList.get(index));
// Wiping bufferObjects and the bufferIndex so that there is no stale data.
@@ -190,12 +174,9 @@
// I.e., a total of fetchsize elements will be buffered.
// now loop through bufferSize times to add the rest of the objects into the list.
- for (int i = 1; i < bufferSize; i++)
- {
- if (index - i < first)
- {
- if (log.isDebugEnabled())
- {
+ for (int i = 1; i < bufferSize; i++) {
+ if (index - i < first) {
+ if (log.isDebugEnabled()) {
log.debug("Your current index - bufferSize exceeds the size of your number of hits");
}
break;
@@ -215,8 +196,7 @@
* @return Index of next element.
*/
- public int nextIndex()
- {
+ public int nextIndex() {
if (!hasNext()) throw new NoSuchElementException("Out of boundaries");
return index + 1;
@@ -228,8 +208,7 @@
* @return Index of previous element.
*/
- public int previousIndex()
- {
+ public int previousIndex() {
if (!hasPrevious()) throw new NoSuchElementException("Out of boundaries");
return index - 1;
}
@@ -237,8 +216,7 @@
/**
* This method is not supported and should not be used. Use cache.remove() instead.
*/
- public void remove()
- {
+ public void remove() {
throw new UnsupportedOperationException("Not supported as you are trying to change something in the cache. Please use searchableCache.put()");
}
@@ -248,8 +226,7 @@
* @param o
* @throws UnsupportedOperationException
*/
- public void set(Object o) throws UnsupportedOperationException
- {
+ public void set(Object o) throws UnsupportedOperationException {
throw new UnsupportedOperationException("Not supported as you are trying to change something in the cache. Please use searchableCache.put()");
}
@@ -260,8 +237,7 @@
* @throws UnsupportedOperationException
*/
- public void add(Object o)
- {
+ public void add(Object o) {
throw new UnsupportedOperationException("Not supported as you are trying to change something in the cache. Please use searchableCache.put()");
}
Modified: trunk/query/src/main/java/org/infinispan/query/impl/LazyIterator.java
===================================================================
--- trunk/query/src/main/java/org/infinispan/query/impl/LazyIterator.java 2009-09-23 15:39:26 UTC (rev 845)
+++ trunk/query/src/main/java/org/infinispan/query/impl/LazyIterator.java 2009-09-23 16:16:53 UTC (rev 846)
@@ -28,7 +28,6 @@
import org.hibernate.search.engine.SearchFactoryImplementor;
import org.infinispan.Cache;
import org.infinispan.CacheException;
-import org.infinispan.query.impl.AbstractIterator;
import org.infinispan.query.backend.IndexSearcherCloser;
import java.io.IOException;
@@ -36,9 +35,9 @@
import java.util.NoSuchElementException;
/**
- * Implementation for {@link org.infinispan.query.QueryIterator}. This is what is returned when the {@link org.infinispan.query.CacheQuery#lazyIterator()} method
- * is called. This loads the results only when required and hence differs from {@link EagerIterator} which is the
- * other implementation of QueryResultIterator.
+ * Implementation for {@link org.infinispan.query.QueryIterator}. This is what is returned when the {@link
+ * org.infinispan.query.CacheQuery#lazyIterator()} method is called. This loads the results only when required and hence
+ * differs from {@link EagerIterator} which is the other implementation of QueryResultIterator.
*
* @author Navin Surtani
*/
@@ -51,9 +50,8 @@
private SearchFactoryImplementor searchFactory;
-
public LazyIterator(DocumentExtractor extractor, Cache cache,
- IndexSearcher searcher, SearchFactoryImplementor searchFactory, int first, int max, int fetchSize) {
+ IndexSearcher searcher, SearchFactoryImplementor searchFactory, int first, int max, int fetchSize) {
if (fetchSize < 1) {
throw new IllegalArgumentException("Incorrect value for fetchsize passed. Your fetchSize is less than 1");
}
Modified: trunk/query/src/test/java/org/infinispan/query/blackbox/BrokenAnnotationTest.java
===================================================================
--- trunk/query/src/test/java/org/infinispan/query/blackbox/BrokenAnnotationTest.java 2009-09-23 15:39:26 UTC (rev 845)
+++ trunk/query/src/test/java/org/infinispan/query/blackbox/BrokenAnnotationTest.java 2009-09-23 16:16:53 UTC (rev 846)
@@ -2,10 +2,11 @@
import org.infinispan.Cache;
import org.infinispan.manager.CacheManager;
-import org.infinispan.manager.DefaultCacheManager;
+import org.infinispan.query.helper.TestQueryHelperFactory;
+import org.infinispan.query.test.BrokenDocumentId;
import org.infinispan.query.test.BrokenProvided;
-import org.infinispan.query.backend.QueryHelper;
import org.infinispan.test.SingleCacheManagerTest;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
import org.testng.annotations.Test;
/**
@@ -13,37 +14,27 @@
*
* @author Navin Surtani
*/
- at Test (groups = "functional")
-public class BrokenAnnotationTest extends SingleCacheManagerTest
-{
- @Test (expectedExceptions = IllegalArgumentException.class)
- public void testProvided() throws Exception
- {
- org.infinispan.query.test.BrokenProvided provided = new org.infinispan.query.test.BrokenProvided();
- provided.setBoth("Cat", 5);
-
- Cache cache = createCacheManager().getCache();
+ at Test(groups = "functional")
+public class BrokenAnnotationTest extends SingleCacheManagerTest {
+ Cache<?, ?> c;
- QueryHelper qh = new QueryHelper(cache, null, BrokenProvided.class);
+ public BrokenAnnotationTest() {
+ cleanup = CleanupPhase.AFTER_METHOD;
+ }
-
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testProvided() throws Exception {
+ TestQueryHelperFactory.createTestQueryHelperInstance(c, BrokenProvided.class);
}
- @Test (expectedExceptions = IllegalArgumentException.class)
- public void testDocumentId() throws Exception
- {
- org.infinispan.query.test.BrokenDocumentId provided = new org.infinispan.query.test.BrokenDocumentId();
- provided.setBoth("Cat", 5);
-
- Cache cache = createCacheManager().getCache();
-
- QueryHelper qh = new QueryHelper(cache, null, BrokenProvided.class);
-
-
-
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testDocumentId() throws Exception {
+ TestQueryHelperFactory.createTestQueryHelperInstance(c, BrokenDocumentId.class);
}
protected CacheManager createCacheManager() throws Exception {
- return new DefaultCacheManager(); // TODO: Is there a better way to do this?
+ CacheManager cm = TestCacheManagerFactory.createLocalCacheManager();
+ c = cm.getCache();
+ return cm;
}
}
Modified: trunk/query/src/test/java/org/infinispan/query/blackbox/ClusteredCacheTest.java
===================================================================
--- trunk/query/src/test/java/org/infinispan/query/blackbox/ClusteredCacheTest.java 2009-09-23 15:39:26 UTC (rev 845)
+++ trunk/query/src/test/java/org/infinispan/query/blackbox/ClusteredCacheTest.java 2009-09-23 16:16:53 UTC (rev 846)
@@ -8,14 +8,13 @@
import org.infinispan.config.Configuration;
import org.infinispan.query.CacheQuery;
import org.infinispan.query.QueryFactory;
+import org.infinispan.query.helper.TestQueryHelperFactory;
import org.infinispan.query.backend.QueryHelper;
-import org.infinispan.query.helper.IndexCleanUp;
import org.infinispan.query.test.Person;
import org.infinispan.test.MultipleCacheManagersTest;
import org.infinispan.test.TestingUtil;
import org.infinispan.util.logging.Log;
import org.infinispan.util.logging.LogFactory;
-import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
import java.util.List;
@@ -46,51 +45,45 @@
protected void createCacheManagers() throws Throwable {
- Configuration cacheCfg = new Configuration();
- cacheCfg.setCacheMode(Configuration.CacheMode.REPL_SYNC);
- cacheCfg.setFetchInMemoryState(false);
+ Configuration cacheCfg = new Configuration();
+ cacheCfg.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ cacheCfg.setFetchInMemoryState(false);
- List<Cache<String, Person>> caches = createClusteredCaches(2, "infinispan-query", cacheCfg);
+ List<Cache<String, Person>> caches = createClusteredCaches(2, "infinispan-query", cacheCfg);
- cache1 = caches.get(0);
- cache2 = caches.get(1);
+ cache1 = caches.get(0);
+ cache2 = caches.get(1);
- // We will put objects into cache1 and then try and run the queries on cache2. This would mean that indexLocal
- // must be set to false.
+ // We will put objects into cache1 and then try and run the queries on cache2. This would mean that indexLocal
+ // must be set to false.
- System.setProperty(QueryHelper.QUERY_ENABLED_PROPERTY, "true");
- System.setProperty(QueryHelper.QUERY_INDEX_LOCAL_ONLY_PROPERTY, "false");
+ System.setProperty(QueryHelper.QUERY_ENABLED_PROPERTY, "true");
+ System.setProperty(QueryHelper.QUERY_INDEX_LOCAL_ONLY_PROPERTY, "false");
- qh = new QueryHelper(cache2, null, Person.class);
- qh.applyProperties();
+ qh = TestQueryHelperFactory.createTestQueryHelperInstance(cache2, Person.class);
- TestingUtil.blockUntilViewsReceived(60000, cache1, cache2);
+ TestingUtil.blockUntilViewsReceived(60000, cache1, cache2);
- person1 = new Person();
- person1.setName("Navin Surtani");
- person1.setBlurb("Likes playing WoW");
+ person1 = new Person();
+ person1.setName("Navin Surtani");
+ person1.setBlurb("Likes playing WoW");
- person2 = new Person();
- person2.setName("BigGoat");
- person2.setBlurb("Eats grass");
+ person2 = new Person();
+ person2.setName("BigGoat");
+ person2.setBlurb("Eats grass");
- person3 = new Person();
- person3.setName("MiniGoat");
- person3.setBlurb("Eats cheese");
+ person3 = new Person();
+ person3.setName("MiniGoat");
+ person3.setBlurb("Eats cheese");
- //Put the 3 created objects in the cache1.
+ //Put the 3 created objects in the cache1.
- cache1.put(key1, person1);
- cache1.put(key2, person2);
- cache1.put(key3, person3);
+ cache1.put(key1, person1);
+ cache1.put(key2, person2);
+ cache1.put(key3, person3);
}
- @AfterMethod (alwaysRun = true)
- public void tearDown() {
- IndexCleanUp.cleanUpIndexes();
- }
-
public void testSimple() throws ParseException {
cacheQuery = new QueryFactory(cache2, qh)
.getBasicQuery("blurb", "playing");
Modified: trunk/query/src/test/java/org/infinispan/query/blackbox/LocalCacheProfilerTest.java
===================================================================
--- trunk/query/src/test/java/org/infinispan/query/blackbox/LocalCacheProfilerTest.java 2009-09-23 15:39:26 UTC (rev 845)
+++ trunk/query/src/test/java/org/infinispan/query/blackbox/LocalCacheProfilerTest.java 2009-09-23 16:16:53 UTC (rev 846)
@@ -12,10 +12,9 @@
import org.infinispan.config.Configuration;
import org.infinispan.manager.CacheManager;
import org.infinispan.query.CacheQuery;
-import org.infinispan.query.QueryIterator;
import org.infinispan.query.QueryFactory;
+import org.infinispan.query.QueryIterator;
import org.infinispan.query.backend.QueryHelper;
-import org.infinispan.query.helper.IndexCleanUp;
import org.infinispan.query.test.Person;
import org.infinispan.test.SingleCacheManagerTest;
import org.infinispan.test.fwk.TestCacheManagerFactory;
@@ -30,7 +29,7 @@
* @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
*/
- at Test(groups = "functional", enabled = false)
+ at Test(groups = "profiler", enabled = false)
public class LocalCacheProfilerTest extends SingleCacheManagerTest {
Person person1;
Person person2;
@@ -66,10 +65,7 @@
cache = createCacheManager().getCache();
qh = new QueryHelper(cache, null, Person.class);
- qh.applyProperties();
-
-
person1 = new Person();
person1.setName("Navin Surtani");
person1.setBlurb("Likes playing WoW");
@@ -93,14 +89,13 @@
}
- @AfterMethod
+ @AfterMethod (alwaysRun = true)
public void tearDown() {
if (cache != null) cache.stop();
- IndexCleanUp.cleanUpIndexes();
}
- @Test (invocationCount = 2000, enabled = false)
+ @Test(invocationCount = 2000, enabled = false)
public void testSimple() throws ParseException {
cacheQuery = new QueryFactory(cache, qh).getBasicQuery("blurb", "playing");
@@ -110,7 +105,7 @@
assert found.get(0).equals(person1);
}
- @Test (invocationCount = 2000, enabled = false)
+ @Test(invocationCount = 2000, enabled = false)
public void testEagerIterator() throws ParseException {
cacheQuery = new QueryFactory(cache, qh).
@@ -122,7 +117,7 @@
assert found.isLast();
}
- @Test (invocationCount = 2000, enabled = false)
+ @Test(invocationCount = 2000, enabled = false)
public void testMultipleResults() throws ParseException {
queryParser = new QueryParser("name", new StandardAnalyzer());
@@ -137,7 +132,7 @@
}
- @Test (invocationCount = 2000, enabled = false)
+ @Test(invocationCount = 2000, enabled = false)
public void testModified() throws ParseException {
queryParser = new QueryParser("blurb", new StandardAnalyzer());
luceneQuery = queryParser.parse("playing");
@@ -161,7 +156,7 @@
assert found.get(0).equals(person1);
}
- @Test (invocationCount = 2000, enabled = false)
+ @Test(invocationCount = 2000, enabled = false)
public void testAdded() throws ParseException {
queryParser = new QueryParser("name", new StandardAnalyzer());
@@ -190,7 +185,7 @@
assert found.contains(person4) : "This should now contain object person4";
}
- @Test (invocationCount = 2000, enabled = false)
+ @Test(invocationCount = 2000, enabled = false)
public void testRemoved() throws ParseException {
queryParser = new QueryParser("name", new StandardAnalyzer());
@@ -215,7 +210,7 @@
}
- @Test (invocationCount = 2000, enabled = false)
+ @Test(invocationCount = 2000, enabled = false)
public void testSetSort() throws ParseException {
person2.setAge(35);
person3.setAge(12);
@@ -239,7 +234,7 @@
assert found.get(1).equals(person3);
}
- @Test (invocationCount = 2000, enabled = false)
+ @Test(invocationCount = 2000, enabled = false)
public void testSetFilter() throws ParseException {
queryParser = new QueryParser("name", new StandardAnalyzer());
@@ -259,7 +254,7 @@
}
- @Test (invocationCount = 2000, enabled = false)
+ @Test(invocationCount = 2000, enabled = false)
public void testLazyIterator() throws ParseException {
queryParser = new QueryParser("blurb", new StandardAnalyzer());
luceneQuery = queryParser.parse("playing");
@@ -272,7 +267,7 @@
}
- @Test (invocationCount = 2000, enabled = false)
+ @Test(invocationCount = 2000, enabled = false)
public void testGetResultSize() throws ParseException {
queryParser = new QueryParser("blurb", new StandardAnalyzer());
Modified: trunk/query/src/test/java/org/infinispan/query/blackbox/LocalCacheTest.java
===================================================================
--- trunk/query/src/test/java/org/infinispan/query/blackbox/LocalCacheTest.java 2009-09-23 15:39:26 UTC (rev 845)
+++ trunk/query/src/test/java/org/infinispan/query/blackbox/LocalCacheTest.java 2009-09-23 16:16:53 UTC (rev 846)
@@ -12,10 +12,10 @@
import org.infinispan.config.Configuration;
import org.infinispan.manager.CacheManager;
import org.infinispan.query.CacheQuery;
-import org.infinispan.query.QueryIterator;
import org.infinispan.query.QueryFactory;
+import org.infinispan.query.QueryIterator;
+import org.infinispan.query.helper.TestQueryHelperFactory;
import org.infinispan.query.backend.QueryHelper;
-import org.infinispan.query.helper.IndexCleanUp;
import org.infinispan.query.test.Person;
import org.infinispan.test.SingleCacheManagerTest;
import org.infinispan.test.fwk.TestCacheManagerFactory;
@@ -48,11 +48,10 @@
Cache<String, Person> cache;
QueryHelper qh;
-
+
protected CacheManager createCacheManager() throws Exception {
Configuration c = new Configuration();
c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
-
return TestCacheManagerFactory.createCacheManager(c);
}
@@ -65,8 +64,7 @@
cache = createCacheManager().getCache();
- qh = new QueryHelper(cache, null, Person.class);
- qh.applyProperties();
+ qh = TestQueryHelperFactory.createTestQueryHelperInstance(cache, Person.class);
person1 = new Person();
person1.setName("Navin Surtani");
@@ -91,10 +89,9 @@
}
- @AfterMethod
+ @AfterMethod (alwaysRun = true)
public void tearDown() {
if (cache != null) cache.stop();
- IndexCleanUp.cleanUpIndexes();
}
public void testSimple() throws ParseException {
Deleted: trunk/query/src/test/java/org/infinispan/query/helper/IndexCleanUp.java
===================================================================
--- trunk/query/src/test/java/org/infinispan/query/helper/IndexCleanUp.java 2009-09-23 15:39:26 UTC (rev 845)
+++ trunk/query/src/test/java/org/infinispan/query/helper/IndexCleanUp.java 2009-09-23 16:16:53 UTC (rev 846)
@@ -1,41 +0,0 @@
-package org.infinispan.query.helper;
-
-import org.infinispan.query.test.Person;
-
-import java.io.File;
-
-/**
- * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
- */
-public class IndexCleanUp
-{
-
- public static void cleanUpIndexes()
- {
- Class[] knownClasses = {Person.class};
- for (Class c : knownClasses)
- {
- String dirName = c.getName();
- File file = new File(dirName);
- if (file.exists())
- {
- recursiveDelete(file);
- }
- }
- }
-
- private static void recursiveDelete(File f)
- {
- if (f.isDirectory())
- {
- File[] files = f.listFiles();
- for (File file : files) recursiveDelete(file);
- }
- else
- {
- f.delete();
- }
- }
-
-}
-
Added: trunk/query/src/test/java/org/infinispan/query/helper/TestQueryHelperFactory.java
===================================================================
--- trunk/query/src/test/java/org/infinispan/query/helper/TestQueryHelperFactory.java (rev 0)
+++ trunk/query/src/test/java/org/infinispan/query/helper/TestQueryHelperFactory.java 2009-09-23 16:16:53 UTC (rev 846)
@@ -0,0 +1,20 @@
+package org.infinispan.query.helper;
+
+import org.infinispan.Cache;
+import org.infinispan.query.backend.QueryHelper;
+
+import java.util.Properties;
+
+/**
+ * Creates a test query helper
+ *
+ * @author Manik Surtani
+ * @since 4.0
+ */
+public class TestQueryHelperFactory {
+ public static QueryHelper createTestQueryHelperInstance(Cache<?, ?> cache, Class... classes) {
+ Properties p = new Properties();
+ p.setProperty("hibernate.search.default.directory_provider", "org.hibernate.search.store.RAMDirectoryProvider");
+ return new QueryHelper(cache, p, classes);
+ }
+}
Property changes on: trunk/query/src/test/java/org/infinispan/query/helper/TestQueryHelperFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/query/src/test/java/org/infinispan/query/impl/EagerIteratorTest.java
===================================================================
--- trunk/query/src/test/java/org/infinispan/query/impl/EagerIteratorTest.java 2009-09-23 15:39:26 UTC (rev 845)
+++ trunk/query/src/test/java/org/infinispan/query/impl/EagerIteratorTest.java 2009-09-23 16:16:53 UTC (rev 846)
@@ -36,7 +36,7 @@
// create some dummy data
dummyResults = new HashMap<String, String>();
- for (int i=1; i<=10; i++) {
+ for (int i = 1; i <= 10; i++) {
String key = "key" + i;
keys.add(key);
dummyResults.put(key, "Result number " + i);
@@ -45,7 +45,7 @@
// create the instance of the iterator.
cache = createMock(Cache.class);
- expect(cache.get(anyObject())).andAnswer(new IAnswer<String>(){
+ expect(cache.get(anyObject())).andAnswer(new IAnswer<String>() {
public String answer() throws Throwable {
String k = getCurrentArguments()[0].toString();
return dummyResults.get(k);
@@ -56,7 +56,7 @@
EasyMock.replay(cache);
}
- @AfterMethod
+ @AfterMethod (alwaysRun = true)
public void tearDown() {
keys = null;
dummyResults = null;
Modified: trunk/query/src/test/java/org/infinispan/query/impl/LazyIteratorTest.java
===================================================================
--- trunk/query/src/test/java/org/infinispan/query/impl/LazyIteratorTest.java 2009-09-23 15:39:26 UTC (rev 845)
+++ trunk/query/src/test/java/org/infinispan/query/impl/LazyIteratorTest.java 2009-09-23 16:16:53 UTC (rev 846)
@@ -9,15 +9,11 @@
import org.hibernate.search.engine.EntityInfo;
import org.hibernate.search.engine.SearchFactoryImplementor;
import org.infinispan.Cache;
-import org.infinispan.query.helper.IndexCleanUp;
import org.infinispan.query.test.Person;
-import org.infinispan.query.impl.LazyIterator;
import org.testng.annotations.AfterMethod;
-import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
-import org.testng.annotations.ExpectedExceptions;
import java.io.IOException;
import java.util.ArrayList;
@@ -96,11 +92,6 @@
}
- @AfterTest
- public void tearDownAfterTest() {
- IndexCleanUp.cleanUpIndexes();
- }
-
@BeforeMethod
public void setUp() throws ParseException {
@@ -150,7 +141,7 @@
}
- @AfterMethod
+ @AfterMethod (alwaysRun = true)
public void tearDown() {
iterator = null;
}
@@ -170,19 +161,17 @@
}
- //TODO: This is deprecated. What should I be using instead?
- @ExpectedExceptions(IndexOutOfBoundsException.class)
- public void testOutOfBoundsBelow(){
+ @Test(expectedExceptions = IndexOutOfBoundsException.class)
+ public void testOutOfBoundsBelow() {
iterator.jumpToResult(-1);
}
- @ExpectedExceptions(IndexOutOfBoundsException.class)
- public void testOutOfBoundsAbove(){
+ @Test(expectedExceptions = IndexOutOfBoundsException.class)
+ public void testOutOfBoundsAbove() {
iterator.jumpToResult(keyList.size() + 1);
}
-
public void testFirst() {
assert iterator.isFirst() : "We should be pointing at the first element";
Object next = iterator.next();
Modified: trunk/query/src/test/java/org/infinispan/query/test/BrokenDocumentId.java
===================================================================
--- trunk/query/src/test/java/org/infinispan/query/test/BrokenDocumentId.java 2009-09-23 15:39:26 UTC (rev 845)
+++ trunk/query/src/test/java/org/infinispan/query/test/BrokenDocumentId.java 2009-09-23 16:16:53 UTC (rev 846)
@@ -1,17 +1,16 @@
package org.infinispan.query.test;
-import org.hibernate.search.annotations.ProvidedId;
-import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.ProvidedId;
/**
* @author Navin Surtani
*/
@ProvidedId
@Indexed
-public class BrokenDocumentId
-{
+public class BrokenDocumentId {
@DocumentId
@Field
String name;
@@ -19,8 +18,7 @@
@Field
int age;
- public void setBoth(String name, int age)
- {
+ public void setBoth(String name, int age) {
this.name = name;
this.age = age;
}
Modified: trunk/query/src/test/java/org/infinispan/query/test/BrokenProvided.java
===================================================================
--- trunk/query/src/test/java/org/infinispan/query/test/BrokenProvided.java 2009-09-23 15:39:26 UTC (rev 845)
+++ trunk/query/src/test/java/org/infinispan/query/test/BrokenProvided.java 2009-09-23 16:16:53 UTC (rev 846)
@@ -1,23 +1,20 @@
package org.infinispan.query.test;
-import org.hibernate.search.annotations.Indexed;
-import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Indexed;
/**
* @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
*/
@Indexed
-public class BrokenProvided
-{
- @Field
+public class BrokenProvided {
+ @Field
public String name;
@Field
public int age;
- public void setBoth(String name, int age)
- {
+ public void setBoth(String name, int age) {
this.name = name;
this.age = age;
Modified: trunk/query/src/test/java/org/infinispan/query/test/Person.java
===================================================================
--- trunk/query/src/test/java/org/infinispan/query/test/Person.java 2009-09-23 15:39:26 UTC (rev 845)
+++ trunk/query/src/test/java/org/infinispan/query/test/Person.java 2009-09-23 16:16:53 UTC (rev 846)
@@ -8,60 +8,47 @@
import org.hibernate.search.annotations.ProvidedId;
import org.hibernate.search.annotations.Store;
import org.hibernate.search.bridge.builtin.StringBridge;
-import org.infinispan.util.logging.Log;
-import org.infinispan.util.logging.LogFactory;
import java.io.Serializable;
/**
* @author Navin Surtani
*/
- at ProvidedId (bridge = @FieldBridge(impl = StringBridge.class))
- at Indexed
-public class Person implements Serializable
-{
- private static final Log log = LogFactory.getLog(Person.class);
-
-
- @Field (store = Store.YES)
+ at ProvidedId(bridge = @FieldBridge(impl = StringBridge.class))
+ at Indexed(index = "person")
+public class Person implements Serializable {
+ @Field(store = Store.YES)
private String name;
- @Field (store = Store.YES)
+ @Field(store = Store.YES)
private String blurb;
- @Field (store = Store.YES, index = Index.UN_TOKENIZED )
+ @Field(store = Store.YES, index = Index.UN_TOKENIZED)
private int age;
- public String getName()
- {
+ public String getName() {
return name;
}
- public void setName(String name)
- {
+ public void setName(String name) {
this.name = name;
}
- public String getBlurb()
- {
+ public String getBlurb() {
return blurb;
}
- public void setBlurb(String blurb)
- {
+ public void setBlurb(String blurb) {
this.blurb = blurb;
}
- public int getAge()
- {
+ public int getAge() {
return age;
}
- public void setAge(int age)
- {
+ public void setAge(int age) {
this.age = age;
}
- public boolean equals(Object o)
- {
+ public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@@ -73,8 +60,7 @@
return true;
}
- public int hashCode()
- {
+ public int hashCode() {
int result;
result = (name != null ? name.hashCode() : 0);
result = 31 * result + (blurb != null ? blurb.hashCode() : 0);
@@ -82,11 +68,10 @@
}
- public String toString()
- {
+ public String toString() {
return "Person{" +
- "name='" + name + '\'' +
- ", blurb='" + blurb + '\'' +
- '}';
+ "name='" + name + '\'' +
+ ", blurb='" + blurb + '\'' +
+ '}';
}
}
More information about the infinispan-commits
mailing list