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