写出可以从Elephant Bird的ProtobufPigLoader读取的数据

dme*_*ter 5 hadoop apache-pig elephantbird

对于我的一个项目,我想分析大约2 TB的Protobuf对象.我想通过"大象鸟"库在Pig脚本中使用这些对象.但是,我不清楚如何将文件写入HDFS,以便ProtobufPigLoader类可以使用它.

这就是我所拥有的:

猪脚本:

  register ../fs-c/lib/*.jar // this includes the elephant bird library
  register ../fs-c/*.jar    
  raw_data = load 'hdfs://XXX/fsc-data2/XXX*' using com.twitter.elephantbird.pig.load.ProtobufPigLoader('de.pc2.dedup.fschunk.pig.PigProtocol.File');
Run Code Online (Sandbox Code Playgroud)

导入工具(部分):

def getWriter(filenamePath: Path) : ProtobufBlockWriter[de.pc2.dedup.fschunk.pig.PigProtocol.File] = {
  val conf = new Configuration()
  val fs = FileSystem.get(filenamePath.toUri(), conf)
  val os = fs.create(filenamePath, true)
  val writer = new ProtobufBlockWriter[de.pc2.dedup.fschunk.pig.PigProtocol.File](os, classOf[de.pc2.dedup.fschunk.pig.PigProtocol.File])
  return writer
}
val writer = getWriter(new Path(filename))
val builder = de.pc2.dedup.fschunk.pig.PigProtocol.File.newBuilder()
writer.write(builder.build)
writer.finish()
writer.close()
Run Code Online (Sandbox Code Playgroud)

导入工具运行正常.我有一些ProtobufPigLoader的问题因为我不能使用hadoop-lzo压缩库,并且没有修复(见这里)ProtobufPigLoader不起作用.我遇到问题的问题是DUMP raw_data;退货Unable to open iterator for alias raw_dataILLUSTRATE raw_data;退货No (valid) input data found!.

对我来说,看起来ProtobufPigLoader无法读取ProtobufBlockWriter数据.但是要用什么呢?如何将外部工具中的数据写入HDFS,以便ProtobufPigLoader可以处理它.

替代问题:用什么代替?如何将相当大的对象写入Hadoop以使用Pig?对象不是很复杂,但在列表中包含大量子对象(Protobuf中的重复字段).

  • 我想避免任何文本格式或JSON,因为它们只是对我的数据来说很大.我希望它会使数据膨胀2或3倍(很多整数,很多字节字符串,我需要编码为Base64).
  • 我想避免使主对象的ID被附加到每个子对象的标准化数据(这是做现在),因为这也打击了空间占用,使在以后的处理加入必要的.

更新:

  • 我没有使用protobuf加载器类的生成,但使用反射类型加载器
  • protobuf类位于已注册的jar中.DESCRIBE正确显示类型.