Search in sources :

Example 1 with ArrayOfArrays

use of org.locationtech.geowave.core.index.MultiDimensionalCoordinateRangesArray.ArrayOfArrays in project geowave by locationtech.

the class AccumuloOperations method addIndexFilterToIterator.

protected <T> void addIndexFilterToIterator(final ReaderParams<T> params, final ScannerBase scanner) {
    final List<MultiDimensionalCoordinateRangesArray> coords = params.getCoordinateRanges();
    if ((coords != null) && !coords.isEmpty()) {
        final IteratorSetting iteratorSetting = new IteratorSetting(NumericIndexStrategyFilterIterator.IDX_FILTER_ITERATOR_PRIORITY, NumericIndexStrategyFilterIterator.IDX_FILTER_ITERATOR_NAME, NumericIndexStrategyFilterIterator.class);
        iteratorSetting.addOption(NumericIndexStrategyFilterIterator.INDEX_STRATEGY_KEY, ByteArrayUtils.byteArrayToString(PersistenceUtils.toBinary(params.getIndex().getIndexStrategy())));
        iteratorSetting.addOption(NumericIndexStrategyFilterIterator.COORDINATE_RANGE_KEY, ByteArrayUtils.byteArrayToString(new ArrayOfArrays(coords.toArray(new MultiDimensionalCoordinateRangesArray[] {})).toBinary()));
        scanner.addScanIterator(iteratorSetting);
    }
}
Also used : IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) MultiDimensionalCoordinateRangesArray(org.locationtech.geowave.core.index.MultiDimensionalCoordinateRangesArray) ArrayOfArrays(org.locationtech.geowave.core.index.MultiDimensionalCoordinateRangesArray.ArrayOfArrays)

Example 2 with ArrayOfArrays

use of org.locationtech.geowave.core.index.MultiDimensionalCoordinateRangesArray.ArrayOfArrays in project geowave by locationtech.

the class NumericIndexStrategyFilterIterator method init.

@Override
public void init(final SortedKeyValueIterator<Key, Value> source, final Map<String, String> options, final IteratorEnvironment env) throws IOException {
    this.source = source;
    if (options == null) {
        throw new IllegalArgumentException("Arguments must be set for " + NumericIndexStrategyFilterIterator.class.getName());
    }
    try {
        if (options.containsKey(INDEX_STRATEGY_KEY)) {
            final String idxStrategyStr = options.get(INDEX_STRATEGY_KEY);
            final byte[] idxStrategyBytes = ByteArrayUtils.byteArrayFromString(idxStrategyStr);
            indexStrategy = (NumericIndexStrategy) URLClassloaderUtils.fromBinary(idxStrategyBytes);
            partitionKeyLength = indexStrategy.getPartitionKeyLength();
        } else {
            throw new IllegalArgumentException("'" + INDEX_STRATEGY_KEY + "' must be set for " + NumericIndexStrategyFilterIterator.class.getName());
        }
        if (options.containsKey(COORDINATE_RANGE_KEY)) {
            final String coordRangeStr = options.get(COORDINATE_RANGE_KEY);
            final byte[] coordRangeBytes = ByteArrayUtils.byteArrayFromString(coordRangeStr);
            final ArrayOfArrays arrays = new ArrayOfArrays();
            arrays.fromBinary(coordRangeBytes);
            rangeCache = RangeLookupFactory.createMultiRangeLookup(arrays.getCoordinateArrays());
        } else {
            throw new IllegalArgumentException("'" + COORDINATE_RANGE_KEY + "' must be set for " + NumericIndexStrategyFilterIterator.class.getName());
        }
    } catch (final Exception e) {
        throw new IllegalArgumentException(e);
    }
}
Also used : ArrayOfArrays(org.locationtech.geowave.core.index.MultiDimensionalCoordinateRangesArray.ArrayOfArrays) IOException(java.io.IOException)

Example 3 with ArrayOfArrays

use of org.locationtech.geowave.core.index.MultiDimensionalCoordinateRangesArray.ArrayOfArrays in project geowave by locationtech.

the class CoordinateRangeQueryFilter method fromBinary.

@Override
public void fromBinary(final byte[] bytes) {
    final ByteBuffer buf = ByteBuffer.wrap(bytes);
    try {
        final int indexStrategyLength = VarintUtils.readUnsignedInt(buf);
        final byte[] indexStrategyBytes = ByteArrayUtils.safeRead(buf, indexStrategyLength);
        indexStrategy = (NumericIndexStrategy) PersistenceUtils.fromBinary(indexStrategyBytes);
        final byte[] coordRangeBytes = new byte[buf.remaining()];
        buf.get(coordRangeBytes);
        final ArrayOfArrays arrays = new ArrayOfArrays();
        arrays.fromBinary(coordRangeBytes);
        coordinateRanges = arrays.getCoordinateArrays();
        rangeCache = RangeLookupFactory.createMultiRangeLookup(coordinateRanges);
    } catch (final Exception e) {
        LOGGER.warn("Unable to read parameters", e);
    }
}
Also used : ArrayOfArrays(org.locationtech.geowave.core.index.MultiDimensionalCoordinateRangesArray.ArrayOfArrays) ByteBuffer(java.nio.ByteBuffer)

Example 4 with ArrayOfArrays

use of org.locationtech.geowave.core.index.MultiDimensionalCoordinateRangesArray.ArrayOfArrays in project geowave by locationtech.

the class HBaseNumericIndexStrategyFilter method toByteArray.

@Override
public byte[] toByteArray() throws IOException {
    final byte[] indexStrategyBytes = URLClassloaderUtils.toBinary(indexStrategy);
    final byte[] coordinateRangesBinary = new ArrayOfArrays(coordinateRanges).toBinary();
    final ByteBuffer buf = ByteBuffer.allocate(coordinateRangesBinary.length + indexStrategyBytes.length + VarintUtils.unsignedIntByteLength(indexStrategyBytes.length));
    VarintUtils.writeUnsignedInt(indexStrategyBytes.length, buf);
    buf.put(indexStrategyBytes);
    buf.put(coordinateRangesBinary);
    return buf.array();
}
Also used : ArrayOfArrays(org.locationtech.geowave.core.index.MultiDimensionalCoordinateRangesArray.ArrayOfArrays) ByteBuffer(java.nio.ByteBuffer)

Example 5 with ArrayOfArrays

use of org.locationtech.geowave.core.index.MultiDimensionalCoordinateRangesArray.ArrayOfArrays in project geowave by locationtech.

the class CoordinateRangeQueryFilter method toBinary.

@Override
public byte[] toBinary() {
    final byte[] indexStrategyBytes = PersistenceUtils.toBinary(indexStrategy);
    final byte[] coordinateRangesBinary = new ArrayOfArrays(coordinateRanges).toBinary();
    final ByteBuffer buf = ByteBuffer.allocate(coordinateRangesBinary.length + indexStrategyBytes.length + VarintUtils.unsignedIntByteLength(indexStrategyBytes.length));
    VarintUtils.writeUnsignedInt(indexStrategyBytes.length, buf);
    buf.put(indexStrategyBytes);
    buf.put(coordinateRangesBinary);
    return buf.array();
}
Also used : ArrayOfArrays(org.locationtech.geowave.core.index.MultiDimensionalCoordinateRangesArray.ArrayOfArrays) ByteBuffer(java.nio.ByteBuffer)

Aggregations

ArrayOfArrays (org.locationtech.geowave.core.index.MultiDimensionalCoordinateRangesArray.ArrayOfArrays)6 ByteBuffer (java.nio.ByteBuffer)4 IOException (java.io.IOException)2 MultiDimensionalCoordinateRangesArray (org.locationtech.geowave.core.index.MultiDimensionalCoordinateRangesArray)2 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)1 DeserializationException (org.apache.hadoop.hbase.exceptions.DeserializationException)1 NumericIndexStrategy (org.locationtech.geowave.core.index.NumericIndexStrategy)1