use of org.locationtech.geowave.core.store.api.BinConstraints.ByteArrayConstraints 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.api.BinConstraints.ByteArrayConstraints 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));
}
Aggregations