【问题标题】:Multiple table input for mapreducemapreduce 的多表输入
【发布时间】:2017-06-26 08:41:24
【问题描述】:

我正在考虑使用累加表作为输入进行 mapreduce。
有没有办法将 2 个不同的表作为输入,就像 addInputPath 这样的多个文件输入存在的方式相同?
或者是否可以从文件中获取一个输入,而从带有AccumuloInputFormat 的表中获取另一个输入?

【问题讨论】:

    标签: hadoop mapreduce accumulo


    【解决方案1】:

    您可能想看看AccumuloMultiTableInputFormat。 Accumulo 手册演示了如何使用它here

    示例用法:

    job.setInputFormat(AccumuloInputFormat.class);
    
    AccumuloMultiTableInputFormat.setConnectorInfo(job, user, new PasswordToken(pass));
    AccumuloMultiTableInputFormat.setMockInstance(job, INSTANCE_NAME);
    
    InputTableConfig tableConfig1 = new InputTableConfig();
    InputTableConfig tableConfig2 = new InputTableConfig();
    
    Map<String, InputTableConfig> configMap = new HashMap<String, InputTableConfig>();
    configMap.put(table1, tableConfig1);
    configMap.put(table2, tableConfig2);
    
    AccumuloMultiTableInputFormat.setInputTableConfigs(job, configMap);
    

    有关更多信息,请参阅 AccumuloMultiTableInputFormat here 的单元测试。

    请注意,与正常的多个输入不同,您不能指定不同的映射器在每个表上运行。虽然在这种情况下它不是一个大问题,因为传入的键/值类型是相同的,您可以使用:

    RangeInputSplit split = (RangeInputSplit)c.getInputSplit();
    String tableName = split.getTableName();
    

    在映射器中确定记录来自哪个表(取自 Accumulo 手册)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-25
      • 2011-10-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多