# HG changeset patch # User Martin van Dinther <martin.van.dinther@monetdbsolutions.com> # Date 1518703610 -3600 # Node ID c6abd650aeb4e374671de488b193f7744728d458 # Parent 43aca15634600bd7a4a89f3e9f0e004ce142426a Reduce memory consumption in TupleLineParser which is a subclass of MCLParser. The intValues[] is only used and needed in the HeaderLineParser, hence moved it from superclass MCLParser to subclass HeaderLineParser. diff --git a/src/main/java/nl/cwi/monetdb/mcl/parser/HeaderLineParser.java b/src/main/java/nl/cwi/monetdb/mcl/parser/HeaderLineParser.java --- a/src/main/java/nl/cwi/monetdb/mcl/parser/HeaderLineParser.java +++ b/src/main/java/nl/cwi/monetdb/mcl/parser/HeaderLineParser.java @@ -17,12 +17,14 @@ package nl.cwi.monetdb.mcl.parser; * @author Fabian Groffen */ public class HeaderLineParser extends MCLParser { - private int type; + /* types of meta data supported by MCL protocol */ + public final static int NAME = 1; // name of column + public final static int LENGTH = 2; + public final static int TABLE = 3; // may include the schema name + public final static int TYPE = 4; - public final static int NAME = 1; - public final static int LENGTH = 2; - public final static int TABLE = 3; - public final static int TYPE = 4; + /** The int values found while parsing. Public, you may touch it. */ + public final int intValues[]; /** * Constructs a HeaderLineParser which expects columncount columns. @@ -31,6 +33,7 @@ public class HeaderLineParser extends MC */ public HeaderLineParser(int columncount) { super(columncount); + intValues = new int[columncount]; } /** @@ -53,6 +56,7 @@ public class HeaderLineParser extends MC int pos = 0; boolean foundChar = false; boolean nameFound = false; + // find header name searching from the end of the line for (int i = len - 1; i >= 0; i--) { switch (chrLine[i]) { @@ -83,6 +87,7 @@ public class HeaderLineParser extends MC throw new MCLParseException("invalid header, no header name found", pos); // depending on the name of the header, we continue + int type = 0; switch (chrLine[pos]) { case 'n': if (len - pos == 4 && source.regionMatches(pos + 1, "name", 1, 3)) { diff --git a/src/main/java/nl/cwi/monetdb/mcl/parser/MCLParser.java b/src/main/java/nl/cwi/monetdb/mcl/parser/MCLParser.java --- a/src/main/java/nl/cwi/monetdb/mcl/parser/MCLParser.java +++ b/src/main/java/nl/cwi/monetdb/mcl/parser/MCLParser.java @@ -26,9 +26,7 @@ package nl.cwi.monetdb.mcl.parser; public abstract class MCLParser { /** The String values found while parsing. Public, you may touch it. */ public final String values[]; - /** The int values found while parsing. Public, you may touch it. */ - public final int intValues[]; - private int colnr; + protected int colnr; /** * Creates an MCLParser targetted at a given number of field values. @@ -39,7 +37,6 @@ public abstract class MCLParser { */ protected MCLParser(int capacity) { values = new String[capacity]; - intValues = new int[capacity]; } /** @@ -51,7 +48,6 @@ public abstract class MCLParser { * @throws MCLParseException if source cannot be (fully) parsed by * this parser * @see #next() - * @see #nextInt() * @see #hasNext() */ abstract public int parse(String source) throws MCLParseException; @@ -70,7 +66,6 @@ public abstract class MCLParser { * @return true if the next call to next() or nextInt() is bound to * succeed * @see #next() - * @see #nextInt() */ final public boolean hasNext() { return colnr < values.length; @@ -83,23 +78,9 @@ public abstract class MCLParser { * determine if the call to next() will succeed. * * @return the current field value - * @see #nextInt() * @see #hasNext() */ final public String next() { return values[colnr++]; } - - /** - * Returns the current field value as integer, and advances the - * field counter to the next value. This method has the same - * characteristics as the next() method, apart from returning the - * field value as an integer. - * - * @return the current field value as integer - * @see #next() - */ - final public int nextInt() { - return intValues[colnr++]; - } }