Changeset: 86967be24645 for monetdb-java
URL: http://dev.monetdb.org/hg/monetdb-java?cmd=changeset;node=86967be24645
Added Files:
src/main/java/nl/cwi/monetdb/mcl/protocol/ProtocolException.java
Removed Files:
src/main/java/nl/cwi/monetdb/embedded/mapping/MonetDBEmbeddedBlob.java
src/main/java/nl/cwi/monetdb/mcl/protocol/MCLParseException.java
Modified Files:
src/main/java/nl/cwi/monetdb/embedded/env/MonetDBEmbeddedConnection.java
src/main/java/nl/cwi/monetdb/embedded/mapping/MonetDBRow.java
src/main/java/nl/cwi/monetdb/embedded/mapping/MonetDBToJavaMapping.java
src/main/java/nl/cwi/monetdb/embedded/resultset/AbstractQueryResultSetColumn.java
src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultRowSet.java
src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetBooleanColumn.java
src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetByteColumn.java
src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetDoubleColumn.java
src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetFloatColumn.java
src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetIntColumn.java
src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetLongColumn.java
src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetShortColumn.java
src/main/java/nl/cwi/monetdb/embedded/tables/MonetDBTable.java
src/main/java/nl/cwi/monetdb/embedded/tables/RowIterator.java
src/main/java/nl/cwi/monetdb/jdbc/MonetBlob.java
src/main/java/nl/cwi/monetdb/jdbc/MonetClob.java
src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java
src/main/java/nl/cwi/monetdb/jdbc/MonetDataSource.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/jdbc/types/INET.java
src/main/java/nl/cwi/monetdb/jdbc/types/URL.java
src/main/java/nl/cwi/monetdb/mcl/connection/EmbeddedConnection.java
src/main/java/nl/cwi/monetdb/mcl/connection/MCLException.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/connection/MonetDBLanguage.java
src/main/java/nl/cwi/monetdb/mcl/connection/SendThread.java
src/main/java/nl/cwi/monetdb/mcl/protocol/AbstractProtocol.java
src/main/java/nl/cwi/monetdb/mcl/protocol/ServerResponses.java
src/main/java/nl/cwi/monetdb/mcl/protocol/StarterHeaders.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/OldMapiStartOfHeaderParser.java
src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiTableHeaderParser.java
src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiTupleLineParser.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
Branch: embedded
Log Message:
Ready to start testing the old mapi connection. After passing the tests. The
embedded integration will be very straightforward.
diffs (truncated from 3948 to 300 lines):
diff --git
a/src/main/java/nl/cwi/monetdb/embedded/env/MonetDBEmbeddedConnection.java
b/src/main/java/nl/cwi/monetdb/embedded/env/MonetDBEmbeddedConnection.java
--- a/src/main/java/nl/cwi/monetdb/embedded/env/MonetDBEmbeddedConnection.java
+++ b/src/main/java/nl/cwi/monetdb/embedded/env/MonetDBEmbeddedConnection.java
@@ -215,7 +215,7 @@ public class MonetDBEmbeddedConnection {
/**
* When the database is shuts down, this method is called instead
*/
- public void closeConnectionImplementation() {
+ void closeConnectionImplementation() {
for(AbstractConnectionResult res : this.results.values()) {
res.closeImplementation();
}
@@ -240,7 +240,7 @@ public class MonetDBEmbeddedConnection {
/**
* Removes a query result from this connection.
*/
- protected void removeQueryResult(AbstractConnectionResult res) {
this.results.remove(res.getRandomIdentifier()); }
+ void removeQueryResult(AbstractConnectionResult res) {
this.results.remove(res.getRandomIdentifier()); }
/**
* Internal implementation of sendUpdate.
diff --git
a/src/main/java/nl/cwi/monetdb/embedded/mapping/MonetDBEmbeddedBlob.java
b/src/main/java/nl/cwi/monetdb/embedded/mapping/MonetDBEmbeddedBlob.java
deleted file mode 100644
--- a/src/main/java/nl/cwi/monetdb/embedded/mapping/MonetDBEmbeddedBlob.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * Copyright 2016 MonetDB B.V.
- */
-
-package nl.cwi.monetdb.embedded.mapping;
-
-import java.io.*;
-import java.sql.Blob;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.Collections;
-
-/**
- * A Java representation for the BLOB data type. Added for more efficient data
mapping when fetching from the database.
- *
- * @author <a href="mailto:[email protected]">Pedro
Ferreira</a>
- */
-public class MonetDBEmbeddedBlob implements Serializable, Blob,
Comparable<MonetDBEmbeddedBlob> {
-
- /**
- * The BLOB's content as a Java byte array.
- */
- private byte[] blob;
-
- public MonetDBEmbeddedBlob(byte[] blob) { this.blob = blob; }
-
- /**
- * Get the BLOB content itself,
- *
- * @return A Java byte array containing the BLOB itself
- */
- public byte[] getBlob() { return this.blob; }
-
- /**
- * Overriding the equals method for the byte array.
- */
- @Override
- public boolean equals(Object obj) {
- return obj instanceof MonetDBEmbeddedBlob && Arrays.equals(this.blob,
((MonetDBEmbeddedBlob) obj).getBlob());
- }
-
- /**
- * Overriding the hashCode method for the byte array.
- */
- @Override
- public int hashCode() { return Arrays.hashCode(this.blob); }
-
- /**
- * Overriding the toString method for the byte array.
- */
- @Override
- public String toString() { return Arrays.toString(blob); }
-
- private void checkFreed() throws SQLException {
- if(this.blob == null) {
- throw new SQLException("Thsi blob was freed!");
- }
- }
-
- @Override
- public long length() throws SQLException {
- this.checkFreed();
- return this.blob.length;
- }
-
- @Override
- public byte[] getBytes(long pos, int length) throws SQLException {
- this.checkFreed();
- return Arrays.copyOfRange(this.blob, (int) pos, length);
- }
-
- @Override
- public InputStream getBinaryStream() throws SQLException {
- this.checkFreed();
- return new ByteArrayInputStream(this.blob);
- }
-
- @Override
- public long position(byte[] pattern, long start) throws SQLException {
- this.checkFreed();
- byte[] subArray = Arrays.copyOfRange(this.blob, (int)start,
pattern.length);
- return Collections.indexOfSubList(Arrays.asList(subArray),
Arrays.asList(pattern));
- }
-
- @Override
- public long position(Blob pattern, long start) throws SQLException {
- this.checkFreed();
- byte[] subArray = Arrays.copyOfRange(this.blob, (int)start, (int)
pattern.length());
- return Collections.indexOfSubList(Arrays.asList(subArray),
Arrays.asList(pattern.getBytes(0, (int)pattern.length())));
- }
-
- @Override
- public int setBytes(long pos, byte[] bytes) throws SQLException {
- this.checkFreed();
- int newFinalLength = (int) pos + bytes.length;
- byte[] newblob;
-
- if(newFinalLength > this.blob.length) {
- newblob = new byte[newFinalLength];
- } else {
- newblob = this.blob;
- }
- System.arraycopy(bytes, 0, newblob, (int) pos, bytes.length);
- this.blob = newblob;
- return bytes.length;
- }
-
- @Override
- public int setBytes(long pos, byte[] bytes, int offset, int len) throws
SQLException {
- this.checkFreed();
- int newFinalLength = (int) pos + len;
- byte[] newblob;
-
- if(newFinalLength > this.blob.length) {
- newblob = new byte[newFinalLength];
- } else {
- newblob = this.blob;
- }
- System.arraycopy(bytes, offset, newblob, (int) pos, len);
- this.blob = newblob;
- return bytes.length;
- }
-
- @Override
- public OutputStream setBinaryStream(long pos) throws SQLException {
- this.checkFreed();
- ByteArrayOutputStream res = null;
- try {
- res = new ByteArrayOutputStream();
- res.write(this.blob);
- } catch (IOException e) {
- throw new SQLException(e);
- }
- return res;
- }
-
- @Override
- public void truncate(long len) throws SQLException {
- this.checkFreed();
- byte[] newblob = new byte[(int)len];
- System.arraycopy(this.blob, 0, newblob, 0, (int)len);
- this.blob = newblob;
- }
-
- @Override
- public void free() throws SQLException {
- this.blob = null;
- }
-
- @Override
- public InputStream getBinaryStream(long pos, long length) throws
SQLException {
- this.checkFreed();
- return new ByteArrayInputStream(Arrays.copyOfRange(this.blob, (int)
pos, (int) length));
- }
-
- @Override
- public int compareTo(MonetDBEmbeddedBlob o) {
- byte[] first = this.blob, second = o.blob;
- int len = Math.min(first.length, second.length), res = 0;
- for(int i = 0; i < len ; i++) {
- res = res + first[i] - second[i];
- }
- return res;
- }
-}
diff --git a/src/main/java/nl/cwi/monetdb/embedded/mapping/MonetDBRow.java
b/src/main/java/nl/cwi/monetdb/embedded/mapping/MonetDBRow.java
--- a/src/main/java/nl/cwi/monetdb/embedded/mapping/MonetDBRow.java
+++ b/src/main/java/nl/cwi/monetdb/embedded/mapping/MonetDBRow.java
@@ -28,7 +28,7 @@ public class MonetDBRow implements Itera
*/
private Object[] columns;
- protected MonetDBRow(AbstractRowSet originalSet, Object[] columns) {
+ MonetDBRow(AbstractRowSet originalSet, Object[] columns) {
this.originalSet = originalSet;
this.columns = columns;
}
diff --git
a/src/main/java/nl/cwi/monetdb/embedded/mapping/MonetDBToJavaMapping.java
b/src/main/java/nl/cwi/monetdb/embedded/mapping/MonetDBToJavaMapping.java
--- a/src/main/java/nl/cwi/monetdb/embedded/mapping/MonetDBToJavaMapping.java
+++ b/src/main/java/nl/cwi/monetdb/embedded/mapping/MonetDBToJavaMapping.java
@@ -8,6 +8,8 @@
package nl.cwi.monetdb.embedded.mapping;
+import nl.cwi.monetdb.jdbc.MonetBlob;
+
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.Inet4Address;
@@ -31,9 +33,8 @@ public enum MonetDBToJavaMapping {
Tinyint(Byte.class), Smallint(Short.class), Int(Integer.class),
Wrd(Long.class), Bigint(Long.class),
Hugeint(BigInteger.class), Decimal(BigDecimal.class), Real(Float.class),
Double(Double.class),
MonthInterval(Integer.class), SecondInterval(Long.class),
Time(Time.class), TimeTz(Time.class), Date(Date.class),
- Timestamp(Timestamp.class), TimestampTz(Timestamp.class),
Blob(MonetDBEmbeddedBlob.class),
- Geometry(MonetDBEmbeddedBlob.class), GeometryA(MonetDBEmbeddedBlob.class),
URL(URL.class), Inet(Inet4Address.class),
- JSON(MonetDBEmbeddedBlob.class), UUID(UUID.class);
+ Timestamp(Timestamp.class), TimestampTz(Timestamp.class),
Blob(MonetBlob.class), Geometry(String.class),
+ GeometryA(String.class), URL(URL.class), Inet(Inet4Address.class),
JSON(String.class), UUID(UUID.class);
/**
* The mapping between MonetDB data types and enum values.
@@ -98,12 +99,12 @@ public enum MonetDBToJavaMapping {
AppendMappings.put(Date, Date[].class);
AppendMappings.put(Timestamp, Timestamp[].class);
AppendMappings.put(TimestampTz, Timestamp[].class);
- AppendMappings.put(Blob, MonetDBEmbeddedBlob[].class);
- AppendMappings.put(Geometry, MonetDBEmbeddedBlob[].class);
- AppendMappings.put(GeometryA, MonetDBEmbeddedBlob[].class);
+ AppendMappings.put(Blob, MonetBlob[].class);
+ AppendMappings.put(Geometry, String[].class);
+ AppendMappings.put(GeometryA, String[].class);
AppendMappings.put(URL, URL[].class);
AppendMappings.put(Inet, Inet4Address[].class);
- AppendMappings.put(JSON, MonetDBEmbeddedBlob[].class);
+ AppendMappings.put(JSON, String[].class);
AppendMappings.put(UUID, UUID[].class);
}
diff --git
a/src/main/java/nl/cwi/monetdb/embedded/resultset/AbstractQueryResultSetColumn.java
b/src/main/java/nl/cwi/monetdb/embedded/resultset/AbstractQueryResultSetColumn.java
---
a/src/main/java/nl/cwi/monetdb/embedded/resultset/AbstractQueryResultSetColumn.java
+++
b/src/main/java/nl/cwi/monetdb/embedded/resultset/AbstractQueryResultSetColumn.java
@@ -37,12 +37,12 @@ public abstract class AbstractQueryResul
/**
* The index of the first value mapped to a Java class.
*/
- protected int firstRetrievedIndex;
+ private int firstRetrievedIndex;
/**
* The index of the last value mapped to a Java class.
*/
- protected int lastRetrievedIndex;
+ private int lastRetrievedIndex;
protected AbstractQueryResultSetColumn(String columnType, long
tablePointer, int resultSetIndex, String columnName,
int columnDigits, int columnScale,
int numberOfRows) {
@@ -55,6 +55,15 @@ public abstract class AbstractQueryResul
}
/**
+ * Gets the result set index of the column.
+ *
+ * @return The result set index of the column
+ */
+ public int getResultSetIndex() {
+ return resultSetIndex;
+ }
+
+ /**
* Gets the number of rows in this column.
*
* @return The number of rows
diff --git
a/src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultRowSet.java
b/src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultRowSet.java
--- a/src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultRowSet.java
+++ b/src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultRowSet.java
@@ -23,7 +23,7 @@ import java.util.ListIterator;
*/
public class QueryResultRowSet extends AbstractRowSet implements Iterable {
- protected QueryResultRowSet(QueryResultSet queryResultSet,
MonetDBToJavaMapping[] mappings, Object[][] rows) {
+ QueryResultRowSet(QueryResultSet queryResultSet, MonetDBToJavaMapping[]
mappings, Object[][] rows) {
super(queryResultSet, mappings, rows);
}
diff --git
a/src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetBooleanColumn.java
b/src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetBooleanColumn.java
---
a/src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetBooleanColumn.java
+++
b/src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetBooleanColumn.java
@@ -61,7 +61,8 @@ public final class QueryResultSetBoolean
}
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list