private void appendRange(StringBuilder statement, Range range) { appendScanBound(statement, range.getBegin(), range.getBeginBound().equals(Range.Bound.INCLUSIVE) ? ">=" : ">"); if (!range.getBegin().isEmpty() && !range.getEnd().isEmpty()) { statement.append(" AND "); } appendScanBound(statement, range.getEnd(), range.getEndBound().equals(Range.Bound.INCLUSIVE) ? "<=" : "<"); }
private Scanner getScanner(Range keyRange) { // the method will always prepend the table name as prefix byte[] begin = convertKeyToBytes(keyRange.getBegin(), true); byte[] end = convertKeyToBytes(keyRange.getEnd(), true); // Table.scan() start key is inclusive by default, and if it is EXCLUSTIVE, we want to ensure the start keys are // not empty so that we do not scan from the start of some other table if (!keyRange.getBegin().isEmpty() && keyRange.getBeginBound() == Range.Bound.EXCLUSIVE) { begin = Bytes.stopKeyForPrefix(begin); } // Table.scan() stop key is exclusive by default, so when the end keys are not specifies, we will need to scan to // the end of table, which will be the default table prefix + 1. if (keyRange.getEnd().isEmpty() || keyRange.getEndBound() == Range.Bound.INCLUSIVE) { end = Bytes.stopKeyForPrefix(end); } return table.scan(begin, end); }