@Override public void fromBinary(final byte[] bytes) { final ByteBuffer buf = ByteBuffer.wrap(bytes); try { final int indexStrategyLength = buf.getInt(); final byte[] indexStrategyBytes = new byte[indexStrategyLength]; buf.get(indexStrategyBytes); indexStrategy = PersistenceUtils.fromBinary(indexStrategyBytes, NumericIndexStrategy.class); final byte[] coordRangeBytes = new byte[bytes.length - indexStrategyLength - 4]; 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); } }
@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 = PersistenceUtils.fromBinary(idxStrategyBytes, NumericIndexStrategy.class); } 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); } }