APIS involved in this article:
Hadoop/HDFS: http://hadoop.apache.org/common/docs/current/api/
HBase: http://hbase.apache.org/apidocs/index.html? Overview-summary.html
Begin!
When setting the startRowKey and endRowKey of scan, you often need to add a range after a condition string. (For example, SingleColumnValueFilter will also be used)
For example, if my condition string is "abc", You need to include the following content in the scan range.
Abc123
Abcdabc
Abccca
....
At this time, startRowKey can use "abc". The above string is larger than "abc" in the Lexicographic Order, and the value after the "abc" string is 0 ~
While endRowKey initially used "abc ~", Because when I check the ASCII code table '~ 'Is the second-to-last character. The value is 127, which is large enough and must be greater than 1, d, c, and other characters in the above string.
In this way, it is enough to process the English data and the system runs normally.
However, when I process Chinese data, Chinese is generally processed in the UTF-8 format, a Chinese character is expressed like "0xe6, 0xc2, 0xe1 ". 0xe6 must be greater than 127. So use '~ 'The Chinese character must be miserable.
My solution:
Use UltraEdit to enter the hexadecimal editing mode and change the value to FF. Then return to the text mode and copy the character. This character should be a non-printable character. It looks like the length of two spaces.
Then, when you set the endRowKey
New String (name + ""); // here is just an example. The quotation marks are the copied character. Use this string as the endRowKey, and all Chinese characters are included.
Note: Do not use str when using HBase APIs. getBytes converts String to byte [], instead of Bytes. toBytes (str); also use Bytes. toString (bytes); completes reverse conversion.