Exemple #1
0
  public Stats(List<AggregationField> fields, List<String> clause) {
    this.EMPTY_KEY = new ArrayList<Object>(0);
    this.clauses = clause;
    this.clauseCount = clauses.size();
    this.useClause = clauseCount > 0;
    this.fields = fields;
    this.funcs = new AggregationFunction[fields.size()];
    this.fieldOrder = new ArrayList<String>(clauses);

    // prepare template functions
    for (int i = 0; i < fields.size(); i++) {
      AggregationField f = fields.get(i);
      this.funcs[i] = f.getFunction();
      this.fieldOrder.add(f.getName());
    }
  }
Exemple #2
0
  @Override
  public String toString() {
    String aggregation = "";
    int i = 0;
    for (AggregationField f : this.fields) {
      if (i++ != 0) aggregation += ",";
      aggregation += " " + f.toString();
    }

    String clause = "";
    if (!clauses.isEmpty()) {
      clause = " by";
      i = 0;
      for (String c : clauses) {
        if (i++ != 0) clause += ",";
        clause += " " + c;
      }
    }

    return "stats" + aggregation + clause;
  }