annotate src/main/java/org/monetdb/mcl/parser/HeaderLineParser.java @ 665:8f7d51c478df

Improved implementation of methods ResultSetMetaData.getPrecision() and ResultSetMetaData.getScale(). They now use the Mapi header information as returned by the server when "sizeheader 1" is enabled. This "typesizes" header returns more accurate precision and scale values for columns of types DECIMAL, NUMERIC, CHAR, VARCHAR, CLOB, JSON, URL and BLOB. Also we no longer have to generate and execute a meta data query to retrieve this information, so it also is faster now.
author Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
date Thu, 20 Oct 2022 18:09:07 +0200 (2022-10-20)
parents 6aa38e8c0f2d
children bdeabbd46ec6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1 /*
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2 * This Source Code Form is subject to the terms of the Mozilla Public
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
5 *
610
6aa38e8c0f2d Updated Copyright year.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 406
diff changeset
6 * Copyright 1997 - July 2008 CWI, August 2008 - 2022 MonetDB B.V.
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
7 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
8
391
f523727db392 Moved Java classes from packages starting with nl.cwi.monetdb.* to package org.monetdb.*
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 373
diff changeset
9 package org.monetdb.mcl.parser;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
10
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
11
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
12 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
13 * The HeaderLineParser is a generic MCLParser that extracts values from
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
14 * a metadata header in the MCL protocol either as string or integer
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
15 * values.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
16 *
194
1296dbcc4958 Resolved javadoc many errors and warnings, such as:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 180
diff changeset
17 * @author Fabian Groffen
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
18 */
297
bb273e9c7e09 Add "final" keyword to classes, method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 261
diff changeset
19 public final class HeaderLineParser extends MCLParser {
203
c6abd650aeb4 Reduce memory consumption in TupleLineParser which is a subclass of MCLParser.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 200
diff changeset
20 /* types of meta data supported by MCL protocol */
c6abd650aeb4 Reduce memory consumption in TupleLineParser which is a subclass of MCLParser.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 200
diff changeset
21 public final static int NAME = 1; // name of column
c6abd650aeb4 Reduce memory consumption in TupleLineParser which is a subclass of MCLParser.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 200
diff changeset
22 public final static int LENGTH = 2;
c6abd650aeb4 Reduce memory consumption in TupleLineParser which is a subclass of MCLParser.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 200
diff changeset
23 public final static int TABLE = 3; // may include the schema name
c6abd650aeb4 Reduce memory consumption in TupleLineParser which is a subclass of MCLParser.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 200
diff changeset
24 public final static int TYPE = 4;
665
8f7d51c478df Improved implementation of methods ResultSetMetaData.getPrecision() and ResultSetMetaData.getScale().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 610
diff changeset
25 public final static int TYPESIZES = 5; // precision and scale
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
26
203
c6abd650aeb4 Reduce memory consumption in TupleLineParser which is a subclass of MCLParser.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 200
diff changeset
27 /** The int values found while parsing. Public, you may touch it. */
c6abd650aeb4 Reduce memory consumption in TupleLineParser which is a subclass of MCLParser.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 200
diff changeset
28 public final int intValues[];
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
29
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
30 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
31 * Constructs a HeaderLineParser which expects columncount columns.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
32 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
33 * @param columncount the number of columns in the to be parsed string
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
34 */
297
bb273e9c7e09 Add "final" keyword to classes, method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 261
diff changeset
35 public HeaderLineParser(final int columncount) {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
36 super(columncount);
203
c6abd650aeb4 Reduce memory consumption in TupleLineParser which is a subclass of MCLParser.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 200
diff changeset
37 intValues = new int[columncount];
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
38 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
39
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
40 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
41 * Parses the given String source as header line. If source cannot
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
42 * be parsed, an MCLParseException is thrown. The columncount argument
325
0b8eb1df8276 Optimised parsing of Header line data.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 297
diff changeset
43 * given during construction is used for allocation of the backing array.
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
44 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
45 * @param source a String which should be parsed
665
8f7d51c478df Improved implementation of methods ResultSetMetaData.getPrecision() and ResultSetMetaData.getScale().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 610
diff changeset
46 * @return the type of the parsed header line
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
47 * @throws MCLParseException if an error occurs during parsing
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
48 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
49 @Override
297
bb273e9c7e09 Add "final" keyword to classes, method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 261
diff changeset
50 public int parse(final String source) throws MCLParseException {
bb273e9c7e09 Add "final" keyword to classes, method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 261
diff changeset
51 final char[] chrLine = source.toCharArray();
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
52 int len = chrLine.length;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
53 int pos = 0;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
54 boolean foundChar = false;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
55 boolean nameFound = false;
373
f15d2ac35932 Optimize HeaderLineParser.parse() method by replacing regionMatches() calls by direct character array comparisons.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 350
diff changeset
56 int i;
203
c6abd650aeb4 Reduce memory consumption in TupleLineParser which is a subclass of MCLParser.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 200
diff changeset
57
180
fdf4c888d5b7 Small code and layout improvements
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 119
diff changeset
58 // find header name searching from the end of the line
373
f15d2ac35932 Optimize HeaderLineParser.parse() method by replacing regionMatches() calls by direct character array comparisons.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 350
diff changeset
59 for (i = len - 1; i >= 0; i--) {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
60 switch (chrLine[i]) {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
61 case ' ':
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
62 case '\n':
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
63 case '\t':
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
64 case '\r':
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
65 if (!foundChar) {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
66 len = i - 1;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
67 } else {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
68 pos = i + 1;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
69 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
70 break;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
71 case '#':
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
72 // found!
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
73 nameFound = true;
119
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
74 if (pos == 0)
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
75 pos = i + 1;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
76 i = 0; // force the loop to terminate
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
77 break;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
78 default:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
79 foundChar = true;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
80 pos = 0;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
81 break;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
82 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
83 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
84 if (!nameFound)
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
85 throw new MCLParseException("invalid header, no header name found", pos);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
86
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
87 // depending on the name of the header, we continue
203
c6abd650aeb4 Reduce memory consumption in TupleLineParser which is a subclass of MCLParser.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 200
diff changeset
88 int type = 0;
373
f15d2ac35932 Optimize HeaderLineParser.parse() method by replacing regionMatches() calls by direct character array comparisons.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 350
diff changeset
89 i = pos;
325
0b8eb1df8276 Optimised parsing of Header line data.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 297
diff changeset
90 switch (len - pos) {
0b8eb1df8276 Optimised parsing of Header line data.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 297
diff changeset
91 case 4:
373
f15d2ac35932 Optimize HeaderLineParser.parse() method by replacing regionMatches() calls by direct character array comparisons.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 350
diff changeset
92 // source.regionMatches(pos + 1, "name", 0, 4)
f15d2ac35932 Optimize HeaderLineParser.parse() method by replacing regionMatches() calls by direct character array comparisons.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 350
diff changeset
93 if (chrLine[i] == 'n' && chrLine[++i] == 'a' && chrLine[++i] == 'm' && chrLine[++i] == 'e') {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
94 getValues(chrLine, 2, pos - 3);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
95 type = NAME;
325
0b8eb1df8276 Optimised parsing of Header line data.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 297
diff changeset
96 } else
373
f15d2ac35932 Optimize HeaderLineParser.parse() method by replacing regionMatches() calls by direct character array comparisons.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 350
diff changeset
97 // source.regionMatches(pos + 1, "type", 0, 4)
f15d2ac35932 Optimize HeaderLineParser.parse() method by replacing regionMatches() calls by direct character array comparisons.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 350
diff changeset
98 if (chrLine[i] == 't' && chrLine[++i] == 'y' && chrLine[++i] == 'p' && chrLine[++i] == 'e') {
325
0b8eb1df8276 Optimised parsing of Header line data.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 297
diff changeset
99 getValues(chrLine, 2, pos - 3);
0b8eb1df8276 Optimised parsing of Header line data.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 297
diff changeset
100 type = TYPE;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
101 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
102 break;
325
0b8eb1df8276 Optimised parsing of Header line data.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 297
diff changeset
103 case 6:
373
f15d2ac35932 Optimize HeaderLineParser.parse() method by replacing regionMatches() calls by direct character array comparisons.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 350
diff changeset
104 // source.regionMatches(pos + 1, "length", 0, 6)
f15d2ac35932 Optimize HeaderLineParser.parse() method by replacing regionMatches() calls by direct character array comparisons.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 350
diff changeset
105 if (chrLine[ i ] == 'l' && chrLine[++i] == 'e' && chrLine[++i] == 'n' && chrLine[++i] == 'g'
f15d2ac35932 Optimize HeaderLineParser.parse() method by replacing regionMatches() calls by direct character array comparisons.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 350
diff changeset
106 && chrLine[++i] == 't' && chrLine[++i] == 'h') {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
107 getIntValues(chrLine, 2, pos - 3);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
108 type = LENGTH;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
109 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
110 break;
665
8f7d51c478df Improved implementation of methods ResultSetMetaData.getPrecision() and ResultSetMetaData.getScale().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 610
diff changeset
111 case 9:
8f7d51c478df Improved implementation of methods ResultSetMetaData.getPrecision() and ResultSetMetaData.getScale().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 610
diff changeset
112 // System.out.println("In HeaderLineParser.parse() case 9: source line = " + source);
8f7d51c478df Improved implementation of methods ResultSetMetaData.getPrecision() and ResultSetMetaData.getScale().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 610
diff changeset
113 // source.regionMatches(pos + 1, "typesizes", 0, 9)
8f7d51c478df Improved implementation of methods ResultSetMetaData.getPrecision() and ResultSetMetaData.getScale().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 610
diff changeset
114 if (chrLine[ i ] == 't' && chrLine[++i] == 'y' && chrLine[++i] == 'p' && chrLine[++i] == 'e'
8f7d51c478df Improved implementation of methods ResultSetMetaData.getPrecision() and ResultSetMetaData.getScale().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 610
diff changeset
115 && chrLine[++i] == 's' && chrLine[++i] == 'i' && chrLine[++i] == 'z' && chrLine[++i] == 'e' && chrLine[++i] == 's') {
8f7d51c478df Improved implementation of methods ResultSetMetaData.getPrecision() and ResultSetMetaData.getScale().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 610
diff changeset
116 getValues(chrLine, 2, pos - 3); /* these contain precision and scale values (separated by a space), so read them as strings */
8f7d51c478df Improved implementation of methods ResultSetMetaData.getPrecision() and ResultSetMetaData.getScale().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 610
diff changeset
117 type = TYPESIZES;
8f7d51c478df Improved implementation of methods ResultSetMetaData.getPrecision() and ResultSetMetaData.getScale().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 610
diff changeset
118 }
8f7d51c478df Improved implementation of methods ResultSetMetaData.getPrecision() and ResultSetMetaData.getScale().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 610
diff changeset
119 break;
325
0b8eb1df8276 Optimised parsing of Header line data.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 297
diff changeset
120 case 10:
373
f15d2ac35932 Optimize HeaderLineParser.parse() method by replacing regionMatches() calls by direct character array comparisons.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 350
diff changeset
121 // source.regionMatches(pos + 1, "table_name", 0, 10)
f15d2ac35932 Optimize HeaderLineParser.parse() method by replacing regionMatches() calls by direct character array comparisons.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 350
diff changeset
122 if (chrLine[ i ] == 't' && chrLine[++i] == 'a' && chrLine[++i] == 'b' && chrLine[++i] == 'l' && chrLine[++i] == 'e'
f15d2ac35932 Optimize HeaderLineParser.parse() method by replacing regionMatches() calls by direct character array comparisons.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 350
diff changeset
123 && chrLine[++i] == '_' && chrLine[++i] == 'n' && chrLine[++i] == 'a' && chrLine[++i] == 'm' && chrLine[++i] == 'e') {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
124 getValues(chrLine, 2, pos - 3);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
125 type = TABLE;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
126 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
127 break;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
128 default:
180
fdf4c888d5b7 Small code and layout improvements
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 119
diff changeset
129 throw new MCLParseException("unknown header: " + (new String(chrLine, pos, len - pos)));
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
130 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
131
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
132 // adjust colno
325
0b8eb1df8276 Optimised parsing of Header line data.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 297
diff changeset
133 colnr = 0;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
134
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
135 return type;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
136 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
137
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
138 /**
297
bb273e9c7e09 Add "final" keyword to classes, method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 261
diff changeset
139 * Fills an array of Strings containing the values between
104
839ffec1d36d Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
140 * ',\t' separators.
119
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
141 *
104
839ffec1d36d Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
142 * As of Oct2014-SP1 release MAPI adds double quotes around names when
119
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
143 * the name contains a comma or a tab or a space or a # or " or \ escape character.
104
839ffec1d36d Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
144 * See issue: https://www.monetdb.org/bugzilla/show_bug.cgi?id=3616
839ffec1d36d Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
145 * If the parsed name string part has a " as first and last character,
839ffec1d36d Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
146 * we remove those added double quotes here.
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
147 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
148 * @param chrLine a character array holding the input data
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
149 * @param start where the relevant data starts
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
150 * @param stop where the relevant data stops
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
151 */
297
bb273e9c7e09 Add "final" keyword to classes, method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 261
diff changeset
152 private final void getValues(final char[] chrLine, int start, final int stop) {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
153 int elem = 0;
119
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
154 boolean inString = false, escaped = false;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
155
119
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
156 for (int i = start; i < stop; i++) {
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
157 switch(chrLine[i]) {
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
158 case '\\':
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
159 escaped = !escaped;
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
160 break;
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
161 case '"':
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
162 /**
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
163 * If all strings are wrapped between two quotes, a \" can
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
164 * never exist outside a string. Thus if we believe that we
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
165 * are not within a string, we can safely assume we're about
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
166 * to enter a string if we find a quote.
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
167 * If we are in a string we should stop being in a string if
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
168 * we find a quote which is not prefixed by a \, for that
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
169 * would be an escaped quote. However, a nasty situation can
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
170 * occur where the string is like "test \\" as obvious, a
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
171 * test for a \ in front of a " doesn't hold here for all
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
172 * cases. Because "test \\\"" can exist as well, we need to
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
173 * know if a quote is prefixed by an escaping slash or not.
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
174 */
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
175 if (!inString) {
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
176 inString = true;
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
177 } else if (!escaped) {
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
178 inString = false;
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
179 }
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
180 // reset escaped flag
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
181 escaped = false;
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
182 break;
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
183 case ',':
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
184 if (!inString && chrLine[i + 1] == '\t') {
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
185 // we found the field separator
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
186 if (chrLine[start] == '"')
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
187 start++; // skip leading double quote
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
188 if (elem < values.length) {
325
0b8eb1df8276 Optimised parsing of Header line data.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 297
diff changeset
189 // TODO: also deal with escape characters as done in TupleLineParser.parse()
119
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
190 values[elem++] = new String(chrLine, start, i - (chrLine[i - 1] == '"' ? 1 : 0) - start);
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
191 }
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
192 i++;
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
193 start = i + 1; // reset start for the next name, skipping the field separator (a comma and tab)
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
194 }
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
195 // reset escaped flag
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
196 escaped = false;
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
197 break;
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
198 default:
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
199 escaped = false;
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
200 break;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
201 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
202 }
104
839ffec1d36d Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
203 // add the left over part (last column)
839ffec1d36d Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
204 if (chrLine[start] == '"')
839ffec1d36d Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
205 start++; // skip leading double quote
119
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
206 if (elem < values.length)
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
207 values[elem] = new String(chrLine, start, stop - (chrLine[stop - 1] == '"' ? 1 : 0) - start);
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
208 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
209
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
210 /**
297
bb273e9c7e09 Add "final" keyword to classes, method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 261
diff changeset
211 * Fills an array of ints containing the values between
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
212 * ',\t' separators.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
213 *
116
04c535b05c52 Fixed negative number parsing on the StartOfHeaderParser
Pedro Ferreira <pedro.ferreira@monetdbsolutions.com>
parents: 104
diff changeset
214 * Feb2017 note - This integer parser doesn't have to parse negative
04c535b05c52 Fixed negative number parsing on the StartOfHeaderParser
Pedro Ferreira <pedro.ferreira@monetdbsolutions.com>
parents: 104
diff changeset
215 * numbers, because it is only used to parse column lengths
119
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
216 * which are always greater than 0.
116
04c535b05c52 Fixed negative number parsing on the StartOfHeaderParser
Pedro Ferreira <pedro.ferreira@monetdbsolutions.com>
parents: 104
diff changeset
217 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
218 * @param chrLine a character array holding the input data
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
219 * @param start where the relevant data starts
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
220 * @param stop where the relevant data stops
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
221 */
297
bb273e9c7e09 Add "final" keyword to classes, method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 261
diff changeset
222 private final void getIntValues(final char[] chrLine, final int start, final int stop) throws MCLParseException {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
223 int elem = 0;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
224 int tmp = 0;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
225
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
226 for (int i = start; i < stop; i++) {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
227 if (chrLine[i] == ',' && chrLine[i + 1] == '\t') {
325
0b8eb1df8276 Optimised parsing of Header line data.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 297
diff changeset
228 if (elem < intValues.length) {
0b8eb1df8276 Optimised parsing of Header line data.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 297
diff changeset
229 intValues[elem++] = tmp;
0b8eb1df8276 Optimised parsing of Header line data.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 297
diff changeset
230 }
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
231 tmp = 0;
297
bb273e9c7e09 Add "final" keyword to classes, method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 261
diff changeset
232 i++;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
233 } else {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
234 // note: don't use Character.isDigit() here, because
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
235 // we only want ISO-LATIN-1 digits
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
236 if (chrLine[i] >= '0' && chrLine[i] <= '9') {
119
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
237 tmp *= 10;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
238 tmp += (int)chrLine[i] - (int)'0';
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
239 } else {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
240 throw new MCLParseException("expected a digit in " + new String(chrLine) + " at " + i);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
241 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
242 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
243 }
119
1ea2ee3b946c Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 117
diff changeset
244 // add the left over part (last column)
325
0b8eb1df8276 Optimised parsing of Header line data.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 297
diff changeset
245 if (elem < intValues.length)
0b8eb1df8276 Optimised parsing of Header line data.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 297
diff changeset
246 intValues[elem] = tmp;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
247 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
248 }