Search in sources :

Example 1 with PackedQuadPrefixTree

use of org.apache.lucene.spatial.prefix.tree.PackedQuadPrefixTree in project lucene-solr by apache.

the class RandomSpatialOpFuzzyPrefixTreeTest method setupQuadGrid.

private void setupQuadGrid(int maxLevels, boolean packedQuadPrefixTree) {
    //non-geospatial makes this test a little easier (in gridSnap), and using boundary values 2^X raises
    // the prospect of edge conditions we want to test, plus makes for simpler numbers (no decimals).
    SpatialContextFactory factory = new SpatialContextFactory();
    factory.geo = false;
    factory.worldBounds = new RectangleImpl(0, 256, -128, 128, null);
    this.ctx = factory.newSpatialContext();
    //A fairly shallow grid, and default 2.5% distErrPct
    if (maxLevels == -1)
        //max 64k cells (4^8), also 256*256
        maxLevels = randomIntBetween(1, 8);
    if (packedQuadPrefixTree) {
        this.grid = new PackedQuadPrefixTree(ctx, maxLevels);
    } else {
        this.grid = new QuadPrefixTree(ctx, maxLevels);
    }
    this.strategy = newRPT();
}
Also used : SpatialContextFactory(org.locationtech.spatial4j.context.SpatialContextFactory) PackedQuadPrefixTree(org.apache.lucene.spatial.prefix.tree.PackedQuadPrefixTree) QuadPrefixTree(org.apache.lucene.spatial.prefix.tree.QuadPrefixTree) RectangleImpl(org.locationtech.spatial4j.shape.impl.RectangleImpl) PackedQuadPrefixTree(org.apache.lucene.spatial.prefix.tree.PackedQuadPrefixTree)

Example 2 with PackedQuadPrefixTree

use of org.apache.lucene.spatial.prefix.tree.PackedQuadPrefixTree in project lucene-solr by apache.

the class SpatialRecursivePrefixTreeFieldType method newPrefixTreeStrategy.

@Override
protected RecursivePrefixTreeStrategy newPrefixTreeStrategy(String fieldName) {
    RecursivePrefixTreeStrategy strategy = new RecursivePrefixTreeStrategy(grid, fieldName);
    if (prefixGridScanLevel != null)
        strategy.setPrefixGridScanLevel(prefixGridScanLevel);
    if (grid instanceof PackedQuadPrefixTree) {
        // This grid has a (usually) better prune leafy branch implementation
        ((PackedQuadPrefixTree) grid).setPruneLeafyBranches(true);
        strategy.setPruneLeafyBranches(false);
    }
    return strategy;
}
Also used : RecursivePrefixTreeStrategy(org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy) PackedQuadPrefixTree(org.apache.lucene.spatial.prefix.tree.PackedQuadPrefixTree)

Example 3 with PackedQuadPrefixTree

use of org.apache.lucene.spatial.prefix.tree.PackedQuadPrefixTree in project lucene-solr by apache.

the class DistanceStrategyTest method parameters.

@ParametersFactory(argumentFormatting = "strategy=%s")
public static Iterable<Object[]> parameters() {
    List<Object[]> ctorArgs = new ArrayList<>();
    SpatialContext ctx = SpatialContext.GEO;
    SpatialPrefixTree grid;
    SpatialStrategy strategy;
    grid = new QuadPrefixTree(ctx, 25);
    strategy = new RecursivePrefixTreeStrategy(grid, "recursive_quad");
    ctorArgs.add(new Object[] { strategy.getFieldName(), strategy });
    grid = new GeohashPrefixTree(ctx, 12);
    strategy = new TermQueryPrefixTreeStrategy(grid, "termquery_geohash");
    ctorArgs.add(new Object[] { strategy.getFieldName(), strategy });
    grid = new PackedQuadPrefixTree(ctx, 25);
    strategy = new RecursivePrefixTreeStrategy(grid, "recursive_packedquad");
    ctorArgs.add(new Object[] { strategy.getFieldName(), strategy });
    strategy = PointVectorStrategy.newInstance(ctx, "pointvector");
    ctorArgs.add(new Object[] { strategy.getFieldName(), strategy });
    //  Can't test this without un-inverting since PVS legacy config didn't have docValues.
    //    However, note that Solr's tests use UninvertingReader and thus test this.
    //    strategy = PointVectorStrategy.newLegacyInstance(ctx, "pointvector_legacy");
    //    ctorArgs.add(new Object[]{strategy.getFieldName(), strategy});
    strategy = BBoxStrategy.newInstance(ctx, "bbox");
    ctorArgs.add(new Object[] { strategy.getFieldName(), strategy });
    strategy = new SerializedDVStrategy(ctx, "serialized");
    ctorArgs.add(new Object[] { strategy.getFieldName(), strategy });
    return ctorArgs;
}
Also used : SpatialContext(org.locationtech.spatial4j.context.SpatialContext) PackedQuadPrefixTree(org.apache.lucene.spatial.prefix.tree.PackedQuadPrefixTree) QuadPrefixTree(org.apache.lucene.spatial.prefix.tree.QuadPrefixTree) ArrayList(java.util.ArrayList) RecursivePrefixTreeStrategy(org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy) SpatialPrefixTree(org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree) TermQueryPrefixTreeStrategy(org.apache.lucene.spatial.prefix.TermQueryPrefixTreeStrategy) PackedQuadPrefixTree(org.apache.lucene.spatial.prefix.tree.PackedQuadPrefixTree) SerializedDVStrategy(org.apache.lucene.spatial.serialized.SerializedDVStrategy) GeohashPrefixTree(org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree) ParametersFactory(com.carrotsearch.randomizedtesting.annotations.ParametersFactory)

Example 4 with PackedQuadPrefixTree

use of org.apache.lucene.spatial.prefix.tree.PackedQuadPrefixTree in project lucene-solr by apache.

the class SpatialDocMaker method makeRPTStrategy.

protected RecursivePrefixTreeStrategy makeRPTStrategy(String spatialField, Config config, Map<String, String> configMap, SpatialContext ctx) {
    //A factory for the prefix tree grid
    SpatialPrefixTree grid = SpatialPrefixTreeFactory.makeSPT(configMap, null, ctx);
    RecursivePrefixTreeStrategy strategy = new RecursivePrefixTreeStrategy(grid, spatialField);
    strategy.setPointsOnly(config.get("spatial.docPointsOnly", false));
    final boolean pruneLeafyBranches = config.get("spatial.pruneLeafyBranches", true);
    if (grid instanceof PackedQuadPrefixTree) {
        ((PackedQuadPrefixTree) grid).setPruneLeafyBranches(pruneLeafyBranches);
        //always leave it to packed grid, even though it isn't the same
        strategy.setPruneLeafyBranches(false);
    } else {
        strategy.setPruneLeafyBranches(pruneLeafyBranches);
    }
    int prefixGridScanLevel = config.get("query.spatial.prefixGridScanLevel", -4);
    if (prefixGridScanLevel < 0)
        prefixGridScanLevel = grid.getMaxLevels() + prefixGridScanLevel;
    strategy.setPrefixGridScanLevel(prefixGridScanLevel);
    //doc & query; a default
    double distErrPct = config.get("spatial.distErrPct", .025);
    strategy.setDistErrPct(distErrPct);
    return strategy;
}
Also used : RecursivePrefixTreeStrategy(org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy) SpatialPrefixTree(org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree) PackedQuadPrefixTree(org.apache.lucene.spatial.prefix.tree.PackedQuadPrefixTree) Point(org.locationtech.spatial4j.shape.Point)

Aggregations

PackedQuadPrefixTree (org.apache.lucene.spatial.prefix.tree.PackedQuadPrefixTree)4 RecursivePrefixTreeStrategy (org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy)3 QuadPrefixTree (org.apache.lucene.spatial.prefix.tree.QuadPrefixTree)2 SpatialPrefixTree (org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree)2 ParametersFactory (com.carrotsearch.randomizedtesting.annotations.ParametersFactory)1 ArrayList (java.util.ArrayList)1 TermQueryPrefixTreeStrategy (org.apache.lucene.spatial.prefix.TermQueryPrefixTreeStrategy)1 GeohashPrefixTree (org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree)1 SerializedDVStrategy (org.apache.lucene.spatial.serialized.SerializedDVStrategy)1 SpatialContext (org.locationtech.spatial4j.context.SpatialContext)1 SpatialContextFactory (org.locationtech.spatial4j.context.SpatialContextFactory)1 Point (org.locationtech.spatial4j.shape.Point)1 RectangleImpl (org.locationtech.spatial4j.shape.impl.RectangleImpl)1