Search in sources :

Example 1 with GeoWaveKeyImpl

use of org.locationtech.geowave.core.store.entities.GeoWaveKeyImpl in project geowave by locationtech.

the class AccumuloReader method entryRowIdsMatch.

private boolean entryRowIdsMatch(final Entry<Key, Value> nextEntry, final Entry<Key, Value> peekedEntry) {
    final GeoWaveKey nextKey = new GeoWaveKeyImpl(nextEntry.getKey().getRow().copyBytes(), partitionKeyLength);
    final GeoWaveKey peekedKey = new GeoWaveKeyImpl(peekedEntry.getKey().getRow().copyBytes(), partitionKeyLength);
    return DataStoreUtils.rowIdsMatch(nextKey, peekedKey);
}
Also used : GeoWaveKey(org.locationtech.geowave.core.store.entities.GeoWaveKey) GeoWaveKeyImpl(org.locationtech.geowave.core.store.entities.GeoWaveKeyImpl)

Example 2 with GeoWaveKeyImpl

use of org.locationtech.geowave.core.store.entities.GeoWaveKeyImpl 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 3 with GeoWaveKeyImpl

use of org.locationtech.geowave.core.store.entities.GeoWaveKeyImpl in project geowave by locationtech.

the class DynamoDBRow method getGeoWaveKey.

private static GeoWaveKey getGeoWaveKey(final Map<String, AttributeValue> objMap) {
    final byte[] partitionKey = objMap.get(GW_PARTITION_ID_KEY).getB().array();
    final byte[] rangeKey = objMap.get(GW_RANGE_KEY).getB().array();
    final int length = rangeKey.length;
    final ByteBuffer metadataBuf = ByteBuffer.wrap(rangeKey, length - 8, 8);
    final int dataIdLength = metadataBuf.getInt();
    final int numberOfDuplicates = metadataBuf.getInt();
    final ByteBuffer buf = ByteBuffer.wrap(rangeKey, 0, length - 16);
    final byte[] sortKey = new byte[length - 16 - 2 - dataIdLength];
    final byte[] dataId = new byte[dataIdLength];
    // Range key (row ID) = adapterId + sortKey + dataId
    final byte[] internalAdapterIdBytes = new byte[2];
    buf.get(internalAdapterIdBytes);
    final short internalAdapterId = ByteArrayUtils.byteArrayToShort(internalAdapterIdBytes);
    buf.get(sortKey);
    buf.get(dataId);
    return new GeoWaveKeyImpl(dataId, internalAdapterId, Arrays.equals(DynamoDBUtils.EMPTY_PARTITION_KEY, partitionKey) ? new byte[0] : partitionKey, DynamoDBUtils.decodeSortableBase64(sortKey), numberOfDuplicates);
}
Also used : GeoWaveKeyImpl(org.locationtech.geowave.core.store.entities.GeoWaveKeyImpl) ByteBuffer(java.nio.ByteBuffer)

Example 4 with GeoWaveKeyImpl

use of org.locationtech.geowave.core.store.entities.GeoWaveKeyImpl in project geowave by locationtech.

the class RasterTileResizeMapper method mapNativeValue.

@Override
protected void mapNativeValue(final GeoWaveInputKey key, final GridCoverage value, final MapContext<GeoWaveInputKey, GridCoverage, GeoWaveInputKey, Object> context) throws IOException, InterruptedException {
    if (helper.isOriginalCoverage(key.getInternalAdapterId())) {
        final InternalDataAdapter<?> adapter = super.serializationTool.getInternalAdapter(key.getInternalAdapterId());
        if ((adapter != null) && (adapter.getAdapter() != null) && (adapter.getAdapter() instanceof RasterDataAdapter)) {
            final Iterator<GridCoverage> coverages = helper.getCoveragesForIndex(value);
            if (coverages == null) {
                LOGGER.error("Couldn't get coverages instance, getCoveragesForIndex returned null");
                throw new IOException("Couldn't get coverages instance, getCoveragesForIndex returned null");
            }
            while (coverages.hasNext()) {
                final GridCoverage c = coverages.next();
                // converted above
                if (c instanceof FitToIndexGridCoverage) {
                    final byte[] partitionKey = ((FitToIndexGridCoverage) c).getPartitionKey();
                    final byte[] sortKey = ((FitToIndexGridCoverage) c).getSortKey();
                    final GeoWaveKey geowaveKey = new GeoWaveKeyImpl(helper.getNewDataId(c), key.getInternalAdapterId(), partitionKey, sortKey, 0);
                    final GeoWaveInputKey inputKey = new GeoWaveInputKey(helper.getNewAdapterId(), geowaveKey, helper.getIndexName());
                    context.write(inputKey, c);
                }
            }
        }
    }
}
Also used : RasterDataAdapter(org.locationtech.geowave.adapter.raster.adapter.RasterDataAdapter) FitToIndexGridCoverage(org.locationtech.geowave.adapter.raster.FitToIndexGridCoverage) GridCoverage(org.opengis.coverage.grid.GridCoverage) FitToIndexGridCoverage(org.locationtech.geowave.adapter.raster.FitToIndexGridCoverage) GeoWaveKey(org.locationtech.geowave.core.store.entities.GeoWaveKey) GeoWaveKeyImpl(org.locationtech.geowave.core.store.entities.GeoWaveKeyImpl) IOException(java.io.IOException) GeoWaveInputKey(org.locationtech.geowave.mapreduce.input.GeoWaveInputKey)

Example 5 with GeoWaveKeyImpl

use of org.locationtech.geowave.core.store.entities.GeoWaveKeyImpl in project geowave by locationtech.

the class DataStoreUtils method mergeSingleRowValues.

public static GeoWaveRow mergeSingleRowValues(final GeoWaveRow singleRow, final RowTransform rowTransform) {
    if (singleRow.getFieldValues().length < 2) {
        return singleRow;
    }
    // merge all values into a single value
    Mergeable merged = null;
    for (final GeoWaveValue fieldValue : singleRow.getFieldValues()) {
        final Mergeable mergeable = rowTransform.getRowAsMergeableObject(singleRow.getAdapterId(), new ByteArray(fieldValue.getFieldMask()), fieldValue.getValue());
        if (merged == null) {
            merged = mergeable;
        } else {
            merged.merge(mergeable);
        }
    }
    final GeoWaveValue[] mergedFieldValues = new GeoWaveValue[] { new GeoWaveValueImpl(singleRow.getFieldValues()[0].getFieldMask(), singleRow.getFieldValues()[0].getVisibility(), rowTransform.getBinaryFromMergedObject(merged)) };
    return new GeoWaveRowImpl(new GeoWaveKeyImpl(singleRow.getDataId(), singleRow.getAdapterId(), singleRow.getPartitionKey(), singleRow.getSortKey(), singleRow.getNumberOfDuplicates()), mergedFieldValues);
}
Also used : Mergeable(org.locationtech.geowave.core.index.Mergeable) GeoWaveRowImpl(org.locationtech.geowave.core.store.entities.GeoWaveRowImpl) GeoWaveValueImpl(org.locationtech.geowave.core.store.entities.GeoWaveValueImpl) GeoWaveKeyImpl(org.locationtech.geowave.core.store.entities.GeoWaveKeyImpl) ByteArray(org.locationtech.geowave.core.index.ByteArray) GeoWaveValue(org.locationtech.geowave.core.store.entities.GeoWaveValue)

Aggregations

GeoWaveKeyImpl (org.locationtech.geowave.core.store.entities.GeoWaveKeyImpl)10 GeoWaveKey (org.locationtech.geowave.core.store.entities.GeoWaveKey)4 GeoWaveValue (org.locationtech.geowave.core.store.entities.GeoWaveValue)3 ByteArray (org.locationtech.geowave.core.index.ByteArray)2 MultiDimensionalCoordinates (org.locationtech.geowave.core.index.MultiDimensionalCoordinates)2 GeoWaveRowImpl (org.locationtech.geowave.core.store.entities.GeoWaveRowImpl)2 GeoWaveValueImpl (org.locationtech.geowave.core.store.entities.GeoWaveValueImpl)2 IOException (java.io.IOException)1 ByteBuffer (java.nio.ByteBuffer)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Random (java.util.Random)1 Key (org.apache.accumulo.core.data.Key)1 Value (org.apache.accumulo.core.data.Value)1 ColumnVisibility (org.apache.accumulo.core.security.ColumnVisibility)1 Cell (org.apache.hadoop.hbase.Cell)1 Text (org.apache.hadoop.io.Text)1 Test (org.junit.Test)1 FitToIndexGridCoverage (org.locationtech.geowave.adapter.raster.FitToIndexGridCoverage)1 RasterDataAdapter (org.locationtech.geowave.adapter.raster.adapter.RasterDataAdapter)1