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