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();
}
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;
}
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;
}
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;
}
Aggregations