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


Java MemPipeline.typedTableOf方法代码示例

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


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

示例1: testPercentilesExact

import org.apache.crunch.impl.mem.MemPipeline; //导入方法依赖的package包/类
@Test
public void testPercentilesExact() {
  PTable<String, Integer> testTable = MemPipeline.typedTableOf(
          tableOf(strings(), ints()),
          "a", 5,
          "a", 2,
          "a", 3,
          "a", 4,
          "a", 1);
  Map<String, Result<Integer>> actualS = Percentiles.distributed(testTable, 0, 0.5, 1.0).materializeToMap();
  Map<String, Result<Integer>> actualM = Percentiles.inMemory(testTable, 0, 0.5, 1.0).materializeToMap();
  Map<String, Result<Integer>> expected = ImmutableMap.of(
          "a", result(5, Pair.of(0.0, 1), Pair.of(0.5, 3), Pair.of(1.0, 5))
  );

  assertEquals(expected, actualS);
  assertEquals(expected, actualM);
}
 
开发者ID:spotify,项目名称:crunch-lib,代码行数:19,代码来源:PercentilesTest.java

示例2: testPercentilesBetween

import org.apache.crunch.impl.mem.MemPipeline; //导入方法依赖的package包/类
@Test
public void testPercentilesBetween() {
  PTable<String, Integer> testTable = MemPipeline.typedTableOf(
          tableOf(strings(), ints()),
          "a", 5,
          "a", 2, // We expect the 0.5 to correspond to this element, according to the "nearest rank" %ile definition.
          "a", 4,
          "a", 1);
  Map<String, Result<Integer>> actualS = Percentiles.distributed(testTable, 0.5).materializeToMap();
  Map<String, Result<Integer>> actualM = Percentiles.inMemory(testTable, 0.5).materializeToMap();
  Map<String, Result<Integer>> expected = ImmutableMap.of(
          "a", result(4, Pair.of(0.5, 2))
  );

  assertEquals(expected, actualS);
  assertEquals(expected, actualM);
}
 
开发者ID:spotify,项目名称:crunch-lib,代码行数:18,代码来源:PercentilesTest.java

示例3: testPercentilesNines

import org.apache.crunch.impl.mem.MemPipeline; //导入方法依赖的package包/类
@Test
public void testPercentilesNines() {
  PTable<String, Integer> testTable = MemPipeline.typedTableOf(
          tableOf(strings(), ints()),
          "a", 10,
          "a", 20,
          "a", 30,
          "a", 40,
          "a", 50,
          "a", 60,
          "a", 70,
          "a", 80,
          "a", 90,
          "a", 100);
  Map<String, Result<Integer>> actualS = Percentiles.distributed(testTable, 0.9, 0.99).materializeToMap();
  Map<String, Result<Integer>> actualM = Percentiles.inMemory(testTable, 0.9, 0.99).materializeToMap();
  Map<String, Result<Integer>> expected = ImmutableMap.of(
          "a", result(10, Pair.of(0.9, 90), Pair.of(0.99, 100))
  );

  assertEquals(expected, actualS);
  assertEquals(expected, actualM);
}
 
开发者ID:spotify,项目名称:crunch-lib,代码行数:24,代码来源:PercentilesTest.java

示例4: testPercentilesLessThanOrEqual

import org.apache.crunch.impl.mem.MemPipeline; //导入方法依赖的package包/类
@Test
public void testPercentilesLessThanOrEqual() {
  PTable<String, Integer> testTable = MemPipeline.typedTableOf(
          tableOf(strings(), ints()),
          "a", 10,
          "a", 20,
          "a", 30,
          "a", 40,
          "a", 50,
          "a", 60,
          "a", 70,
          "a", 80,
          "a", 90,
          "a", 100);
  Map<String, Result<Integer>> actualS = Percentiles.distributed(testTable, 0.5).materializeToMap();
  Map<String, Result<Integer>> actualM = Percentiles.inMemory(testTable, 0.5).materializeToMap();
  Map<String, Result<Integer>> expected = ImmutableMap.of(
          "a", result(10, Pair.of(0.5, 50))
  );

  assertEquals(expected, actualS);
  assertEquals(expected, actualM);
}
 
开发者ID:spotify,项目名称:crunch-lib,代码行数:24,代码来源:PercentilesTest.java

示例5: testMeanValue

import org.apache.crunch.impl.mem.MemPipeline; //导入方法依赖的package包/类
@Test
public void testMeanValue() {
  PTable<String, Integer> testTable = MemPipeline.typedTableOf(
          tableOf(strings(), ints()),
          "a", 2,
          "a", 10,
          "b", 3,
          "c", 3,
          "c", 4,
          "c", 5);
  Map<String, Double> actual = Averages.meanValue(testTable).materializeToMap();
  Map<String, Double> expected = ImmutableMap.of(
          "a", 6.0,
          "b", 3.0,
          "c", 4.0
  );

  assertEquals(expected, actual);
}
 
开发者ID:spotify,项目名称:crunch-lib,代码行数:20,代码来源:AveragesTest.java

示例6: testTopNYbyX

import org.apache.crunch.impl.mem.MemPipeline; //导入方法依赖的package包/类
@Test
public void testTopNYbyX() {
  PTable<String, String> data = MemPipeline.typedTableOf(tableOf(strings(), strings()),
          "a","x",
          "a","x",
          "a","x",
          "a","y",
          "a","y",
          "a","z",
          "b","x",
          "b","x",
          "b","z");
  Map<String, Collection<Pair<Long, String>>> actual = TopLists.topNYbyX(data, 2).materializeToMap();
  Map<String, Collection<Pair<Long, String>>> expected = ImmutableMap.of(
          "a", collectionOf(Pair.of(3L, "x"), Pair.of(2L, "y")),
          "b", collectionOf(Pair.of(2L, "x"), Pair.of(1L, "z")));

  assertEquals(expected, actual);
}
 
开发者ID:spotify,项目名称:crunch-lib,代码行数:20,代码来源:TopListsTest.java

示例7: testSwapKeyValue

import org.apache.crunch.impl.mem.MemPipeline; //导入方法依赖的package包/类
@Test
public void testSwapKeyValue() {
  PTable<String, Long> table = MemPipeline.typedTableOf(tableOf(strings(), longs()), "hello", 14L, "goodbye", 21L);
  PTable<Long, String> actual = SPTables.swapKeyValue(table);
  Map<Long, String> expected = ImmutableMap.of(14L, "hello", 21L, "goodbye");
  assertEquals(expected, actual.materializeToMap());
}
 
开发者ID:spotify,项目名称:crunch-lib,代码行数:8,代码来源:SPTablesTest.java


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