resultsetcol
This commit is contained in:
snoop 2017-04-25 16:59:44 +09:00
parent 4a9fca0bbd
commit 8d5d36b872

View File

@ -33,7 +33,64 @@ public class OFResultSetCol extends OFResultSet{
public Map<String, String> parse() {
return null;
List<String> metrics = this.item.getMetrics();
String[] arrayColumns = (String[])this.item.getQuery().getQueryInfo().get("arrayColumns");
// this.meta
Map<String, String> resultMap = new HashMap<>();
List<String> row = null;
String metric = null;
List<String> 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<String> 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;
}
}