Changeset: 87ba760038b6 for monetdb-java
URL: http://dev.monetdb.org/hg/monetdb-java?cmd=changeset;node=87ba760038b6
Added Files:
        src/main/java/nl/cwi/monetdb/mcl/protocol/MCLParseException.java
        
src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiTupleLineParser.java
Removed Files:
        src/main/java/nl/cwi/monetdb/mcl/io/AbstractMCLReader.java
        src/main/java/nl/cwi/monetdb/mcl/io/AbstractMCLWriter.java
        src/main/java/nl/cwi/monetdb/mcl/io/BufferedMCLReader.java
        src/main/java/nl/cwi/monetdb/mcl/io/BufferedMCLWriter.java
        src/main/java/nl/cwi/monetdb/mcl/parser/HeaderLineParser.java
        src/main/java/nl/cwi/monetdb/mcl/parser/MCLParseException.java
        src/main/java/nl/cwi/monetdb/mcl/parser/MCLParser.java
        src/main/java/nl/cwi/monetdb/mcl/parser/TupleLineParser.java
        
src/main/java/nl/cwi/monetdb/mcl/parser/socket/SocketTupleLineParser.java
Modified Files:
        src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java
        src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java
        src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java
        src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
        src/main/java/nl/cwi/monetdb/jdbc/MonetStatement.java
        src/main/java/nl/cwi/monetdb/mcl/connection/EmbeddedConnection.java
        src/main/java/nl/cwi/monetdb/mcl/connection/MapiConnection.java
        
src/main/java/nl/cwi/monetdb/mcl/connection/MonetDBConnectionFactory.java
        src/main/java/nl/cwi/monetdb/mcl/protocol/AbstractProtocol.java
        src/main/java/nl/cwi/monetdb/mcl/protocol/embedded/EmbeddedProtocol.java
        src/main/java/nl/cwi/monetdb/mcl/protocol/newmapi/NewMapiProtocol.java
        src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiProtocol.java
        
src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiServerResponseParser.java
        
src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiStartOfHeaderParser.java
        
src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiTableHeaderParser.java
        src/main/java/nl/cwi/monetdb/mcl/responses/DataBlockResponse.java
        src/main/java/nl/cwi/monetdb/mcl/responses/IIncompleteResponse.java
        src/main/java/nl/cwi/monetdb/mcl/responses/ResultSetResponse.java
        src/main/java/nl/cwi/monetdb/mcl/responses/SchemaResponse.java
        src/main/java/nl/cwi/monetdb/merovingian/Control.java
        src/main/java/nl/cwi/monetdb/merovingian/SabaothDB.java
        src/main/java/nl/cwi/monetdb/util/CmdLineOpts.java
        src/main/java/nl/cwi/monetdb/util/Extract.java
        src/main/java/nl/cwi/monetdb/util/SQLExporter.java
        src/main/java/nl/cwi/monetdb/util/SQLRestore.java
        src/main/java/nl/cwi/monetdb/util/XMLExporter.java
Branch: embedded
Log Message:

More cleanup. About to start the tuple conversions.


diffs (truncated from 2715 to 300 lines):

diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java 
b/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java
@@ -5,7 +5,7 @@ import nl.cwi.monetdb.jdbc.types.URL;
 import nl.cwi.monetdb.mcl.connection.MCLException;
 import nl.cwi.monetdb.mcl.connection.Debugger;
 import nl.cwi.monetdb.mcl.connection.MonetDBLanguage;
-import nl.cwi.monetdb.mcl.parser.MCLParseException;
+import nl.cwi.monetdb.mcl.protocol.MCLParseException;
 import nl.cwi.monetdb.mcl.protocol.AbstractProtocol;
 import nl.cwi.monetdb.mcl.protocol.ServerResponses;
 import nl.cwi.monetdb.mcl.responses.*;
@@ -1398,7 +1398,7 @@ public abstract class MonetConnection ex
         /** The sequence number of this ResponseList */
         private final int seqnr;
         /** A list of the Responses associated with the query, in the right 
order */
-        private List<IResponse> responses = new ArrayList<>();
+        private final List<IResponse> responses = new ArrayList<>();
         /** A map of ResultSetResponses, used for additional DataBlockResponse 
mapping */
         private Map<Integer, ResultSetResponse> rsresponses;
         /** The current header returned by getNextResponse() */
@@ -1414,7 +1414,7 @@ public abstract class MonetConnection ex
          * @param rstype the type of result sets to produce
          * @param rsconcur the concurrency of result sets to produce
          */
-        public ResponseList(int cachesize, int maxrows, int rstype, int 
rsconcur) throws SQLException {
+        ResponseList(int cachesize, int maxrows, int rstype, int rsconcur) 
throws SQLException {
             this.cachesize = cachesize;
             this.maxrows = maxrows;
             this.rstype = rstype;
@@ -1439,8 +1439,7 @@ public abstract class MonetConnection ex
         }
 
         /**
-         * Retrieves the next available response, or null if there are
-         * no more responses.
+         * Retrieves the next available response, or null if there are no more 
responses.
          *
          * @return the next Response available or null
          */
@@ -1495,8 +1494,7 @@ public abstract class MonetConnection ex
         }
 
         /**
-         * Closes this ResponseList by closing all the Responses in this
-         * ResponseList.
+         * Closes this ResponseList by closing all the Responses in this 
ResponseList.
          */
         public void close() {
             for (int i = 0; i < responses.size(); i++) {
@@ -1505,10 +1503,9 @@ public abstract class MonetConnection ex
         }
 
         /**
-         * Returns whether this ResponseList has still unclosed
-         * Responses.
+         * Returns whether this ResponseList has still unclosed Responses.
          */
-        public boolean hasUnclosedResponses() {
+        boolean hasUnclosedResponses() {
             for (IResponse r : responses) {
                 if (r != null)
                     return true;
@@ -1517,13 +1514,12 @@ public abstract class MonetConnection ex
         }
 
         /**
-         * Executes the query contained in this ResponseList, and
-         * stores the Responses resulting from this query in this
+         * Executes the query contained in this ResponseList, and stores the 
Responses resulting from this query in this
          * ResponseList.
          *
          * @throws SQLException if a database error occurs
          */
-        public void processQuery(String query) throws SQLException {
+        void processQuery(String query) throws SQLException {
             this.executeQuery(language.getQueryTemplates(), query);
         }
 
@@ -1534,7 +1530,7 @@ public abstract class MonetConnection ex
          * @param query the query to execute
          * @throws SQLException if a database error occurs
          */
-        @SuppressWarnings({"fallthrough", "unchecked"})
+        @SuppressWarnings("fallthrough")
         public void executeQuery(byte[][] templ, String query) throws 
SQLException {
             String error = null;
 
@@ -1555,7 +1551,8 @@ public abstract class MonetConnection ex
                 int size = cachesize == 0 ? DEF_FETCHSIZE : cachesize;
                 size = maxrows != 0 ? Math.min(maxrows, size) : size;
                 // don't do work if it's not needed
-                if (language == MonetDBLanguage.LANG_SQL && size != 
curReplySize && !Arrays.deepEquals(templ, language.getCommandTemplates())) {
+                if (language == MonetDBLanguage.LANG_SQL && size != 
curReplySize &&
+                        !Arrays.deepEquals(templ, 
language.getCommandTemplates())) {
                     sendControlCommand("reply_size " + size);
 
                     // store the reply size after a successful change
@@ -1581,7 +1578,8 @@ public abstract class MonetConnection ex
                 } else {
                     // this is a simple call, which is a lot cheaper and will
                     // always succeed for small queries.
-                    protocol.writeNextCommand((templ[0] == null) ? 
MonetDBLanguage.EmptyString : templ[0], query.getBytes(), (templ[1] == null) ? 
MonetDBLanguage.EmptyString : templ[1]);
+                    protocol.writeNextCommand((templ[0] == null) ? 
MonetDBLanguage.EmptyString : templ[0],
+                            query.getBytes(), (templ[1] == null) ? 
MonetDBLanguage.EmptyString : templ[1]);
                 }
 
                 // go for new results
@@ -1589,8 +1587,7 @@ public abstract class MonetConnection ex
                 ServerResponses nextResponse = 
protocol.getCurrentServerResponseHeader();
                 IResponse res = null;
                 while (nextResponse != ServerResponses.PROMPT) {
-                    // each response should start with a start of header
-                    // (or error)
+                    // each response should start with a start of header (or 
error)
                     switch (nextResponse) {
                         case SOHEADER:
                             // make the response object, and fill it
@@ -1600,8 +1597,9 @@ public abstract class MonetConnection ex
                                         throw new MCLParseException("Q_PARSE 
header not allowed here", 1);
                                     case Q_TABLE:
                                     case Q_PREPARE: {
-                                        res = 
protocol.getNextResultSetResponse(MonetConnection.this, ResponseList.this, 
seqnr);
-                                        ResultSetResponse<?> rsreponse = 
(ResultSetResponse<?>) res;
+                                        res = 
protocol.getNextResultSetResponse(MonetConnection.this,
+                                                ResponseList.this, this.seqnr);
+                                        ResultSetResponse rsreponse = 
(ResultSetResponse) res;
                                         // only add this resultset to
                                         // the hashmap if it can possibly
                                         // have an additional datablock
@@ -1628,7 +1626,7 @@ public abstract class MonetConnection ex
                                         MonetConnection.this.autoCommit = 
isAutoCommit;
                                         break;
                                     case Q_BLOCK: {
-                                        DataBlockResponse<?> next = 
protocol.getNextDatablockResponse(rsresponses);
+                                        DataBlockResponse next = 
protocol.getNextDatablockResponse(rsresponses);
                                         if (next == null) {
                                             error = "M0M12!No 
ResultSetResponse for a DataBlock found";
                                             break;
@@ -1646,16 +1644,14 @@ public abstract class MonetConnection ex
                                 break;
                             }
 
-                            // immediately handle errors after parsing
-                            // the header (res may be null)
+                            // immediately handle errors after parsing the 
header (res may be null)
                             if (error != null) {
                                protocol.waitUntilPrompt();
                                nextResponse = 
protocol.getCurrentServerResponseHeader();
                                break;
                             }
 
-                            // here we have a res object, which
-                            // we can start filling
+                            // here we have a res object, which we can start 
filling
                             if(res instanceof IIncompleteResponse) {
                                 IIncompleteResponse iter = 
(IIncompleteResponse) res;
                                 while (iter.wantsMore()) {
@@ -1663,8 +1659,7 @@ public abstract class MonetConnection ex
                                         protocol.fetchNextResponseData();
                                         
iter.addLine(protocol.getCurrentServerResponseHeader(), 
protocol.getCurrentData());
                                     } catch (MCLParseException ex) {
-                                        // right, some protocol violation,
-                                        // skip the rest of the result
+                                        // right, some protocol violation, 
skip the rest of the result
                                         error = "M0M10!" + ex.getMessage();
                                         protocol.waitUntilPrompt();
                                         nextResponse = 
protocol.getCurrentServerResponseHeader();
@@ -1676,33 +1671,25 @@ public abstract class MonetConnection ex
                             if (error != null) {
                                 break;
                             }
-                            // it is of no use to store
-                            // DataBlockResponses, you never want to
+
+                            // it is of no use to store DataBlockResponses, 
you never want to
                             // retrieve them directly anyway
                             if (!(res instanceof DataBlockResponse)) {
                                 responses.add(res);
                             }
-
-                            // read the next line (can be prompt, new
-                            // result, error, etc.) before we start the
-                            // loop over
+                            // read the next line (can be prompt, new result, 
error, etc.) before we start the loop over
                             protocol.fetchNextResponseData();
                             nextResponse = 
protocol.getCurrentServerResponseHeader();
                             break;
                         case INFO:
                             addWarning(protocol.getRemainingStringLine(1), 
"01000");
-
-                            // read the next line (can be prompt, new
-                            // result, error, etc.) before we start the
-                            // loop over
+                            // read the next line (can be prompt, new result, 
error, etc.) before we start the loop over
                             protocol.fetchNextResponseData();
                             nextResponse = 
protocol.getCurrentServerResponseHeader();
                             break;
                         case ERROR:
-                            // read everything till the prompt (should be
-                            // error) we don't know if we ignore some
-                            // garbage here... but the log should reveal
-                            // that
+                            // read everything till the prompt (should be 
error) we don't know if we ignore some
+                            // garbage here... but the log should reveal that
                             protocol.waitUntilPrompt();
                             nextResponse = 
protocol.getCurrentServerResponseHeader();
                             error = protocol.getRemainingStringLine(1);
diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java 
b/src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java
@@ -331,7 +331,7 @@ final public class MonetDriver implement
         * @return the mathing java.sql.Types constant or java.sql.Types.OTHER 
if
         *         nothing matched on the given string
         */
-       static int getJavaType(String type) {
+       public static int getJavaType(String type) {
                // match the currentColumns type on a java.sql.Types constant
                Integer tp = typeMap.get(type);
                if (tp != null) {
diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java 
b/src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java
@@ -428,8 +428,7 @@ public class MonetPreparedStatement exte
                                        case Types.BIGINT:
                                                String monettype = 
getColumnTypeName(column);
                                                if (monettype != null) {
-                                                       if 
("oid".equals(monettype)
-                                                        || 
"ptr".equals(monettype))
+                                                       if 
("oid".equals(monettype) || "ptr".equals(monettype))
                                                                return false;
                                                }
                                                return true;
diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java 
b/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
@@ -10,8 +10,7 @@ package nl.cwi.monetdb.jdbc;
 
 import nl.cwi.monetdb.jdbc.types.INET;
 import nl.cwi.monetdb.jdbc.types.URL;
-import nl.cwi.monetdb.mcl.parser.MCLParseException;
-import nl.cwi.monetdb.mcl.protocol.AbstractProtocol;
+import nl.cwi.monetdb.mcl.protocol.MCLParseException;
 import nl.cwi.monetdb.mcl.responses.ResultSetResponse;
 
 import java.io.ByteArrayInputStream;
@@ -72,7 +71,6 @@ public class MonetResultSet extends Mone
 
        /** The current position of the cursor for this ResultSet object */
        int curRow = 0;
-
        // a blank final is immutable once assigned in the constructor
        /** A Header to retrieve lines from */
        private final ResultSetResponse header;
@@ -84,10 +82,8 @@ public class MonetResultSet extends Mone
        private final int[] JdbcSQLTypes;
        /** The number of rows in this ResultSet */
        final int tupleCount;
-
        /** The parental Statement object */
        private final Statement statement;
-
        /** The type of this ResultSet (forward or scrollable) */
        private int type = TYPE_FORWARD_ONLY;
        /** The concurrency of this ResultSet (currently only read-only) */
@@ -98,10 +94,9 @@ public class MonetResultSet extends Mone
        private boolean lastReadWasNull = true;
        /** Just a dummy variable to keep store the fetchsize set. */
        private int fetchSize;
+       /** The current row's values */
+       Object[] values;
 
-       final Object[] values;
-
-       private final AbstractProtocol<?> protocol;
        /**
         * Main constructor backed by the given Header.
         *
@@ -123,20 +118,12 @@ public class MonetResultSet extends Mone
                /* if we have a header object, the fetchSize used for this 
result set
                   is the header's cacheSize */
                this.fetchSize = header.getCacheSize();
-               // well there is only one supported concurrency, so we don't 
have to
-               // bother about that
-
-               // throws SQLException on getters of Header, so we find out 
immediately
-               // if an error occurred for this query
+               // well there is only one supported concurrency, so we don't 
have to bother about that
+               // throws SQLException on getters of Header, so we find out 
immediately if an error occurred for this query
+               this.tupleCount = header.getTuplecount();
                this.columns = header.getNames();
                this.types = header.getTypes();
-               this.tupleCount = header.getTuplecount();
-
-               // create result array
-               this.protocol = 
((MonetConnection)statement.getConnection()).getProtocol();
-               this.values = new Object[this.columns.length];
-               this.JdbcSQLTypes = new int[types.length];
-               populateJdbcSQLtypesArray();
+               this.JdbcSQLTypes = header.getJdbcSQLTypes();
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to