NumericUtils.subtract(bytesPerDim, dim, maxPackedValue, minPackedValue, scratchDiff); if (splitDim == -1 || FutureArrays.compareUnsigned(scratchDiff, 0, bytesPerDim, scratch1, 0, bytesPerDim) > 0) { System.arraycopy(scratchDiff, 0, scratch1, 0, bytesPerDim);
protected int split(byte[] minPackedValue, byte[] maxPackedValue) { // Find which dim has the largest span so we can split on it: int splitDim = -1; for(int dim=0;dim<numIndexDims;dim++) { NumericUtils.subtract(bytesPerDim, dim, maxPackedValue, minPackedValue, scratchDiff); if (splitDim == -1 || FutureArrays.compareUnsigned(scratchDiff, 0, bytesPerDim, scratch1, 0, bytesPerDim) > 0) { System.arraycopy(scratchDiff, 0, scratch1, 0, bytesPerDim); splitDim = dim; } } //System.out.println("SPLIT: " + splitDim); return splitDim; }
/** * Return the {@link InetAddress} that compares immediately less than * {@code address}. * @throws ArithmeticException if the provided address is the * {@link #MIN_VALUE minimum ip address} */ public static InetAddress nextDown(InetAddress address) { if (address.equals(MIN_VALUE)) { throw new ArithmeticException("Underflow: there is no smaller InetAddress than " + address.getHostAddress()); } byte[] delta = new byte[BYTES]; delta[BYTES-1] = 1; byte[] nextDownBytes = new byte[InetAddressPoint.BYTES]; NumericUtils.subtract(InetAddressPoint.BYTES, 0, encode(address), delta, nextDownBytes); return decode(nextDownBytes); }
NumericUtils.subtract(bytesPerDim, dim, maxPackedValue, minPackedValue, scratchDiff); if (splitDim == -1 || FutureArrays.compareUnsigned(scratchDiff, 0, bytesPerDim, scratch1, 0, bytesPerDim) > 0) { System.arraycopy(scratchDiff, 0, scratch1, 0, bytesPerDim);
private static BiFunction<Query, Version, Result> pointRangeQuery() { return (query, version) -> { PointRangeQuery pointRangeQuery = (PointRangeQuery) query; if (pointRangeQuery.getNumDims() != 1) { throw new UnsupportedQueryException(query); } byte[] lowerPoint = pointRangeQuery.getLowerPoint(); byte[] upperPoint = pointRangeQuery.getUpperPoint(); // Need to check whether upper is not smaller than lower, otherwise NumericUtils.subtract(...) fails IAE // If upper is really smaller than lower then we deal with like MatchNoDocsQuery. (verified and no extractions) if (new BytesRef(lowerPoint).compareTo(new BytesRef(upperPoint)) > 0) { return new Result(true, Collections.emptySet(), 0); } byte[] interval = new byte[16]; NumericUtils.subtract(16, 0, prepad(upperPoint), prepad(lowerPoint), interval); return new Result(false, Collections.singleton(new QueryExtraction( new Range(pointRangeQuery.getField(), lowerPoint, upperPoint, interval))), 1); }; }
private static BiFunction<Query, Version, Result> pointRangeQuery() { return (query, version) -> { PointRangeQuery pointRangeQuery = (PointRangeQuery) query; if (pointRangeQuery.getNumDims() != 1) { throw new UnsupportedQueryException(query); } byte[] lowerPoint = pointRangeQuery.getLowerPoint(); byte[] upperPoint = pointRangeQuery.getUpperPoint(); // Need to check whether upper is not smaller than lower, otherwise NumericUtils.subtract(...) fails IAE // If upper is really smaller than lower then we deal with like MatchNoDocsQuery. (verified and no extractions) if (new BytesRef(lowerPoint).compareTo(new BytesRef(upperPoint)) > 0) { return new Result(true, Collections.emptySet(), 0); } byte[] interval = new byte[16]; NumericUtils.subtract(16, 0, prepad(upperPoint), prepad(lowerPoint), interval); return new Result(false, Collections.singleton(new QueryExtraction( new Range(pointRangeQuery.getField(), lowerPoint, upperPoint, interval))), 1); }; }