Section 5.7.3 of the HBase book displays a scan operation:

HTable htable = ...      // instantiate HTable

Scan scan = new Scan();
scan.addColumn(Bytes.toBytes("cf"),Bytes.toBytes("attr"));
scan.setStartRow( Bytes.toBytes("row"));
scan.setStopRow( Bytes.toBytes("row" +  new byte[] {0}));  // note: stop key != 
start key
for(Result result : htable.getScanner(scan)) {
  // process Result instance
}


Can someone explain why the stop key is "row" plus an empty byte? The example says it should return all rows that start with "row" however wouldn't this only return a row with the exact row key of "row"?

"row" < "row\000" => true
"row\000" < "row1" => false

Shouldn't the example be "row" + new byte[] {255}?

"row1" < "row\255" => true

Can someone please clarify?


Reply via email to