byte[0] is an empty array (so it's nothing) whereas the latter is a byte of value 0. This gets appended to the end of your last key. Appending nothing means it's the same key.
J-D On Tue, Aug 16, 2011 at 10:39 AM, Mark <[email protected]> wrote: > Thanks for info however I'm confused on byte[0] vs byte[] {0}. Would you > mind explaining why the former doesn't work as expected. > > On 8/16/11 10:28 AM, Jean-Daniel Cryans wrote: >> >> I guess the POSTFIX would be defined like this in your class: >> >> private static final byte[] POSTFIX = new byte[] {0}; >> >> This is very different from something like: >> >> new byte[0]; >> >> Which wouldn't add anything and lastRow would be returned. >> >> Then you use the code you pasted. >> >> J-D >> >> On Tue, Aug 16, 2011 at 8:40 AM, Mark<[email protected]> wrote: >>> >>> I'm reading the HBase book at >>> http://ofps.oreilly.com/titles/9781449396107/clientapisadv.html and I >>> have a >>> question regarding pagination. >>> >>> byte[] startRow = Bytes.add(lastRow, POSTFIX); >>> >>> >>> "Since the lexicographical sorting of the row keys by HBase and the >>> comparison taking care of finding the row keys in order, and the fact >>> that >>> the start key on a scan in always inclusive, you need to add an extra >>> zero >>> byte to the previous key. This will ensure that the last seen row key is >>> skipped and the next, in sorting order, is found. The zero byte is the >>> smallest increment and therefore safe to use when resetting the scan >>> boundaries. Even if there were a row that would match the previous plus >>> the >>> extra zero byte the scan would be correctly doing the next iteration - >>> this >>> is because the start key is inclusive." >>> >>> What should be used as POSTFIX... ie how does one add a zero byte to an >>> existing key? >>> >>> Thanks >>> >
