本文整理汇总了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));
}