Search in sources :

Example 6 with LeanNode

use of com.insightfullogic.honest_profiler.core.profiles.lean.LeanNode in project honest-profiler by jvm-profiling-tools.

the class AncestorTreeAggregator method addAncestors.

/**
 * Recursive method for aggregating the parents (and ancestors) of the {@link LeanNode}s which are aggregated by the
 * provided {@link Node} and adding them as children.
 * <p>
 * @param source the original {@link AggregationProfile}
 * @param child the input {@link Node} whose ancestors will be aggregated and added as children
 * @param tree the resulting {@link Tree}
 * @param grouping the key calculation grouping
 */
private void addAncestors(AggregationProfile source, Node child, Tree tree, CombinedGrouping grouping) {
    Map<String, Node> result = child.getAggregatedNodes().stream().map(node -> node.getParent()).filter(node -> node != null).distinct().collect(groupingBy(// Group LeanNodes by calculated key
    node -> grouping.apply(source, node), // Downstream collector, aggregates LeanNodes in a single group
    of(// Supplier, creates an empty Node
    () -> {
        Node node = new Node(tree);
        // Set the reference by default for all nodes to the global aggregation.
        node.setReference(source.getGlobalData());
        return node;
    }, // Accumulator, aggregates a LeanNode into the Entry accumulator
    (node, leanNode) -> {
        node.add(leanNode);
        node.setKey(grouping.apply(source, leanNode));
    }, // Combiner, combines two Nodes with the same key
    (node1, node2) -> node1.combine(node2))));
    // Add the aggregated parents as children to the Node, and recurse
    result.entrySet().forEach(mapEntry -> {
        // The "child" Node in the ancestor Tree has its parents (the values of the calculated map) as children.
        child.addChild(mapEntry.getValue());
        // Recursively add ancestors
        addAncestors(source, mapEntry.getValue(), tree, grouping);
    });
}
Also used : CombinedGrouping(com.insightfullogic.honest_profiler.core.aggregation.grouping.CombinedGrouping) LeanNode(com.insightfullogic.honest_profiler.core.profiles.lean.LeanNode) Tree(com.insightfullogic.honest_profiler.core.aggregation.result.straight.Tree) Map(java.util.Map) Aggregation(com.insightfullogic.honest_profiler.core.aggregation.result.Aggregation) Keyed(com.insightfullogic.honest_profiler.core.aggregation.result.Keyed) Entry(com.insightfullogic.honest_profiler.core.aggregation.result.straight.Entry) Node(com.insightfullogic.honest_profiler.core.aggregation.result.straight.Node) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) AggregationProfile(com.insightfullogic.honest_profiler.core.aggregation.AggregationProfile) Collector.of(java.util.stream.Collector.of) LeanNode(com.insightfullogic.honest_profiler.core.profiles.lean.LeanNode) Node(com.insightfullogic.honest_profiler.core.aggregation.result.straight.Node)

Example 7 with LeanNode

use of com.insightfullogic.honest_profiler.core.profiles.lean.LeanNode in project honest-profiler by jvm-profiling-tools.

the class Node method addChild.

/**
 * Aggregates a {@link LeanNode} into the children of this Node, using the specified {@link CombinedGrouping} to
 * determine the aggregation key, and recursively aggregating the {@link LeanNode} descendants as well if specified.
 * <p>
 * @param child the {@link LeanNode} to be aggregated into the children of this Node
 * @param grouping the {@link CombinedGrouping} used for determining the aggregation key
 * @param recurse a boolean specifying whether the {@link LeanNode} descendants should be aggregated recursively
 */
public void addChild(LeanNode child, CombinedGrouping grouping, boolean recurse) {
    // Construct intermediate Node
    Node childNode = new Node(getAggregation());
    childNode.add(child);
    childNode.setKey(grouping.apply(getAggregation().getSource(), child));
    // Aggregate it into existing children
    Node newChild = addChild(childNode);
    if (recurse) {
        child.getChildren().forEach(grandChild -> newChild.addChild(grandChild, grouping, true));
    }
}
Also used : LeanNode(com.insightfullogic.honest_profiler.core.profiles.lean.LeanNode)

Aggregations

LeanNode (com.insightfullogic.honest_profiler.core.profiles.lean.LeanNode)7 AggregationProfile (com.insightfullogic.honest_profiler.core.aggregation.AggregationProfile)4 CombinedGrouping (com.insightfullogic.honest_profiler.core.aggregation.grouping.CombinedGrouping)4 LeanProfile (com.insightfullogic.honest_profiler.core.profiles.lean.LeanProfile)4 Map (java.util.Map)4 Collector.of (java.util.stream.Collector.of)4 Collectors.groupingBy (java.util.stream.Collectors.groupingBy)4 Entry (com.insightfullogic.honest_profiler.core.aggregation.result.straight.Entry)3 Node (com.insightfullogic.honest_profiler.core.aggregation.result.straight.Node)3 Tree (com.insightfullogic.honest_profiler.core.aggregation.result.straight.Tree)3 Aggregation (com.insightfullogic.honest_profiler.core.aggregation.result.Aggregation)2 Keyed (com.insightfullogic.honest_profiler.core.aggregation.result.Keyed)2 Method (com.insightfullogic.honest_profiler.core.parser.Method)2 StackFrame (com.insightfullogic.honest_profiler.core.parser.StackFrame)2 ThreadMeta (com.insightfullogic.honest_profiler.core.parser.ThreadMeta)2 FrameInfo (com.insightfullogic.honest_profiler.core.profiles.lean.info.FrameInfo)2 MethodInfo (com.insightfullogic.honest_profiler.core.profiles.lean.info.MethodInfo)2 NumericInfo (com.insightfullogic.honest_profiler.core.profiles.lean.info.NumericInfo)2 ThreadInfo (com.insightfullogic.honest_profiler.core.profiles.lean.info.ThreadInfo)2 LeanLogCollectorDriver (com.insightfullogic.honest_profiler.framework.LeanLogCollectorDriver)2