use of org.locationtech.geowave.core.index.MultiDimensionalCoordinates in project geowave by locationtech.
the class NumericIndexStrategyFilterIterator method inBounds.
private boolean inBounds(final Key k) {
k.getRow(row);
final GeoWaveKeyImpl key = new GeoWaveKeyImpl(row.getBytes(), partitionKeyLength, row.getLength());
final MultiDimensionalCoordinates coordinates = indexStrategy.getCoordinatesPerDimension(key.getPartitionKey(), key.getSortKey());
if (coordinates == null) {
// this is a filter, so caution should be on the side of accepting values that can't be parsed
return true;
}
return rangeCache.inBounds(coordinates);
}
use of org.locationtech.geowave.core.index.MultiDimensionalCoordinates in project geowave by locationtech.
the class TieredSFCIndexStrategy method getCoordinatesPerDimension.
@Override
public MultiDimensionalCoordinates getCoordinatesPerDimension(final byte[] partitionKey, final byte[] sortKey) {
if ((partitionKey != null) && (partitionKey.length > 0)) {
final byte[] rowId = ByteArrayUtils.combineArrays(partitionKey, sortKey == null ? null : sortKey);
final Integer orderedSfcIndex = orderedSfcIndexToTierId.inverse().get(rowId[0]);
return new MultiDimensionalCoordinates(new byte[] { rowId[0] }, BinnedSFCUtils.getCoordinatesForId(rowId, baseDefinitions, orderedSfcs[orderedSfcIndex]));
} else {
LOGGER.warn("Row's partition key must at least contain a byte for the tier");
}
return null;
}
use of org.locationtech.geowave.core.index.MultiDimensionalCoordinates in project geowave by locationtech.
the class HBaseNumericIndexStrategyFilter method inBounds.
private boolean inBounds(final Cell cell) {
final GeoWaveKeyImpl cellKey = new GeoWaveKeyImpl(cell.getRowArray(), indexStrategy.getPartitionKeyLength(), cell.getRowOffset(), cell.getRowLength());
final byte[] sortKey = cellKey.getSortKey();
final byte[] partitionKey = cellKey.getPartitionKey();
final MultiDimensionalCoordinates coordinates = indexStrategy.getCoordinatesPerDimension(partitionKey, sortKey);
return rangeCache.inBounds(coordinates);
}
use of org.locationtech.geowave.core.index.MultiDimensionalCoordinates in project geowave by locationtech.
the class HashKeyIndexStrategyTest method testGetCoordinatesPerDimension.
@Test
public void testGetCoordinatesPerDimension() {
final NumericRange dimension1Range = new NumericRange(20.01, 20.02);
final NumericRange dimension2Range = new NumericRange(30.51, 30.59);
final MultiDimensionalNumericData sfcIndexedRange = new BasicNumericDataset(new NumericData[] { dimension1Range, dimension2Range });
final InsertionIds id = compoundIndexStrategy.getInsertionIds(sfcIndexedRange);
for (final SinglePartitionInsertionIds partitionKey : id.getPartitionKeys()) {
for (final byte[] sortKey : partitionKey.getSortKeys()) {
final MultiDimensionalCoordinates coords = compoundIndexStrategy.getCoordinatesPerDimension(partitionKey.getPartitionKey(), sortKey);
assertTrue(coords.getCoordinate(0).getCoordinate() > 0);
assertTrue(coords.getCoordinate(1).getCoordinate() > 0);
}
}
final Iterator<SinglePartitionInsertionIds> it = id.getPartitionKeys().iterator();
assertTrue(it.hasNext());
final SinglePartitionInsertionIds partitionId = it.next();
assertTrue(!it.hasNext());
for (final byte[] sortKey : partitionId.getSortKeys()) {
final MultiDimensionalNumericData nd = compoundIndexStrategy.getRangeForId(partitionId.getPartitionKey(), sortKey);
assertEquals(20.02, nd.getMaxValuesPerDimension()[0], 0.01);
assertEquals(30.59, nd.getMaxValuesPerDimension()[1], 0.1);
assertEquals(20.01, nd.getMinValuesPerDimension()[0], 0.01);
assertEquals(30.51, nd.getMinValuesPerDimension()[1], 0.1);
}
}
use of org.locationtech.geowave.core.index.MultiDimensionalCoordinates in project geowave by locationtech.
the class RoundRobinKeyIndexStrategyTest method testGetInsertionIds.
@Test
public void testGetInsertionIds() {
final List<ByteArray> ids = new ArrayList<>();
final InsertionIds ids2 = sfcIndexStrategy.getInsertionIds(sfcIndexedRange, 1);
final List<byte[]> compositeIds = ids2.getCompositeInsertionIds();
for (int i = 0; i < 3; i++) {
for (final byte[] id2 : compositeIds) {
ids.add(new ByteArray(ByteArrayUtils.combineArrays(new byte[] { (byte) i }, id2)));
}
}
final Set<ByteArray> testIds = new HashSet<>(ids);
final Set<ByteArray> compoundIndexIds = compoundIndexStrategy.getInsertionIds(sfcIndexedRange, 8).getCompositeInsertionIds().stream().map(i -> new ByteArray(i)).collect(Collectors.toSet());
Assert.assertTrue(testIds.containsAll(compoundIndexIds));
final SinglePartitionInsertionIds id2 = ids2.getPartitionKeys().iterator().next();
final MultiDimensionalCoordinates sfcIndexCoordinatesPerDim = sfcIndexStrategy.getCoordinatesPerDimension(id2.getPartitionKey(), id2.getSortKeys().get(0));
// the first 2 bytes are the partition keys
final MultiDimensionalCoordinates coordinatesPerDim = compoundIndexStrategy.getCoordinatesPerDimension(Arrays.copyOfRange(ids.get(0).getBytes(), 0, 2), Arrays.copyOfRange(ids.get(0).getBytes(), 2, ids.get(0).getBytes().length));
Assert.assertTrue(sfcIndexCoordinatesPerDim.equals(coordinatesPerDim));
}
Aggregations