当前位置: 首页>>代码示例>>Java>>正文


Java ShuffleUtils类代码示例

本文整理汇总了Java中org.htuple.ShuffleUtils的典型用法代码示例。如果您正苦于以下问题:Java ShuffleUtils类的具体用法?Java ShuffleUtils怎么用?Java ShuffleUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ShuffleUtils类属于org.htuple包,在下文中一共展示了ShuffleUtils类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import org.htuple.ShuffleUtils; //导入依赖的package包/类
/**
 * The MapReduce driver - setup and launch the job.
 *
 * @param args the command-line arguments
 * @return the process exit code
 * @throws Exception if something goes wrong
 */
public int run(final String[] args) throws Exception {

  Cli cli = Cli.builder().setArgs(args).addOptions(Options.values()).build();
  int result = cli.runCmd();

  if (result != 0) {
    return result;
  }

  Path usersPath = new Path(cli.getArgValueAsString(Options.USERS));
  Path userLogsPath = new Path(cli.getArgValueAsString(Options.USER_LOGS));
  Path outputPath = new Path(cli.getArgValueAsString(Options.OUTPUT));

  Configuration conf = super.getConf();

  Job job = new Job(conf);
  job.setJarByClass(StreamingRepartitionJoin.class);

  MultipleInputs.addInputPath(job, usersPath, TextInputFormat.class, UserMap.class);
  MultipleInputs.addInputPath(job, userLogsPath, TextInputFormat.class, UserLogMap.class);

  ShuffleUtils.configBuilder()
      .useNewApi()
      .setSortIndices(KeyFields.USER, KeyFields.DATASET)
      .setPartitionerIndices(KeyFields.USER)
      .setGroupIndices(KeyFields.USER)
      .configure(job.getConfiguration());

  job.setReducerClass(Reduce.class);

  job.setMapOutputKeyClass(Tuple.class);
  job.setMapOutputValueClass(Tuple.class);

  FileOutputFormat.setOutputPath(job, outputPath);

  return job.waitForCompletion(true) ? 0 : 1;
}
 
开发者ID:Hanmourang,项目名称:hiped2,代码行数:45,代码来源:StreamingRepartitionJoin.java

示例2: setupSecondarySort

import org.htuple.ShuffleUtils; //导入依赖的package包/类
/**
 * Partition and group on just the last name; sort on both last and first name.
 *
 * @param conf the Hadoop config
 */
public static void setupSecondarySort(Configuration conf) {
    ShuffleUtils.configBuilder()
            .useNewApi()
            .setPartitionerIndices(TupleFields.LAST_NAME)
            .setSortIndices(TupleFields.values())
            .setGroupIndices(TupleFields.LAST_NAME)
            .configure(conf);
}
 
开发者ID:alexholmes,项目名称:htuple,代码行数:14,代码来源:SecondarySort.java

示例3: testDifferentPartitions

import org.htuple.ShuffleUtils; //导入依赖的package包/类
@Test
public void testDifferentPartitions() {

    Tuple t1 = new Tuple();
    Tuple t2 = new Tuple();

    t1.add("alex").add(1).add(3);
    t2.add("alex").add(2).add(2);

    ShuffleUtils.configBuilder().setPartitionerIndices(0).configure(conf);
    TuplePartitioner partitioner = new TuplePartitioner(conf);
    assertEquals(partitioner.getPartition(t1, 10), partitioner.getPartition(t2, 10));

    ShuffleUtils.configBuilder().setPartitionerIndices(1).configure(conf);
    partitioner = new TuplePartitioner(conf);
    assertNotSame(partitioner.getPartition(t1, 10), partitioner.getPartition(t2, 10));

    ShuffleUtils.configBuilder().setPartitionerIndices(2).configure(conf);
    partitioner = new TuplePartitioner(conf);
    assertNotSame(partitioner.getPartition(t1, 10), partitioner.getPartition(t2, 10));

    ShuffleUtils.configBuilder().setPartitionerIndices(0, 1).configure(conf);
    partitioner = new TuplePartitioner(conf);
    assertNotSame(partitioner.getPartition(t1, 10), partitioner.getPartition(t2, 10));

    ShuffleUtils.configBuilder().setPartitionerIndices(0, 2).configure(conf);
    partitioner = new TuplePartitioner(conf);
    assertNotSame(partitioner.getPartition(t1, 10), partitioner.getPartition(t2, 10));
}
 
开发者ID:alexholmes,项目名称:htuple,代码行数:30,代码来源:TuplePartitionerTest.java

示例4: testIndexOutOfBounds

import org.htuple.ShuffleUtils; //导入依赖的package包/类
@Test
public void testIndexOutOfBounds() {

    Tuple t1 = new Tuple();
    Tuple t2 = new Tuple();

    t1.add("alex").add(1).add(3);
    t2.add("alex").add(2).add(2);

    ShuffleUtils.configBuilder().setPartitionerIndices(0, 5).configure(conf);
    TuplePartitioner partitioner = new TuplePartitioner(conf);
    assertEquals(partitioner.getPartition(t1, 10), partitioner.getPartition(t2, 10));
}
 
开发者ID:alexholmes,项目名称:htuple,代码行数:14,代码来源:TuplePartitionerTest.java

示例5: getConfigName

import org.htuple.ShuffleUtils; //导入依赖的package包/类
@Override
public String getConfigName() {
    return ShuffleUtils.SORTING_INDEXES_CONFIG_NAME;
}
 
开发者ID:alexholmes,项目名称:htuple,代码行数:5,代码来源:SortTupleComparatorTest.java

示例6: setComparatorIndices

import org.htuple.ShuffleUtils; //导入依赖的package包/类
@Override
public void setComparatorIndices(Configuration conf, int... indices) {
    ShuffleUtils.configBuilder().setSortIndices(indices).configure(conf);
}
 
开发者ID:alexholmes,项目名称:htuple,代码行数:5,代码来源:SortTupleComparatorTest.java

示例7: getConfigName

import org.htuple.ShuffleUtils; //导入依赖的package包/类
@Override
public String getConfigName() {
    return ShuffleUtils.GROUPING_INDEXES_CONFIG_NAME;
}
 
开发者ID:alexholmes,项目名称:htuple,代码行数:5,代码来源:GroupingTupleComparatorTest.java

示例8: setComparatorIndices

import org.htuple.ShuffleUtils; //导入依赖的package包/类
@Override
public void setComparatorIndices(Configuration conf, int... indices) {
    ShuffleUtils.configBuilder().setGroupIndices(indices).configure(conf);
}
 
开发者ID:alexholmes,项目名称:htuple,代码行数:5,代码来源:GroupingTupleComparatorTest.java

示例9: testEmptyConfig

import org.htuple.ShuffleUtils; //导入依赖的package包/类
@Test(expected = IllegalStateException.class)
public void testEmptyConfig() {
    conf.setStrings(ShuffleUtils.PARTITIONER_INDEXES_CONFIG_NAME, "");
    new TuplePartitioner(conf);
}
 
开发者ID:alexholmes,项目名称:htuple,代码行数:6,代码来源:TuplePartitionerTest.java


注:本文中的org.htuple.ShuffleUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。