Closed frdo closed 9 years ago
Astro does not actually use HBase's Bytes utilities which was discovered to be not order-preserving. Please consider using Astro's own utilities in the org.apache.spark.sql.hbase.util package.
Yes, the integer is stored as binary array in HBase. To keep its ordering, for example, -1 and 1, we need to handle it by ourselves, not via HBase Bytes utility.
Thank you. It works now.
Hi @frdo. How exactly did you make it work? We are facing the same problem. Thank you.
I'm sorry to answer you too late. Hope this is still useful. I solved it by encoding the integer value as follow:
import org.apache.spark.sql.hbase.util.BinaryBytesUtils;
import org.apache.spark.sql.types.DataType;
byte[] bytes_value = BinaryBytesUtils.create(DataType.fromCaseClassString("IntegerType")).toBytes(21);
I write an int value (the 21 in this case) into HBase through the HBase's Java API as follow:
Then i read it through the connector as follow:
But i can't figure out why when i try to print it out with the
df_table.show()
function i don't get the 21 instead i get the -2147483627 value.