【问题标题】:Outputting a Scalding TypedPipe to a SequenceFile in multiple directories based on one of the fields根据字段之一将 Scalding TypedPipe 输出到多个目录中的 SequenceFile
【发布时间】:2015-05-10 10:08:07
【问题描述】:

我在 Hadoop 上使用 Scalding,我有一个 TypedPipe 形式的大型数据集,我希望根据其中一个数据字段分块输出。

例如数据是<category, field1, field2>,我希望将每个类别的数据存储在一个单独的类别中的 SequenceFile 中,例如outPath/cat1outPath/cat2 等。我想要一个 MapReduce 阶段(或避免循环)。

我在此处阅读了有关 TemplatedTsv 选项的信息: How to bucket outputs in Scalding

这里: How to output data with Hive-style directory structure in Scalding?

但这仅在您需要 Tsv 文件而不是 SequenceFile 时才有效。

显然循环有效:

var category = 0L

for (category <- categories) {
    data
    .filter(_.category == category)
    .map(t => (NullWritable.get, new BytesWritable(SerializationUtils.serialize(t))))
    .write(WritableSequenceFile(outPath + "/" + category))
}

那么是否有与TemplateTsv 等效的方法可以编写一个序列文件,避免循环?

【问题讨论】:

    标签: hadoop cascading scalding sequencefile


    【解决方案1】:

    com.twitter.scalding.TemplatedSequenceFile 可以满足您的需求。它看起来就像 TemplateTsv,但输出到 SequenceFile

    【讨论】:

      猜你喜欢
      • 2015-12-18
      • 2015-12-07
      • 1970-01-01
      • 2015-04-25
      • 2023-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多