@Override protected ResultSetSchema map(ResultSetSchema schema) { return schema.withAddColumn(new MetricColumn(ROW_NUM_COLUMN_NAME)); }
@Override public String toString() { return "{metric:'" + getName() + "'}"; } }
MetricColumn pageViewColumn = new MetricColumn("pageViews"); metricValues.put(pageViewColumn, new BigDecimal(111));
/** * Generates the metric names and their value map from Result for custom serialization. * * @param result Result object for the custom serialization * * @return custom map of metric names and their values */ private Map<String, Object> getMetricValues(Result result) { return result.getMetricValues().entrySet().stream().collect(Collectors.toMap( metricColumn -> metricColumn.getKey().getName(), metricColumn -> metricColumn.getValue() )); } }
MetricColumn pageViewColumn = new MetricColumn("pageViews"); metricValues.put(pageViewColumn, new BigDecimal(111));
/** * Get type of class type of metric values mapped with metric names. * * @return Map of metric names and its value type */ @JsonIgnore public Map<String, String> getMetricValuesType() { return result.getMetricValues().entrySet().stream() .filter(metricValue -> metricValue != null) .collect(Collectors.toMap(k -> k.getKey().getName(), v -> getType(v.getValue()))); }
/** * Extract the metric values for a json object given the set of all available metric columns and the json object. * * @param metricColumns the set of metric columns * @param entry the json object * * @return map of metric columns to metric values */ private LinkedHashMap<MetricColumn, Object> extractMetricValues( Set<MetricColumn> metricColumns, JsonNode entry ) { LinkedHashMap<MetricColumn, Object> metricValues = new LinkedHashMap<>(); for (MetricColumn mc : metricColumns) { JsonNode fieldNode = entry.get(mc.getName()); if (fieldNode == null) { LOG.warn("Found null node for metric column {}", mc.getName()); } else { metricValues.put(mc, getNodeValue(fieldNode)); } } return metricValues; }
row.put(apiMetricColumn.getName(), result.getMetricValue(apiMetricColumn));
row.put(apiMetricColumn.getName(), result.getMetricValue(apiMetricColumn));