无法将 python 整数存储回 habase google 云中的 java
Can't get stored python integer back in java in habase google cloud
我在 google 云大表上使用 hbase 来存储我的大数据。我有 2 个程序。首先,使用 python 将数据存储到 hbase 中,其次,通过连接到同一端点从 java 读取这些信息。
所以从 python 交互式 shell 我可以将字节数组读回整数(命令 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,)
但我无法将相同的字节数组读回 java 整数数据类型
我在 java
中使用以下内容
byte[] columnFamilyBytes = Bytes.toBytes("stat");
byte[] viewabilityColumnBytes = Bytes.toBytes("viewability");
Integer viewability = Bytes.toInt(c1.getValue(columnFamilyBytes, viewabilityColumnBytes));
我的响应为 NULL。
我发现了问题
该列存储为 long 值,所以我必须首先在 java 中读取它,然后将其转换为 int
我在 google 云大表上使用 hbase 来存储我的大数据。我有 2 个程序。首先,使用 python 将数据存储到 hbase 中,其次,通过连接到同一端点从 java 读取这些信息。
所以从 python 交互式 shell 我可以将字节数组读回整数(命令 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,)
但我无法将相同的字节数组读回 java 整数数据类型
我在 java
byte[] columnFamilyBytes = Bytes.toBytes("stat");
byte[] viewabilityColumnBytes = Bytes.toBytes("viewability");
Integer viewability = Bytes.toInt(c1.getValue(columnFamilyBytes, viewabilityColumnBytes));
我的响应为 NULL。
我发现了问题
该列存储为 long 值,所以我必须首先在 java 中读取它,然后将其转换为 int