| Index: lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java |
| IDEA additional info: |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP |
| <+>UTF-8 |
| =================================================================== |
| --- lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java (revision 1651344) |
| +++ lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java (revision ) |
| @@ -21,10 +21,11 @@ |
| 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.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 @@ |
| 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 @@ |
| 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 @@ |
| } |
| |
| 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); |
| } |
| Index: lucene/spatial/src/java/org/apache/lucene/spatial/prefix/RecursivePrefixTreeStrategy.java |
| IDEA additional info: |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP |
| <+>UTF-8 |
| =================================================================== |
| --- lucene/spatial/src/java/org/apache/lucene/spatial/prefix/RecursivePrefixTreeStrategy.java (revision 1651344) |
| +++ lucene/spatial/src/java/org/apache/lucene/spatial/prefix/RecursivePrefixTreeStrategy.java (revision ) |
| @@ -17,6 +17,9 @@ |
| * 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.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 @@ |
| // 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 @@ |
| 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,15 +79,17 @@ |
| 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}. */ |
| public void setMultiOverlappingIndexedShapes(boolean multiOverlappingIndexedShapes) { |
| this.multiOverlappingIndexedShapes = multiOverlappingIndexedShapes; |
| + } |
| + |
| + public boolean isPruneLeafyBranches() { |
| + return pruneLeafyBranches; |
| } |
| |
| /** An optional hint affecting non-point shapes: it will |