LUCENE-2032: Spatial Filter is now correctly Serializable

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@832987 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2009-11-05 03:43:02 +00:00
parent b082951277
commit 072f9e3218
2 changed files with 11 additions and 2 deletions

View File

@ -36,12 +36,13 @@ import org.apache.lucene.util.OpenBitSet;
*/ */
public class CartesianShapeFilter extends Filter { public class CartesianShapeFilter extends Filter {
private static final Logger log = Logger.getLogger(CartesianShapeFilter.class.getName());
/** /**
* *
*/ */
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Shape shape; private Shape shape;
private Logger log = Logger.getLogger(getClass().getName());
private String fieldName; private String fieldName;
CartesianShapeFilter(Shape shape, String fieldName){ CartesianShapeFilter(Shape shape, String fieldName){

View File

@ -19,6 +19,8 @@ package org.apache.lucene.spatial.tier;
import java.util.Map; import java.util.Map;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import java.util.HashMap; import java.util.HashMap;
import java.io.IOException;
import java.io.ObjectInputStream;
import org.apache.lucene.search.Filter; import org.apache.lucene.search.Filter;
import org.apache.lucene.spatial.tier.DistanceHandler.Precision; import org.apache.lucene.spatial.tier.DistanceHandler.Precision;
@ -36,7 +38,7 @@ public abstract class DistanceFilter extends Filter {
protected double distance; protected double distance;
protected int nextDocBase; protected int nextDocBase;
protected final WeakHashMap<String,Double> distanceLookupCache; protected transient WeakHashMap<String,Double> distanceLookupCache;
/** Filters the startingFilter by precise distance /** Filters the startingFilter by precise distance
* checking filter */ * checking filter */
@ -61,6 +63,12 @@ public abstract class DistanceFilter extends Filter {
distanceLookupCache = new WeakHashMap<String,Double>(); distanceLookupCache = new WeakHashMap<String,Double>();
} }
/** needed for deserialization, because the cache is transient */
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
distanceLookupCache = new WeakHashMap<String,Double>();
}
public Map<Integer,Double> getDistances(){ public Map<Integer,Double> getDistances(){
return distances; return distances;
} }