Package com.fasterxml.jackson.databind.node

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


  private Set<DrillTable> tables = Sets.newHashSet();
  private final boolean isRef;
 
  public DrillImplementor(boolean isRef) {
    this.isRef = isRef;
    final ObjectNode headNode = mapper.createObjectNode();
    rootNode.put("head", headNode);
    headNode.put("type", "APACHE_DRILL_LOGICAL");
    headNode.put("version", "1");

    final ObjectNode generatorNode = mapper.createObjectNode();
    headNode.put("generator", generatorNode);
    generatorNode.put("type", "optiq");
    generatorNode.put("info", "na");

    // TODO: populate sources based on the sources of scans that occur in
    // the query
    sourcesNode = mapper.createObjectNode();
    rootNode.put("storage", sourcesNode);

    if(isRef){
      {
        final ObjectNode sourceNode = mapper.createObjectNode();
        sourceNode.put("type", "classpath");
        sourcesNode.put("donuts-json", sourceNode);
      }
      {
        final ObjectNode sourceNode = mapper.createObjectNode();
        sourceNode.put("type", "queue");
        sourcesNode.put("queue", sourceNode);
      }
    }

View Full Code Here


  public int go(DrillRel root) {
    int inputId = root.implement(this);

    // Add a last node, to write to the output queue.
    final ObjectNode writeOp = mapper.createObjectNode();
    writeOp.put("op", "store");
    writeOp.put("input", inputId);
    writeOp.put("storageengine", "queue");
    writeOp.put("memo", "output sink");
    QueueOutputInfo output = new QueueOutputInfo();
    output.number = 0;
    writeOp.put("target", mapper.convertValue(output, JsonNode.class));
    return add(writeOp);
  }
View Full Code Here

    final List<String> fields = getRowType().getFieldNames();
    /*
     * E.g. { op: "segment", ref: "segment", exprs: ["deptId"] }, { op: "collapsingaggregate", within: "segment",
     * carryovers: ["deptId"], aggregations: [ {ref: "c", expr: "count(1)"} ] }
     */
    final ObjectNode segment = implementor.mapper.createObjectNode();
    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

  }

  @Override
  public int implement(DrillImplementor implementor) {
    final int inputId = implementor.visitChild(this, 0, getChild());
    final ObjectNode filter = implementor.mapper.createObjectNode();
    /*
     * E.g. { op: "filter", expr: "donuts.ppu < 1.00" }
     */
    filter.put("op", "filter");
    filter.put("input", inputId);
    filter.put("expr", DrillOptiq.toDrill(getChild(), getCondition()));
    return implementor.add(filter);
  }
View Full Code Here

    int inputId = implementor.visitChild(this, 0, getChild());
    final List<String> childFields = getChild().getRowType().getFieldNames();
    /*
     * 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);
    }

View Full Code Here

  }

  @Override
  public int implement(DrillImplementor implementor) {
    int inputId = implementor.visitChild(this, 0, getChild());
    final ObjectNode project = implementor.mapper.createObjectNode();
    /*
     * 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);
    }
    return implementor.add(project);
  }
View Full Code Here

      op: "union",
      distinct: true,
    inputs: [2, 4]
  }
*/
    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

  JsonHelper(DrillConfig config){
    mapper = config.getMapper();
  }
 
  public JsonNode get(Map<String, ValueVector> vectors, int index){
    final ObjectNode map = mapper.createObjectNode();
    for(Map.Entry<String, ValueVector> e : vectors.entrySet()){
      Object o = e.getValue().getAccessor().getObject(index);
      if(o == null) continue;
      String k = e.getKey().replace("_MAP.", "");
     
      if(o instanceof Integer) map.put(k, (Integer) o);
      else if(o instanceof Long) map.put(k, (Long) o);
      else if(o instanceof Boolean) map.put(k, (Boolean) o);
      else if(o instanceof String) map.put(k, (String) o);
      else if(o instanceof byte[]) map.put(k, new String((byte[]) o));
      else if(o instanceof Float) map.put(k, (Float) o);
      else if(o instanceof Double) map.put(k, (Double) o);
      else map.put(k, "---Unknown Type---");
     
    }
    return map;
  }
View Full Code Here

    }

    @Override
    public JsonNode getSchema(SerializerProvider provider, Type typeHint)
    {
        ObjectNode o = createSchemaNode("array", true);
        o.put("items", createSchemaNode(_schemeElementType));
        return o;
    }
View Full Code Here

    getState().put("issues", issues);
   
    // trigger an error event
    try {
      String event = issue.getType().toString();
      ObjectNode data = JOM.createObjectNode();
      data.put("issue", JOM.getInstance().convertValue(issue,
          ObjectNode.class));
      ObjectNode params = JOM.createObjectNode();
      params.put("description", issue.getMessage());
      params.put("data", data);
      trigger(event, params);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

TOP

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

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.