Search in sources :

Example 1 with ArrayTraverser

use of com.yahoo.slime.ArrayTraverser in project vespa by vespa-engine.

the class AllocatedHosts method fromSlime.

private static AllocatedHosts fromSlime(Inspector inspector, Optional<NodeFlavors> nodeFlavors) {
    Inspector array = inspector.field(mappingKey);
    Set<HostSpec> hosts = new LinkedHashSet<>();
    array.traverse(new ArrayTraverser() {

        @Override
        public void entry(int i, Inspector inspector) {
            hosts.add(hostsFromSlime(inspector.field(hostSpecKey), nodeFlavors));
        }
    });
    return new AllocatedHosts(hosts);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Inspector(com.yahoo.slime.Inspector) ArrayTraverser(com.yahoo.slime.ArrayTraverser)

Example 2 with ArrayTraverser

use of com.yahoo.slime.ArrayTraverser 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 3 with ArrayTraverser

use of com.yahoo.slime.ArrayTraverser in project vespa by vespa-engine.

the class ConfigVerification method listConfigs.

private static Map<String, Stack<String>> listConfigs(List<String> urls) throws IOException {
    Map<String, String> outputs = performRequests(urls);
    Map<String, Stack<String>> recurseMappings = new LinkedHashMap<>();
    for (Map.Entry<String, String> entry : outputs.entrySet()) {
        Slime slime = new JsonDecoder().decode(new Slime(), Utf8.toBytes(entry.getValue()));
        final List<String> list = new ArrayList<>();
        slime.get().field("configs").traverse(new ArrayTraverser() {

            @Override
            public void entry(int idx, Inspector inspector) {
                list.add(inspector.asString());
            }
        });
        Stack<String> stack = new Stack<>();
        Collections.sort(list);
        stack.addAll(list);
        recurseMappings.put(entry.getKey(), stack);
    }
    return recurseMappings;
}
Also used : Slime(com.yahoo.slime.Slime) JsonDecoder(com.yahoo.slime.JsonDecoder) Inspector(com.yahoo.slime.Inspector) ArrayTraverser(com.yahoo.slime.ArrayTraverser)

Example 4 with ArrayTraverser

use of com.yahoo.slime.ArrayTraverser in project vespa by vespa-engine.

the class JobQueueSerializer method fromJson.

public Deque<ApplicationId> fromJson(byte[] data) {
    Inspector inspector = SlimeUtils.jsonToSlime(data).get();
    Deque<ApplicationId> queue = new ArrayDeque<>();
    inspector.traverse((ArrayTraverser) (index, value) -> queue.addLast(ApplicationId.fromSerializedForm(value.asString())));
    return queue;
}
Also used : HashSet(java.util.HashSet) Cursor(com.yahoo.slime.Cursor) List(java.util.List) Inspector(com.yahoo.slime.Inspector) ApplicationId(com.yahoo.config.provision.ApplicationId) SlimeUtils(com.yahoo.vespa.config.SlimeUtils) ArrayTraverser(com.yahoo.slime.ArrayTraverser) Slime(com.yahoo.slime.Slime) Set(java.util.Set) IOException(java.io.IOException) ArrayDeque(java.util.ArrayDeque) Deque(java.util.Deque) Inspector(com.yahoo.slime.Inspector) ApplicationId(com.yahoo.config.provision.ApplicationId) ArrayDeque(java.util.ArrayDeque)

Example 5 with ArrayTraverser

use of com.yahoo.slime.ArrayTraverser in project vespa by vespa-engine.

the class StringSetSerializer method fromJson.

public Set<String> fromJson(byte[] data) {
    Inspector inspector = SlimeUtils.jsonToSlime(data).get();
    Set<String> stringSet = new HashSet<>();
    inspector.traverse((ArrayTraverser) (index, name) -> stringSet.add(name.asString()));
    return stringSet;
}
Also used : HashSet(java.util.HashSet) Cursor(com.yahoo.slime.Cursor) Inspector(com.yahoo.slime.Inspector) SlimeUtils(com.yahoo.vespa.config.SlimeUtils) ArrayTraverser(com.yahoo.slime.ArrayTraverser) Slime(com.yahoo.slime.Slime) Set(java.util.Set) IOException(java.io.IOException) Inspector(com.yahoo.slime.Inspector) HashSet(java.util.HashSet)

Aggregations

ArrayTraverser (com.yahoo.slime.ArrayTraverser)9 Inspector (com.yahoo.slime.Inspector)9 Slime (com.yahoo.slime.Slime)5 Cursor (com.yahoo.slime.Cursor)4 SlimeUtils (com.yahoo.vespa.config.SlimeUtils)3 IOException (java.io.IOException)3 HashSet (java.util.HashSet)3 Set (java.util.Set)3 LinkedHashSet (java.util.LinkedHashSet)2 List (java.util.List)2 CompressionType (com.yahoo.compress.CompressionType)1 Compressor (com.yahoo.compress.Compressor)1 ApplicationId (com.yahoo.config.provision.ApplicationId)1 GlobalId (com.yahoo.document.GlobalId)1 IdIdString (com.yahoo.document.idstring.IdIdString)1 FastHit (com.yahoo.prelude.fastsearch.FastHit)1 BinaryFormat (com.yahoo.slime.BinaryFormat)1 JsonDecoder (com.yahoo.slime.JsonDecoder)1 TraceNode (com.yahoo.yolean.trace.TraceNode)1 ArrayDeque (java.util.ArrayDeque)1