use of com.yahoo.yolean.trace.TraceNode in project vespa by vespa-engine.
the class SlimeTraceDeserializer method deserialize.
private static TraceNode deserialize(Inspector entry) {
Object payload = decodePayload(entry.field(SlimeTraceSerializer.PAYLOAD));
long timestamp = decodeTimestamp(entry.field(SlimeTraceSerializer.TIMESTAMP));
final TraceNode node = new TraceNode(payload, timestamp);
Inspector children = entry.field(SlimeTraceSerializer.CHILDREN);
children.traverse(new ArrayTraverser() {
@Override
public void entry(int idx, Inspector inspector) {
node.add(deserialize(inspector));
}
});
return node;
}
use of com.yahoo.yolean.trace.TraceNode in project vespa by vespa-engine.
the class SlimeTraceSerializerTest method assertTraceEqual.
private void assertTraceEqual(TraceNode deser, TraceNode root) {
assertThat(deser.timestamp(), is(root.timestamp()));
assertThat(deser.payload(), is(root.payload()));
Iterator<TraceNode> actualIt = deser.children().iterator();
Iterator<TraceNode> expectedIt = root.children().iterator();
Map<Long, TraceNode> expectedMapping = new HashMap<>();
Map<Long, TraceNode> actualMapping = new HashMap<>();
while (expectedIt.hasNext()) {
assertTrue(actualIt.hasNext());
TraceNode actualNode = actualIt.next();
TraceNode expectedNode = expectedIt.next();
expectedMapping.put(expectedNode.timestamp(), expectedNode);
actualMapping.put(actualNode.timestamp(), actualNode);
}
assertFalse(expectedIt.hasNext());
assertFalse(actualIt.hasNext());
for (long timestamp : expectedMapping.keySet()) {
assertTraceEqual(actualMapping.get(timestamp), expectedMapping.get(timestamp));
}
}
use of com.yahoo.yolean.trace.TraceNode in project vespa by vespa-engine.
the class SlimeTraceSerializerTest method test_unknown.
@Test
public void test_unknown() throws IOException {
TraceNode root = new TraceNode(new ArrayList<String>(), 5);
assertThat(toJson(root), is("{\"timestamp\":5}"));
}
use of com.yahoo.yolean.trace.TraceNode in project vespa by vespa-engine.
the class SlimeTraceSerializerTest method test_null.
@Test
public void test_null() throws IOException {
TraceNode root = new TraceNode(null, 5);
assertThat(toJson(root), is("{\"timestamp\":5}"));
assertSerialize(root);
}
use of com.yahoo.yolean.trace.TraceNode in project vespa by vespa-engine.
the class SlimeTraceSerializerTest method test_double.
@Test
public void test_double() throws IOException {
TraceNode root = new TraceNode(3.5, 5);
assertThat(toJson(root), is("{\"timestamp\":5,\"payload\":3.5}"));
assertSerialize(root);
}
Aggregations