本文整理汇总了Java中org.apache.beam.sdk.transforms.Combine.BinaryCombineIntegerFn方法的典型用法代码示例。如果您正苦于以下问题:Java Combine.BinaryCombineIntegerFn方法的具体用法?Java Combine.BinaryCombineIntegerFn怎么用?Java Combine.BinaryCombineIntegerFn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.beam.sdk.transforms.Combine
的用法示例。
在下文中一共展示了Combine.BinaryCombineIntegerFn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCombiningValueEquality
import org.apache.beam.sdk.transforms.Combine; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
@Test
public void testCombiningValueEquality() {
Combine.BinaryCombineIntegerFn maxFn = Max.ofIntegers();
Coder<Integer> input1 = VarIntCoder.of();
Coder<Integer> input2 = BigEndianIntegerCoder.of();
Combine.BinaryCombineIntegerFn minFn = Min.ofIntegers();
StateTag<?> fooCoder1Max1 = StateTags.combiningValueFromInputInternal("foo", input1, maxFn);
StateTag<?> fooCoder1Max2 = StateTags.combiningValueFromInputInternal("foo", input1, maxFn);
StateTag<?> fooCoder1Min = StateTags.combiningValueFromInputInternal("foo", input1, minFn);
StateTag<?> fooCoder2Max = StateTags.combiningValueFromInputInternal("foo", input2, maxFn);
StateTag<?> barCoder1Max = StateTags.combiningValueFromInputInternal("bar", input1, maxFn);
// Same name, coder and combineFn
assertEquals(fooCoder1Max1, fooCoder1Max2);
assertEquals(
StateTags.convertToBagTagInternal((StateTag) fooCoder1Max1),
StateTags.convertToBagTagInternal((StateTag) fooCoder1Max2));
// Different combineFn, but we treat them as equal since we only serialize the bits.
assertEquals(fooCoder1Max1, fooCoder1Min);
assertEquals(
StateTags.convertToBagTagInternal((StateTag) fooCoder1Max1),
StateTags.convertToBagTagInternal((StateTag) fooCoder1Min));
// Different input coder coder.
assertNotEquals(fooCoder1Max1, fooCoder2Max);
assertNotEquals(
StateTags.convertToBagTagInternal((StateTag) fooCoder1Max1),
StateTags.convertToBagTagInternal((StateTag) fooCoder2Max));
// These StateTags have different IDs.
assertNotEquals(fooCoder1Max1, barCoder1Max);
assertNotEquals(
StateTags.convertToBagTagInternal((StateTag) fooCoder1Max1),
StateTags.convertToBagTagInternal((StateTag) barCoder1Max));
}
示例2: testCombiningValueWithContextEquality
import org.apache.beam.sdk.transforms.Combine; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
@Test
public void testCombiningValueWithContextEquality() {
CoderRegistry registry = CoderRegistry.createDefault();
Combine.BinaryCombineIntegerFn maxFn = Max.ofIntegers();
Combine.BinaryCombineIntegerFn minFn = Min.ofIntegers();
Coder<int[]> accum1 = maxFn.getAccumulatorCoder(registry, VarIntCoder.of());
Coder<int[]> accum2 = minFn.getAccumulatorCoder(registry, BigEndianIntegerCoder.of());
StateTag<?> fooCoder1Max1 = StateTags.combiningValueWithContext(
"foo", accum1, CombineFnUtil.toFnWithContext(maxFn));
StateTag<?> fooCoder1Max2 = StateTags.combiningValueWithContext(
"foo", accum1, CombineFnUtil.toFnWithContext(maxFn));
StateTag<?> fooCoder1Min = StateTags.combiningValueWithContext(
"foo", accum1, CombineFnUtil.toFnWithContext(minFn));
StateTag<?> fooCoder2Max = StateTags.combiningValueWithContext(
"foo", accum2, CombineFnUtil.toFnWithContext(maxFn));
StateTag<?> barCoder1Max = StateTags.combiningValueWithContext(
"bar", accum1, CombineFnUtil.toFnWithContext(maxFn));
// Same name, coder and combineFn
assertEquals(fooCoder1Max1, fooCoder1Max2);
assertEquals(
StateTags.convertToBagTagInternal((StateTag) fooCoder1Max1),
StateTags.convertToBagTagInternal((StateTag) fooCoder1Max2));
// Different combineFn, but we treat them as equal since we only serialize the bits.
assertEquals(fooCoder1Max1, fooCoder1Min);
assertEquals(
StateTags.convertToBagTagInternal((StateTag) fooCoder1Max1),
StateTags.convertToBagTagInternal((StateTag) fooCoder1Min));
// Different input coder coder.
assertNotEquals(fooCoder1Max1, fooCoder2Max);
assertNotEquals(
StateTags.convertToBagTagInternal((StateTag) fooCoder1Max1),
StateTags.convertToBagTagInternal((StateTag) fooCoder2Max));
// These StateTags have different IDs.
assertNotEquals(fooCoder1Max1, barCoder1Max);
assertNotEquals(
StateTags.convertToBagTagInternal((StateTag) fooCoder1Max1),
StateTags.convertToBagTagInternal((StateTag) barCoder1Max));
}