Class RecursivePrefixTreeStrategy

Direct Known Subclasses:
NumberRangePrefixTreeStrategy

public class RecursivePrefixTreeStrategy extends PrefixTreeStrategy
A PrefixTreeStrategy which uses AbstractVisitingPrefixTreeQuery. This strategy has support for searching non-point shapes (note: not tested). Even a query shape with distErrPct=0 (fully precise to the grid) should have good performance for typical data, unless there is a lot of indexed data coincident with the shape's edge.
WARNING: This API is experimental and might change in incompatible ways in the next release.
  • Field Details

    • prefixGridScanLevel

      protected int prefixGridScanLevel
    • pruneLeafyBranches

      protected boolean pruneLeafyBranches
    • multiOverlappingIndexedShapes

      protected boolean multiOverlappingIndexedShapes
  • Constructor Details

  • Method Details

    • getPrefixGridScanLevel

      public int getPrefixGridScanLevel()
    • setPrefixGridScanLevel

      public void setPrefixGridScanLevel(int 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 final level, maxLevels, is always scanned.
      Parameters:
      prefixGridScanLevel - 1 to maxLevels
    • isMultiOverlappingIndexedShapes

      public boolean isMultiOverlappingIndexedShapes()
    • setMultiOverlappingIndexedShapes

      public void setMultiOverlappingIndexedShapes(boolean multiOverlappingIndexedShapes)
    • isPruneLeafyBranches

      public boolean isPruneLeafyBranches()
    • setPruneLeafyBranches

      public void setPruneLeafyBranches(boolean pruneLeafyBranches)
      An optional hint affecting non-point shapes and tree cells implementing CellCanPrune, otherwise ignored.

      It will prune away a complete set sibling leaves to their parent (recursively), resulting in ~20-50% fewer indexed cells, and consequently that much less disk and that much faster indexing. So if it's a quad tree and all 4 sub-cells are there marked as a leaf, then they will be removed (pruned) and the parent is marked as a leaf instead. This occurs recursively on up. Unfortunately, the current implementation will buffer all cells to do this, so consider disabling for high precision (low distErrPct) shapes. (default=true)

    • toString

      public String toString()
      Overrides:
      toString in class SpatialStrategy
    • createCellIteratorToIndex

      protected Iterator<Cell> createCellIteratorToIndex(org.locationtech.spatial4j.shape.Shape shape, int detailLevel, Iterator<Cell> reuse)
      Overrides:
      createCellIteratorToIndex in class PrefixTreeStrategy
    • makeQuery

      public Query makeQuery(SpatialArgs args)
      Description copied from class: SpatialStrategy
      Make a Query based principally on SpatialOperation and Shape from the supplied args. It should be constant scoring of 1.
      Specified by:
      makeQuery in class SpatialStrategy
    • isGridAlignedShape

      protected boolean isGridAlignedShape(org.locationtech.spatial4j.shape.Shape shape)
      A quick check of the shape to see if it is perfectly aligned to a grid. Points always are as they are indivisible. It's okay to return false if the shape actually is aligned; this is an optimization hint.
    • makeGridShapeIntersectsQuery

      protected Query makeGridShapeIntersectsQuery(org.locationtech.spatial4j.shape.Shape gridShape)
      makeQuery(SpatialArgs) specialized for the query being a grid square.