Search in sources :

Example 1 with MultiDimensionalCoordinates

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);
}
Also used : GeoWaveKeyImpl(org.locationtech.geowave.core.store.entities.GeoWaveKeyImpl) MultiDimensionalCoordinates(org.locationtech.geowave.core.index.MultiDimensionalCoordinates)

Example 2 with MultiDimensionalCoordinates

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;
}
Also used : BigInteger(java.math.BigInteger) MultiDimensionalCoordinates(org.locationtech.geowave.core.index.MultiDimensionalCoordinates)

Example 3 with MultiDimensionalCoordinates

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);
}
Also used : GeoWaveKeyImpl(org.locationtech.geowave.core.store.entities.GeoWaveKeyImpl) MultiDimensionalCoordinates(org.locationtech.geowave.core.index.MultiDimensionalCoordinates)

Example 4 with MultiDimensionalCoordinates

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);
    }
}
Also used : NumericRange(org.locationtech.geowave.core.index.numeric.NumericRange) MultiDimensionalNumericData(org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData) SinglePartitionInsertionIds(org.locationtech.geowave.core.index.SinglePartitionInsertionIds) BasicNumericDataset(org.locationtech.geowave.core.index.numeric.BasicNumericDataset) SinglePartitionInsertionIds(org.locationtech.geowave.core.index.SinglePartitionInsertionIds) InsertionIds(org.locationtech.geowave.core.index.InsertionIds) MultiDimensionalCoordinates(org.locationtech.geowave.core.index.MultiDimensionalCoordinates) Test(org.junit.Test)

Example 5 with MultiDimensionalCoordinates

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));
}
Also used : ByteArray(org.locationtech.geowave.core.index.ByteArray) CompoundIndexStrategy(org.locationtech.geowave.core.index.CompoundIndexStrategy) Arrays(java.util.Arrays) BasicNumericDataset(org.locationtech.geowave.core.index.numeric.BasicNumericDataset) PersistenceUtils(org.locationtech.geowave.core.index.persist.PersistenceUtils) HashMap(java.util.HashMap) NumericDimensionDefinition(org.locationtech.geowave.core.index.dimension.NumericDimensionDefinition) NumericData(org.locationtech.geowave.core.index.numeric.NumericData) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Map(java.util.Map) ByteArrayRange(org.locationtech.geowave.core.index.ByteArrayRange) BasicDimensionDefinition(org.locationtech.geowave.core.index.dimension.BasicDimensionDefinition) NumericRange(org.locationtech.geowave.core.index.numeric.NumericRange) SinglePartitionInsertionIds(org.locationtech.geowave.core.index.SinglePartitionInsertionIds) Set(java.util.Set) TieredSFCIndexFactory(org.locationtech.geowave.core.index.sfc.tiered.TieredSFCIndexFactory) Test(org.junit.Test) Collectors(java.util.stream.Collectors) List(java.util.List) InsertionIds(org.locationtech.geowave.core.index.InsertionIds) SFCType(org.locationtech.geowave.core.index.sfc.SFCFactory.SFCType) ByteArrayUtils(org.locationtech.geowave.core.index.ByteArrayUtils) MultiDimensionalNumericData(org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData) Assert(org.junit.Assert) NumericIndexStrategy(org.locationtech.geowave.core.index.NumericIndexStrategy) Assert.assertEquals(org.junit.Assert.assertEquals) MultiDimensionalCoordinates(org.locationtech.geowave.core.index.MultiDimensionalCoordinates) SinglePartitionInsertionIds(org.locationtech.geowave.core.index.SinglePartitionInsertionIds) SinglePartitionInsertionIds(org.locationtech.geowave.core.index.SinglePartitionInsertionIds) InsertionIds(org.locationtech.geowave.core.index.InsertionIds) ArrayList(java.util.ArrayList) ByteArray(org.locationtech.geowave.core.index.ByteArray) MultiDimensionalCoordinates(org.locationtech.geowave.core.index.MultiDimensionalCoordinates) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

MultiDimensionalCoordinates (org.locationtech.geowave.core.index.MultiDimensionalCoordinates)5 Test (org.junit.Test)2 InsertionIds (org.locationtech.geowave.core.index.InsertionIds)2 SinglePartitionInsertionIds (org.locationtech.geowave.core.index.SinglePartitionInsertionIds)2 BasicNumericDataset (org.locationtech.geowave.core.index.numeric.BasicNumericDataset)2 MultiDimensionalNumericData (org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData)2 NumericRange (org.locationtech.geowave.core.index.numeric.NumericRange)2 GeoWaveKeyImpl (org.locationtech.geowave.core.store.entities.GeoWaveKeyImpl)2 BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Assert (org.junit.Assert)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 ByteArray (org.locationtech.geowave.core.index.ByteArray)1