You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vxquery.apache.org by ti...@apache.org on 2014/03/17 21:15:32 UTC
git commit: reuse streams for pretty-printing
Repository: incubator-vxquery
Updated Branches:
refs/heads/westmann/prettyprint 04c11094c -> 8cc2837c5
reuse streams for pretty-printing
Project: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/commit/8cc2837c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/tree/8cc2837c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/diff/8cc2837c
Branch: refs/heads/westmann/prettyprint
Commit: 8cc2837c58216885a6ec9d56f1abfd00d9ca3d25
Parents: 04c1109
Author: Till Westmann <we...@gmail.com>
Authored: Mon Mar 17 13:15:12 2014 -0700
Committer: Till Westmann <we...@gmail.com>
Committed: Mon Mar 17 13:15:12 2014 -0700
----------------------------------------------------------------------
.../VXQueryLogicalExpressionPrettyPrintVisitor.java | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/8cc2837c/vxquery-core/src/main/java/org/apache/vxquery/compiler/algebricks/prettyprint/VXQueryLogicalExpressionPrettyPrintVisitor.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/compiler/algebricks/prettyprint/VXQueryLogicalExpressionPrettyPrintVisitor.java b/vxquery-core/src/main/java/org/apache/vxquery/compiler/algebricks/prettyprint/VXQueryLogicalExpressionPrettyPrintVisitor.java
index 65ace85..ccdfb6b 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/compiler/algebricks/prettyprint/VXQueryLogicalExpressionPrettyPrintVisitor.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/compiler/algebricks/prettyprint/VXQueryLogicalExpressionPrettyPrintVisitor.java
@@ -49,12 +49,16 @@ public class VXQueryLogicalExpressionPrettyPrintVisitor implements ILogicalExpre
IntegerPointable ip;
TaggedValuePointable tvp;
XMLSerializer serializer;
+ ByteArrayOutputStream os;
+ PrintStream ps;
public VXQueryLogicalExpressionPrettyPrintVisitor(StaticContext ctx) {
this.ctx = ctx;
this.ip = (IntegerPointable) IntegerPointable.FACTORY.createPointable();
this.tvp = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
this.serializer = new XMLSerializer();
+ this.os = new ByteArrayOutputStream();
+ this.ps = new PrintStream(os);
}
@Override
@@ -63,17 +67,15 @@ public class VXQueryLogicalExpressionPrettyPrintVisitor implements ILogicalExpre
if (value instanceof VXQueryConstantValue) {
VXQueryConstantValue vxqValue = (VXQueryConstantValue) value;
tvp.set(vxqValue.getValue(), 0, vxqValue.getValue().length);
-
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(os);
-
serializer.printTaggedValuePointable(ps, tvp);
-
try {
return vxqValue.getType() + ": " + os.toString("UTF8");
} catch (UnsupportedEncodingException e) {
// print stack trace and return the default
e.printStackTrace();
+ } finally {
+ ps.flush();
+ os.reset();
}
}
return value.toString();