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


Java ExportSnapshot.getBalancedSplits方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.snapshot.ExportSnapshot.getBalancedSplits方法的典型用法代码示例。如果您正苦于以下问题:Java ExportSnapshot.getBalancedSplits方法的具体用法?Java ExportSnapshot.getBalancedSplits怎么用?Java ExportSnapshot.getBalancedSplits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.snapshot.ExportSnapshot的用法示例。


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

示例1: testBalanceSplit

import org.apache.hadoop.hbase.snapshot.ExportSnapshot; //导入方法依赖的package包/类
/**
 * Verfy the result of getBalanceSplits() method.
 * The result are groups of files, used as input list for the "export" mappers.
 * All the groups should have similar amount of data.
 *
 * The input list is a pair of file path and length.
 * The getBalanceSplits() function sort it by length,
 * and assign to each group a file, going back and forth through the groups.
 */
@Test
public void testBalanceSplit() throws Exception {
  // Create a list of files
  List<Pair<Path, Long>> files = new ArrayList<Pair<Path, Long>>();
  for (long i = 0; i <= 20; i++) {
    files.add(new Pair<Path, Long>(new Path("file-" + i), i));
  }

  // Create 5 groups (total size 210)
  //    group 0: 20, 11, 10,  1 (total size: 42)
  //    group 1: 19, 12,  9,  2 (total size: 42)
  //    group 2: 18, 13,  8,  3 (total size: 42)
  //    group 3: 17, 12,  7,  4 (total size: 42)
  //    group 4: 16, 11,  6,  5 (total size: 42)
  List<List<Path>> splits = ExportSnapshot.getBalancedSplits(files, 5);
  assertEquals(5, splits.size());
  assertEquals(Arrays.asList(new Path("file-20"), new Path("file-11"),
    new Path("file-10"), new Path("file-1"), new Path("file-0")), splits.get(0));
  assertEquals(Arrays.asList(new Path("file-19"), new Path("file-12"),
    new Path("file-9"), new Path("file-2")), splits.get(1));
  assertEquals(Arrays.asList(new Path("file-18"), new Path("file-13"),
    new Path("file-8"), new Path("file-3")), splits.get(2));
  assertEquals(Arrays.asList(new Path("file-17"), new Path("file-14"),
    new Path("file-7"), new Path("file-4")), splits.get(3));
  assertEquals(Arrays.asList(new Path("file-16"), new Path("file-15"),
    new Path("file-6"), new Path("file-5")), splits.get(4));
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:37,代码来源:TestExportSnapshot.java


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