use of com.linkedin.thirdeye.dashboard.views.contributor.ContributorViewResponse in project pinot by linkedin.
the class DataReportHelper method getDimensionReportList.
// report list metric vs groupByKey vs dimensionVal vs timeBucket vs values
public List<MetricDimensionReport> getDimensionReportList(List<ContributorViewResponse> reports) {
List<MetricDimensionReport> ultimateResult = new ArrayList<>();
for (ContributorViewResponse report : reports) {
MetricDimensionReport metricDimensionReport = new MetricDimensionReport();
String metric = report.getMetrics().get(0);
String groupByDimension = report.getDimensions().get(0);
metricDimensionReport.setMetricName(metric);
metricDimensionReport.setDimensionName(groupByDimension);
int valIndex = report.getResponseData().getSchema().getColumnsToIndexMapping().get("percentageChange");
int dimensionIndex = report.getResponseData().getSchema().getColumnsToIndexMapping().get("dimensionValue");
int numDimensions = report.getDimensionValuesMap().get(groupByDimension).size();
int numBuckets = report.getTimeBuckets().size();
// this is dimension vs timeBucketValue map, this should be sorted based on first bucket value
Map<String, Map<String, String>> dimensionValueMap = new LinkedHashMap<>();
// Lets populate 'OverAll' contribution
Map<String, String> overAllValueMap = new LinkedHashMap<>();
populateOverAllValuesMap(report, overAllValueMap);
dimensionValueMap.put(OVER_ALL, overAllValueMap);
Map<String, Map<String, String>> dimensionValueMapUnordered = new HashMap<>();
for (int p = 0; p < numDimensions; p++) {
if (p == 0) {
metricDimensionReport.setCurrentStartTime(report.getTimeBuckets().get(0).getCurrentStart());
metricDimensionReport.setCurrentEndTime(report.getTimeBuckets().get(numBuckets - 1).getCurrentEnd());
metricDimensionReport.setBaselineStartTime(report.getTimeBuckets().get(0).getBaselineStart());
metricDimensionReport.setBaselineEndTime(report.getTimeBuckets().get(numBuckets - 1).getBaselineEnd());
}
// valueMap is timeBucket vs value map
LinkedHashMap<String, String> valueMap = new LinkedHashMap<>();
String currentDimension = "";
for (int q = 0; q < numBuckets; q++) {
int index = p * numBuckets + q;
currentDimension = report.getResponseData().getResponseData().get(index)[dimensionIndex];
valueMap.put(String.valueOf(report.getTimeBuckets().get(q).getCurrentStart()), String.format(DECIMAL_FORMATTER, Double.valueOf(report.getResponseData().getResponseData().get(index)[valIndex])));
}
dimensionValueMapUnordered.put(currentDimension, valueMap);
}
orderDimensionValueMap(dimensionValueMapUnordered, dimensionValueMap, report.getDimensionValuesMap().get(groupByDimension));
metricDimensionReport.setSubDimensionValueMap(dimensionValueMap);
populateShareAndTotalMap(report, metricDimensionReport, metric, groupByDimension);
ultimateResult.add(metricDimensionReport);
}
return ultimateResult;
}
Aggregations