Improve generation of task descriptions for deeply nested structures
Closed this issue · 1 comments
jodzga commented
Here is an example that shows the problem:
package com.linkedin.parseq.example.simple;
import static com.linkedin.parseq.example.common.ExampleUtil.printTracingResults;
import java.util.concurrent.ThreadLocalRandom;
import com.linkedin.parseq.Engine;
import com.linkedin.parseq.Task;
import com.linkedin.parseq.example.common.AbstractExample;
public class NestedFlatMap extends AbstractExample {
public static void main(String[] args) throws Exception {
new NestedFlatMap().runExample();
}
@Override
protected void doRunExample(final Engine engine) throws Exception {
Task<String> task1 = Task.value("x");
Task<String> task2 = Task.value("y");
Task<?> task = Task.par(task1, task2).flatMap((t1, t2) -> {
if (2 < ThreadLocalRandom.current().nextDouble())
return Task.value("a");
else
return Task.value("b").flatMap(x -> {
if (2 < ThreadLocalRandom.current().nextDouble())
return Task.value("c");
else
return Task.value("d");
});
});
engine.run(task);
task.await();
printTracingResults(task);
}
}
Above program generates the following trace:
{"planId":5,"planClass":"com.linkedin.parseq.Task$1","traces":[{"id":0,"name":"value","resultType":"SUCCESS","hidden":false,"systemHidden":false,"startNanos":7866896119553,"pendingNanos":7866896134176,"endNanos":7866896137271,"taskType":"fusion"},{"id":1,"name":"value","resultType":"SUCCESS","hidden":false,"systemHidden":false,"startNanos":7866892366208,"pendingNanos":7866895918666,"endNanos":7866895954020,"taskType":"fusion"},{"id":2,"name":"par2","resultType":"SUCCESS","hidden":false,"systemHidden":false,"startNanos":7866889586253,"pendingNanos":7866892353402,"endNanos":7866896162677},{"id":3,"name":"async fused","resultType":"SUCCESS","hidden":false,"systemHidden":true,"startNanos":7866882949082,"pendingNanos":7866889564548,"endNanos":7866900766575,"taskType":"fusion"},{"id":4,"name":"flatMap: doRunExample(NestedFlatMap:23)","resultType":"SUCCESS","hidden":false,"systemHidden":false,"startNanos":7866875885363,"pendingNanos":7866882266050,"endNanos":7866904960272,"taskType":"flatten"},{"id":1000,"name":"flatMap: doRunExample(NestedFlatMap:23)","resultType":"SUCCESS","hidden":false,"systemHidden":true,"startNanos":7866898291297,"pendingNanos":7866900740409,"endNanos":7866900745536},{"id":1001,"name":"value","resultType":"SUCCESS","hidden":false,"systemHidden":false,"startNanos":7866901608010,"pendingNanos":7866904075956,"endNanos":7866904091911,"taskType":"fusion"},{"id":1002,"name":"fused","resultType":"SUCCESS","hidden":false,"systemHidden":true,"startNanos":7866900900638,"pendingNanos":7866904836592,"endNanos":7866904841609,"taskType":"fusion"},{"id":1003,"name":"flatMap: accept(PromiseTransformer:27)","resultType":"SUCCESS","hidden":false,"systemHidden":false,"startNanos":7866900867101,"pendingNanos":7866900891546,"endNanos":7866904942087,"taskType":"flatten"},{"id":1004,"name":"flatMap: accept(PromiseTransformer:27)","resultType":"SUCCESS","hidden":false,"systemHidden":true,"startNanos":7866904765071,"pendingNanos":7866904811345,"endNanos":7866904811345},{"id":1005,"name":"value","resultType":"SUCCESS","hidden":false,"systemHidden":false,"startNanos":7866904894938,"pendingNanos":7866904928449,"endNanos":7866904931534,"taskType":"fusion"}],"relationships":[{"relationship":"PARENT_OF","from":3,"to":1000},{"relationship":"PARENT_OF","from":1003,"to":1005},{"relationship":"PARENT_OF","from":1002,"to":1004},{"relationship":"PARENT_OF","from":4,"to":3},{"relationship":"SUCCESSOR_OF","from":1003,"to":3},{"relationship":"SUCCESSOR_OF","from":1000,"to":2},{"relationship":"PARENT_OF","from":4,"to":1003},{"relationship":"SUCCESSOR_OF","from":1004,"to":1001},{"relationship":"PARENT_OF","from":2,"to":1},{"relationship":"PARENT_OF","from":2,"to":0},{"relationship":"PARENT_OF","from":3,"to":2},{"relationship":"PARENT_OF","from":1003,"to":1002},{"relationship":"PARENT_OF","from":1002,"to":1001},{"relationship":"SUCCESSOR_OF","from":1005,"to":1002}]}
Deeply nested flatMap has description: "flatMap: accept(PromiseTransformer:33)". Ideally it should say: "flatMap: doRunExample(FlatMap:33)".
jodzga commented
Fixed in 2.6.22.