Index: src/java/org/apache/lucene/util/Attribute.java
===================================================================
--- src/java/org/apache/lucene/util/Attribute.java (revision 725699)
+++ src/java/org/apache/lucene/util/Attribute.java (working copy)
@@ -17,7 +17,6 @@
* limitations under the License.
*/
-import java.io.Serializable;
/**
* Base class for Attributes that can be added to a
@@ -30,7 +29,7 @@
* The APIs introduced in these classes with Lucene 2.9 might change in the future.
* We will make our best efforts to keep the APIs backwards-compatible.
*/
-public abstract class Attribute implements Cloneable, Serializable {
+public abstract class Attribute implements Cloneable {
/**
* Clears the values in this Attribute and resets it to its
* default value.
Index: src/java/org/apache/lucene/util/OpenBitSet.java
===================================================================
--- src/java/org/apache/lucene/util/OpenBitSet.java (revision 725699)
+++ src/java/org/apache/lucene/util/OpenBitSet.java (working copy)
@@ -18,7 +18,6 @@
package org.apache.lucene.util;
import java.util.Arrays;
-import java.io.Serializable;
import org.apache.lucene.search.DocIdSet;
import org.apache.lucene.search.DocIdSetIterator;
@@ -77,7 +76,7 @@
* @version $Id$
*/
-public class OpenBitSet extends DocIdSet implements Cloneable, Serializable {
+public class OpenBitSet extends DocIdSet implements Cloneable {
protected long[] bits;
protected int wlen; // number of words (elements) used in the array
Index: src/java/org/apache/lucene/util/Parameter.java
===================================================================
--- src/java/org/apache/lucene/util/Parameter.java (revision 725699)
+++ src/java/org/apache/lucene/util/Parameter.java (working copy)
@@ -18,7 +18,6 @@
*/
import java.io.ObjectStreamException;
-import java.io.Serializable;
import java.io.StreamCorruptedException;
import java.util.HashMap;
import java.util.Map;
@@ -26,7 +25,7 @@
/**
* A serializable Enum class.
*/
-public abstract class Parameter implements Serializable
+public abstract class Parameter
{
static Map allParameters = new HashMap();
Index: src/java/org/apache/lucene/index/Payload.java
===================================================================
--- src/java/org/apache/lucene/index/Payload.java (revision 725699)
+++ src/java/org/apache/lucene/index/Payload.java (working copy)
@@ -17,8 +17,6 @@
* limitations under the License.
*/
-import java.io.Serializable;
-
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.util.ArrayUtil;
@@ -34,7 +32,7 @@
* to retrieve the payloads from the index.
*
*/
-public class Payload implements Serializable, Cloneable {
+public class Payload implements Cloneable {
/** the byte array containing the payload data */
protected byte[] data;
Index: src/java/org/apache/lucene/index/TermVectorOffsetInfo.java
===================================================================
--- src/java/org/apache/lucene/index/TermVectorOffsetInfo.java (revision 725699)
+++ src/java/org/apache/lucene/index/TermVectorOffsetInfo.java (working copy)
@@ -1,6 +1,5 @@
package org.apache.lucene.index;
-import java.io.Serializable;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -24,7 +23,7 @@
* offset information. This offset information is the character offset as set during the Analysis phase (and thus may not be the actual offset in the
* original content).
*/
-public class TermVectorOffsetInfo implements Serializable {
+public class TermVectorOffsetInfo {
/**
* Convenience declaration when creating a {@link org.apache.lucene.index.TermPositionVector} that stores only position information.
*/
Index: src/java/org/apache/lucene/index/Term.java
===================================================================
--- src/java/org/apache/lucene/index/Term.java (revision 725699)
+++ src/java/org/apache/lucene/index/Term.java (working copy)
@@ -25,7 +25,7 @@
Note that terms may represent more than words from text fields, but also
things like dates, email addresses, urls, etc. */
-public final class Term implements Comparable, java.io.Serializable {
+public final class Term implements Comparable {
String field;
String text;
Index: src/java/org/apache/lucene/document/FieldSelector.java
===================================================================
--- src/java/org/apache/lucene/document/FieldSelector.java (revision 725699)
+++ src/java/org/apache/lucene/document/FieldSelector.java (working copy)
@@ -1,6 +1,5 @@
package org.apache.lucene.document;
-import java.io.Serializable;
/**
* Copyright 2004 The Apache Software Foundation
*
@@ -22,7 +21,7 @@
* what Fields get loaded on a {@link Document} by {@link org.apache.lucene.index.IndexReader#document(int,org.apache.lucene.document.FieldSelector)}
*
**/
-public interface FieldSelector extends Serializable {
+public interface FieldSelector {
/**
*
Index: src/java/org/apache/lucene/document/Document.java
===================================================================
--- src/java/org/apache/lucene/document/Document.java (revision 725699)
+++ src/java/org/apache/lucene/document/Document.java (working copy)
@@ -36,7 +36,7 @@
* IndexReader#document(int)}.
*/
-public final class Document implements java.io.Serializable {
+public final class Document {
List fields = new ArrayList();
private float boost = 1.0f;
Index: src/java/org/apache/lucene/document/Fieldable.java
===================================================================
--- src/java/org/apache/lucene/document/Fieldable.java (revision 725699)
+++ src/java/org/apache/lucene/document/Fieldable.java (working copy)
@@ -20,7 +20,6 @@
import org.apache.lucene.index.FieldInvertState;
import java.io.Reader;
-import java.io.Serializable;
/**
* Synonymous with {@link Field}.
@@ -32,7 +31,7 @@
*
Scorer is constructed by {@link #scorer(IndexReader)}.
*
*/
-public interface Weight extends java.io.Serializable {
+public interface Weight {
/** The query that this concerns. */
Query getQuery();
Index: src/java/org/apache/lucene/search/Query.java
===================================================================
--- src/java/org/apache/lucene/search/Query.java (revision 725699)
+++ src/java/org/apache/lucene/search/Query.java (working copy)
@@ -44,7 +44,7 @@
b. Documents
Index: src/java/org/apache/lucene/search/BooleanClause.java
===================================================================
--- src/java/org/apache/lucene/search/BooleanClause.java (revision 725699)
+++ src/java/org/apache/lucene/search/BooleanClause.java (working copy)
@@ -20,10 +20,10 @@
*/
/** A clause in a BooleanQuery. */
-public class BooleanClause implements java.io.Serializable {
+public class BooleanClause {
/** Specifies how clauses are to occur in matching documents. */
- public static final class Occur extends Parameter implements java.io.Serializable {
+ public static final class Occur extends Parameter {
private Occur(String name) {
// typesafe enum pattern, no public constructor
Index: src/java/org/apache/lucene/search/Searchable.java
===================================================================
--- src/java/org/apache/lucene/search/Searchable.java (revision 725699)
+++ src/java/org/apache/lucene/search/Searchable.java (working copy)
@@ -35,7 +35,7 @@
* they may be efficiently passed to a remote index, with only the top-scoring
* hits being returned, rather than every matching hit.
*/
-public interface Searchable extends java.rmi.Remote {
+public interface Searchable {
/** Lower-level search API.
*
* {@link HitCollector#collect(int,float)} is called for every non-zero
Index: src/java/org/apache/lucene/search/function/ValueSource.java
===================================================================
--- src/java/org/apache/lucene/search/function/ValueSource.java (revision 725699)
+++ src/java/org/apache/lucene/search/function/ValueSource.java (working copy)
@@ -21,7 +21,6 @@
import org.apache.lucene.search.function.DocValues;
import java.io.IOException;
-import java.io.Serializable;
/**
* Expert: source of values for basic function queries.
@@ -38,7 +37,7 @@
*
*
*/
-public abstract class ValueSource implements Serializable {
+public abstract class ValueSource {
/**
* Return the DocValues used by the function query.
Index: src/java/org/apache/lucene/search/FilterManager.java
===================================================================
--- src/java/org/apache/lucene/search/FilterManager.java (revision 725699)
+++ src/java/org/apache/lucene/search/FilterManager.java (working copy)
@@ -1,204 +0,0 @@
-package org.apache.lucene.search;
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.util.Comparator;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.TreeSet;
-
-/**
- * Filter caching singleton. It can be used by {@link org.apache.lucene.search.RemoteCachingWrapperFilter}
- * or just to save filters locally for reuse.
- * This class makes it possble to cache Filters even when using RMI, as it
- * keeps the cache on the seaercher side of the RMI connection.
- *
- * Also could be used as a persistent storage for any filter as long as the
- * filter provides a proper hashCode(), as that is used as the key in the cache.
- *
- * The cache is periodically cleaned up from a separate thread to ensure the
- * cache doesn't exceed the maximum size.
- */
-public class FilterManager {
-
- protected static FilterManager manager;
-
- /** The default maximum number of Filters in the cache */
- protected static final int DEFAULT_CACHE_CLEAN_SIZE = 100;
- /** The default frequency of cache clenup */
- protected static final long DEFAULT_CACHE_SLEEP_TIME = 1000 * 60 * 10;
-
- /** The cache itself */
- protected Map cache;
- /** Maximum allowed cache size */
- protected int cacheCleanSize;
- /** Cache cleaning frequency */
- protected long cleanSleepTime;
- /** Cache cleaner that runs in a separate thread */
- protected FilterCleaner filterCleaner;
-
- public synchronized static FilterManager getInstance() {
- if (manager == null) {
- manager = new FilterManager();
- }
- return manager;
- }
-
- /**
- * Sets up the FilterManager singleton.
- */
- protected FilterManager() {
- cache = new HashMap();
- cacheCleanSize = DEFAULT_CACHE_CLEAN_SIZE; // Let the cache get to 100 items
- cleanSleepTime = DEFAULT_CACHE_SLEEP_TIME; // 10 minutes between cleanings
-
- filterCleaner = new FilterCleaner();
- Thread fcThread = new Thread(filterCleaner);
- // setto be a Daemon so it doesn't have to be stopped
- fcThread.setDaemon(true);
- fcThread.start();
- }
-
- /**
- * Sets the max size that cache should reach before it is cleaned up
- * @param cacheCleanSize maximum allowed cache size
- */
- public void setCacheSize(int cacheCleanSize) {
- this.cacheCleanSize = cacheCleanSize;
- }
-
- /**
- * Sets the cache cleaning frequency in milliseconds.
- * @param cleanSleepTime cleaning frequency in millioseconds
- */
- public void setCleanThreadSleepTime(long cleanSleepTime) {
- this.cleanSleepTime = cleanSleepTime;
- }
-
- /**
- * Returns the cached version of the filter. Allows the caller to pass up
- * a small filter but this will keep a persistent version around and allow
- * the caching filter to do its job.
- *
- * @param filter The input filter
- * @return The cached version of the filter
- */
- public Filter getFilter(Filter filter) {
- synchronized(cache) {
- FilterItem fi = null;
- fi = (FilterItem)cache.get(new Integer(filter.hashCode()));
- if (fi != null) {
- fi.timestamp = new Date().getTime();
- return fi.filter;
- }
- cache.put(new Integer(filter.hashCode()), new FilterItem(filter));
- return filter;
- }
- }
-
- /**
- * Holds the filter and the last time the filter was used, to make LRU-based
- * cache cleaning possible.
- * TODO: Clean this up when we switch to Java 1.5
- */
- protected class FilterItem {
- public Filter filter;
- public long timestamp;
-
- public FilterItem (Filter filter) {
- this.filter = filter;
- this.timestamp = new Date().getTime();
- }
- }
-
-
- /**
- * Keeps the cache from getting too big.
- * If we were using Java 1.5, we could use LinkedHashMap and we would not need this thread
- * to clean out the cache.
- *
- * The SortedSet sortedFilterItems is used only to sort the items from the cache,
- * so when it's time to clean up we have the TreeSet sort the FilterItems by
- * timestamp.
- *
- * Removes 1.5 * the numbers of items to make the cache smaller.
- * For example:
- * If cache clean size is 10, and the cache is at 15, we would remove (15 - 10) * 1.5 = 7.5 round up to 8.
- * This way we clean the cache a bit more, and avoid having the cache cleaner having to do it frequently.
- */
- protected class FilterCleaner implements Runnable {
-
- private boolean running = true;
- private TreeSet sortedFilterItems;
-
- public FilterCleaner() {
- sortedFilterItems = new TreeSet(new Comparator() {
- public int compare(Object a, Object b) {
- if( a instanceof Map.Entry && b instanceof Map.Entry) {
- FilterItem fia = (FilterItem) ((Map.Entry)a).getValue();
- FilterItem fib = (FilterItem) ((Map.Entry)b).getValue();
- if ( fia.timestamp == fib.timestamp ) {
- return 0;
- }
- // smaller timestamp first
- if ( fia.timestamp < fib.timestamp ) {
- return -1;
- }
- // larger timestamp last
- return 1;
- } else {
- throw new ClassCastException("Objects are not Map.Entry");
- }
- }
- });
- }
-
- public void run () {
- while (running) {
-
- // sort items from oldest to newest
- // we delete the oldest filters
- if (cache.size() > cacheCleanSize) {
- // empty the temporary set
- sortedFilterItems.clear();
- synchronized (cache) {
- sortedFilterItems.addAll(cache.entrySet());
- Iterator it = sortedFilterItems.iterator();
- int numToDelete = (int) ((cache.size() - cacheCleanSize) * 1.5);
- int counter = 0;
- // loop over the set and delete all of the cache entries not used in a while
- while (it.hasNext() && counter++ < numToDelete) {
- Map.Entry entry = (Map.Entry)it.next();
- cache.remove(entry.getKey());
- }
- }
- // empty the set so we don't tie up the memory
- sortedFilterItems.clear();
- }
- // take a nap
- try {
- Thread.sleep(cleanSleepTime);
- } catch (InterruptedException e) {
- // just keep going
- }
- }
- }
- }
-}
Index: src/java/org/apache/lucene/search/Sort.java
===================================================================
--- src/java/org/apache/lucene/search/Sort.java (revision 725699)
+++ src/java/org/apache/lucene/search/Sort.java (working copy)
@@ -17,7 +17,6 @@
* limitations under the License.
*/
-import java.io.Serializable;
import java.util.Arrays;
@@ -98,8 +97,7 @@
* @since lucene 1.4
* @version $Id$
*/
-public class Sort
-implements Serializable {
+public class Sort {
/**
* Represents sorting by computed relevance. Using this sort criteria returns
Index: src/java/org/apache/lucene/search/Hit.java
===================================================================
--- src/java/org/apache/lucene/search/Hit.java (revision 725699)
+++ src/java/org/apache/lucene/search/Hit.java (working copy)
@@ -28,7 +28,7 @@
*
* @deprecated Hits will be removed in Lucene 3.0. Use {@link TopDocCollector} and {@link TopDocs} instead.
*/
-public class Hit implements java.io.Serializable {
+public class Hit {
private Document doc = null;
Index: src/java/org/apache/lucene/search/Explanation.java
===================================================================
--- src/java/org/apache/lucene/search/Explanation.java (revision 725699)
+++ src/java/org/apache/lucene/search/Explanation.java (working copy)
@@ -20,7 +20,7 @@
import java.util.ArrayList;
/** Expert: Describes the score computation for document and query. */
-public class Explanation implements java.io.Serializable {
+public class Explanation {
private float value; // the value of this node
private String description; // what it represents
private ArrayList details; // sub-explanations
Index: src/java/org/apache/lucene/search/SortField.java
===================================================================
--- src/java/org/apache/lucene/search/SortField.java (revision 725699)
+++ src/java/org/apache/lucene/search/SortField.java (working copy)
@@ -17,7 +17,6 @@
* limitations under the License.
*/
-import java.io.Serializable;
import java.util.Locale;
/**
@@ -30,8 +29,7 @@
* @version $Id$
* @see Sort
*/
-public class SortField
-implements Serializable {
+public class SortField {
/** Sort by document score (relevancy). Sort values are Float and higher
* values are at the front. */
Index: src/java/org/apache/lucene/search/SortComparatorSource.java
===================================================================
--- src/java/org/apache/lucene/search/SortComparatorSource.java (revision 725699)
+++ src/java/org/apache/lucene/search/SortComparatorSource.java (working copy)
@@ -19,7 +19,6 @@
import org.apache.lucene.index.IndexReader;
import java.io.IOException;
-import java.io.Serializable;
/**
* Expert: returns a comparator for sorting ScoreDocs.
@@ -30,8 +29,7 @@
* @version $Id$
* @since 1.4
*/
-public interface SortComparatorSource
-extends Serializable {
+public interface SortComparatorSource {
/**
* Creates a comparator for the field in the given index.
Index: src/java/org/apache/lucene/search/Similarity.java
===================================================================
--- src/java/org/apache/lucene/search/Similarity.java (revision 725699)
+++ src/java/org/apache/lucene/search/Similarity.java (working copy)
@@ -22,7 +22,6 @@
import org.apache.lucene.util.SmallFloat;
import java.io.IOException;
-import java.io.Serializable;
import java.util.Collection;
import java.util.Iterator;
@@ -286,7 +285,7 @@
* @see org.apache.lucene.index.IndexWriter#setSimilarity(Similarity)
* @see Searcher#setSimilarity(Similarity)
*/
-public abstract class Similarity implements Serializable {
+public abstract class Similarity {
/** The Similarity implementation used by default. */
private static Similarity defaultImpl = new DefaultSimilarity();
Index: src/java/org/apache/lucene/analysis/tokenattributes/PayloadAttribute.java
===================================================================
--- src/java/org/apache/lucene/analysis/tokenattributes/PayloadAttribute.java (revision 725699)
+++ src/java/org/apache/lucene/analysis/tokenattributes/PayloadAttribute.java (working copy)
@@ -17,8 +17,6 @@
* limitations under the License.
*/
-import java.io.Serializable;
-
import org.apache.lucene.index.Payload;
import org.apache.lucene.util.Attribute;
@@ -30,7 +28,7 @@
* The APIs introduced in these classes with Lucene 2.9 might change in the future.
* We will make our best efforts to keep the APIs backwards-compatible.
*/
-public class PayloadAttribute extends Attribute implements Cloneable, Serializable {
+public class PayloadAttribute extends Attribute implements Cloneable {
private Payload payload;
/**
Index: src/java/org/apache/lucene/analysis/tokenattributes/PositionIncrementAttribute.java
===================================================================
--- src/java/org/apache/lucene/analysis/tokenattributes/PositionIncrementAttribute.java (revision 725699)
+++ src/java/org/apache/lucene/analysis/tokenattributes/PositionIncrementAttribute.java (working copy)
@@ -17,8 +17,6 @@
* limitations under the License.
*/
-import java.io.Serializable;
-
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.util.Attribute;
@@ -53,7 +51,7 @@
*
* @see org.apache.lucene.index.TermPositions
*/
-public class PositionIncrementAttribute extends Attribute implements Cloneable, Serializable {
+public class PositionIncrementAttribute extends Attribute implements Cloneable {
private int positionIncrement = 1;
/** Set the position increment. The default value is one.
Index: src/java/org/apache/lucene/analysis/tokenattributes/FlagsAttribute.java
===================================================================
--- src/java/org/apache/lucene/analysis/tokenattributes/FlagsAttribute.java (revision 725699)
+++ src/java/org/apache/lucene/analysis/tokenattributes/FlagsAttribute.java (working copy)
@@ -17,7 +17,6 @@
* limitations under the License.
*/
-import java.io.Serializable;
import org.apache.lucene.util.Attribute;
@@ -31,7 +30,7 @@
* We will make our best efforts to keep the APIs backwards-compatible.
*/
-public class FlagsAttribute extends Attribute implements Cloneable, Serializable {
+public class FlagsAttribute extends Attribute implements Cloneable {
private int flags = 0;
/**
Index: src/java/org/apache/lucene/analysis/tokenattributes/TypeAttribute.java
===================================================================
--- src/java/org/apache/lucene/analysis/tokenattributes/TypeAttribute.java (revision 725699)
+++ src/java/org/apache/lucene/analysis/tokenattributes/TypeAttribute.java (working copy)
@@ -17,8 +17,6 @@
* limitations under the License.
*/
-import java.io.Serializable;
-
import org.apache.lucene.util.Attribute;
/**
@@ -29,7 +27,7 @@
* The APIs introduced in these classes with Lucene 2.9 might change in the future.
* We will make our best efforts to keep the APIs backwards-compatible.
*/
-public class TypeAttribute extends Attribute implements Cloneable, Serializable {
+public class TypeAttribute extends Attribute implements Cloneable {
private String type;
public static final String DEFAULT_TYPE = "word";
Index: src/java/org/apache/lucene/analysis/tokenattributes/OffsetAttribute.java
===================================================================
--- src/java/org/apache/lucene/analysis/tokenattributes/OffsetAttribute.java (revision 725699)
+++ src/java/org/apache/lucene/analysis/tokenattributes/OffsetAttribute.java (working copy)
@@ -17,8 +17,6 @@
* limitations under the License.
*/
-import java.io.Serializable;
-
import org.apache.lucene.util.Attribute;
/**
@@ -29,7 +27,7 @@
* The APIs introduced in these classes with Lucene 2.9 might change in the future.
* We will make our best efforts to keep the APIs backwards-compatible.
*/
-public class OffsetAttribute extends Attribute implements Cloneable, Serializable {
+public class OffsetAttribute extends Attribute implements Cloneable {
private int startOffset;
private int endOffset;
Index: src/java/org/apache/lucene/analysis/tokenattributes/TermAttribute.java
===================================================================
--- src/java/org/apache/lucene/analysis/tokenattributes/TermAttribute.java (revision 725699)
+++ src/java/org/apache/lucene/analysis/tokenattributes/TermAttribute.java (working copy)
@@ -17,8 +17,6 @@
* limitations under the License.
*/
-import java.io.Serializable;
-
import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.util.Attribute;
@@ -30,7 +28,7 @@
* The APIs introduced in these classes with Lucene 2.9 might change in the future.
* We will make our best efforts to keep the APIs backwards-compatible.
*/
-public class TermAttribute extends Attribute implements Cloneable, Serializable {
+public class TermAttribute extends Attribute implements Cloneable {
private static int MIN_BUFFER_SIZE = 10;
private char[] termBuffer;
Index: src/java/org/apache/lucene/store/RAMDirectory.java
===================================================================
--- src/java/org/apache/lucene/store/RAMDirectory.java (revision 725699)
+++ src/java/org/apache/lucene/store/RAMDirectory.java (working copy)
@@ -20,7 +20,6 @@
import java.io.IOException;
import java.io.FileNotFoundException;
import java.io.File;
-import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
@@ -32,7 +31,7 @@
*
* @version $Id$
*/
-public class RAMDirectory extends Directory implements Serializable {
+public class RAMDirectory extends Directory {
private static final long serialVersionUID = 1l;
Index: src/java/org/apache/lucene/store/RAMFile.java
===================================================================
--- src/java/org/apache/lucene/store/RAMFile.java (revision 725699)
+++ src/java/org/apache/lucene/store/RAMFile.java (working copy)
@@ -18,11 +18,8 @@
*/
import java.util.ArrayList;
-import java.io.Serializable;
-class RAMFile implements Serializable {
-
- private static final long serialVersionUID = 1l;
+class RAMFile {
private ArrayList buffers = new ArrayList();
long length;
Index: src/test/org/apache/lucene/search/QueryUtils.java
===================================================================
--- src/test/org/apache/lucene/search/QueryUtils.java (revision 725699)
+++ src/test/org/apache/lucene/search/QueryUtils.java (working copy)
@@ -1,13 +1,9 @@
package org.apache.lucene.search;
+import java.io.IOException;
+
import junit.framework.TestCase;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-
/**
* Copyright 2005 Apache Software Foundation
*
@@ -88,7 +84,6 @@
checkSkipTo(q1,is);
}
checkExplanations(q1,s);
- checkSerialization(q1,s);
}
} catch (IOException e) {
throw new RuntimeException(e);
@@ -95,31 +90,6 @@
}
}
- /** check that the query weight is serializable.
- * @throws IOException if serialization check fail.
- */
- private static void checkSerialization(Query q, Searcher s) throws IOException {
- Weight w = q.weight(s);
- try {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(bos);
- oos.writeObject(w);
- oos.close();
- ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bos.toByteArray()));
- ois.readObject();
- ois.close();
-
- //skip rquals() test for now - most weights don't overide equals() and we won't add this just for the tests.
- //TestCase.assertEquals("writeObject(w) != w. ("+w+")",w2,w);
-
- } catch (Exception e) {
- IOException e2 = new IOException("Serialization failed for "+w);
- e2.initCause(e);
- throw e2;
- }
- }
-
-
/** alternate scorer skipTo(),skipTo(),next(),next(),skipTo(),skipTo(), etc
* and ensure a hitcollector receives same docs and scores
*/
Index: src/test/org/apache/lucene/search/TestSort.java
===================================================================
--- src/test/org/apache/lucene/search/TestSort.java (revision 725699)
+++ src/test/org/apache/lucene/search/TestSort.java (working copy)
@@ -31,10 +31,6 @@
import org.apache.lucene.util.DocIdBitSet;
import java.io.IOException;
-import java.io.Serializable;
-import java.rmi.Naming;
-import java.rmi.registry.LocateRegistry;
-import java.rmi.registry.Registry;
import java.util.BitSet;
import java.util.HashMap;
import java.util.Iterator;
@@ -51,19 +47,18 @@
*/
public class TestSort
-extends TestCase
-implements Serializable {
+extends TestCase {
- private Searcher full;
- private Searcher searchX;
- private Searcher searchY;
- private Query queryX;
- private Query queryY;
- private Query queryA;
+ protected Searcher full;
+ protected Searcher searchX;
+ protected Searcher searchY;
+ protected Query queryX;
+ protected Query queryY;
+ protected Query queryA;
private Query queryE;
private Query queryF;
private Query queryG;
- private Sort sort;
+ protected Sort sort;
public TestSort (String name) {
@@ -75,13 +70,6 @@
TestRunner.run (suite());
else if ("server".equals (argv[0])) {
TestSort test = new TestSort (null);
- try {
- test.startServer();
- Thread.sleep (500000);
- } catch (Exception e) {
- System.out.println (e);
- e.printStackTrace();
- }
}
}
@@ -144,7 +132,7 @@
return new IndexSearcher (indexStore);
}
- private Searcher getFullIndex()
+ protected Searcher getFullIndex()
throws IOException {
return getIndex (true, true);
}
@@ -479,132 +467,6 @@
runMultiSorts (searcher);
}
- // test a variety of sorts using a remote searcher
- public void testRemoteSort() throws Exception {
- Searchable searcher = getRemote();
- MultiSearcher multi = new MultiSearcher (new Searchable[] { searcher });
- runMultiSorts (multi);
- }
-
- // test custom search when remote
- public void testRemoteCustomSort() throws Exception {
- Searchable searcher = getRemote();
- MultiSearcher multi = new MultiSearcher (new Searchable[] { searcher });
- sort.setSort (new SortField ("custom", SampleComparable.getComparatorSource()));
- assertMatches (multi, queryX, sort, "CAIEG");
- sort.setSort (new SortField ("custom", SampleComparable.getComparatorSource(), true));
- assertMatches (multi, queryY, sort, "HJDBF");
- SortComparator custom = SampleComparable.getComparator();
- sort.setSort (new SortField ("custom", custom));
- assertMatches (multi, queryX, sort, "CAIEG");
- sort.setSort (new SortField ("custom", custom, true));
- assertMatches (multi, queryY, sort, "HJDBF");
- }
-
- // test that the relevancy scores are the same even if
- // hits are sorted
- public void testNormalizedScores() throws Exception {
-
- // capture relevancy scores
- HashMap scoresX = getScores (full.search (queryX, null, 1000).scoreDocs, full);
- HashMap scoresY = getScores (full.search (queryY, null, 1000).scoreDocs, full);
- HashMap scoresA = getScores (full.search (queryA, null, 1000).scoreDocs, full);
-
- // we'll test searching locally, remote and multi
- MultiSearcher remote = new MultiSearcher (new Searchable[] { getRemote() });
- MultiSearcher multi = new MultiSearcher (new Searchable[] { searchX, searchY });
-
- // change sorting and make sure relevancy stays the same
-
- sort = new Sort();
- assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full));
- assertSameValues (scoresX, getScores (remote.search (queryX, null, 1000, sort).scoreDocs, remote));
- assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi));
- assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full));
- assertSameValues (scoresY, getScores (remote.search (queryY, null, 1000, sort).scoreDocs, remote));
- assertSameValues (scoresY, getScores (multi.search (queryY, null, 1000, sort).scoreDocs, multi));
- assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full));
- assertSameValues (scoresA, getScores (remote.search (queryA, null, 1000, sort).scoreDocs, remote));
- assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi));
-
- sort.setSort(SortField.FIELD_DOC);
- assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full));
- assertSameValues (scoresX, getScores (remote.search (queryX, null, 1000, sort).scoreDocs, remote));
- assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi));
- assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full));
- assertSameValues (scoresY, getScores (remote.search (queryY, null, 1000, sort).scoreDocs, remote));
- assertSameValues (scoresY, getScores (multi.search (queryY, null, 1000, sort).scoreDocs, multi));
- assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full));
- assertSameValues (scoresA, getScores (remote.search (queryA, null, 1000, sort).scoreDocs, remote));
- assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi));
-
- sort.setSort ("int");
- assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full));
- assertSameValues (scoresX, getScores (remote.search (queryX, null, 1000, sort).scoreDocs, remote));
- assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi));
- assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full));
- assertSameValues (scoresY, getScores (remote.search (queryY, null, 1000, sort).scoreDocs, remote));
- assertSameValues (scoresY, getScores (multi.search (queryY, null, 1000, sort).scoreDocs, multi));
- assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full));
- assertSameValues (scoresA, getScores (remote.search (queryA, null, 1000, sort).scoreDocs, remote));
- assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi));
-
- sort.setSort ("float");
- assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full));
- assertSameValues (scoresX, getScores (remote.search (queryX, null, 1000, sort).scoreDocs, remote));
- assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi));
- assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full));
- assertSameValues (scoresY, getScores (remote.search (queryY, null, 1000, sort).scoreDocs, remote));
- assertSameValues (scoresY, getScores (multi.search (queryY, null, 1000, sort).scoreDocs, multi));
- assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full));
- assertSameValues (scoresA, getScores (remote.search (queryA, null, 1000, sort).scoreDocs, remote));
- assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi));
-
- sort.setSort ("string");
- assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full));
- assertSameValues (scoresX, getScores (remote.search (queryX, null, 1000, sort).scoreDocs, remote));
- assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi));
- assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full));
- assertSameValues (scoresY, getScores (remote.search (queryY, null, 1000, sort).scoreDocs, remote));
- assertSameValues (scoresY, getScores (multi.search (queryY, null, 1000, sort).scoreDocs, multi));
- assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full));
- assertSameValues (scoresA, getScores (remote.search (queryA, null, 1000, sort).scoreDocs, remote));
- assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi));
-
- sort.setSort (new String[] {"int","float"});
- assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full));
- assertSameValues (scoresX, getScores (remote.search (queryX, null, 1000, sort).scoreDocs, remote));
- assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi));
- assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full));
- assertSameValues (scoresY, getScores (remote.search (queryY, null, 1000, sort).scoreDocs, remote));
- assertSameValues (scoresY, getScores (multi.search (queryY, null, 1000, sort).scoreDocs, multi));
- assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full));
- assertSameValues (scoresA, getScores (remote.search (queryA, null, 1000, sort).scoreDocs, remote));
- assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi));
-
- sort.setSort (new SortField[] { new SortField ("int", true), new SortField (null, SortField.DOC, true) });
- assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full));
- assertSameValues (scoresX, getScores (remote.search (queryX, null, 1000, sort).scoreDocs, remote));
- assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi));
- assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full));
- assertSameValues (scoresY, getScores (remote.search (queryY, null, 1000, sort).scoreDocs, remote));
- assertSameValues (scoresY, getScores (multi.search (queryY, null, 1000, sort).scoreDocs, multi));
- assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full));
- assertSameValues (scoresA, getScores (remote.search (queryA, null, 1000, sort).scoreDocs, remote));
- assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi));
-
- sort.setSort (new String[] {"float","string"});
- assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full));
- assertSameValues (scoresX, getScores (remote.search (queryX, null, 1000, sort).scoreDocs, remote));
- assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi));
- assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full));
- assertSameValues (scoresY, getScores (remote.search (queryY, null, 1000, sort).scoreDocs, remote));
- assertSameValues (scoresY, getScores (multi.search (queryY, null, 1000, sort).scoreDocs, multi));
- assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full));
- assertSameValues (scoresA, getScores (remote.search (queryA, null, 1000, sort).scoreDocs, remote));
- assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi));
-
- }
public void testTopDocsScores() throws Exception {
@@ -633,7 +495,7 @@
// runs a variety of sorts useful for multisearchers
- private void runMultiSorts (Searcher multi) throws Exception {
+ protected void runMultiSorts (Searcher multi) throws Exception {
sort.setSort (SortField.FIELD_DOC);
assertMatchesPattern (multi, queryA, sort, "[AB]{2}[CD]{2}[EF]{2}[GH]{2}[IJ]{2}");
@@ -693,7 +555,7 @@
}
// make sure the documents returned by the search match the expected list
- private void assertMatches (Searcher searcher, Query query, Sort sort, String expectedResult)
+ protected void assertMatches (Searcher searcher, Query query, Sort sort, String expectedResult)
throws IOException {
ScoreDoc[] result = searcher.search (query, null, 1000, sort).scoreDocs;
StringBuffer buff = new StringBuffer(10);
@@ -709,7 +571,7 @@
}
// make sure the documents returned by the search match the expected list pattern
- private void assertMatchesPattern (Searcher searcher, Query query, Sort sort, String pattern)
+ protected void assertMatchesPattern (Searcher searcher, Query query, Sort sort, String pattern)
throws IOException {
ScoreDoc[] result = searcher.search (query, null, 1000, sort).scoreDocs;
StringBuffer buff = new StringBuffer(10);
@@ -725,7 +587,7 @@
assertTrue (Pattern.compile(pattern).matcher(buff.toString()).matches());
}
- private HashMap getScores (ScoreDoc[] hits, Searcher searcher)
+ protected HashMap getScores (ScoreDoc[] hits, Searcher searcher)
throws IOException {
HashMap scoreMap = new HashMap();
int n = hits.length;
@@ -739,7 +601,7 @@
}
// make sure all the values in the maps match
- private void assertSameValues (HashMap m1, HashMap m2) {
+ protected void assertSameValues (HashMap m1, HashMap m2) {
int n = m1.size();
int m = m2.size();
assertEquals (n, m);
@@ -755,29 +617,4 @@
}
}
}
-
- private Searchable getRemote () throws Exception {
- try {
- return lookupRemote ();
- } catch (Throwable e) {
- startServer ();
- return lookupRemote ();
- }
- }
-
- private Searchable lookupRemote () throws Exception {
- return (Searchable) Naming.lookup ("//localhost/SortedSearchable");
- }
-
- private void startServer () throws Exception {
- // construct an index
- Searcher local = getFullIndex();
- // local.search (queryA, new Sort());
-
- // publish it
- Registry reg = LocateRegistry.createRegistry (1099);
- RemoteSearchable impl = new RemoteSearchable (local);
- Naming.rebind ("//localhost/SortedSearchable", impl);
- }
-
}
Index: src/test/org/apache/lucene/search/SampleComparable.java
===================================================================
--- src/test/org/apache/lucene/search/SampleComparable.java (revision 725699)
+++ src/test/org/apache/lucene/search/SampleComparable.java (working copy)
@@ -23,7 +23,6 @@
import org.apache.lucene.index.TermEnum;
import java.io.IOException;
-import java.io.Serializable;
/**
* An example Comparable for use with the custom sort tests.
@@ -47,7 +46,7 @@
* @since 1.4
*/
public class SampleComparable
-implements Comparable, Serializable {
+implements Comparable {
String string_part;
Integer int_part;
Index: src/test/org/apache/lucene/search/RemoteCachingWrapperFilterHelper.java
===================================================================
--- src/test/org/apache/lucene/search/RemoteCachingWrapperFilterHelper.java (revision 725699)
+++ src/test/org/apache/lucene/search/RemoteCachingWrapperFilterHelper.java (working copy)
@@ -1,59 +0,0 @@
-package org.apache.lucene.search;
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.io.IOException;
-import java.util.BitSet;
-
-import junit.framework.TestCase;
-
-import org.apache.lucene.index.IndexReader;
-
-/**
- * A unit test helper class to help with RemoteCachingWrapperFilter testing and
- * assert that it is working correctly.
- */
-public class RemoteCachingWrapperFilterHelper extends RemoteCachingWrapperFilter {
-
- private boolean shouldHaveCache;
-
- public RemoteCachingWrapperFilterHelper(Filter filter, boolean shouldHaveCache) {
- super(filter);
- this.shouldHaveCache = shouldHaveCache;
- }
-
- public void shouldHaveCache(boolean shouldHaveCache) {
- this.shouldHaveCache = shouldHaveCache;
- }
-
- public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
- Filter cachedFilter = FilterManager.getInstance().getFilter(filter);
-
- TestCase.assertNotNull("Filter should not be null", cachedFilter);
- if (!shouldHaveCache) {
- TestCase.assertSame("First time filter should be the same ", filter, cachedFilter);
- } else {
- TestCase.assertNotSame("We should have a cached version of the filter", filter, cachedFilter);
- }
-
- if (filter instanceof CachingWrapperFilterHelper) {
- ((CachingWrapperFilterHelper)cachedFilter).setShouldHaveCache(shouldHaveCache);
- }
- return cachedFilter.getDocIdSet(reader);
- }
-}
Index: src/test/org/apache/lucene/search/TestCustomSearcherSort.java
===================================================================
--- src/test/org/apache/lucene/search/TestCustomSearcherSort.java (revision 725699)
+++ src/test/org/apache/lucene/search/TestCustomSearcherSort.java (working copy)
@@ -17,7 +17,6 @@
*/
import java.io.IOException;
-import java.io.Serializable;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Map;
@@ -45,8 +44,7 @@
*/
public class TestCustomSearcherSort
-extends TestCase
-implements Serializable {
+extends TestCase {
private Directory index = null;
private Query query = null;
Index: src/test/org/apache/lucene/search/TestRemoteCachingWrapperFilter.java
===================================================================
--- src/test/org/apache/lucene/search/TestRemoteCachingWrapperFilter.java (revision 725699)
+++ src/test/org/apache/lucene/search/TestRemoteCachingWrapperFilter.java (working copy)
@@ -1,127 +0,0 @@
-package org.apache.lucene.search;
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.rmi.Naming;
-import java.rmi.registry.LocateRegistry;
-
-import org.apache.lucene.util.LuceneTestCase;
-
-import org.apache.lucene.analysis.SimpleAnalyzer;
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.store.RAMDirectory;
-
-/**
- * Tests that the index is cached on the searcher side of things.
- * NOTE: This is copied from TestRemoteSearchable since it already had a remote index set up.
- */
-public class TestRemoteCachingWrapperFilter extends LuceneTestCase {
- public TestRemoteCachingWrapperFilter(String name) {
- super(name);
- }
-
- private static Searchable getRemote() throws Exception {
- try {
- return lookupRemote();
- } catch (Throwable e) {
- startServer();
- return lookupRemote();
- }
- }
-
- private static Searchable lookupRemote() throws Exception {
- return (Searchable)Naming.lookup("//localhost/Searchable");
- }
-
- private static void startServer() throws Exception {
- // construct an index
- RAMDirectory indexStore = new RAMDirectory();
- IndexWriter writer = new IndexWriter(indexStore, new SimpleAnalyzer(), true,
- IndexWriter.MaxFieldLength.LIMITED);
- Document doc = new Document();
- doc.add(new Field("test", "test text", Field.Store.YES, Field.Index.ANALYZED));
- doc.add(new Field("type", "A", Field.Store.YES, Field.Index.ANALYZED));
- doc.add(new Field("other", "other test text", Field.Store.YES, Field.Index.ANALYZED));
- writer.addDocument(doc);
- //Need a second document to search for
- doc = new Document();
- doc.add(new Field("test", "test text", Field.Store.YES, Field.Index.ANALYZED));
- doc.add(new Field("type", "B", Field.Store.YES, Field.Index.ANALYZED));
- doc.add(new Field("other", "other test text", Field.Store.YES, Field.Index.ANALYZED));
- writer.addDocument(doc);
- writer.optimize();
- writer.close();
-
- // publish it
- LocateRegistry.createRegistry(1099);
- Searchable local = new IndexSearcher(indexStore);
- RemoteSearchable impl = new RemoteSearchable(local);
- Naming.rebind("//localhost/Searchable", impl);
- }
-
- private static void search(Query query, Filter filter, int hitNumber, String typeValue) throws Exception {
- Searchable[] searchables = { getRemote() };
- Searcher searcher = new MultiSearcher(searchables);
- ScoreDoc[] result = searcher.search(query,filter, 1000).scoreDocs;
- assertEquals(1, result.length);
- Document document = searcher.doc(result[hitNumber].doc);
- assertTrue("document is null and it shouldn't be", document != null);
- assertEquals(typeValue, document.get("type"));
- assertTrue("document.getFields() Size: " + document.getFields().size() + " is not: " + 3, document.getFields().size() == 3);
- }
-
-
- public void testTermRemoteFilter() throws Exception {
- CachingWrapperFilterHelper cwfh = new CachingWrapperFilterHelper(new QueryWrapperFilter(new TermQuery(new Term("type", "a"))));
-
- // This is what we are fixing - if one uses a CachingWrapperFilter(Helper) it will never
- // cache the filter on the remote site
- cwfh.setShouldHaveCache(false);
- search(new TermQuery(new Term("test", "test")), cwfh, 0, "A");
- cwfh.setShouldHaveCache(false);
- search(new TermQuery(new Term("test", "test")), cwfh, 0, "A");
-
- // This is how we fix caching - we wrap a Filter in the RemoteCachingWrapperFilter(Handler - for testing)
- // to cache the Filter on the searcher (remote) side
- RemoteCachingWrapperFilterHelper rcwfh = new RemoteCachingWrapperFilterHelper(cwfh, false);
- search(new TermQuery(new Term("test", "test")), rcwfh, 0, "A");
-
- // 2nd time we do the search, we should be using the cached Filter
- rcwfh.shouldHaveCache(true);
- search(new TermQuery(new Term("test", "test")), rcwfh, 0, "A");
-
- // assert that we get the same cached Filter, even if we create a new instance of RemoteCachingWrapperFilter(Helper)
- // this should pass because the Filter parameters are the same, and the cache uses Filter's hashCode() as cache keys,
- // and Filters' hashCode() builds on Filter parameters, not the Filter instance itself
- rcwfh = new RemoteCachingWrapperFilterHelper(new QueryWrapperFilter(new TermQuery(new Term("type", "a"))), false);
- rcwfh.shouldHaveCache(false);
- search(new TermQuery(new Term("test", "test")), rcwfh, 0, "A");
-
- rcwfh = new RemoteCachingWrapperFilterHelper(new QueryWrapperFilter(new TermQuery(new Term("type", "a"))), false);
- rcwfh.shouldHaveCache(true);
- search(new TermQuery(new Term("test", "test")), rcwfh, 0, "A");
-
- // assert that we get a non-cached version of the Filter because this is a new Query (type:b)
- rcwfh = new RemoteCachingWrapperFilterHelper(new QueryWrapperFilter(new TermQuery(new Term("type", "b"))), false);
- rcwfh.shouldHaveCache(false);
- search(new TermQuery(new Term("type", "b")), rcwfh, 0, "B");
- }
-}
Index: src/test/org/apache/lucene/search/TestRemoteSearchable.java
===================================================================
--- src/test/org/apache/lucene/search/TestRemoteSearchable.java (revision 725699)
+++ src/test/org/apache/lucene/search/TestRemoteSearchable.java (working copy)
@@ -1,136 +0,0 @@
-package org.apache.lucene.search;
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.analysis.SimpleAnalyzer;
-import org.apache.lucene.document.*;
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.store.RAMDirectory;
-
-import java.rmi.Naming;
-import java.rmi.registry.LocateRegistry;
-import java.util.Collections;
-import java.util.Set;
-import java.util.HashSet;
-
-/**
- * @version $Id$
- */
-public class TestRemoteSearchable extends LuceneTestCase {
- public TestRemoteSearchable(String name) {
- super(name);
- }
-
- private static Searchable getRemote() throws Exception {
- try {
- return lookupRemote();
- } catch (Throwable e) {
- startServer();
- return lookupRemote();
- }
- }
-
- private static Searchable lookupRemote() throws Exception {
- return (Searchable)Naming.lookup("//localhost/Searchable");
- }
-
- private static void startServer() throws Exception {
- // construct an index
- RAMDirectory indexStore = new RAMDirectory();
- IndexWriter writer = new IndexWriter(indexStore,new SimpleAnalyzer(),true, IndexWriter.MaxFieldLength.LIMITED);
- Document doc = new Document();
- doc.add(new Field("test", "test text", Field.Store.YES, Field.Index.ANALYZED));
- doc.add(new Field("other", "other test text", Field.Store.YES, Field.Index.ANALYZED));
- writer.addDocument(doc);
- writer.optimize();
- writer.close();
-
- // publish it
- LocateRegistry.createRegistry(1099);
- Searchable local = new IndexSearcher(indexStore);
- RemoteSearchable impl = new RemoteSearchable(local);
- Naming.rebind("//localhost/Searchable", impl);
- }
-
- private static void search(Query query) throws Exception {
- // try to search the published index
- Searchable[] searchables = { getRemote() };
- Searcher searcher = new MultiSearcher(searchables);
- ScoreDoc[] result = searcher.search(query, null, 1000).scoreDocs;
-
- assertEquals(1, result.length);
- Document document = searcher.doc(result[0].doc);
- assertTrue("document is null and it shouldn't be", document != null);
- assertEquals("test text", document.get("test"));
- assertTrue("document.getFields() Size: " + document.getFields().size() + " is not: " + 2, document.getFields().size() == 2);
- Set ftl = new HashSet();
- ftl.add("other");
- FieldSelector fs = new SetBasedFieldSelector(ftl, Collections.EMPTY_SET);
- document = searcher.doc(0, fs);
- assertTrue("document is null and it shouldn't be", document != null);
- assertTrue("document.getFields() Size: " + document.getFields().size() + " is not: " + 1, document.getFields().size() == 1);
- fs = new MapFieldSelector(new String[]{"other"});
- document = searcher.doc(0, fs);
- assertTrue("document is null and it shouldn't be", document != null);
- assertTrue("document.getFields() Size: " + document.getFields().size() + " is not: " + 1, document.getFields().size() == 1);
- }
-
- public void testTermQuery() throws Exception {
- search(new TermQuery(new Term("test", "test")));
- }
-
- public void testBooleanQuery() throws Exception {
- BooleanQuery query = new BooleanQuery();
- query.add(new TermQuery(new Term("test", "test")), BooleanClause.Occur.MUST);
- search(query);
- }
-
- public void testPhraseQuery() throws Exception {
- PhraseQuery query = new PhraseQuery();
- query.add(new Term("test", "test"));
- query.add(new Term("test", "text"));
- search(query);
- }
-
- // Tests bug fix at http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20290
- public void testQueryFilter() throws Exception {
- // try to search the published index
- Searchable[] searchables = { getRemote() };
- Searcher searcher = new MultiSearcher(searchables);
- ScoreDoc[] hits = searcher.search(
- new TermQuery(new Term("test", "text")),
- new QueryWrapperFilter(new TermQuery(new Term("test", "test"))), 1000).scoreDocs;
- assertEquals(1, hits.length);
- ScoreDoc[] nohits = searcher.search(
- new TermQuery(new Term("test", "text")),
- new QueryWrapperFilter(new TermQuery(new Term("test", "non-existent-term"))), 1000).scoreDocs;
- assertEquals(0, nohits.length);
- }
-
- public void testConstantScoreQuery() throws Exception {
- // try to search the published index
- Searchable[] searchables = { getRemote() };
- Searcher searcher = new MultiSearcher(searchables);
- ScoreDoc[] hits = searcher.search(
- new ConstantScoreQuery(new QueryWrapperFilter(
- new TermQuery(new Term("test", "test")))), null, 1000).scoreDocs;
- assertEquals(1, hits.length);
- }
-}
Index: build.xml
===================================================================
--- build.xml (revision 725699)
+++ build.xml (working copy)
@@ -75,11 +75,7 @@