asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ti...@apache.org
Subject incubator-asterixdb git commit: fewer copies
Date Tue, 24 May 2016 01:36:00 GMT
Repository: incubator-asterixdb
Updated Branches:
  refs/heads/master 535d86b56 -> 8afce8f68


fewer copies

Change-Id: Ia409bf61140816c8246ab79c11732654613b20bf
Reviewed-on: https://asterix-gerrit.ics.uci.edu/823
Reviewed-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Yingyi Bu <buyingyi@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/commit/8afce8f6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/tree/8afce8f6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/diff/8afce8f6

Branch: refs/heads/master
Commit: 8afce8f6841cfc46a896051b9c5f42785a4cc589
Parents: 535d86b
Author: Till Westmann <tillw@apache.org>
Authored: Fri May 20 07:43:50 2016 -0700
Committer: Till Westmann <tillw@apache.org>
Committed: Mon May 23 18:35:52 2016 -0700

----------------------------------------------------------------------
 .../asterix/lang/aql/parser/FunctionParser.java | 21 +++++++++-----------
 1 file changed, 9 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/8afce8f6/asterixdb/asterix-lang-aql/src/main/java/org/apache/asterix/lang/aql/parser/FunctionParser.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-lang-aql/src/main/java/org/apache/asterix/lang/aql/parser/FunctionParser.java
b/asterixdb/asterix-lang-aql/src/main/java/org/apache/asterix/lang/aql/parser/FunctionParser.java
index 96086a1..1f58d08 100644
--- a/asterixdb/asterix-lang-aql/src/main/java/org/apache/asterix/lang/aql/parser/FunctionParser.java
+++ b/asterixdb/asterix-lang-aql/src/main/java/org/apache/asterix/lang/aql/parser/FunctionParser.java
@@ -19,7 +19,6 @@
 
 package org.apache.asterix.lang.aql.parser;
 
-import java.io.StringReader;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -30,6 +29,7 @@ import org.apache.asterix.lang.common.base.Statement;
 import org.apache.asterix.lang.common.statement.FunctionDecl;
 import org.apache.asterix.lang.common.struct.VarIdentifier;
 import org.apache.asterix.metadata.entities.Function;
+import org.apache.commons.io.input.CharSequenceReader;
 
 public class FunctionParser {
 
@@ -48,23 +48,20 @@ public class FunctionParser {
         builder.append(" use dataverse " + function.getDataverseName() + ";");
         builder.append(" declare function " + function.getName().split("@")[0]);
         builder.append("(");
+        boolean first = true;
         for (String param : params) {
             VarIdentifier varId = new VarIdentifier(param);
             varIdentifiers.add(varId);
+            if (first) {
+                first = false;
+            } else {
+                builder.append(",");
+            }
             builder.append(param);
-            builder.append(",");
         }
-        if (params.size() > 0) {
-            builder.delete(builder.length() - 1, builder.length());
-        }
-        builder.append(")");
-        builder.append("{");
-        builder.append("\n");
-        builder.append(functionBody);
-        builder.append("\n");
-        builder.append("}");
+        builder.append("){\n").append(functionBody).append("\n}");
 
-        IParser parser = parserFactory.createParser(new StringReader(new String(builder)));
+        IParser parser = parserFactory.createParser(new CharSequenceReader(builder));
         List<Statement> statements = parser.parse();
         FunctionDecl decl = (FunctionDecl) statements.get(1);
         return decl;


Mime
View raw message