final long physicalOptimization = evaluator.physicalOptimization();
if (mode == EvaluationMode.DEMO) {
final EvaluationDemoToolBar bottomToolBar = new EvaluationDemoToolBar(this.webdemo != DEMO_ENUM.ECLIPSE);
final Result result = (evaluator instanceof BasicIndexRuleEvaluator)? ((BasicIndexRuleEvaluator)evaluator).getResultOperator() : ((CommonCoreQueryEvaluator<Node>)evaluator).getResultOperator();
final ShowResult sr = new ShowResult(bottomToolBar, result);
evaluator.prepareForQueryDebugSteps(bottomToolBar);
System.out.println("Evaluate query ...");
final Thread thread = new Thread() {
@Override
public void run() {
try {
evaluator.evaluateQueryDebugSteps(bottomToolBar, sr);
bottomToolBar.endOfEvaluation();
Demo_Applet.this.enableOrDisableButtons(evaluation instanceof SPARQLEvaluation);
} catch (final Exception e) {
System.err
.println(e);
e.printStackTrace();
}
}
};
bottomToolBar.setEvaluationThread(thread);
thread.start();
final BasicOperator root = (evaluator instanceof BasicIndexRuleEvaluator)? ((BasicIndexRuleEvaluator)evaluator).getRootNode() :((CommonCoreQueryEvaluator<Node>) evaluator).getRootNode();
this.operatorGraphViewer = new Viewer(
new GraphWrapperBasicOperator(
root),
this.prefixInstance,
"Evaluation Demo",
false,
this.webdemo != DEMO_ENUM.ECLIPSE,
bottomToolBar);
bottomToolBar.setOperatorGraphViewer(this.operatorGraphViewer);
} else {
final JTextArea ta_prefixes = new JTextArea();
ta_prefixes.setEditable(false);
ta_prefixes.setFont(new Font("Courier New", Font.PLAIN, 12));
System.out.println("Evaluate query ...");
if(evaluator instanceof CommonCoreQueryEvaluator){
((CommonCoreQueryEvaluator)evaluator).getResultOperator().addApplication(new IterateOneTimeThrough());
}
final long evaluateQuery = evaluator.evaluateQuery();
final int times = xpref.datatypes.IntegerDatatype.getFirstValue("repetitionsOfExecution");
if(times >1){
long compileQueryTime = 0;
long logicalOptimizationTime = 0;
long physicalOptimizationTime = 0;
long evaluateQueryTime = 0;
long totalTime = 0;
final long[] compileQueryTimeArray = new long[times];
final long[] logicalOptimizationTimeArray = new long[times];
final long[] physicalOptimizationTimeArray = new long[times];
final long[] evaluateQueryTimeArray = new long[times];
final long[] totalTimeArray = new long[times];
for (int i = 0; i < times; i++) {
compileQueryTimeArray[i] = evaluator.compileQuery(this.query);
compileQueryTime += compileQueryTimeArray[i];
logicalOptimizationTimeArray[i] = evaluator.logicalOptimization();
logicalOptimizationTime += logicalOptimizationTimeArray[i];
physicalOptimizationTimeArray[i] = evaluator.physicalOptimization();
physicalOptimizationTime += physicalOptimizationTimeArray[i];
if(evaluator instanceof CommonCoreQueryEvaluator){
((CommonCoreQueryEvaluator)evaluator).getResultOperator().addApplication(new IterateOneTimeThrough());
}
evaluateQueryTimeArray[i] = evaluator.evaluateQuery();
evaluateQueryTime += evaluateQueryTimeArray[i];
totalTimeArray[i] = compileQueryTimeArray[i] + logicalOptimizationTimeArray[i] + physicalOptimizationTimeArray[i] + evaluateQueryTimeArray[i];
totalTime += totalTimeArray[i];
}
String result = "Evaluator " + this.cobo_evaluator.getSelectedItem().toString() + "\n\nBuild indices : " + ((double) prepareInputData / 1000);
result += "\n\n(I) Time in seconds to compile query:\nAvg" + QueryEvaluator.toString(compileQueryTimeArray) + "/1000 = " + (((double) compileQueryTime) / times) / 1000;
result += "\nStandard deviation of the sample: " + QueryEvaluator.computeStandardDeviationOfTheSample(compileQueryTimeArray) / 1000;
result += "\nSample standard deviation : " + QueryEvaluator.computeSampleStandardDeviation(compileQueryTimeArray) / 1000;
result += "\n\n(II) Time in seconds used for logical optimization:\nAvg" + QueryEvaluator.toString(logicalOptimizationTimeArray) + "/1000 = " + (((double) logicalOptimizationTime) / times) / 1000;
result += "\nStandard deviation of the sample: " + QueryEvaluator.computeStandardDeviationOfTheSample(logicalOptimizationTimeArray) / 1000;
result += "\nSample standard deviation : " + QueryEvaluator.computeSampleStandardDeviation(logicalOptimizationTimeArray) / 1000;
result += "\n\n(III) Time in seconds used for physical optimization:\nAvg" + QueryEvaluator.toString(physicalOptimizationTimeArray) + "/1000 = " + (((double) physicalOptimizationTime) / times) / 1000;
result += "\nStandard deviation of the sample: " + QueryEvaluator.computeStandardDeviationOfTheSample(physicalOptimizationTimeArray) / 1000;
result += "\nSample standard deviation : " + QueryEvaluator.computeSampleStandardDeviation(physicalOptimizationTimeArray) / 1000;
result += "\n\n(IV) Time in seconds to evaluate query:\nAvg" + QueryEvaluator.toString(evaluateQueryTimeArray) + "/1000 = " + (((double) evaluateQueryTime) / times) / 1000;
result += "\nStandard deviation of the sample: " + QueryEvaluator.computeStandardDeviationOfTheSample(evaluateQueryTimeArray) / 1000;
result += "\nSample standard deviation : " + QueryEvaluator.computeSampleStandardDeviation(evaluateQueryTimeArray) / 1000;
result += "\n\nTotal time in seconds (I)+(II)+(III)+(IV):\nAvg" + QueryEvaluator.toString(totalTimeArray) + "/1000 = " + (((double) totalTime) / times) / 1000;
result += "\nStandard deviation of the sample: " + QueryEvaluator.computeStandardDeviationOfTheSample(totalTimeArray) / 1000;
result += "\nSample standard deviation : " + QueryEvaluator.computeSampleStandardDeviation(totalTimeArray) / 1000;
ta_prefixes.setText(result);
} else {
ta_prefixes.setText("Evaluator "
+ this.cobo_evaluator.getSelectedItem().toString()
+ "\n\nBuild indices : " + ((double) prepareInputData / 1000)
+ "\n\nTotal time query processing: " + ((double) (compileQuery + logicalOptimization + physicalOptimization + evaluateQuery) / 1000)
+ ((evaluator instanceof JenaQueryEvaluator || evaluator instanceof SesameQueryEvaluator) ? ""
: "\n - Compile query : "
+ ((double) compileQuery / 1000)
+ "\n - Logical optimization : "
+ ((double) logicalOptimization / 1000)
+ "\n - Physical optimization: "
+ ((double) physicalOptimization / 1000)
+ "\n - Evaluation : "
+ ((double) evaluateQuery / 1000)));
}
final JFrame frame1 = new JFrame("Execution times in seconds");
frame1.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
frame1.setLocationRelativeTo(Demo_Applet.this);
final JScrollPane scroll = new JScrollPane(ta_prefixes);
frame1.add(scroll);
frame1.pack();
frame1.setVisible(true);
}
} catch (final Throwable t) {
this.dealWithThrowable(t, mode, evaluation instanceof SPARQLEvaluation);
}
} catch (final Throwable t) {
this.dealWithThrowable(t, mode, evaluation instanceof SPARQLEvaluation);
}
evaluation.enableButtons();
} else {
try {
this.prefixInstance = new ViewerPrefix(this.usePrefixes.isTrue());
evaluation.prepareInputData(this.defaultGraphs, new LinkedList<URILiteral>());
System.out.println("Compile query...");
try {
try {
this.debugViewerCreator = evaluation.compileQueryDebugByteArray(this.query);
if (this.debugViewerCreator != null) {
this.ruleApplications = this.debugViewerCreator.getCorrectOperatorGraphRules();
} else {
this.ruleApplications = null;
}
System.out.println("Logical optimization...");
if (this.ruleApplications != null) {
this.ruleApplications.addAll(evaluator.logicalOptimizationDebugByteArray(this.prefixInstance));
} else {
this.ruleApplications = evaluator.logicalOptimizationDebugByteArray(this.prefixInstance);
}
System.out.println("Physical optimization...");
if (this.ruleApplications != null) {
this.ruleApplications.addAll(evaluator.physicalOptimizationDebugByteArray(this.prefixInstance));
} else {
this.ruleApplications = evaluator.physicalOptimizationDebugByteArray(this.prefixInstance);
}
System.out.println("Evaluate query ...");
if (evaluator instanceof CommonCoreQueryEvaluator || evaluator instanceof BasicIndexRuleEvaluator) {
final CollectRIFResult crr = new CollectRIFResult(false);
final Result resultOperator = (evaluator instanceof CommonCoreQueryEvaluator)?((CommonCoreQueryEvaluator<Node>)evaluator).getResultOperator(): ((BasicIndexRuleEvaluator)evaluator).getResultOperator();
resultOperator.addApplication(crr);
evaluator.evaluateQuery();
this.resultQueryEvaluator = crr.getQueryResults();
} else {
this.resultQueryEvaluator = new QueryResult[1];
this.resultQueryEvaluator[0] = evaluator.getResult();