[
https://issues.apache.org/jira/browse/DRILL-5601?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16093511#comment-16093511
]
ASF GitHub Bot commented on DRILL-5601:
---------------------------------------
Github user paul-rogers commented on a diff in the pull request:
https://github.com/apache/drill/pull/860#discussion_r128143815
--- Diff:
exec/java-exec/src/test/java/org/apache/drill/test/ClientFixture.java ---
@@ -231,4 +236,120 @@ public void setControls(String controls) {
public RowSetBuilder rowSetBuilder(BatchSchema schema) {
return new RowSetBuilder(allocator(), schema);
}
+
+ /**
+ * Very simple parser for semi-colon separated lists of SQL statements
which
+ * handles quoted semicolons. Drill can execute only one statement at a
time
+ * (without a trailing semi-colon.) This parser breaks up a statement
list
+ * into single statements. Input:<code><pre>
+ * USE a.b;
+ * ALTER SESSION SET `foo` = ";";
+ * SELECT * FROM bar WHERE x = "\";";
+ * </pre><code>Output:
+ * <ul>
+ * <li><tt>USE a.b</tt></li>
+ * <li><tt>ALTER SESSION SET `foo` = ";"</tt></li>
+ * <li><tt>SELECT * FROM bar WHERE x = "\";"</tt></li>
+ */
+
+ public static class StatementParser {
+ private final Reader in;
+ private StringBuilder buf;
+
+ public StatementParser(Reader in) {
+ this.in = in;
+ }
+
+ public String parseNext() throws IOException {
+ boolean eof = false;
+ buf = new StringBuilder();
+ outer:
+ for (;;) {
+ int c = in.read();
+ if (c == -1) {
+ eof = true;
+ break;
+ }
+ if (c == ';') {
+ break;
+ }
+ buf.append((char) c);
+ if (c == '"' || c == '\'' || c == '`') {
+ int quote = c;
+ boolean escape = false;
+ for (;;) {
+ c = in.read();
+ if (c == -1) {
+ break outer;
--- End diff --
OK, so this isn't the world's most robust parser. Is just just trying to do
a bit better than String.split(";")... But fixed.
> Rollup of External Sort memory management fixes
> -----------------------------------------------
>
> Key: DRILL-5601
> URL: https://issues.apache.org/jira/browse/DRILL-5601
> Project: Apache Drill
> Issue Type: Task
> Affects Versions: 1.11.0
> Reporter: Paul Rogers
> Assignee: Paul Rogers
> Fix For: 1.12.0
>
>
> Rollup of a set of specific JIRA entries that all relate to the very
> difficult problem of managing memory within Drill in order for the external
> sort to stay within a memory budget. In general, the fixes relate to better
> estimating memory used by the three ways that Drill allocates vector memory
> (see DRILL-5522) and to predicting the size of vectors that the sort will
> create, to avoid repeated realloc-copy cycles (see DRILL-5594).
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)