2017-06-02 276 views
0

当我尝试通过scala程序将具有一列的Row键放入Hbase表时,我在输出文件(Hbase表)中看到了这种32位表示。这完全阻止了我的工作。Hbase表填充了scala代码中值= x00 x00 x00 x00 x00 x00 x00 x00 x00

请告知我们如何才能在Hbase表中获得'Double'类型字段的正确表示。

与此相关的代码如下:我在这里丢失了什么?

VarValue_Output: Double 
p(3).toDouble 
final val colVarValueBytes = Bytes.toBytes("VarValue_Output") 
put.add(cfDataBytes, colVarValueBytes, Bytes.toBytes(Data.VarValue_Output) 

感谢 维贾雅·库马尔Pabothu

回答

0

它的预期行为。 您已经保存了Double数据类型,但HBase shell(我假设您使用它)不知道任何事情(HBase中的所有内容均表示为字节数组)。因此,在默认情况下它试图从你的字节数组中提取字符串,明显显示的Unicode符号的一些无信息的列表:

Bytes.toBytes("15.0")不等于Bytes.toBytes(15.0)

  1. 尝试将其保存为字符串转换为字节数组(你就可以在底座壳阅读)
  2. 从您的应用程序读取它,并确保你改变你的列值Bytes.toDouble
+0

请参阅下面我的代码,请告诉我在哪里DOI恩错了。 (日期和时间) –

+0

def convertToPut(sensor:Sensor):(ImmutableBytesWritable,Put)= { val dateTime = sensor.TimeStamp_Output val rowkey = sensor.ToolName_Output +“_”+ dateTime val put = new Put(Bytes.toBytes(rowkey)) put.add(cfDataBytes,colLookupBytes,Bytes.toBytes(sensor.Lookup)) \t put.add(cfDataBytes,colVarNameBytes,Bytes.toBytes(sensor.VarName_Output)) put.add(cfDataBytes,colVarValueBytes,Bytes.toBytes( sensor.VarValue_Output)) 回报(新ImmutableBytesWritable(Bytes.toBytes(rowkey)),放) } –

+0

定义 - 最终VAL colVarValueBytes = Bytes.toBytes( “VarValue_Output”) –

相关问题