private String requestedFields(String fl,Set<String> schema){
  if (fl == null || fl.isEmpty()) {
    return null;
  }
  if (fl.indexOf('-') == -1 && fl.indexOf('+') == -1) {
    return fl + ChronixQueryParams.JOIN_SEPARATOR + String.join(ChronixQueryParams.JOIN_SEPARATOR,REQUIRED_FIELDS);
  }
 else {
    Set<String> fields=new HashSet<>(Arrays.asList(fl.split(ChronixQueryParams.JOIN_SEPARATOR)));
    Set<String> resultingFields=new HashSet<>(schema);
    if (fl.contains(ChronixQueryParams.DATA_AS_JSON)) {
      resultingFields.add(ChronixQueryParams.DATA_AS_JSON);
    }
    for (    String field : fields) {
      if (field.indexOf('-') > -1) {
        resultingFields.remove(field.substring(1));
      }
    }
    return String.join(ChronixQueryParams.JOIN_SEPARATOR,resultingFields);
  }
}

private String requestedFields ( String fl , Set < String > schema ) { if ( fl == null || fl . isEmpty ( ) ) { return null ; } if ( fl . indexOf ( '-' ) == - 1 && fl . indexOf ( '+' ) == - 1 ) { return fl + ChronixQueryParams . JOIN_SEPARATOR + String . join ( ChronixQueryParams . JOIN_SEPARATOR , REQUIRED_FIELDS ) ; } else { Set < String > fields = new HashSet < > ( Arrays . asList ( fl . split ( ChronixQueryParams . JOIN_SEPARATOR ) ) ) ; Set < String > resultingFields = new HashSet < > ( schema ) ; if ( fl . contains ( ChronixQueryParams . DATA_AS_JSON ) ) { resultingFields . add ( ChronixQueryParams . DATA_AS_JSON ) ; } for ( String field : fields ) { if ( field . indexOf ( '-' ) > - 1 ) { resultingFields . remove ( field . substring ( 1 ) ) ; } } return String . join ( ChronixQueryParams . JOIN_SEPARATOR , resultingFields ) ; } }
gets the requested fields . joins the required_fields_with_data and the user defined fields . e . g . : user requested fields : userfield = > data , start , end , metric , userfield
