问题描述
我试图使用HBase REST API调用将值插入到Hbase表中。下面是我使用的curl命令。
I'm trying to insert values into a Hbase table using the HBase REST API call.. Below is the curl command i'm using..
curl -v -XPUT 'http://localhost:8080/emp/1/pers:name' -H "Accept: application/json" -H "Content-Type: application/json" --data '{ "Row": [ { "Cell": [ { "column": "cGVyczpuYW1lCg==", "$": "TXlOYW1lCg==" } ], "key": "MQo=" } ] }'
呼叫工作正常,我得到一个HTTP / 1.1 200 OK Hbase表,而不是更新行1中的值,调用创建一个新行1 \x0A,并插入具有相同垃圾字符的新值。
The call works fine and I get a "HTTP/1.1 200 OK" .. But when i see the Hbase table, instead of updating the value in Row "1", the call creates a new row "1\x0A" and inserts the new value with the same junk characters..
1\x0A column=pers:name\x0A, timestamp=1437596697507, value=MyName\x0A
任何人看到这样的东西?提前感谢。
Anyone seen something like this? Thanks in advance..
推荐答案
好的,我排序了。
\x0A是转义的十六进制Line Feed 。相当于\\\
..
当我们使用base64编码时,需要将\\\
转义字符考虑在内。因此,当我们对rowkey,column和value进行base64编码时,我们需要传递一个-n。 。
Ok i sorted this out..\x0A is the escaped hexadecimal Line Feed. The equivalent of \n..When we base64 encode, it takes the \n escape character into account.. so we need to pass a " -n " when we base64 encode the rowkey, column and value..
例如:
echo -n MyName | base64
TXlOYW1l
echo MyName | base64
TXlOYW1lCg==
两者之间有区别..我的问题..
There is a difference between the two.. and thats what caused my problem..
这篇关于Hbase REST调用 - 获取垃圾字符“ \ x0A“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!