Package com.fasterxml.jackson.databind.node

Examples of com.fasterxml.jackson.databind.node.ArrayNode


  private int rename(DrillImplementor implementor, int inputId, List<String> inputFields, List<String> outputFields) {
    final ObjectNode project = implementor.mapper.createObjectNode();
    project.put("op", "project");
    project.put("input", inputId);
    final ArrayNode transforms = implementor.mapper.createArrayNode();
    project.put("projections", transforms);
    for (Pair<String, String> pair : Pair.zip(inputFields, outputFields)) {
      final ObjectNode objectNode = implementor.mapper.createObjectNode();
      transforms.add(objectNode);
      objectNode.put("expr", pair.left);
      objectNode.put("ref", "output." + pair.right);
//      objectNode.put("ref", pair.right);
    }
    return implementor.add(project);
View Full Code Here


        sourcesNode.put("queue", sourceNode);
      }
    }


    final ArrayNode queryNode = mapper.createArrayNode();
    rootNode.put("query", queryNode);

    this.operatorsNode = queryNode;
  }
View Full Code Here

    segment.put("op", "segment");
    segment.put("input", inputId);
    // TODO: choose different name for field if there is already a field
    // called "segment"
    segment.put("ref", "segment");
    final ArrayNode exprs = implementor.mapper.createArrayNode();
    segment.put("exprs", exprs);
    for (int group : Util.toIter(groupSet)) {
      exprs.add(childFields.get(group));
    }

    final int segmentId = implementor.add(segment);

    final ObjectNode aggregate = implementor.mapper.createObjectNode();
    aggregate.put("op", "collapsingaggregate");
    aggregate.put("input", segmentId);
    aggregate.put("within", "segment");
    final ArrayNode carryovers = implementor.mapper.createArrayNode();
    aggregate.put("carryovers", carryovers);
    for (int group : Util.toIter(groupSet)) {
      carryovers.add(childFields.get(group));
    }
    final ArrayNode aggregations = implementor.mapper.createArrayNode();
    aggregate.put("aggregations", aggregations);
    for (Ord<AggregateCall> aggCall : Ord.zip(aggCalls)) {
      final ObjectNode aggregation = implementor.mapper.createObjectNode();
      aggregation.put("ref", fields.get(groupSet.cardinality() + aggCall.i));
      aggregation.put("expr", toDrill(aggCall.e, childFields));
      aggregations.add(aggregation);
    }

    return implementor.add(aggregate);
  }
View Full Code Here

     * E.g. { op: "order", input: 4, ordering: [ {order: "asc", expr: "deptId"} ] }
     */
    final ObjectNode order = implementor.mapper.createObjectNode();
    order.put("op", "order");
    order.put("input", inputId);
    final ArrayNode orderings = implementor.mapper.createArrayNode();
    order.put("orderings", orderings);
    for (Ord<RelFieldCollation> fieldCollation : Ord.zip(this.collation.getFieldCollations())) {
      final ObjectNode ordering = implementor.mapper.createObjectNode();
      ordering.put("order", toDrill(fieldCollation.e));
      ordering.put("expr", childFields.get(fieldCollation.e.getFieldIndex()));
      switch (fieldCollation.e.nullDirection) {
      case FIRST:
        ordering.put("nullCollation", "first");
        break;
      default:
        ordering.put("nullCollation", "last");
        break;
      }
      orderings.add(ordering);
    }

    return implementor.add(order);
  }
View Full Code Here

    /*
     * E.g. { op: "project", projections: [ { ref: "output.quantity", expr: "donuts.sales"} ]
     */
    project.put("op", "project");
    project.put("input", inputId);
    final ArrayNode transforms = implementor.mapper.createArrayNode();
    project.put("projections", transforms);
    for (Pair<RexNode, String> pair : projects()) {
      final ObjectNode objectNode = implementor.mapper.createObjectNode();
      transforms.add(objectNode);
      String expr = DrillOptiq.toDrill(getChild(), pair.left);
      objectNode.put("expr", expr);
      String ref = "output." + pair.right;
//      String ref = pair.right;
      objectNode.put("ref", ref);
View Full Code Here

  }
*/
    final ObjectNode union = implementor.mapper.createObjectNode();
    union.put("op", "union");
    union.put("distinct", !all);
    final ArrayNode inputs = implementor.mapper.createArrayNode();
    union.put("inputs", inputs);
    for (Integer inputId : inputIds) {
      inputs.add(inputId);
    }
    return implementor.add(union);
  }
View Full Code Here

    if (preferred != null) {
      mergedPreferred = WeightsUtil.merge(preferred);
    }

    if (infeasible != null) {
      ArrayNode arr = JOM.createArrayNode();
      for (Interval interval : infeasible) {
        ObjectNode o = JOM.createObjectNode();
        o.put("start", interval.getStart().toString());
        o.put("end", interval.getEnd().toString());
        arr.add(o);
      }
      intervals.put("infeasible", arr);
    }

    if (preferred != null) {
      ArrayNode arr = JOM.createArrayNode();
      for (Weight weight : preferred) {
        ObjectNode o = JOM.createObjectNode();
        o.put("start", weight.getStart().toString());
        o.put("end", weight.getEnd().toString());
        o.put("weight", weight.getWeight());
        arr.add(o);
      }
      intervals.put("preferred", arr);
    }

    if (solutions != null) {
      ArrayNode arr = JOM.createArrayNode();
      for (Weight weight : solutions) {
        ObjectNode o = JOM.createObjectNode();
        o.put("start", weight.getStart().toString());
        o.put("end", weight.getEnd().toString());
        o.put("weight", weight.getWeight());
        arr.add(o);
      }
      intervals.put("solutions", arr);
    }

    if (mergedInfeasible != null) {
      ArrayNode arr = JOM.createArrayNode();
      for (Interval i : mergedInfeasible) {
        ObjectNode o = JOM.createObjectNode();
        o.put("start", i.getStart().toString());
        o.put("end", i.getEnd().toString());
        arr.add(o);
      }
      intervals.put("mergedInfeasible", arr);
    }

    if (mergedPreferred != null) {
      ArrayNode arr = JOM.createArrayNode();
      for (Weight wi : mergedPreferred) {
        ObjectNode o = JOM.createObjectNode();
        o.put("start", wi.getStart().toString());
        o.put("end", wi.getEnd().toString());
        o.put("weight", wi.getWeight());
        arr.add(o);
      }
      intervals.put("mergedPreferred", arr);
    }   

    return intervals;   
View Full Code Here

      params.put("timeMax", timeMax.toString());

      // exclude the event managed by this agent from the busy intervals
      String eventId = getAgentData(agent).eventId;
      if (eventId != null) {
        ArrayNode excludeEventIds = JOM.createArrayNode();
        excludeEventIds.add(eventId);
        params.put("excludeEventIds", excludeEventIds);
      }

      // get the busy intervals from the agent
      ArrayNode array = send(agent, "getBusy", params, ArrayNode.class);

      // convert from ArrayNode to List
      List<Interval> busy = new ArrayList<Interval>();
      for (int i = 0; i < array.size(); i++) {
        ObjectNode obj = (ObjectNode) array.get(i);
        String start = obj.has("start") ? obj.get("start").asText()
            : null;
        String end = obj.has("end") ? obj.get("end").asText() : null;
        busy.add(new Interval(new DateTime(start), new DateTime(end)));
      }
View Full Code Here

      @Name("timeMax") String timeMax) {
    List<Interval> available = IntervalsUtil.getOfficeHours(new DateTime(
        timeMin), new DateTime(timeMax));

    // convert to JSON array
    ArrayNode array = JOM.createArrayNode();
    for (Interval interval : available) {
      ObjectNode obj = JOM.createObjectNode();
      obj.put("start", interval.getStart().toString());
      obj.put("end", interval.getEnd().toString());
      array.add(obj);
    }
    return array;
  }
View Full Code Here

        }
        ObjectNode objectNode = createSchemaNode("string", true);
        if (typeHint != null) {
            JavaType type = provider.constructType(typeHint);
            if (type.isEnumType()) {
                ArrayNode enumNode = objectNode.putArray("enum");
                for (SerializableString value : _values.values()) {
                    enumNode.add(value.getValue());
                }
            }
        }
        return objectNode;
    }
View Full Code Here

TOP

Related Classes of com.fasterxml.jackson.databind.node.ArrayNode

Copyright © 2018 www.massapicom. 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.