@Override public int compare(byte [] left, byte [] right) { return compareTo(left, right); } @Override
@Override public int compare(byte [] left, byte [] right) { return compareTo(left, right); } @Override
/** * @param left left operand * @param right right operand * @return True if equal */ public static boolean equals(final byte [] left, final byte [] right) { // Could use Arrays.equals? //noinspection SimplifiableConditionalExpression if (left == right) return true; if (left == null || right == null) return false; if (left.length != right.length) return false; if (left.length == 0) return true; // Since we're often comparing adjacent sorted data, // it's usual to have equal arrays except for the very last byte // so check that first if (left[left.length - 1] != right[right.length - 1]) return false; return compareTo(left, right) == 0; }
/** * @param left left operand * @param right right operand * @return True if equal */ public static boolean equals(final byte [] left, final byte [] right) { // Could use Arrays.equals? //noinspection SimplifiableConditionalExpression if (left == right) return true; if (left == null || right == null) return false; if (left.length != right.length) return false; if (left.length == 0) return true; // Since we're often comparing adjacent sorted data, // it's usual to have equal arrays except for the very last byte // so check that first if (left[left.length - 1] != right[right.length - 1]) return false; return compareTo(left, right) == 0; }
bPadded = b; if (compareTo(aPadded,bPadded) >= 0) { throw new IllegalArgumentException("b <= a");
bPadded = b; if (compareTo(aPadded,bPadded) >= 0) { throw new IllegalArgumentException("b <= a");
byte[] stopRow = selectedRange.getSecond().get(j); if ((startRow.length == 0 || regionStopKey.length == 0 || Bytes.compareTo(startRow, regionStopKey) < 0) && (stopRow.length == 0 || Bytes.compareTo(stopRow, regionStartKey) > 0)) { final byte[] fragmentStart = (startRow.length == 0 || Bytes.compareTo(regionStartKey, startRow) >= 0) ? regionStartKey : startRow; final byte[] fragmentStop = (stopRow.length == 0 || Bytes.compareTo(regionStopKey, stopRow) <= 0) && regionStopKey.length > 0 ? regionStopKey : stopRow; if (Bytes.compareTo(fragmentStart, prevFragment.getStartRow()) < 0) { prevFragment.setStartRow(fragmentStart); if (Bytes.compareTo(fragmentStop, prevFragment.getStopRow()) > 0) { prevFragment.setStopRow(fragmentStop);
byte[] stopRow = selectedRange.getSecond().get(j); if ((startRow.length == 0 || regionStopKey.length == 0 || Bytes.compareTo(startRow, regionStopKey) < 0) && (stopRow.length == 0 || Bytes.compareTo(stopRow, regionStartKey) > 0)) { final byte[] fragmentStart = (startRow.length == 0 || Bytes.compareTo(regionStartKey, startRow) >= 0) ? regionStartKey : startRow; final byte[] fragmentStop = (stopRow.length == 0 || Bytes.compareTo(regionStopKey, stopRow) <= 0) && regionStopKey.length > 0 ? regionStopKey : stopRow; if (Bytes.compareTo(fragmentStart, prevFragment.getStartKey().getBytes()) < 0) { prevFragment.setStartRow(fragmentStart); if (Bytes.compareTo(fragmentStop, prevFragment.getEndKey().getBytes()) > 0) { prevFragment.setStopRow(fragmentStop);
@Override public int compareTo(Datum datum) { switch (datum.type()) { case INET4: byte[] bytes = asByteArray(); byte[] other = datum.asByteArray(); return Bytes.compareTo(bytes, 0, size, other, 0, size); case NULL_TYPE: return -1; default: throw new InvalidOperationException(datum.type()); } }