mirror of https://github.com/apache/lucene.git
LUCENE-4197 rename CachedDistanceValueSource
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1364882 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2fd2d60e19
commit
035c057cbf
|
@ -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.Node;
|
||||||
import org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree;
|
import org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree;
|
||||||
import org.apache.lucene.spatial.query.SpatialArgs;
|
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.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -144,7 +144,7 @@ public abstract class PrefixTreeStrategy extends SpatialStrategy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Point point = args.getShape().getCenter();
|
Point point = args.getShape().getCenter();
|
||||||
return new CachedDistanceValueSource(point, calc, p);
|
return new ShapeFieldCacheDistanceValueSource(point, calc, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpatialPrefixTree getGrid() {
|
public SpatialPrefixTree getGrid() {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
package org.apache.lucene.spatial.util;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
@ -15,8 +17,6 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.lucene.spatial.util;
|
|
||||||
|
|
||||||
import com.spatial4j.core.distance.DistanceCalculator;
|
import com.spatial4j.core.distance.DistanceCalculator;
|
||||||
import com.spatial4j.core.shape.Point;
|
import com.spatial4j.core.shape.Point;
|
||||||
import org.apache.lucene.index.AtomicReaderContext;
|
import org.apache.lucene.index.AtomicReaderContext;
|
||||||
|
@ -28,17 +28,20 @@ import java.util.List;
|
||||||
import java.util.Map;
|
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
|
* @lucene.internal
|
||||||
*/
|
*/
|
||||||
public class CachedDistanceValueSource extends ValueSource {
|
public class ShapeFieldCacheDistanceValueSource extends ValueSource {
|
||||||
|
|
||||||
private final ShapeFieldCacheProvider<Point> provider;
|
private final ShapeFieldCacheProvider<Point> provider;
|
||||||
private final DistanceCalculator calculator;
|
private final DistanceCalculator calculator;
|
||||||
private final Point from;
|
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.from = from;
|
||||||
this.provider = provider;
|
this.provider = provider;
|
||||||
this.calculator = calc;
|
this.calculator = calc;
|
||||||
|
@ -46,7 +49,7 @@ public class CachedDistanceValueSource extends ValueSource {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String description() {
|
public String description() {
|
||||||
return "DistanceValueSource("+calculator+")";
|
return getClass().getSimpleName()+"("+calculator+")";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -85,7 +88,7 @@ public class CachedDistanceValueSource extends ValueSource {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
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 (calculator != null ? !calculator.equals(that.calculator) : that.calculator != null) return false;
|
||||||
if (from != null ? !from.equals(that.from) : that.from != null) return false;
|
if (from != null ? !from.equals(that.from) : that.from != null) return false;
|
Loading…
Reference in New Issue