19455 Simplify conflate signature for the common case
This commit is contained in:
parent
c36fdb111c
commit
3081e2895b
21 changed files with 281 additions and 55 deletions
|
|
@ -60,7 +60,7 @@ public class RateTransformationDocTest {
|
|||
//#conflate-summarize
|
||||
final Flow<Double, Tuple3<Double, Double, Integer>, NotUsed> statsFlow =
|
||||
Flow.of(Double.class)
|
||||
.conflate(elem -> Collections.singletonList(elem), (acc, elem) -> {
|
||||
.conflateWithSeed(elem -> Collections.singletonList(elem), (acc, elem) -> {
|
||||
return Stream
|
||||
.concat(acc.stream(), Collections.singletonList(elem).stream())
|
||||
.collect(Collectors.toList());
|
||||
|
|
@ -86,7 +86,7 @@ public class RateTransformationDocTest {
|
|||
//#conflate-sample
|
||||
final Double p = 0.01;
|
||||
final Flow<Double, Double, NotUsed> sampleFlow = Flow.of(Double.class)
|
||||
.conflate(elem -> Collections.singletonList(elem), (acc, elem) -> {
|
||||
.conflateWithSeed(elem -> Collections.singletonList(elem), (acc, elem) -> {
|
||||
if (r.nextDouble() < p) {
|
||||
return Stream
|
||||
.concat(acc.stream(), Collections.singletonList(elem).stream())
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ public class StreamBuffersRateDocTest {
|
|||
final Source<String, Cancellable> tickSource =
|
||||
Source.tick(oneSecond.mul(3), oneSecond.mul(3), "tick");
|
||||
final Flow<String, Integer, NotUsed> conflate =
|
||||
Flow.of(String.class).conflate(
|
||||
Flow.of(String.class).conflateWithSeed(
|
||||
first -> 1, (count, elem) -> count + 1);
|
||||
|
||||
RunnableGraph.fromGraph(GraphDSL.create(b -> {
|
||||
|
|
|
|||
|
|
@ -58,11 +58,11 @@ public class RecipeMissedTicks extends RecipeTest {
|
|||
@SuppressWarnings("unused")
|
||||
//#missed-ticks
|
||||
final Flow<Tick, Integer, NotUsed> missedTicks =
|
||||
Flow.of(Tick.class).conflate(tick -> 0, (missed, tick) -> missed + 1);
|
||||
Flow.of(Tick.class).conflateWithSeed(tick -> 0, (missed, tick) -> missed + 1);
|
||||
//#missed-ticks
|
||||
final TestLatch latch = new TestLatch(3, system);
|
||||
final Flow<Tick, Integer, NotUsed> realMissedTicks =
|
||||
Flow.of(Tick.class).conflate(tick -> 0, (missed, tick) -> { latch.countDown(); return missed + 1; });
|
||||
Flow.of(Tick.class).conflateWithSeed(tick -> 0, (missed, tick) -> { latch.countDown(); return missed + 1; });
|
||||
|
||||
Pair<TestPublisher.Probe<Tick>, TestSubscriber.Probe<Integer>> pubSub =
|
||||
tickStream.via(realMissedTicks).toMat(sink, Keep.both()).run(mat);
|
||||
|
|
|
|||
|
|
@ -46,11 +46,11 @@ public class RecipeSimpleDrop extends RecipeTest {
|
|||
@SuppressWarnings("unused")
|
||||
//#simple-drop
|
||||
final Flow<Message, Message, NotUsed> droppyStream =
|
||||
Flow.of(Message.class).conflate(i -> i, (lastMessage, newMessage) -> newMessage);
|
||||
Flow.of(Message.class).conflate((lastMessage, newMessage) -> newMessage);
|
||||
//#simple-drop
|
||||
final TestLatch latch = new TestLatch(2, system);
|
||||
final Flow<Message, Message, NotUsed> realDroppyStream =
|
||||
Flow.of(Message.class).conflate(i -> i, (lastMessage, newMessage) -> { latch.countDown(); return newMessage; });
|
||||
Flow.of(Message.class).conflate((lastMessage, newMessage) -> { latch.countDown(); return newMessage; });
|
||||
|
||||
final Pair<TestPublisher.Probe<Message>, TestSubscriber.Probe<Message>> pubSub = TestSource
|
||||
.<Message> probe(system)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue