Search in sources :

Example 1 with TraceNode

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;
}
Also used : Inspector(com.yahoo.slime.Inspector) TraceNode(com.yahoo.yolean.trace.TraceNode) ArrayTraverser(com.yahoo.slime.ArrayTraverser)

Example 2 with TraceNode

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));
    }
}
Also used : HashMap(java.util.HashMap) TraceNode(com.yahoo.yolean.trace.TraceNode)

Example 3 with TraceNode

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}"));
}
Also used : TraceNode(com.yahoo.yolean.trace.TraceNode) Test(org.junit.Test)

Example 4 with TraceNode

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);
}
Also used : TraceNode(com.yahoo.yolean.trace.TraceNode) Test(org.junit.Test)

Example 5 with TraceNode

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);
}
Also used : TraceNode(com.yahoo.yolean.trace.TraceNode) Test(org.junit.Test)

Aggregations

TraceNode (com.yahoo.yolean.trace.TraceNode)19 Test (org.junit.Test)11 Query (com.yahoo.search.Query)4 Result (com.yahoo.search.Result)4 JSONString (com.yahoo.prelude.hitfield.JSONString)3 Execution (com.yahoo.search.searchchain.Execution)3 XMLWriter (com.yahoo.text.XMLWriter)3 Trace (com.yahoo.processing.execution.Execution.Trace)1 DefaultRenderer (com.yahoo.search.rendering.DefaultRenderer)1 ArrayTraverser (com.yahoo.slime.ArrayTraverser)1 Cursor (com.yahoo.slime.Cursor)1 Inspector (com.yahoo.slime.Inspector)1 Slime (com.yahoo.slime.Slime)1 TraceVisitor (com.yahoo.yolean.trace.TraceVisitor)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1