Search in sources :

Example 1 with MultiDimensionalNumericData

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;
}
Also used : MultiDimensionalNumericData(org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData) SinglePartitionInsertionIds(org.locationtech.geowave.core.index.SinglePartitionInsertionIds) Envelope(org.locationtech.jts.geom.Envelope) Polygon(org.locationtech.jts.geom.Polygon) Point(org.locationtech.jts.geom.Point)

Example 2 with MultiDimensionalNumericData

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

Example 3 with MultiDimensionalNumericData

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;
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) MultiDimensionalNumericData(org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData)

Example 4 with MultiDimensionalNumericData

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));
}
Also used : NumericRange(org.locationtech.geowave.core.index.numeric.NumericRange) MultiDimensionalNumericData(org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData) HashMap(java.util.HashMap) BasicNumericDataset(org.locationtech.geowave.core.index.numeric.BasicNumericDataset) ByteArray(org.locationtech.geowave.core.index.ByteArray) Test(org.junit.Test)

Example 5 with MultiDimensionalNumericData

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

Aggregations

MultiDimensionalNumericData (org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData)49 Test (org.junit.Test)24 BasicNumericDataset (org.locationtech.geowave.core.index.numeric.BasicNumericDataset)14 NumericData (org.locationtech.geowave.core.index.numeric.NumericData)12 ArrayList (java.util.ArrayList)10 NumericRange (org.locationtech.geowave.core.index.numeric.NumericRange)9 InsertionIds (org.locationtech.geowave.core.index.InsertionIds)8 NumericIndexStrategy (org.locationtech.geowave.core.index.NumericIndexStrategy)8 ByteArray (org.locationtech.geowave.core.index.ByteArray)7 SimpleFeature (org.opengis.feature.simple.SimpleFeature)7 HashMap (java.util.HashMap)6 Coordinate (org.locationtech.jts.geom.Coordinate)6 ByteArrayRange (org.locationtech.geowave.core.index.ByteArrayRange)5 Index (org.locationtech.geowave.core.store.api.Index)5 QueryRanges (org.locationtech.geowave.core.index.QueryRanges)4 BasicQueryByClass (org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass)4 Geometry (org.locationtech.jts.geom.Geometry)4 GeometryFactory (org.locationtech.jts.geom.GeometryFactory)4 HashSet (java.util.HashSet)3 FeatureDataAdapter (org.locationtech.geowave.adapter.vector.FeatureDataAdapter)3