@Override @SuppressWarnings("unchecked") protected BufferEntrySerializer<T> createOuterSerializerWithNestedSerializers(TypeSerializer<?>[] nestedSerializers) { return new BufferEntrySerializer<>((TypeSerializer<T>) nestedSerializers[0]); }
@Override public TypeSerializerSnapshot<BufferEntry<T>> snapshotConfiguration() { return new BufferEntrySerializerSnapshot<>(this); } }
@Override public BufferEntry<T> copy(BufferEntry<T> from) { return new BufferEntry<>(from.element, from.hasBeenJoined); }
@Test public void testNegativeExclusiveAndNegativeExlusive() throws Exception { setupHarness(-3, false, -1, false) .processElementsAndWatermarks(1, 4) .andExpect( streamRecordOf(3, 1), streamRecordOf(4, 2) ) .noLateRecords() .close(); }
@Test(expected = FlinkException.class) public void testFailsWithNoTimestampsLeft() throws Exception { TestHarness newTestHarness = createTestHarness(0L, true, 0L, true); newTestHarness.setup(); newTestHarness.open(); // note that the StreamRecord has no timestamp in constructor newTestHarness.processElement1(new StreamRecord<>(new TestElem(0, "lhs"))); }
@Test(expected = FlinkException.class) public void testFailsWithNoTimestampsRight() throws Exception { try (TestHarness newTestHarness = createTestHarness(0L, true, 0L, true)) { newTestHarness.setup(); newTestHarness.open(); // note that the StreamRecord has no timestamp in constructor newTestHarness.processElement2(new StreamRecord<>(new TestElem(0, "rhs"))); } }
@Override public TypeSerializerSchemaCompatibility<BufferEntry<T>> resolveSchemaCompatibility(TypeSerializer<BufferEntry<T>> newSerializer) { return CompositeTypeSerializerUtil.delegateCompatibilityCheckToNewSnapshot( newSerializer, new BufferEntrySerializerSnapshot<>(), getSingleNestedSerializerAndConfig().f1); } }
/** * Process a {@link StreamRecord} from the left stream. Whenever an {@link StreamRecord} * arrives at the left stream, it will get added to the left buffer. Possible join candidates * for that element will be looked up from the right buffer and if the pair lies within the * user defined boundaries, it gets passed to the {@link ProcessJoinFunction}. * * @param record An incoming record to be joined * @throws Exception Can throw an Exception during state access */ @Override public void processElement1(StreamRecord<T1> record) throws Exception { processElement(record, leftBuffer, rightBuffer, lowerBound, upperBound, true); }
@Override public BufferEntry<T> deserialize(BufferEntry<T> reuse, DataInputView source) throws IOException { return deserialize(source); }
@Override public BufferEntry<T> copy(BufferEntry<T> from, BufferEntry<T> reuse) { return copy(from); }
@SuppressWarnings({"unused", "WeakerAccess"}) public BufferEntrySerializerSnapshot() { super(correspondingSerializerClass()); }
private static <KEY, IN1, IN2, OUT> TwoInputStreamOperatorTestHarness<IN1, IN2, OUT> getInitializedTestHarness( final TypeInformation<KEY> keyTypeInfo, final KeySelector<IN1, KEY> keyKeySelector, final KeyedBroadcastProcessFunction<KEY, IN1, IN2, OUT> function) throws Exception { return getInitializedTestHarness( keyTypeInfo, keyKeySelector, function, 1, 1, 0); }
private static <IN1, IN2, OUT> TwoInputStreamOperatorTestHarness<IN1, IN2, OUT> getInitializedTestHarness( final BroadcastProcessFunction<IN1, IN2, OUT> function, final MapStateDescriptor<?, ?>... descriptors) throws Exception { return getInitializedTestHarness( function, 1, 1, 0, descriptors); }
public JoinTestBuilder processElement2(int ts) throws Exception { testHarness.processElement2(createStreamRecord(ts, "rhs")); return this; }
public void close() throws Exception { testHarness.close(); } }
public JoinTestBuilder processElement1(int ts) throws Exception { testHarness.processElement1(createStreamRecord(ts, "lhs")); return this; }
@Test public void testNegativeExclusiveAndPositiveExlusive() throws Exception { setupHarness(-1, false, 1, false) .processElementsAndWatermarks(1, 4) .andExpect( streamRecordOf(1, 1), streamRecordOf(2, 2), streamRecordOf(3, 3), streamRecordOf(4, 4) ) .noLateRecords() .close(); }
/** * Process a {@link StreamRecord} from the right stream. Whenever a {@link StreamRecord} * arrives at the right stream, it will get added to the right buffer. Possible join candidates * for that element will be looked up from the left buffer and if the pair lies within the user * defined boundaries, it gets passed to the {@link ProcessJoinFunction}. * * @param record An incoming record to be joined * @throws Exception Can throw an exception during state access */ @Override public void processElement2(StreamRecord<T2> record) throws Exception { processElement(record, rightBuffer, leftBuffer, -upperBound, -lowerBound, false); }
@Test public void testPositiveExclusiveAndPositiveExlusive() throws Exception { setupHarness(1, false, 3, false) .processElementsAndWatermarks(1, 4) .andExpect( streamRecordOf(1, 3), streamRecordOf(2, 4) ) .noLateRecords() .close(); }