double[] endy = new double[algoAggregates.size()];
XYSeries series1 = new XYSeries("CostBenefit");
XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(series1);
DefaultIntervalXYDataset datasetxy = new DefaultIntervalXYDataset();
if (connectionModel.getSchema() != null) {
Map<Parameter, Object> algorithmParams = ArgumentUtils.validateParameters(algorithm, algorithmUiExtension.getAlgorithmParameters());
List<Algorithm.CostBenefit> costBenefit = algorithm.computeAggregateCosts(connectionModel.getSchema(), algorithmParams, algoAggregates);
double totalbenefit = 0;
double x = 0;
int count = 0;
for (Algorithm.CostBenefit cb : costBenefit) {
Aggregate agg = algoAggregates.get(count);
double estimateSpace = agg.estimateSpace();
double hx = estimateSpace / 2;
totalLoadTime += cb.getLoadTime();
totalbenefit += cb.getSavedQueryRowCount();
series1.add(x + hx, totalbenefit);
xs[count] = x + hx;
startx[count] = x;
x += estimateSpace;
endx[count] = x;
ys[count] = totalbenefit;
starty[count] = 0;
endy[count] = 0;
count++;
}
// update summary table
aggregateSummaryModel.setSelectedAggregateCount(format.format(totalAggregatesSelected));
aggregateSummaryModel.setSelectedAggregateRows(format.format(totalRows));
aggregateSummaryModel.setSelectedAggregateSpace(format.format(totalSpace) + " bytes");
aggregateSummaryModel.setSelectedAggregateLoadTime(format.format(totalLoadTime));
} else {
aggregateSummaryModel.setSelectedAggregateCount("");
aggregateSummaryModel.setSelectedAggregateRows("");
aggregateSummaryModel.setSelectedAggregateSpace("");
aggregateSummaryModel.setSelectedAggregateLoadTime("");
}
// render cost benefit chart
double[][] data = new double[][] {xs, startx, endx, ys, starty, endy};
datasetxy.addSeries("", data);
JFreeChart chart = ChartFactory.createXYBarChart(
"", // chart title
"Cost", // x axis label
false,