Java – HBase: the filter is not applicable to negative integers
We have successfully implemented hifier's qualifierfilter and valuefilter (using binarycomparator), and they work normally in most cases However, they failed in the case of number > and so on- 10 or the number < - 10 please note that the number = - 10 works normally In addition, the numbers > 10 and < 10 also work properly If you want to view the code, please see the following link:
According to this blog, if we want to store negative values for rowkeys, this may be a serialization problem. We should write our own serializer for comparison So we want to know: 1 Is it really necessary to write your own serializer in this case? If so, what? Any example will be of great help
Solution
Because HBase has only binary comparators and not other "type" comparators, negative integers cannot be filtered because it stores 2.5% of negative numbers In addition, the binary representation of negative 2 Complement integers will be arranged in dictionary order after the maximum positive number, which is why it does not work
The solution is to change the signed bit of the number It works normally afterwards Note that this applies only to integers and not floating point types