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


Java DataSet.union方法代码示例

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


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

示例1: testSupportForDataAndEnumSerialization

import org.apache.flink.api.java.DataSet; //导入方法依赖的package包/类
@Test
public void testSupportForDataAndEnumSerialization() throws Exception {
	/**
	 * Test support for Date and enum serialization
	 */
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	DataSet<PojoWithDateAndEnum> ds = env.generateSequence(0,2).map(new Mapper1());
	ds = ds.union(CollectionDataSets.getPojoWithDateAndEnum(env));

	DataSet<String> res = ds.groupBy("group").reduceGroup(new GroupReducer1());

	List<String> result = res.collect();

	String expected = "ok\nok";

	compareResultAsText(result, expected);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:18,代码来源:ReduceITCase.java

示例2: testUnion2IdenticalDataSets

import org.apache.flink.api.java.DataSet; //导入方法依赖的package包/类
@Test
public void testUnion2IdenticalDataSets() throws Exception {
	/*
	 * Union of 2 Same Data Sets
	 */
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<Tuple3<Integer, Long, String>> ds = CollectionDataSets.get3TupleDataSet(env);
	DataSet<Tuple3<Integer, Long, String>> unionDs = ds.union(CollectionDataSets.get3TupleDataSet(env));

	List<Tuple3<Integer, Long, String>> result = unionDs.collect();

	String expected = FULL_TUPLE_3_STRING + FULL_TUPLE_3_STRING;

	compareResultAsTuples(result, expected);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:17,代码来源:UnionITCase.java

示例3: testSupportForDataAndEnumSerialization

import org.apache.flink.api.java.DataSet; //导入方法依赖的package包/类
@Test
public void testSupportForDataAndEnumSerialization() throws Exception {
	/**
	 * Test support for Date and enum serialization
	 */
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	DataSet<PojoWithDateAndEnum> ds = env.generateSequence(0, 2).map(new Mapper1());
	ds = ds.union(CollectionDataSets.getPojoWithDateAndEnum(env));

	DataSet<String> res = ds.groupBy("group").reduceGroup(new GroupReducer1());

	List<String> result = res.collect();

	String expected = "ok\nok";

	compareResultAsText(result, expected);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:18,代码来源:ReduceITCase.java

示例4: testUnionReplacement

import org.apache.flink.api.java.DataSet; //导入方法依赖的package包/类
@Test
public void testUnionReplacement() {
	try {
		ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
		DataSet<String> input1 = env.fromElements("test1");
		DataSet<String> input2 = env.fromElements("test2");

		DataSet<String> union = input1.union(input2);

		union.output(new DiscardingOutputFormat<String>());
		union.output(new DiscardingOutputFormat<String>());

		Plan plan = env.createProgramPlan();
		OptimizedPlan oPlan = compileNoStats(plan);
		JobGraphGenerator jobGen = new JobGraphGenerator();
		jobGen.compileJobGraph(oPlan);
	}
	catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:23,代码来源:UnionReplacementTest.java

示例5: translateNode

import org.apache.flink.api.java.DataSet; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void translateNode(
    PTransform<PCollectionList<T>, PCollection<T>> transform,
    FlinkBatchTranslationContext context) {

  Map<TupleTag<?>, PValue> allInputs = context.getInputs(transform);
  DataSet<WindowedValue<T>> result = null;

  if (allInputs.isEmpty()) {

    // create an empty dummy source to satisfy downstream operations
    // we cannot create an empty source in Flink, therefore we have to
    // add the flatMap that simply never forwards the single element
    DataSource<String> dummySource =
        context.getExecutionEnvironment().fromElements("dummy");
    result = dummySource.flatMap(new FlatMapFunction<String, WindowedValue<T>>() {
      @Override
      public void flatMap(String s, Collector<WindowedValue<T>> collector) throws Exception {
        // never return anything
      }
    }).returns(
        new CoderTypeInformation<>(
            WindowedValue.getFullCoder(
                (Coder<T>) VoidCoder.of(),
                GlobalWindow.Coder.INSTANCE)));
  } else {
    for (PValue taggedPc : allInputs.values()) {
      checkArgument(
          taggedPc instanceof PCollection,
          "Got non-PCollection input to flatten: %s of type %s",
          taggedPc,
          taggedPc.getClass().getSimpleName());
      PCollection<T> collection = (PCollection<T>) taggedPc;
      DataSet<WindowedValue<T>> current = context.getInputDataSet(collection);
      if (result == null) {
        result = current;
      } else {
        result = result.union(current);
      }
    }
  }

  // insert a dummy filter, there seems to be a bug in Flink
  // that produces duplicate elements after the union in some cases
  // if we don't
  result = result.filter(new FilterFunction<WindowedValue<T>>() {
    @Override
    public boolean filter(WindowedValue<T> tWindowedValue) throws Exception {
      return true;
    }
  }).name("UnionFixFilter");
  context.setOutputDataSet(context.getOutput(transform), result);
}
 
开发者ID:apache,项目名称:beam,代码行数:55,代码来源:FlinkBatchTransformTranslators.java


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