cz.seznam.euphoria.core.client.operator.Union.of()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(154)

本文整理了Java中cz.seznam.euphoria.core.client.operator.Union.of()方法的一些代码示例,展示了Union.of()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Union.of()方法的具体详情如下:
包路径:cz.seznam.euphoria.core.client.operator.Union
类名称:Union
方法名:of

Union.of介绍

[英]Starts building a nameless Union operator to view at least two datasets as one.
[中]开始构建一个无名的联合操作符,以将至少两个数据集视为一个。

代码示例

代码示例来源:origin: seznam/euphoria

/**
 * Starts building a nameless Union operator to view at least two datasets as one.
 *
 * @param <IN> the type of elements in the data sets
 *
 * @param dataSets at least the two data sets
 *
 * @return the next builder to complete the setup of the {@link Union} operator
 *
 * @see #named(String)
 * @see OfBuilder#of(List)
 */
@SafeVarargs
public static <IN> OutputBuilder<IN> of(Dataset<IN>... dataSets) {
 return of(Arrays.asList(dataSets));
}

代码示例来源:origin: seznam/euphoria

/**
 * Starts building a nameless Union operator to view at least two datasets as one.
 *
 * @param <IN> the type of elements in the data sets
 *
 * @param dataSets at least the two data sets
 *
 * @return the next builder to complete the setup of the {@link Union} operator
 *
 * @see #named(String)
 * @see OfBuilder#of(List)
 */
@SafeVarargs
public static <IN> OutputBuilder<IN> of(Dataset<IN>... dataSets) {
 return of(Arrays.asList(dataSets));
}

代码示例来源:origin: seznam/euphoria

public Dataset<T> union(Dataset<T> other) {
 return new Dataset<>(Union.of(this.wrap, other.wrap).output());
}

代码示例来源:origin: seznam/euphoria

@Override
public Dataset<Integer> getOutput(Flow flow, boolean bounded) {
 final Dataset<Integer> first = flow.createInput(ListDataSource.of(bounded,
   Arrays.asList(1, 2, 3),
   Arrays.asList(4, 5, 6)));
 final Dataset<Integer> second = flow.createInput(ListDataSource.of(bounded,
   Arrays.asList(7, 8, 9),
   Arrays.asList(10, 11, 12)));
 return Union.of(first, second).output();
}

代码示例来源:origin: seznam/euphoria

@Override
public Dataset<Integer> getOutput(Flow flow, boolean bounded) {
 final Dataset<Integer> first = flow.createInput(ListDataSource.of(bounded,
   Arrays.asList(1, 2, 3),
   Arrays.asList(4, 5, 6)));
 final Dataset<Integer> second = flow.createInput(ListDataSource.of(bounded,
   Arrays.asList(7, 8, 9),
   Arrays.asList(10, 11, 12)));
 return Union.of(first, second).output();
}

代码示例来源:origin: seznam/euphoria

@Override
public Dataset<Integer> getOutput(Flow flow, boolean bounded) {
 final Dataset<Integer> first = flow.createInput(ListDataSource.of(bounded,
   Arrays.asList(1, 2, 3),
   Arrays.asList(4, 5, 6)));
 final Dataset<Integer> second = flow.createInput(ListDataSource.of(bounded,
   Arrays.asList(7, 8, 9),
   Arrays.asList(10, 11, 12)));
 final Dataset<Integer> third = flow.createInput(ListDataSource.of(bounded,
   Arrays.asList(13, 14, 15),
   Arrays.asList(16, 17, 18)));
 return Union.of(first, second, third).output();
}

代码示例来源:origin: seznam/euphoria

@Override
public Dataset<Integer> getOutput(Flow flow, boolean bounded) {
 final Dataset<Integer> first = flow.createInput(ListDataSource.of(bounded,
   Arrays.asList(1, 2, 3)));
 final Dataset<Integer> second = flow.createInput(ListDataSource.of(bounded,
   Arrays.asList(4, 5, 6),
   Arrays.asList(7, 8, 9)));
 final Dataset<Integer> third = flow.createInput(ListDataSource.of(bounded,
   Arrays.asList(10, 11, 12),
   Arrays.asList(13, 14, 15),
   Arrays.asList(16, 17, 18)));
 return Union.of(first, second, third).output();
}

代码示例来源:origin: seznam/euphoria

@Override
public Dataset<Integer> getOutput(Flow flow, boolean bounded) {
 final Dataset<Integer> first = flow.createInput(ListDataSource.of(bounded,
   Arrays.asList(1, 2, 3)));
 final Dataset<Integer> second = flow.createInput(ListDataSource.of(bounded,
   Arrays.asList(4, 5, 6),
   Arrays.asList(7, 8, 9)));
 final Dataset<Integer> third = flow.createInput(ListDataSource.of(bounded,
   Arrays.asList(10, 11, 12),
   Arrays.asList(13, 14, 15),
   Arrays.asList(16, 17, 18)));
 return Union.of(first, second, third).output();
}

代码示例来源:origin: seznam/euphoria

@Override
public Dataset<Integer> getOutput(Flow flow, boolean bounded) {
 final Dataset<Integer> first = flow.createInput(ListDataSource.of(bounded,
   Arrays.asList(1, 2, 3),
   Arrays.asList(4, 5, 6)));
 final Dataset<Integer> second = flow.createInput(ListDataSource.of(bounded,
   Arrays.asList(7, 8, 9),
   Arrays.asList(10, 11, 12)));
 final Dataset<Integer> third = flow.createInput(ListDataSource.of(bounded,
   Arrays.asList(13, 14, 15),
   Arrays.asList(16, 17, 18)));
 return Union.of(first, second, third).output();
}

代码示例来源:origin: seznam/euphoria

@Override
public Dataset<Integer> getOutput(Flow flow, boolean bounded) {
 final Dataset<Integer> first = flow.createInput(ListDataSource.of(bounded,
   Arrays.asList(1, 2, 3)));
 final Dataset<Integer> second = flow.createInput(ListDataSource.of(bounded,
   Arrays.asList(4, 5, 6)));
 final Dataset<Integer> third = flow.createInput(ListDataSource.of(bounded,
   Arrays.asList(7, 8, 9)));
 final Dataset<Integer> fourth = flow.createInput(ListDataSource.of(bounded,
   Arrays.asList(10, 11, 12)));
 final Dataset<Integer> fifth = flow.createInput(ListDataSource.of(bounded,
   Arrays.asList(13, 14, 15)));
 return Union.of(first, second, third, fourth, fifth).output();
}

代码示例来源:origin: seznam/euphoria

@Override
public Dataset<Integer> getOutput(Flow flow, boolean bounded) {
 final Dataset<Integer> first = flow.createInput(ListDataSource.of(bounded,
   Arrays.asList(1, 2, 3)));
 final Dataset<Integer> second = flow.createInput(ListDataSource.of(bounded,
   Arrays.asList(4, 5, 6)));
 final Dataset<Integer> third = flow.createInput(ListDataSource.of(bounded,
   Arrays.asList(7, 8, 9)));
 final Dataset<Integer> fourth = flow.createInput(ListDataSource.of(bounded,
   Arrays.asList(10, 11, 12)));
 final Dataset<Integer> fifth = flow.createInput(ListDataSource.of(bounded,
   Arrays.asList(13, 14, 15)));
 return Union.of(first, second, third, fourth, fifth).output();
}

代码示例来源:origin: seznam/euphoria

@Test
 public void testBuild_ImplicitName() {
  final Flow flow = Flow.create("TEST");
  final Dataset<String> left = Util.createMockDataset(flow, 2);
  final Dataset<String> right = Util.createMockDataset(flow, 3);

  Union.of(left, right).output();

  final Union union = (Union) flow.operators().iterator().next();
  assertEquals("Union", union.getName());
 }
}

代码示例来源:origin: seznam/euphoria

@Test
public void simpleUnionTest() throws InterruptedException, ExecutionException {
 Dataset<Integer> first = flow.createInput(
   ListDataSource.unbounded(
     Arrays.asList(1),
     Arrays.asList(2, 3, 4, 5, 6)));
 Dataset<Integer> second = flow.createInput(
   ListDataSource.unbounded(
     Arrays.asList(7, 8, 9)));
 // collector of outputs
 ListDataSink<Integer> outputSink = ListDataSink.get();
 Union.of(first, second)
   .output()
   .persist(outputSink);
 executor.submit(flow).get();
 List<Integer> outputs = outputSink.getOutputs();
 DatasetAssert.unorderedEquals(
   outputs,
   1, 2, 3, 4, 5, 6, 7, 8, 9);
}

代码示例来源:origin: seznam/euphoria

@Test
public void testDatasetConsumers() throws Exception {
 Dataset<Object> input = flow.createInput(new MockStreamDataSource<>());
 Dataset<Object> transformed = MapElements.of(input).using(e -> e).output();
 Dataset<Object> transformed2 = Filter.of(transformed).by(e -> false).output();
 Dataset<Object> union = Union.of(transformed, transformed2).output();
 assertEquals(1, input.getConsumers().size());
 assertEquals(2, transformed.getConsumers().size());
 assertEquals(1, transformed2.getConsumers().size());
 assertEquals(0, union.getConsumers().size());
 // the 'transformed' data set is consumed by Filter and Union operators
 assertEquals(toSet(Arrays.asList(Filter.class, Union.class)),
   toSet(transformed.getConsumers().stream().map(Object::getClass)));
}

代码示例来源:origin: seznam/euphoria

@Test(timeout = 5000L)
public void testInputMultiConsumption() throws InterruptedException, ExecutionException {
 final int N = 1000;
 Dataset<Integer> input = flow.createInput(
   ListDataSource.unbounded(sequenceInts(0, N)));
 // there seems to be bug in LocalExecutor
 // that makes it impossible to consume the
 // same dataset twice by single union operator
 Dataset<Integer> first = MapElements.of(input)
   .using(e -> e)
   .output();
 Dataset<Integer> second = MapElements.of(input)
   .using(e -> e)
   .output();
 // ~ consume the input another time
 Dataset<Integer> union = Union.of(first, second)
   .output();
 Dataset<Pair<Integer, Integer>> sum = ReduceByKey
   .of(union)
   .keyBy(e -> 0)
   .valueBy(e -> e)
   .reduceBy(Sums.ofInts())
   .output();
 ListDataSink<Pair<Integer, Integer>> sumOut = ListDataSink.get();
 sum.persist(sumOut);
 executor.submit(flow).get();
 DatasetAssert.unorderedEquals(
   sumOut.getOutputs(),
   Pair.of(0, 2 * (N - 1) * N / 2));
}

相关文章