use of org.locationtech.geowave.core.store.statistics.query.BinConstraintsImpl.ExplicitConstraints in project geowave by locationtech.
the class CompositeBinningStrategy method concat.
private ByteArrayConstraints concat(final List<ByteArrayConstraints> perStrategyConstraints) {
final ByteArray[][] c = new ByteArray[perStrategyConstraints.size()][];
boolean allBins = true;
for (int i = 0; i < perStrategyConstraints.size(); i++) {
final ByteArrayConstraints constraints = perStrategyConstraints.get(i);
if (constraints.isAllBins()) {
if (!allBins) {
throw new IllegalArgumentException("Cannot use 'all bins' query for one strategy and not the other");
}
} else {
allBins = false;
}
if (constraints.isPrefix()) {
// can only use a prefix if its the last field or the rest of the fields are 'all bins'
boolean isValid = true;
for (final int j = i + 1; i < perStrategyConstraints.size(); i++) {
final ByteArrayConstraints innerConstraints = perStrategyConstraints.get(j);
if (!innerConstraints.isAllBins()) {
isValid = false;
break;
} else {
c[i] = new ByteArray[] { new ByteArray() };
}
}
if (isValid) {
return new ExplicitConstraints(getAllCombinations(c), true);
} else {
throw new IllegalArgumentException("Cannot use 'prefix' query for a strategy that is also using exact constraints on a subsequent strategy");
}
}
c[i] = constraints.getBins();
}
return new ExplicitConstraints(getAllCombinations(c), false);
}
use of org.locationtech.geowave.core.store.statistics.query.BinConstraintsImpl.ExplicitConstraints in project geowave by locationtech.
the class GeohashBinningHelper method getGeometryConstraints.
@Override
public ByteArrayConstraints getGeometryConstraints(final Geometry geometry, final int precision) {
final GeohashGeometryHandler geometryHandler = new GeohashGeometryHandler(precision);
GeometryUtils.visitGeometry(geometry, geometryHandler);
// this can really help with query performance
if (removePrefixes(geometryHandler.hashes)) {
return new ExplicitConstraints(geometryHandler.hashes.stream().map(str -> StringUtils.stringToBinary(str)).map(bytes -> new ByteArrayRange(bytes, bytes)).toArray(ByteArrayRange[]::new));
}
return new ExplicitConstraints(geometryHandler.hashes.stream().map(ByteArray::new).toArray(ByteArray[]::new));
}
use of org.locationtech.geowave.core.store.statistics.query.BinConstraintsImpl.ExplicitConstraints in project geowave by locationtech.
the class S2BinningHelper method getGeometryConstraints.
@Override
public ByteArrayConstraints getGeometryConstraints(final Geometry geom, final int precision) {
final S2RegionCoverer coverer = new S2RegionCoverer();
coverer.setMaxCells(100);
// no sense decomposing further than the max precision the stats are binned at
coverer.setMaxLevel(precision);
final S2CellUnion s2CellUnion = cellCoverage(geom, coverer);
return new ExplicitConstraints(Streams.stream(s2CellUnion.iterator()).map(c -> new ByteArrayRange(Lexicoders.LONG.toByteArray(c.rangeMin().id()), Lexicoders.LONG.toByteArray(c.rangeMax().id()))).toArray(ByteArrayRange[]::new));
}
Aggregations