Search code examples
javapythonhbasegoogle-cloud-dataproc

Can't get stored python integer back in java in habase google cloud


I'm using hbase over google cloud bigtable to store my bigdata. I have 2 programs. first, store data using python into hbase and the second, read those info back from java by connecting to the same endpoint.

so from python interactive shell I can read byte arrays back into an integer (command 15)

In [13]: row.cells['stat']['viewability'][0].value 
Out[13]: '\x00\x00\x00\x00\x00\x00\x00A'

In [14]: len(row.cells['stat']['viewability'][0].value) 
Out[14]: 8

In [15]: struct.unpack('>Q', row.cells['stat']['viewability'][0].value) 
Out[15]: (65,)

but I can't read back the same byte array into java Integer data type
I'm using the following in java

byte[] columnFamilyBytes = Bytes.toBytes("stat");
byte[] viewabilityColumnBytes = Bytes.toBytes("viewability");
Integer viewability = Bytes.toInt(c1.getValue(columnFamilyBytes, viewabilityColumnBytes));

and I'm getting NULL in response.


Solution

  • I found the problem
    the column stored as long value so I had to first read it as long in java and then convert it to int