use of org.apache.samza.operators.StreamGraphImpl in project samza by apache.
the class TestExecutionPlanner method createStreamGraphWithJoinAndWindow.
private StreamGraphImpl createStreamGraphWithJoinAndWindow() {
StreamGraphImpl streamGraph = new StreamGraphImpl(runner, config);
BiFunction msgBuilder = mock(BiFunction.class);
MessageStream m1 = streamGraph.getInputStream("input1", msgBuilder).map(m -> m);
MessageStream m2 = streamGraph.getInputStream("input2", msgBuilder).partitionBy(m -> "haha").filter(m -> true);
MessageStream m3 = streamGraph.getInputStream("input3", msgBuilder).filter(m -> true).partitionBy(m -> "hehe").map(m -> m);
Function mockFn = mock(Function.class);
OutputStream<Object, Object, Object> output1 = streamGraph.getOutputStream("output1", mockFn, mockFn);
OutputStream<Object, Object, Object> output2 = streamGraph.getOutputStream("output2", mockFn, mockFn);
m1.map(m -> m).filter(m -> true).window(Windows.<Object, Object>keyedTumblingWindow(m -> m, Duration.ofMillis(8)));
m2.map(m -> m).filter(m -> true).window(Windows.<Object, Object>keyedTumblingWindow(m -> m, Duration.ofMillis(16)));
m1.join(m2, mock(JoinFunction.class), Duration.ofMillis(1600)).sendTo(output1);
m3.join(m2, mock(JoinFunction.class), Duration.ofMillis(100)).sendTo(output2);
m3.join(m2, mock(JoinFunction.class), Duration.ofMillis(252)).sendTo(output2);
return streamGraph;
}
use of org.apache.samza.operators.StreamGraphImpl in project samza by apache.
the class TestOperatorSpecs method testCreatePartialJoinOperator.
@Test
public void testCreatePartialJoinOperator() {
PartialJoinFunction<String, TestMessageEnvelope, TestMessageEnvelope, TestOutputMessageEnvelope> thisPartialJoinFn = mock(PartialJoinFunction.class);
PartialJoinFunction<String, TestMessageEnvelope, TestMessageEnvelope, TestOutputMessageEnvelope> otherPartialJoinFn = mock(PartialJoinFunction.class);
StreamGraphImpl mockGraph = mock(StreamGraphImpl.class);
MessageStreamImpl<TestOutputMessageEnvelope> joinOutput = TestMessageStreamImplUtil.getMessageStreamImpl(mockGraph);
PartialJoinOperatorSpec<String, TestMessageEnvelope, TestMessageEnvelope, TestOutputMessageEnvelope> partialJoinSpec = OperatorSpecs.createPartialJoinOperatorSpec(thisPartialJoinFn, otherPartialJoinFn, 1000 * 60, joinOutput, 1);
assertEquals(partialJoinSpec.getNextStream(), joinOutput);
assertEquals(partialJoinSpec.getThisPartialJoinFn(), thisPartialJoinFn);
assertEquals(partialJoinSpec.getOtherPartialJoinFn(), otherPartialJoinFn);
}
Aggregations