You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ds...@apache.org on 2015/01/15 16:59:27 UTC
svn commit: r1652147 - in
/lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/prefix:
PrefixTreeStrategy.java RecursivePrefixTreeStrategy.java
Author: dsmiley
Date: Thu Jan 15 15:59:27 2015
New Revision: 1652147
URL: http://svn.apache.org/r1652147
Log:
LUCENE-6181: spatial move pointsOnly to superclass and add some getters too.
Modified:
lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java
lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/RecursivePrefixTreeStrategy.java
Modified: lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java?rev=1652147&r1=1652146&r2=1652147&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java (original)
+++ lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java Thu Jan 15 15:59:27 2015
@@ -21,10 +21,11 @@ import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+import com.spatial4j.core.shape.Point;
+import com.spatial4j.core.shape.Shape;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
-import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.spatial.SpatialStrategy;
@@ -32,8 +33,6 @@ import org.apache.lucene.spatial.prefix.
import org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree;
import org.apache.lucene.spatial.query.SpatialArgs;
import org.apache.lucene.spatial.util.ShapeFieldCacheDistanceValueSource;
-import com.spatial4j.core.shape.Point;
-import com.spatial4j.core.shape.Shape;
/**
* An abstract SpatialStrategy based on {@link SpatialPrefixTree}. The two
@@ -81,6 +80,7 @@ public abstract class PrefixTreeStrategy
private final Map<String, PointPrefixTreeFieldCacheProvider> provider = new ConcurrentHashMap<>();
protected int defaultFieldValuesArrayLen = 2;
protected double distErrPct = SpatialArgs.DEFAULT_DISTERRPCT;// [ 0 TO 0.5 ]
+ protected boolean pointsOnly = false;//if true, there are no leaves
public PrefixTreeStrategy(SpatialPrefixTree grid, String fieldName) {
super(grid.getSpatialContext(), fieldName);
@@ -116,6 +116,16 @@ public abstract class PrefixTreeStrategy
this.distErrPct = distErrPct;
}
+ public boolean isPointsOnly() {
+ return pointsOnly;
+ }
+
+ /** True if only indexed points shall be supported. There are no "leafs" in such a case. See
+ * {@link org.apache.lucene.spatial.prefix.IntersectsPrefixTreeFilter#hasIndexedLeaves}. */
+ public void setPointsOnly(boolean pointsOnly) {
+ this.pointsOnly = pointsOnly;
+ }
+
@Override
public Field[] createIndexableFields(Shape shape) {
double distErr = SpatialArgs.calcDistanceFromErrPct(shape, distErrPct, ctx);
@@ -137,6 +147,9 @@ public abstract class PrefixTreeStrategy
}
protected TokenStream createTokenStream(Shape shape, int detailLevel) {
+ if (pointsOnly && shape instanceof Point) {
+ throw new IllegalArgumentException("pointsOnly is true yet a point is given for indexing");
+ }
Iterator<Cell> cells = grid.getTreeCellIterator(shape, detailLevel);
return new CellTokenStream().setCells(cells);
}
Modified: lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/RecursivePrefixTreeStrategy.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/RecursivePrefixTreeStrategy.java?rev=1652147&r1=1652146&r2=1652147&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/RecursivePrefixTreeStrategy.java (original)
+++ lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/RecursivePrefixTreeStrategy.java Thu Jan 15 15:59:27 2015
@@ -17,6 +17,9 @@ package org.apache.lucene.spatial.prefix
* limitations under the License.
*/
+import java.util.ArrayList;
+import java.util.List;
+
import com.spatial4j.core.shape.Point;
import com.spatial4j.core.shape.Shape;
import org.apache.lucene.analysis.TokenStream;
@@ -29,9 +32,6 @@ import org.apache.lucene.spatial.query.S
import org.apache.lucene.spatial.query.SpatialOperation;
import org.apache.lucene.spatial.query.UnsupportedSpatialOperation;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* A {@link PrefixTreeStrategy} which uses {@link AbstractVisitingPrefixTreeFilter}.
* This strategy has support for searching non-point shapes (note: not tested).
@@ -56,8 +56,6 @@ public class RecursivePrefixTreeStrategy
// and a LegacyPrefixTree.
protected boolean pruneLeafyBranches = true;
- protected boolean pointsOnly = false;//if true, there are no leaves
-
protected boolean multiOverlappingIndexedShapes = true;
public RecursivePrefixTreeStrategy(SpatialPrefixTree grid, String fieldName) {
@@ -65,6 +63,10 @@ public class RecursivePrefixTreeStrategy
prefixGridScanLevel = grid.getMaxLevels() - 4;//TODO this default constant is dependent on the prefix grid size
}
+ public int getPrefixGridScanLevel() {
+ return prefixGridScanLevel;
+ }
+
/**
* Sets the grid level [1-maxLevels] at which indexed terms are scanned brute-force
* instead of by grid decomposition. By default this is maxLevels - 4. The
@@ -77,10 +79,8 @@ public class RecursivePrefixTreeStrategy
this.prefixGridScanLevel = prefixGridScanLevel;
}
- /** True if only indexed points shall be supported. There are no "leafs" in such a case. See
- * {@link IntersectsPrefixTreeFilter#hasIndexedLeaves}. */
- public void setPointsOnly(boolean pointsOnly) {
- this.pointsOnly = pointsOnly;
+ public boolean isMultiOverlappingIndexedShapes() {
+ return multiOverlappingIndexedShapes;
}
/** See {@link ContainsPrefixTreeFilter#multiOverlappingIndexedShapes}. */
@@ -88,6 +88,10 @@ public class RecursivePrefixTreeStrategy
this.multiOverlappingIndexedShapes = multiOverlappingIndexedShapes;
}
+ public boolean isPruneLeafyBranches() {
+ return pruneLeafyBranches;
+ }
+
/** An optional hint affecting non-point shapes: it will
* simplify/aggregate sets of complete leaves in a cell to its parent, resulting in ~20-25%
* fewer indexed cells. However, it will likely be removed in the future. (default=true)