尝试将 JSON 与 HBASE 的 REST 网关一起使用时出现反序列化错误

Deserialization error when trying to use JSON with HBASE's REST gateway

我正在尝试使用 hbase rest API。我在这里阅读了文档 (http://wiki.apache.org/hadoop/Hbase/Stargate), but they seem to be incomplete (doesn't cover json) and out of date.

我也 运行 跨越 this gist,这主要是我要去的地方。

这是我要发送的(插入)请求:

和 json 有效负载(其中键、列和 $ 都是 base64 编码值):

{
    "Row": {

        "key": "NjQ=",
        "Cell": [{
            "column": "NjQ=",
            "$": "NjQ="
        }]
    }
}

这是我得到的错误:

Error 500 Can not deserialize instance of java.util.List out of START_OBJECT token
 at [Source: org.mortbay.jetty.HttpParser$Input@3da0b822; line: 2, column: 5]
 (through reference chain: org.apache.hadoop.hbase.rest.model.CellSetModel["Row"])

该错误似乎表明有些东西应该是数组,但不是。我试过把方括号放在几乎所有地方,但除了稍微改变错误消息的性质外,我无法让它做任何事情。

我查看了 source code,这似乎表明我的方括号位置是正确的。但是,据我所知,整个请求看起来是正确的。不过,我对 Java 不是很流利,所以也许我遗漏了一些东西。

使用 hbase rest 网关插入记录的正确 JSON 语法是什么?

现在这是正确的格式:

{
    "Row": [{

        "key": "NjQ=",
        "Cell": [{
            "column": "NjQ=",
            "$": "NjQ="
        }]
    }]
}

其中:

  • key - 是行键
  • column - 是列名
  • $ - 是您存储在给定 table、列和行中的数据。