use of org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData in project geowave by locationtech.
the class RDDUtils method trimIndexIds.
public static InsertionIds trimIndexIds(final InsertionIds rawIds, final Geometry geom, final NumericIndexStrategy index) {
for (final SinglePartitionInsertionIds insertionId : rawIds.getPartitionKeys()) {
final byte[] partitionKey = insertionId.getPartitionKey();
final int size = insertionId.getSortKeys().size();
if (size > 3) {
final Iterator<byte[]> it = insertionId.getSortKeys().iterator();
while (it.hasNext()) {
final byte[] sortKey = it.next();
final MultiDimensionalNumericData keyTile = index.getRangeForId(partitionKey, sortKey);
final Envelope other = new Envelope();
other.init(keyTile.getMinValuesPerDimension()[0], keyTile.getMaxValuesPerDimension()[0], keyTile.getMinValuesPerDimension()[1], keyTile.getMaxValuesPerDimension()[1]);
final Polygon rect = JTS.toGeometry(other);
if (!RectangleIntersects.intersects(rect, geom)) {
it.remove();
}
}
}
}
return rawIds;
}
use of org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData in project geowave by locationtech.
the class AbstractPartitioner method partition.
@Override
public void partition(final T entry, final PartitionDataCallback callback) throws Exception {
final NumericDataHolder numericData = getNumericData(entry);
if (numericData == null) {
return;
}
final InsertionIds primaryIds = getIndex().getIndexStrategy().getInsertionIds(numericData.primary);
for (final SinglePartitionInsertionIds partitionInsertionIds : primaryIds.getPartitionKeys()) {
for (final byte[] sortKey : partitionInsertionIds.getSortKeys()) {
callback.partitionWith(new PartitionData(new ByteArray(partitionInsertionIds.getPartitionKey()), new ByteArray(sortKey), true));
}
}
for (final MultiDimensionalNumericData expansionData : numericData.expansion) {
final InsertionIds expansionIds = getIndex().getIndexStrategy().getInsertionIds(expansionData);
for (final SinglePartitionInsertionIds partitionInsertionIds : expansionIds.getPartitionKeys()) {
for (final byte[] sortKey : partitionInsertionIds.getSortKeys()) {
callback.partitionWith(new PartitionData(new ByteArray(partitionInsertionIds.getPartitionKey()), new ByteArray(sortKey), false));
}
}
}
}
use of org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData in project geowave by locationtech.
the class OrthodromicDistancePartitioner method getNumericData.
@Override
protected NumericDataHolder getNumericData(final T entry) {
final NumericDataHolder numericDataHolder = new NumericDataHolder();
final Geometry entryGeometry = dimensionExtractor.getGeometry(entry);
final double[] otherDimensionData = dimensionExtractor.getDimensions(entry);
numericDataHolder.primary = getNumericData(entryGeometry.getEnvelope(), otherDimensionData);
final List<Geometry> geometries = getGeometries(entryGeometry.getCentroid().getCoordinate(), getDistancePerDimension());
final MultiDimensionalNumericData[] values = new MultiDimensionalNumericData[geometries.size()];
int i = 0;
for (final Geometry geometry : geometries) {
values[i++] = getNumericData(geometry.getEnvelope(), otherDimensionData);
}
numericDataHolder.expansion = values;
return numericDataHolder;
}
use of org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData in project geowave by locationtech.
the class HashKeyIndexStrategyTest method testDistribution.
@Test
public void testDistribution() {
final Map<ByteArray, Long> counts = new HashMap<>();
int total = 0;
for (double x = 90; x < 180; x += 0.05) {
for (double y = 50; y < 90; y += 0.5) {
final NumericRange dimension1Range = new NumericRange(x, x + 0.002);
final NumericRange dimension2Range = new NumericRange(y - 0.002, y);
final MultiDimensionalNumericData sfcIndexedRange = new BasicNumericDataset(new NumericData[] { dimension1Range, dimension2Range });
for (final byte[] id : hashIdexStrategy.getInsertionPartitionKeys(sfcIndexedRange)) {
final Long count = counts.get(new ByteArray(id));
final long nextcount = count == null ? 1 : count + 1;
counts.put(new ByteArray(id), nextcount);
total++;
}
}
}
final double mean = total / counts.size();
double diff = 0.0;
for (final Long count : counts.values()) {
diff += Math.pow(mean - count, 2);
}
final double sd = Math.sqrt(diff / counts.size());
assertTrue(sd < (mean * 0.18));
}
use of org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData in project geowave by locationtech.
the class SimpleNumericIndexStrategyTest method testGetQueryRangesRange.
@Test
public void testGetQueryRangesRange() {
final long startValue = 10;
final long endValue = 15;
final MultiDimensionalNumericData indexedRange = getIndexedRange(startValue, endValue);
final List<ByteArrayRange> ranges = strategy.getQueryRanges(indexedRange).getCompositeQueryRanges();
Assert.assertEquals(ranges.size(), 1);
final ByteArrayRange range = ranges.get(0);
final byte[] start = range.getStart();
final byte[] end = range.getEnd();
Assert.assertEquals(castToLong(strategy.getLexicoder().fromByteArray(start)), startValue);
Assert.assertEquals(castToLong(strategy.getLexicoder().fromByteArray(end)), endValue);
}
Aggregations