lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sim...@apache.org
Subject svn commit: r833122 - in /lucene/java/trunk/contrib/spatial/src: java/org/apache/lucene/spatial/tier/ test/org/apache/lucene/spatial/tier/
Date Thu, 05 Nov 2009 18:49:22 GMT
Author: simonw
Date: Thu Nov  5 18:49:21 2009
New Revision: 833122

URL: http://svn.apache.org/viewvc?rev=833122&view=rev
Log:
LUCENE-2032: fixed serialization issue in CartesianShapeFilter and removed referenced to java
5 logging API

Added:
    lucene/java/trunk/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesianShapeFilter.java
Modified:
    lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/CartesianPolyFilterBuilder.java
    lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/CartesianShapeFilter.java
    lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/Shape.java

Modified: lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/CartesianPolyFilterBuilder.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/CartesianPolyFilterBuilder.java?rev=833122&r1=833121&r2=833122&view=diff
==============================================================================
--- lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/CartesianPolyFilterBuilder.java
(original)
+++ lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/CartesianPolyFilterBuilder.java
Thu Nov  5 18:49:21 2009
@@ -19,11 +19,8 @@
 
 import java.math.BigDecimal;
 import java.math.RoundingMode;
-import java.util.logging.Level;
-import java.util.logging.Logger;
 
 import org.apache.lucene.search.Filter;
-import org.apache.lucene.spatial.geometry.shape.Rectangle;
 import org.apache.lucene.spatial.tier.projections.CartesianTierPlotter;
 import org.apache.lucene.spatial.tier.projections.IProjector;
 import org.apache.lucene.spatial.tier.projections.SinusoidalProjector;
@@ -46,8 +43,6 @@
   public static final double MILES_FLOOR = 1.0;
 
   private IProjector projector = new SinusoidalProjector();
-  private Logger log = Logger.getLogger(getClass().getName());
-  
   private final String tierPrefix;
   
   public CartesianPolyFilterBuilder( String tierPrefix ) {
@@ -59,7 +54,6 @@
     if (miles < MILES_FLOOR) {
       miles = MILES_FLOOR;
     }
-    Rectangle box = DistanceUtils.getInstance().getBoundary(latitude, longitude, miles);
     LLRect box1 = LLRect.createBox( new FloatLatLng( latitude, longitude ), miles, miles
);
     LatLng ll = box1.getLowerLeft();
     LatLng ur = box1.getUpperRight();
@@ -84,7 +78,6 @@
     CartesianTierPlotter ctp = new CartesianTierPlotter(2, projector,tierPrefix);
     int bestFit = ctp.bestFit(miles);
     
-    log.info("Best Fit is : " + bestFit);
     ctp = new CartesianTierPlotter(bestFit, projector,tierPrefix);
     Shape shape = new Shape(ctp.getTierFieldName());
     
@@ -133,9 +126,6 @@
     int scale = (int)Math.log10(tierVert);
     endY = new BigDecimal(endY).setScale(scale, RoundingMode.HALF_EVEN).doubleValue();
     startY = new BigDecimal(startY).setScale(scale, RoundingMode.HALF_EVEN).doubleValue();
-    if(log.isLoggable(Level.FINE)) {
-      log.fine("scale "+scale+" startX "+ startX + " endX "+endX +" startY "+ startY + "
endY "+ endY +" tierVert "+ tierVert);
-    }
     double xInc = 1.0d / tierVert;
     xInc = new BigDecimal(xInc).setScale(scale, RoundingMode.HALF_EVEN).doubleValue();
     

Modified: lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/CartesianShapeFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/CartesianShapeFilter.java?rev=833122&r1=833121&r2=833122&view=diff
==============================================================================
--- lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/CartesianShapeFilter.java
(original)
+++ lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/CartesianShapeFilter.java
Thu Nov  5 18:49:21 2009
@@ -35,49 +35,33 @@
  * release.</font>
  */
 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 String fieldName;
+ 
+  private final Shape shape;
+  private final String fieldName;
   
-  CartesianShapeFilter(Shape shape, String fieldName){
+  CartesianShapeFilter(final Shape shape, final String fieldName){
     this.shape = shape;
     this.fieldName = fieldName;
   }
   
   @Override
-  public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
-    long start = System.currentTimeMillis();
-      
-    OpenBitSet bits = new OpenBitSet(reader.maxDoc());
-
-    TermDocs termDocs = reader.termDocs();
-    List<Double> area = shape.getArea();
+  public DocIdSet getDocIdSet(final IndexReader reader) throws IOException {
+    final OpenBitSet bits = new OpenBitSet(reader.maxDoc());
+    final TermDocs termDocs = reader.termDocs();
+    final List<Double> area = shape.getArea();
     int sz = area.size();
-    log.fine("Area size "+ sz);
-
+    
+    final Term term = new Term(fieldName);
     // iterate through each boxid
     for (int i =0; i< sz; i++) {
       double boxId = area.get(i).doubleValue();
-      termDocs.seek(new Term(fieldName,
-          NumericUtils.doubleToPrefixCoded(boxId)));
-      
+      termDocs.seek(term.createTerm(NumericUtils.doubleToPrefixCoded(boxId)));
       // iterate through all documents
       // which have this boxId
       while (termDocs.next()) {
         bits.fastSet(termDocs.doc());
       }
     }
-    
-    long end = System.currentTimeMillis();
-    if(log.isLoggable(Level.FINE)) {
-      log.fine("BoundaryBox Time Taken: "+ (end - start) + " found: "+bits.cardinality()+"
candidates");
-    }
     return bits;
   }
 }

Modified: lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/Shape.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/Shape.java?rev=833122&r1=833121&r2=833122&view=diff
==============================================================================
--- lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/Shape.java (original)
+++ lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/Shape.java Thu
Nov  5 18:49:21 2009
@@ -17,6 +17,7 @@
 
 package org.apache.lucene.spatial.tier;
 
+import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -25,7 +26,7 @@
  * flux and might change in incompatible ways in the next
  * release.</font>
  */
-public class Shape {
+public class Shape implements Serializable{
 
   private List<Double> area = new ArrayList<Double>();
   private String tierId;

Added: lucene/java/trunk/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesianShapeFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesianShapeFilter.java?rev=833122&view=auto
==============================================================================
--- lucene/java/trunk/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesianShapeFilter.java
(added)
+++ lucene/java/trunk/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesianShapeFilter.java
Thu Nov  5 18:49:21 2009
@@ -0,0 +1,44 @@
+/**
+ * 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.
+ */
+package org.apache.lucene.spatial.tier;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.NotSerializableException;
+import java.io.ObjectOutputStream;
+
+import junit.framework.TestCase;
+/**
+ * 
+ * Test for {@link CartesianShapeFilter}
+ *
+ */
+public class TestCartesianShapeFilter extends TestCase {
+
+  public void testSerializable() throws IOException {
+    CartesianShapeFilter filter = new CartesianShapeFilter(new Shape("1"),
+        "test");
+    try {
+      ByteArrayOutputStream bos = new ByteArrayOutputStream();
+      ObjectOutputStream oos = new ObjectOutputStream(bos);
+      oos.writeObject(filter);
+    } catch (NotSerializableException e) {
+      fail("Filter should be serializable but raised a NotSerializableException ["+e.getMessage()+"]");
+    }
+  }
+
+}



Mime
View raw message