是否可以使用Nifi将json文件加载到结构化表中?

我调用了以下天气预报数据(来自6000个气象站),目前将它们加载到HDFS中。全部显示在一行上:

{"SiteRep":{"Wx":{"Param":[{"name":"F","units":"C","$":"Feels Like Temperature"},{"name":"G","units":"mph","$":"Wind Gust"},{"name":"H","units":"%","$":"Screen Relative Humidity"},{"name":"T","units":"C","$":"Temperature"},{"name":"V","units":"","$":"Visibility"},{"name":"D","units":"compass","$":"Wind Direction"},{"name":"S","units":"mph","$":"Wind Speed"},{"name":"U","units":"","$":"Max UV Index"},{"name":"W","units":"","$":"Weather Type"},{"name":"Pp","units":"%","$":"Precipitation Probability"}]},"DV":{"dataDate":"2017-01-12T22:00:00Z","type":"Forecast","Location":[{"i":"14","lat":"54.9375","lon":"-2.8092","name":"CARLISLE AIRPORT","country":"ENGLAND","continent":"EUROPE","elevation":"50.0","Period":{"type":"Day","value":"2017-01-13Z","Rep":{"D":"WNW","F":"-3","G":"25","H":"67","Pp":"0","S":"13","T":"2","V":"EX","W":"1","U":"1","$":"720"}}},{"i":"22","lat":"53.5797","lon":"-0.3472","name":"HUMBERSIDE AIRPORT","country":"ENGLAND","continent":"EUROPE","elevation":"24.0","Period":{"type":"Day","value":"2017-01-13Z","Rep":{"D":"NW","F":"-2","G":"43","H":"63","Pp":"3","S":"25","T":"4","V":"EX","W":"3","U":"1","$":"720"}}}, .....

理想情况下,我希望将模式结构化为6000行表。

我曾尝试编写一个将上述内容传递给Pig的模式,但没有成功,可能是因为我对json不够熟悉,无法正确转换它。

为了找到一种向数据添加一些结构的简单方法,我发现Nifi中有一个PutHBaseJson处理器。

谁能建议该PutHBaseJson处理器是否可以使用上述数据结构?如果是这样,谁能指出我一个不错的教程,为我提供有关配置的起点?

非常感谢任何指导。

最佳答案

您可能想使用 SplitJson 处理器将6000条记录的JSON结构拆分为6000个单独的流文件。如果您需要从顶级响应中“注入(inject)”参数定义,则可以执行 ReplaceText JoltTransformJSON 操作来处理单个JSON记录。这是Yolanda Davis的good article,它描述了如何在NiFi中执行Jolt转换(JSON-> JSON)。

一旦具有包含单个JSON记录的单个流文件,将它们放入HBase就非常容易了。 Bryan Bende为PutHBaseJson处理器编写了一个article describing the necessary configurations

09-11 12:30