/** * Scan records by rowkey range from a table */ public RowIterator scan(String table, byte[] startRow, boolean inclusiveStart, byte[] stopRow, boolean inclusiveStop) { assert !this.hasChanges(); Scan scan = new Scan().withStartRow(startRow, inclusiveStart); if (stopRow != null) { String version = VersionInfo.getVersion(); if (inclusiveStop && !VersionUtil.gte(version, "2.0")) { // The parameter stoprow-inclusive doesn't work before v2.0 // https://issues.apache.org/jira/browse/HBASE-20675 inclusiveStop = false; // Add a trailing 0 byte to stopRow stopRow = Arrays.copyOf(stopRow, stopRow.length + 1); } if (Bytes.equals(startRow, stopRow) && inclusiveStart && !inclusiveStop) { // Bug https://issues.apache.org/jira/browse/HBASE-21618 return new RowIterator(); } scan.withStopRow(stopRow, inclusiveStop); } return this.scan(table, scan); }
private void seek() { if (this.keyBegin == null) { // Seek to the first if no `keyBegin` this.itor.seekToFirst(); } else { /* * Seek to `keyBegin`: * if set SCAN_GT_BEGIN/SCAN_GTE_BEGIN (key > / >= 'xx') * or if set SCAN_PREFIX_WITH_BEGIN (key prefix with 'xx') */ this.itor.seek(this.keyBegin); // Skip `keyBegin` if set SCAN_GT_BEGIN (key > 'xx') if (this.match(Session.SCAN_GT_BEGIN) && !this.match(Session.SCAN_GTE_BEGIN)) { while (this.itor.isValid() && Bytes.equals(this.itor.key(), this.keyBegin)) { this.itor.next(); } } } }
private void seek() { if (this.keyBegin == null) { // Seek to the first if no `keyBegin` this.itor.seekToFirst(); } else { /* * Seek to `keyBegin`: * if set SCAN_GT_BEGIN/SCAN_GTE_BEGIN (key > / >= 'xx') * or if set SCAN_PREFIX_WITH_BEGIN (key prefix with 'xx') */ this.itor.seek(this.keyBegin); // Skip `keyBegin` if set SCAN_GT_BEGIN (key > 'xx') if (this.match(Session.SCAN_GT_BEGIN) && !this.match(Session.SCAN_GTE_BEGIN)) { while (this.hasNext() && !Bytes.equals(this.itor.key(), this.keyBegin)) { this.next(); } } } }