Repository: vxquery
Updated Branches:
  refs/heads/master 44717b267 -> ef31a814c


Fix for issue VXQUERY-177.


Project: http://git-wip-us.apache.org/repos/asf/vxquery/repo
Commit: http://git-wip-us.apache.org/repos/asf/vxquery/commit/a849cdc0
Tree: http://git-wip-us.apache.org/repos/asf/vxquery/tree/a849cdc0
Diff: http://git-wip-us.apache.org/repos/asf/vxquery/diff/a849cdc0

Branch: refs/heads/master
Commit: a849cdc025799b196e1942e2700afb18261d5011
Parents: 44717b2
Author: Preston Carman <[email protected]>
Authored: Fri Sep 11 11:50:08 2015 -0700
Committer: Preston Carman <[email protected]>
Committed: Fri Sep 11 11:50:08 2015 -0700

----------------------------------------------------------------------
 .../main/java/org/apache/vxquery/cli/VXQuery.java  | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/vxquery/blob/a849cdc0/vxquery-cli/src/main/java/org/apache/vxquery/cli/VXQuery.java
----------------------------------------------------------------------
diff --git a/vxquery-cli/src/main/java/org/apache/vxquery/cli/VXQuery.java 
b/vxquery-cli/src/main/java/org/apache/vxquery/cli/VXQuery.java
index cf21c76..2a48f84 100644
--- a/vxquery-cli/src/main/java/org/apache/vxquery/cli/VXQuery.java
+++ b/vxquery-cli/src/main/java/org/apache/vxquery/cli/VXQuery.java
@@ -15,7 +15,9 @@
 package org.apache.vxquery.cli;
 
 import java.io.File;
+import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.OutputStream;
 import java.io.PrintWriter;
 import java.io.StringReader;
 import java.nio.ByteBuffer;
@@ -115,8 +117,9 @@ public class VXQuery {
             timingMessage("Execution time: " + (end.getTime() - 
start.getTime()) + " ms");
             if (opts.repeatExec > opts.timingIgnoreQueries) {
                 long mean = sumTiming / (opts.repeatExec - 
opts.timingIgnoreQueries);
-                double sd = Math.sqrt(sumSquaredTiming
-                        / (opts.repeatExec - new 
Integer(opts.timingIgnoreQueries).doubleValue()) - mean * mean);
+                double sd = Math
+                        .sqrt(sumSquaredTiming / (opts.repeatExec - new 
Integer(opts.timingIgnoreQueries).doubleValue())
+                                - mean * mean);
                 timingMessage("Average execution time: " + mean + " ms");
                 timingMessage("Standard deviation: " + String.format("%.4f", 
sd));
                 timingMessage("Coefficient of variation: " + 
String.format("%.4f", (sd / mean)));
@@ -199,7 +202,12 @@ public class VXQuery {
             DynamicContext dCtx = new 
DynamicContextImpl(module.getModuleContext());
             js.setGlobalJobDataFactory(new 
VXQueryGlobalDataFactory(dCtx.createFactory()));
 
-            PrintWriter writer = new PrintWriter(System.out, true);
+            OutputStream resultWriter = System.out;
+            if (opts.resultFile != null) {
+                resultWriter = new FileOutputStream(new File(opts.resultFile));
+            }
+
+            PrintWriter writer = new PrintWriter(resultWriter, true);
             // Repeat execution for number of times provided in -repeatexec 
argument
             for (int i = 0; i < opts.repeatExec; ++i) {
                 start = opts.timing ? new Date() : null;
@@ -401,6 +409,9 @@ public class VXQuery {
         @Option(name = "-repeatexec", usage = "Number of times to repeat 
execution.")
         private int repeatExec = 1;
 
+        @Option(name = "-result-file", usage = "File path to save the query 
result.")
+        private String resultFile = null;
+
         @Option(name = "-timing", usage = "Produce timing information.")
         private boolean timing;
 

Reply via email to