當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。