Skip to content

Apache Lucene open-source search software

LUCENE-4197 rename CachedDistanceValueSource

David Wayne Smiley035c057cbfbd
diff --git a/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java b/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java
index cac0862ea03..a024ef5539d 100644
--- a/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java
+++ b/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java
@@ -30,7 +30,7 @@ import org.apache.lucene.spatial.SpatialStrategy;
import org.apache.lucene.spatial.prefix.tree.Node;
import org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree;
import org.apache.lucene.spatial.query.SpatialArgs;
-import org.apache.lucene.spatial.util.CachedDistanceValueSource;
+import org.apache.lucene.spatial.util.ShapeFieldCacheDistanceValueSource;
import java.util.Iterator;
import java.util.List;
@@ -144,7 +144,7 @@ public abstract class PrefixTreeStrategy extends SpatialStrategy {
}
}
Point point = args.getShape().getCenter();
- return new CachedDistanceValueSource(point, calc, p);
+ return new ShapeFieldCacheDistanceValueSource(point, calc, p);
}
public SpatialPrefixTree getGrid() {
diff --git a/lucene/spatial/src/java/org/apache/lucene/spatial/util/CachedDistanceValueSource.java b/lucene/spatial/src/java/org/apache/lucene/spatial/util/ShapeFieldCacheDistanceValueSource.java
similarity index 83%
rename from lucene/spatial/src/java/org/apache/lucene/spatial/util/CachedDistanceValueSource.java
rename to lucene/spatial/src/java/org/apache/lucene/spatial/util/ShapeFieldCacheDistanceValueSource.java
index 49bb4de832a..c2d8b0f61fe 100644
--- a/lucene/spatial/src/java/org/apache/lucene/spatial/util/CachedDistanceValueSource.java
+++ b/lucene/spatial/src/java/org/apache/lucene/spatial/util/ShapeFieldCacheDistanceValueSource.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.spatial.util;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.lucene.spatial.util;
-
import com.spatial4j.core.distance.DistanceCalculator;
import com.spatial4j.core.shape.Point;
import org.apache.lucene.index.AtomicReaderContext;
@@ -28,17 +28,20 @@ import java.util.List;
import java.util.Map;
/**
- * An implementation of the Lucene ValueSource model to support spatial relevance ranking.
+ * An implementation of the Lucene ValueSource that returns the spatial distance
+ * between an input point and a document's points in
+ * {@link ShapeFieldCacheProvider}. The shortest distance is returned if a
+ * document has more than one point.
*
* @lucene.internal
*/
-public class CachedDistanceValueSource extends ValueSource {
+public class ShapeFieldCacheDistanceValueSource extends ValueSource {
private final ShapeFieldCacheProvider<Point> provider;
private final DistanceCalculator calculator;
private final Point from;
- public CachedDistanceValueSource(Point from, DistanceCalculator calc, ShapeFieldCacheProvider<Point> provider) {
+ public ShapeFieldCacheDistanceValueSource(Point from, DistanceCalculator calc, ShapeFieldCacheProvider<Point> provider) {
this.from = from;
this.provider = provider;
this.calculator = calc;
@@ -46,7 +49,7 @@ public class CachedDistanceValueSource extends ValueSource {
@Override
public String description() {
- return "DistanceValueSource("+calculator+")";
+ return getClass().getSimpleName()+"("+calculator+")";
}
@Override
@@ -85,7 +88,7 @@ public class CachedDistanceValueSource extends ValueSource {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
- CachedDistanceValueSource that = (CachedDistanceValueSource) o;
+ ShapeFieldCacheDistanceValueSource that = (ShapeFieldCacheDistanceValueSource) o;
if (calculator != null ? !calculator.equals(that.calculator) : that.calculator != null) return false;
if (from != null ? !from.equals(that.from) : that.from != null) return false;