use of org.spf4j.ssdump2.avro.AMethod in project spf4j by zolyfarkas.
the class Converter method convert.
public static SampleNode convert(final Iterator<ASample> samples) {
TIntObjectMap<SampleNode> index = new TIntObjectHashMap<>();
while (samples.hasNext()) {
ASample asmp = samples.next();
SampleNode sn = new SampleNode(asmp.count, new THashMap<Method, SampleNode>(4));
SampleNode parent = index.get(asmp.parentId);
if (parent != null) {
AMethod method = asmp.getMethod();
Method m = Method.getMethod(method.declaringClass, method.getName());
final Map<Method, SampleNode> subNodes = parent.getSubNodes();
if (subNodes == null) {
throw new IllegalStateException("Bug, state " + index + "; at node " + asmp);
}
subNodes.put(m, sn);
}
index.put(asmp.id, sn);
}
return index.get(0);
}
use of org.spf4j.ssdump2.avro.AMethod in project spf4j by zolyfarkas.
the class Converter method convert.
public static <E extends Exception> int convert(final Method method, final SampleNode node, final int parentId, final int id, final Handler<ASample, E> handler) throws E {
final Deque<TraversalNode> dq = new ArrayDeque<>();
dq.addLast(new TraversalNode(method, node, parentId));
int nid = id;
while (!dq.isEmpty()) {
TraversalNode first = dq.removeFirst();
Method m = first.getMethod();
ASample sample = new ASample();
sample.id = nid;
SampleNode n = first.getNode();
sample.count = n.getSampleCount();
AMethod am = new AMethod();
am.setName(m.getMethodName());
am.setDeclaringClass(m.getDeclaringClass());
sample.method = am;
sample.parentId = first.getParentId();
final TMap<Method, SampleNode> subNodes = n.getSubNodes();
final int pid = nid;
if (subNodes != null) {
subNodes.forEachEntry((a, b) -> {
dq.addLast(new TraversalNode(a, b, pid));
return true;
});
}
handler.handle(sample, parentId);
nid++;
}
return nid;
}
Aggregations