/** * Annotate the used and ignored columns in the job parameter JSON For both the used and the * ignored columns, the following rules apply: If the number of columns is less or equal than * 100, a dense list of used columns is reported. If the number of columns is greater than 100, * the number of columns is reported. If the number of columns is 0, a "N/A" is reported. * * @return JsonObject annotated with used/ignored columns */ @Override public JsonObject toJSON() { JsonObject jo = super.toJSON(); if (!jo.has("source") || source == null) return jo; HashMap<String, int[]> map = new HashMap<String, int[]>(); map.put("used_cols", cols); map.put("ignored_cols", ignored_cols); for (String key : map.keySet()) { int[] val = map.get(key); if (val != null) { if (val.length > 100) jo.getAsJsonObject("source").addProperty("num_" + key, val.length); else if (val.length > 0) { StringBuilder sb = new StringBuilder(); for (int c : val) sb.append(c + ","); jo.getAsJsonObject("source") .addProperty(key, sb.toString().substring(0, sb.length() - 1)); } else { jo.getAsJsonObject("source").add(key, JsonNull.INSTANCE); } } } return jo; }