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


Java FlatMapFunction.call方法代码示例

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


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

示例1: morphlineMapper

import org.apache.spark.api.java.function.FlatMapFunction; //导入方法依赖的package包/类
@Test
public void morphlineMapper(
    final @Mocked MorphlineUtils.Pipeline pipeline,
    final @Mocked Row row,
    final @Mocked StructType schema
) throws Exception {

  new Expectations(MorphlineUtils.class) {{
    MorphlineUtils.getPipeline("file", "id"); result = pipeline; times = 1;
    MorphlineUtils.executePipeline(pipeline, (Record) any); result = Lists.newArrayList(); times = 1;
    row.schema(); result = schema;
    row.get(anyInt); returns("val1", "val2"); times = 2;
    schema.fieldNames(); result = new String[] { "one", "two"};
  }};

  FlatMapFunction<Row, Row> function = MorphlineUtils.morphlineMapper("file", "id", schema);
  Iterator<Row> results = function.call(row);

  assertEquals("Invalid number of Rows returned", 0, Lists.newArrayList(results).size());

  new Verifications() {{
    Record record;
    MorphlineUtils.executePipeline(pipeline, record = withCapture());
    assertEquals(2, record.getFields().size());
    assertEquals("val1", record.get("one").get(0));
  }};
}
 
开发者ID:cloudera-labs,项目名称:envelope,代码行数:28,代码来源:TestMorphlineUtils.java

示例2: morphlineMapperNoPipeline

import org.apache.spark.api.java.function.FlatMapFunction; //导入方法依赖的package包/类
@Test
public void morphlineMapperNoPipeline(
    final @Mocked MorphlineUtils.Pipeline pipeline,
    final @Mocked Row row,
    final @Mocked StructType schema
) throws Exception {

  new Expectations(MorphlineUtils.class) {{
    MorphlineUtils.getPipeline("file", "id"); result = null; times = 1;
    MorphlineUtils.setPipeline("file", "id", (MorphlineUtils.Collector) any, true); result = pipeline; times = 1;
    MorphlineUtils.executePipeline(pipeline, (Record) any); result = Lists.newArrayList(); times = 1;
    row.schema(); result = schema;
    row.get(anyInt); returns("val1", "val2"); times = 2;
    schema.fieldNames(); result = new String[] { "one", "two"};
  }};

  FlatMapFunction<Row, Row> function = MorphlineUtils.morphlineMapper("file", "id", schema);
  Iterator<Row> results = function.call(row);

  assertEquals("Invalid number of Rows returned", 0, Lists.newArrayList(results).size());

  new Verifications() {{
    Record record;
    MorphlineUtils.executePipeline(pipeline, record = withCapture());
    assertEquals(2, record.getFields().size());
    assertEquals("val1", record.get("one").get(0));
  }};
}
 
开发者ID:cloudera-labs,项目名称:envelope,代码行数:29,代码来源:TestMorphlineUtils.java

示例3: morphlineMapperNoSchema

import org.apache.spark.api.java.function.FlatMapFunction; //导入方法依赖的package包/类
@Test (expected = RuntimeException.class)
public void morphlineMapperNoSchema(
    final @Mocked MorphlineUtils.Pipeline pipeline,
    final @Mocked Row row,
    final @Mocked StructType schema
) throws Exception {

  new Expectations(MorphlineUtils.class) {{
    MorphlineUtils.getPipeline("file", "id"); result = pipeline; times = 1;
    row.schema(); result = null;
  }};

  FlatMapFunction<Row, Row> function = MorphlineUtils.morphlineMapper("file", "id", schema);
  function.call(row);
}
 
开发者ID:cloudera-labs,项目名称:envelope,代码行数:16,代码来源:TestMorphlineUtils.java

示例4: call

import org.apache.spark.api.java.function.FlatMapFunction; //导入方法依赖的package包/类
@Override
public Iterable<R> call(T t) throws Exception {
	FlatMapFunction<T, R> function = SpringContext.getContext(springConfigurationClass).getBean(springBeanClass);
	return function.call(t);
}
 
开发者ID:politie,项目名称:cinch,代码行数:6,代码来源:SpringFlatMapFunction.java


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