diff --git a/src/main/java/com/loafle/overflow/crawler/result/OFResultSetCol.java b/src/main/java/com/loafle/overflow/crawler/result/OFResultSetCol.java index aeed290..0028bec 100644 --- a/src/main/java/com/loafle/overflow/crawler/result/OFResultSetCol.java +++ b/src/main/java/com/loafle/overflow/crawler/result/OFResultSetCol.java @@ -33,7 +33,64 @@ public class OFResultSetCol extends OFResultSet{ public Map parse() { - return null; + List metrics = this.item.getMetrics(); + String[] arrayColumns = (String[])this.item.getQuery().getQueryInfo().get("arrayColumns"); +// this.meta + + Map resultMap = new HashMap<>(); + + List row = null; + + String metric = null; + List arrayValue = new ArrayList<>(); + + + int columnIdx = 0; + + for(int indexI = 0; indexI < this.rows.size(); ++indexI) { + + row = this.rows.get(indexI); + for (int indexJ= 0; indexJ < row.size(); ++indexJ) { + + arrayValue.clear(); + + for(int indexL =0; indexL < arrayColumns.length; ++indexL) { + columnIdx = this.meta.get(arrayColumns[indexL]); + + arrayValue.add(row.get(columnIdx)); + } + + + for(int indexK = 0 ; indexK < metrics.size(); ++indexK) { + + metric = metrics.get(indexK); + + metric = convertMetric(metric, arrayValue); + + resultMap.put(metric, row.get(indexI)); + } + + } + + } + + return resultMap; } + + private String convertMetric(String metric, List arrayValue) { + + char convertChar = '$'; + String convertStr = "$"; + + for(int indexI = 0 ; indexI < arrayValue.size(); ++indexI) { + + convertStr = convertChar + String.valueOf(indexI +1); + + metric = metric.replaceFirst(convertStr, arrayValue.get(indexI)); + + } + + return metric; + } }