Search in sources :

Example 1 with SinglePartitionInsertionIds

use of org.locationtech.geowave.core.index.SinglePartitionInsertionIds 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 SinglePartitionInsertionIds

use of org.locationtech.geowave.core.index.SinglePartitionInsertionIds in project geowave by locationtech.

the class IndexCompositeWriter method internalWrite.

protected WriteResults internalWrite(final T entry, final Function<Writer<T>, WriteResults> internalWriter) {
    final Map<String, List<SinglePartitionInsertionIds>> insertionIdsPerIndex = new HashMap<>();
    for (final Writer<T> indexWriter : writers) {
        final WriteResults ids = internalWriter.apply(indexWriter);
        for (final String indexName : ids.getWrittenIndexNames()) {
            List<SinglePartitionInsertionIds> partitionInsertionIds = insertionIdsPerIndex.get(indexName);
            if (partitionInsertionIds == null) {
                partitionInsertionIds = new ArrayList<>();
                insertionIdsPerIndex.put(indexName, partitionInsertionIds);
            }
            partitionInsertionIds.addAll(ids.getInsertionIdsWritten(indexName).getPartitionKeys());
        }
    }
    return new WriteResults(Maps.transformValues(insertionIdsPerIndex, v -> new InsertionIds(v)));
}
Also used : Arrays(java.util.Arrays) SinglePartitionInsertionIds(org.locationtech.geowave.core.index.SinglePartitionInsertionIds) HashMap(java.util.HashMap) Function(java.util.function.Function) Maps(com.google.common.collect.Maps) ArrayList(java.util.ArrayList) WriteResults(org.locationtech.geowave.core.store.api.WriteResults) List(java.util.List) VisibilityHandler(org.locationtech.geowave.core.store.api.VisibilityHandler) Writer(org.locationtech.geowave.core.store.api.Writer) InsertionIds(org.locationtech.geowave.core.index.InsertionIds) Map(java.util.Map) Index(org.locationtech.geowave.core.store.api.Index) WriteResults(org.locationtech.geowave.core.store.api.WriteResults) SinglePartitionInsertionIds(org.locationtech.geowave.core.index.SinglePartitionInsertionIds) HashMap(java.util.HashMap) SinglePartitionInsertionIds(org.locationtech.geowave.core.index.SinglePartitionInsertionIds) InsertionIds(org.locationtech.geowave.core.index.InsertionIds) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with SinglePartitionInsertionIds

use of org.locationtech.geowave.core.index.SinglePartitionInsertionIds in project geowave by locationtech.

the class GeoWaveKeyImpl method createKeys.

public static GeoWaveKey[] createKeys(final InsertionIds insertionIds, final byte[] dataId, final short internalAdapterId) {
    if (insertionIds == null) {
        return new GeoWaveKey[] { new GeoWaveKeyImpl(dataId, internalAdapterId, null, null, 0) };
    }
    final GeoWaveKey[] keys = new GeoWaveKey[insertionIds.getSize()];
    final Collection<SinglePartitionInsertionIds> partitionKeys = insertionIds.getPartitionKeys();
    final Iterator<SinglePartitionInsertionIds> it = partitionKeys.iterator();
    final int numDuplicates = keys.length - 1;
    int i = 0;
    while (it.hasNext()) {
        final SinglePartitionInsertionIds partitionKey = it.next();
        if ((partitionKey.getSortKeys() == null) || partitionKey.getSortKeys().isEmpty()) {
            keys[i++] = new GeoWaveKeyImpl(dataId, internalAdapterId, partitionKey.getPartitionKey(), new byte[] {}, numDuplicates);
        } else {
            byte[] partitionKeyBytes;
            if (partitionKey.getPartitionKey() == null) {
                partitionKeyBytes = new byte[] {};
            } else {
                partitionKeyBytes = partitionKey.getPartitionKey();
            }
            final List<byte[]> sortKeys = partitionKey.getSortKeys();
            for (final byte[] sortKey : sortKeys) {
                keys[i++] = new GeoWaveKeyImpl(dataId, internalAdapterId, partitionKeyBytes, sortKey, numDuplicates);
            }
        }
    }
    return keys;
}
Also used : SinglePartitionInsertionIds(org.locationtech.geowave.core.index.SinglePartitionInsertionIds)

Example 4 with SinglePartitionInsertionIds

use of org.locationtech.geowave.core.index.SinglePartitionInsertionIds in project geowave by locationtech.

the class DataStoreUtils method keysToInsertionIds.

public static InsertionIds keysToInsertionIds(final GeoWaveKey... geoWaveKeys) {
    final Map<ByteArray, List<byte[]>> sortKeysPerPartition = new HashMap<>();
    for (final GeoWaveKey key : geoWaveKeys) {
        final ByteArray partitionKey = new ByteArray(key.getPartitionKey());
        List<byte[]> sortKeys = sortKeysPerPartition.get(partitionKey);
        if (sortKeys == null) {
            sortKeys = new ArrayList<>();
            sortKeysPerPartition.put(partitionKey, sortKeys);
        }
        sortKeys.add(key.getSortKey());
    }
    final Set<SinglePartitionInsertionIds> insertionIds = new HashSet<>();
    for (final Entry<ByteArray, List<byte[]>> e : sortKeysPerPartition.entrySet()) {
        insertionIds.add(new SinglePartitionInsertionIds(e.getKey().getBytes(), e.getValue()));
    }
    return new InsertionIds(insertionIds);
}
Also used : SinglePartitionInsertionIds(org.locationtech.geowave.core.index.SinglePartitionInsertionIds) HashMap(java.util.HashMap) InsertionIds(org.locationtech.geowave.core.index.InsertionIds) SinglePartitionInsertionIds(org.locationtech.geowave.core.index.SinglePartitionInsertionIds) GeoWaveKey(org.locationtech.geowave.core.store.entities.GeoWaveKey) ByteArray(org.locationtech.geowave.core.index.ByteArray) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet)

Example 5 with SinglePartitionInsertionIds

use of org.locationtech.geowave.core.index.SinglePartitionInsertionIds 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)

Aggregations

SinglePartitionInsertionIds (org.locationtech.geowave.core.index.SinglePartitionInsertionIds)24 InsertionIds (org.locationtech.geowave.core.index.InsertionIds)16 ArrayList (java.util.ArrayList)8 HashSet (java.util.HashSet)6 HashMap (java.util.HashMap)5 ByteArray (org.locationtech.geowave.core.index.ByteArray)5 BinnedNumericDataset (org.locationtech.geowave.core.index.numeric.BinnedNumericDataset)5 MultiDimensionalNumericData (org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData)5 List (java.util.List)4 Map (java.util.Map)4 BigInteger (java.math.BigInteger)3 Test (org.junit.Test)3 BasicNumericDataset (org.locationtech.geowave.core.index.numeric.BasicNumericDataset)3 Index (org.locationtech.geowave.core.store.api.Index)3 Maps (com.google.common.collect.Maps)2 Arrays (java.util.Arrays)2 Function (java.util.function.Function)2 ByteArrayRange (org.locationtech.geowave.core.index.ByteArrayRange)2 MultiDimensionalCoordinates (org.locationtech.geowave.core.index.MultiDimensionalCoordinates)2 NumericIndexStrategy (org.locationtech.geowave.core.index.NumericIndexStrategy)2