Examples of ITransientMap


Examples of clojure.lang.ITransientMap

        return eofValue;
      }
    }
    switch (jp.getCurrentToken()) {
    case START_OBJECT:
      ITransientMap map = PersistentArrayMap.EMPTY.asTransient();
      jp.nextToken();
      while (jp.getCurrentToken() != JsonToken.END_OBJECT) {
        String keyStr = jp.getText();
        jp.nextToken();
        Object key = keywords ? Keyword.intern(keyStr) : keyStr;
        map = map.assoc(key, parse(jp, false, keywords, eofValue));
        jp.nextToken();
      }
      return map.persistent();
    case START_ARRAY:
      ITransientCollection vec = PersistentVector.EMPTY.asTransient();
      jp.nextToken();
      while (jp.getCurrentToken() != JsonToken.END_ARRAY) {
        vec = vec.conj(parse(jp, false, keywords, eofValue));
View Full Code Here

Examples of clojure.lang.ITransientMap

      if (use_extensions) {
        Object map_field_by = def.mapFieldBy(field);
        DescriptorProtos.FieldOptions options = field.getOptions();
        if (map_field_by != null) {
          ITransientMap map = (ITransientMap)OrderedMap.EMPTY.asTransient();
          while (iterator.hasNext()) {
            PersistentProtocolBufferMap v =
              (PersistentProtocolBufferMap)fromProtoValue(field, iterator.next());
            Object k = v.valAt(map_field_by);
            PersistentProtocolBufferMap existing = (PersistentProtocolBufferMap)map.valAt(k);
            map = map.assoc(k, def.mapValue(field, existing, v));
          }
          return map.persistent();
        } else if (options.getExtension(Extensions.counter)) {
          Object count = iterator.next();
          while (iterator.hasNext()) {
            count = Numbers.add(count, iterator.next());
          }
          return count;
        } else if (options.getExtension(Extensions.succession)) {
          return fromProtoValue(field, values.get(values.size() - 1));
        } else if (options.getExtension(Extensions.map)) {
          Descriptors.Descriptor type = field.getMessageType();
          Descriptors.FieldDescriptor key_field = type.findFieldByName("key");
          Descriptors.FieldDescriptor val_field = type.findFieldByName("val");

          ITransientMap map = (ITransientMap)OrderedMap.EMPTY.asTransient();
          while (iterator.hasNext()) {
            DynamicMessage message = (DynamicMessage)iterator.next();
            Object k = fromProtoValue(key_field, message.getField(key_field));
            Object v = fromProtoValue(val_field, message.getField(val_field));
            Object existing = map.valAt(k);

            if (existing instanceof PersistentProtocolBufferMap) {
              map = map.assoc(k, def.mapValue(field,
                                              (PersistentProtocolBufferMap)existing,
                                              (PersistentProtocolBufferMap)v));
            } else if (existing instanceof IPersistentCollection) {
              map = map.assoc(k, ((IPersistentCollection)existing).cons(v));
            } else {
              map = map.assoc(k, v);
            }
          }
          return map.persistent();
        } else if (options.getExtension(Extensions.set)) {
          Descriptors.Descriptor type = field.getMessageType();
          Descriptors.FieldDescriptor item_field = type.findFieldByName("item");
          Descriptors.FieldDescriptor exists_field = type.findFieldByName("exists");
View Full Code Here

Examples of clojure.lang.ITransientMap

                return eofValue;
            }
        }
        switch (jp.getCurrentToken()) {
        case START_OBJECT:
            ITransientMap map = PersistentArrayMap.EMPTY.asTransient();
            jp.nextToken();
            while (jp.getCurrentToken() != JsonToken.END_OBJECT) {
                String keyStr = jp.getText();
                jp.nextToken();
                Object key = keywords ? Keyword.intern(keyStr) : keyStr;
                map = map.assoc(key, parse(jp, false, keywords, eofValue));
                jp.nextToken();
            }
            return map.persistent();
        case START_ARRAY:
            ITransientCollection vec = PersistentVector.EMPTY.asTransient();
            jp.nextToken();
            while (jp.getCurrentToken() != JsonToken.END_ARRAY) {
                vec = vec.conj(parse(jp, false, keywords, eofValue));
View Full Code Here

Examples of clojure.lang.ITransientMap

  }

  // Parse arguments
  public static IPersistentMap argMap(final String args) {
    final Scanner sc = new Scanner(args).useDelimiter(",");
    ITransientMap m = PersistentHashMap.EMPTY.asTransient();
    try {
      while (sc.hasNext()) {
        // Parse k=v pairs and assoc! into map
        final String pair = sc.next();
        final int offset  = pair.indexOf("=");
        final String key  = pair.substring(0, offset);
        final String val  = pair.substring(offset + 1);
        if (key.equals("port") ||
            key.equals("dt")) {
          m.assoc(Keyword.intern(key), Integer.parseInt(val));
        } else if (key.equals("load")) {
          m.assoc(Keyword.intern(key), Float.parseFloat(val));
        } else {
          m.assoc(Keyword.intern(key), val);
        }
      }
      return m.persistent();
    } catch (Exception e) {
      System.err.println("Riemann-jvm-profiler agent takes a list of comma-separated k=v pairs for riemann.jvm-profiler/start. For instance, -javaagent:riemann-jvm-profiler.jar=host=my.riemann.host,port=5556,dt=10");
      System.exit(1);
      return null; // unreachable
    } finally {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.