本文整理了Java中org.apache.beam.sdk.transforms.Filter.greaterThan()
方法的一些代码示例,展示了Filter.greaterThan()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Filter.greaterThan()
方法的具体详情如下:
包路径:org.apache.beam.sdk.transforms.Filter
类名称:Filter
方法名:greaterThan
[英]Returns a PTransform that takes an input PCollection and returns a PCollection with elements that are greater than a given value, based on the elements' natural ordering. Elements must be Comparable.
Example of use:
PCollection listOfNumbers = ...;
See also #greaterThanEq, #lessThan, #equal and #lessThanEq, which return elements satisfying various inequalities with the specified value based on the elements' natural ordering.
See also #by, which returns elements that satisfy the given predicate.
[中]返回一个PTransform,该PTransform接受一个输入PCollection,并根据元素的自然顺序返回一个包含大于给定值的元素的PCollection。要素必须具有可比性。
使用示例:
PCollection listOfNumbers = ...;
另请参见#greaterThanEq、#lessThan、#equal和#lessThanEq,它们根据元素的自然顺序返回满足各种不等式的元素,并返回指定值。
另请参见#by,它返回满足给定谓词的元素。
代码示例来源:origin: org.apache.beam/beam-sdks-java-core
@Test
public void testDisplayData() {
assertThat(DisplayData.from(Filter.lessThan(123)), hasDisplayItem("predicate", "x < 123"));
assertThat(DisplayData.from(Filter.lessThanEq(234)), hasDisplayItem("predicate", "x ≤ 234"));
assertThat(DisplayData.from(Filter.greaterThan(345)), hasDisplayItem("predicate", "x > 345"));
assertThat(DisplayData.from(Filter.greaterThanEq(456)), hasDisplayItem("predicate", "x ≥ 456"));
assertThat(DisplayData.from(Filter.equal(567)), hasDisplayItem("predicate", "x == 567"));
}
代码示例来源:origin: org.apache.beam/beam-sdks-java-core
@Test
@Category(NeedsRunner.class)
public void testFilterGreaterThan() {
PCollection<Integer> output =
p.apply(Create.of(1, 2, 3, 4, 5, 6, 7)).apply(Filter.greaterThan(4));
PAssert.that(output).containsInAnyOrder(5, 6, 7);
p.run();
}
代码示例来源:origin: org.apache.beam/beam-runners-direct-java
@Before
public void setup() {
createdInts = p.apply("createdInts", Create.of(1, 2, 3));
filtered = createdInts.apply("filtered", Filter.greaterThan(1));
filteredTimesTwo =
filtered.apply(
"timesTwo",
ParDo.of(
new DoFn<Integer, Integer>() {
@ProcessElement
public void processElement(ProcessContext c) throws Exception {
c.output(c.element() * 2);
}
}));
keyed = createdInts.apply("keyed", WithKeys.of("MyKey"));
intsToFlatten = p.apply("intsToFlatten", Create.of(-1, 256, 65535));
PCollectionList<Integer> preFlatten = PCollectionList.of(createdInts).and(intsToFlatten);
flattened = preFlatten.apply("flattened", Flatten.pCollections());
clock = MockClock.fromInstant(new Instant(1000));
DirectGraphs.performDirectOverrides(p);
graph = DirectGraphs.getGraph(p);
manager = WatermarkManager.create(clock, graph, AppliedPTransform::getFullName);
bundleFactory = ImmutableListBundleFactory.create();
}
内容来源于网络,如有侵权,请联系作者删除!