From 072f9e32183cb021668f6d1ff900566e9d124b8e Mon Sep 17 00:00:00 2001 From: Uwe Schindler Date: Thu, 5 Nov 2009 03:43:02 +0000 Subject: [PATCH] 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 --- .../lucene/spatial/tier/CartesianShapeFilter.java | 3 ++- .../org/apache/lucene/spatial/tier/DistanceFilter.java | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/contrib/spatial/src/java/org/apache/lucene/spatial/tier/CartesianShapeFilter.java b/contrib/spatial/src/java/org/apache/lucene/spatial/tier/CartesianShapeFilter.java index c8dbf516aa4..76feb98390c 100644 --- a/contrib/spatial/src/java/org/apache/lucene/spatial/tier/CartesianShapeFilter.java +++ b/contrib/spatial/src/java/org/apache/lucene/spatial/tier/CartesianShapeFilter.java @@ -36,12 +36,13 @@ import org.apache.lucene.util.OpenBitSet; */ public class CartesianShapeFilter extends Filter { + private static final Logger log = Logger.getLogger(CartesianShapeFilter.class.getName()); + /** * */ private static final long serialVersionUID = 1L; private Shape shape; - private Logger log = Logger.getLogger(getClass().getName()); private String fieldName; CartesianShapeFilter(Shape shape, String fieldName){ diff --git a/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceFilter.java b/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceFilter.java index 412752717d2..df884012ed9 100644 --- a/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceFilter.java +++ b/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceFilter.java @@ -19,6 +19,8 @@ package org.apache.lucene.spatial.tier; import java.util.Map; import java.util.WeakHashMap; import java.util.HashMap; +import java.io.IOException; +import java.io.ObjectInputStream; import org.apache.lucene.search.Filter; import org.apache.lucene.spatial.tier.DistanceHandler.Precision; @@ -36,7 +38,7 @@ public abstract class DistanceFilter extends Filter { protected double distance; protected int nextDocBase; - protected final WeakHashMap distanceLookupCache; + protected transient WeakHashMap distanceLookupCache; /** Filters the startingFilter by precise distance * checking filter */ @@ -61,6 +63,12 @@ public abstract class DistanceFilter extends Filter { distanceLookupCache = new WeakHashMap(); } + /** needed for deserialization, because the cache is transient */ + private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { + stream.defaultReadObject(); + distanceLookupCache = new WeakHashMap(); + } + public Map getDistances(){ return distances; }