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;
}
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)));
}
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;
}
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);
}
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));
}
}
}
}
Aggregations