Changeset: 3a19ebf83af6 for monetdb-java URL: http://dev.monetdb.org/hg/monetdb-java?cmd=changeset;node=3a19ebf83af6 Added Files: src/main/java/nl/cwi/monetdb/embedded/env/AbstractConnectionResult.java src/main/java/nl/cwi/monetdb/embedded/env/MonetDBEmbeddedConnection.java src/main/java/nl/cwi/monetdb/embedded/env/MonetDBEmbeddedDatabase.java src/main/java/nl/cwi/monetdb/embedded/env/MonetDBEmbeddedException.java src/main/java/nl/cwi/monetdb/embedded/env/MonetDBEmbeddedInstance.java src/main/java/nl/cwi/monetdb/embedded/mapping/AbstractColumn.java src/main/java/nl/cwi/monetdb/embedded/mapping/AbstractResultTable.java src/main/java/nl/cwi/monetdb/embedded/mapping/MonetDBEmbeddedBlob.java src/main/java/nl/cwi/monetdb/embedded/mapping/MonetDBToJavaMapping.java src/main/java/nl/cwi/monetdb/embedded/resultset/EmbeddedPreparedStatement.java src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSet.java src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetColumn.java src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetRows.java src/main/java/nl/cwi/monetdb/embedded/resultset/UpdateResultSet.java src/main/java/nl/cwi/monetdb/embedded/tables/IMonetDBTableBaseIterator.java src/main/java/nl/cwi/monetdb/embedded/tables/IMonetDBTableIterator.java src/main/java/nl/cwi/monetdb/embedded/tables/IMonetDBTableRemover.java src/main/java/nl/cwi/monetdb/embedded/tables/IMonetDBTableUpdater.java src/main/java/nl/cwi/monetdb/embedded/tables/MonetDBTable.java src/main/java/nl/cwi/monetdb/embedded/tables/MonetDBTableColumn.java src/main/java/nl/cwi/monetdb/embedded/tables/RowIterator.java src/main/java/nl/cwi/monetdb/embedded/tables/RowRemover.java src/main/java/nl/cwi/monetdb/embedded/tables/RowUpdater.java Removed Files: src/main/java/nl/cwi/monetdb/embedded/AbstractColumn.java src/main/java/nl/cwi/monetdb/embedded/AbstractStatementResult.java src/main/java/nl/cwi/monetdb/embedded/EmbeddedPreparedStatement.java src/main/java/nl/cwi/monetdb/embedded/MonetDBEmbeddedBlob.java src/main/java/nl/cwi/monetdb/embedded/MonetDBEmbeddedConnection.java src/main/java/nl/cwi/monetdb/embedded/MonetDBEmbeddedDatabase.java src/main/java/nl/cwi/monetdb/embedded/MonetDBEmbeddedException.java src/main/java/nl/cwi/monetdb/embedded/MonetDBEmbeddedInstance.java src/main/java/nl/cwi/monetdb/embedded/MonetDBToJavaMapping.java src/main/java/nl/cwi/monetdb/embedded/QueryResultSet.java src/main/java/nl/cwi/monetdb/embedded/QueryResultSetColumn.java src/main/java/nl/cwi/monetdb/embedded/QueryResultSetRows.java src/main/java/nl/cwi/monetdb/embedded/UpdateResultSet.java Branch: embedded Log Message:
Arranged code in packages and starting tables integration. diffs (truncated from 1272 to 300 lines): diff --git a/src/main/java/nl/cwi/monetdb/embedded/AbstractStatementResult.java b/src/main/java/nl/cwi/monetdb/embedded/env/AbstractConnectionResult.java rename from src/main/java/nl/cwi/monetdb/embedded/AbstractStatementResult.java rename to src/main/java/nl/cwi/monetdb/embedded/env/AbstractConnectionResult.java --- a/src/main/java/nl/cwi/monetdb/embedded/AbstractStatementResult.java +++ b/src/main/java/nl/cwi/monetdb/embedded/env/AbstractConnectionResult.java @@ -6,23 +6,23 @@ * Copyright 2016 MonetDB B.V. */ -package nl.cwi.monetdb.embedded; +package nl.cwi.monetdb.embedded.env; import java.io.Closeable; /** - * The base class for a query result. + * The base class for a pending statement to a connection. * * @author <a href="mailto:pedro.ferre...@monetdbsolutions.com">Pedro Ferreira</a> */ -public abstract class AbstractStatementResult implements Closeable { +public abstract class AbstractConnectionResult implements Closeable { /** * The corresponding connection of this result. */ private final MonetDBEmbeddedConnection connection; - protected AbstractStatementResult(MonetDBEmbeddedConnection connection) { + protected AbstractConnectionResult(MonetDBEmbeddedConnection connection) { this.connection = connection; } diff --git a/src/main/java/nl/cwi/monetdb/embedded/MonetDBEmbeddedConnection.java b/src/main/java/nl/cwi/monetdb/embedded/env/MonetDBEmbeddedConnection.java rename from src/main/java/nl/cwi/monetdb/embedded/MonetDBEmbeddedConnection.java rename to src/main/java/nl/cwi/monetdb/embedded/env/MonetDBEmbeddedConnection.java --- a/src/main/java/nl/cwi/monetdb/embedded/MonetDBEmbeddedConnection.java +++ b/src/main/java/nl/cwi/monetdb/embedded/env/MonetDBEmbeddedConnection.java @@ -6,7 +6,12 @@ * Copyright 2016 MonetDB B.V. */ -package nl.cwi.monetdb.embedded; +package nl.cwi.monetdb.embedded.env; + +import nl.cwi.monetdb.embedded.resultset.EmbeddedPreparedStatement; +import nl.cwi.monetdb.embedded.resultset.QueryResultSet; +import nl.cwi.monetdb.embedded.resultset.QueryResultSetColumn; +import nl.cwi.monetdb.embedded.resultset.UpdateResultSet; import java.util.HashSet; import java.util.Set; @@ -25,7 +30,7 @@ public class MonetDBEmbeddedConnection { private final long connectionPointer; - private final Set<AbstractStatementResult> results = new HashSet<>(); + private final Set<AbstractConnectionResult> results = new HashSet<>(); protected MonetDBEmbeddedConnection(MonetDBEmbeddedDatabase database, long connectionPointer) { this.database = database; @@ -107,10 +112,10 @@ public class MonetDBEmbeddedConnection { * @return The update result object * @throws MonetDBEmbeddedException If an error in the database occurred */ - public UpdateResultSet sendUpdateAsync(String query) throws MonetDBEmbeddedException { - /* CompletableFuture.supplyAsync(() -> this.sendUpdate(query)); */ + /*public UpdateResultSet sendUpdateAsync(String query) throws MonetDBEmbeddedException { + /CompletableFuture.supplyAsync(() -> this.sendUpdate(query)); throw new UnsupportedOperationException("Must wait for Java 8 :("); - } + }*/ /** * Executes a SQL query with a result set. @@ -135,10 +140,10 @@ public class MonetDBEmbeddedConnection { * @return The query result object * @throws MonetDBEmbeddedException If an error in the database occurred */ - public QueryResultSet sendQueryAsync(String query) throws MonetDBEmbeddedException { - /* CompletableFuture.supplyAsync(() -> this.sendQuery(query)); */ + /*public QueryResultSet sendQueryAsync(String query) throws MonetDBEmbeddedException { + CompletableFuture.supplyAsync(() -> this.sendQuery(query)); throw new UnsupportedOperationException("Must wait for Java 8 :("); - } + }*/ /** * Creates a prepared query statement likewise the PreparedStatement in JDBC. @@ -161,10 +166,10 @@ public class MonetDBEmbeddedConnection { * @return An instance of EmbeddedPreparedStatement * @throws MonetDBEmbeddedException If an error in the database occurred */ - public EmbeddedPreparedStatement createPreparedStatementAsync(String query) throws MonetDBEmbeddedException { - /* CompletableFuture.supplyAsync(() -> this.createPreparedStatement(query)); */ + /*public EmbeddedPreparedStatement createPreparedStatementAsync(String query) throws MonetDBEmbeddedException { + CompletableFuture.supplyAsync(() -> this.createPreparedStatement(query)); throw new UnsupportedOperationException("Must wait for Java 8 :("); - } + }*/ /*public MonetDBTable getMonetDBTable(String schemaName, String tableName) throws MonetDBEmbeddedException { MonetDBTable res = this.getMonetDBTableInternal(schemaName, tableName, this.connectionPointer); @@ -224,7 +229,7 @@ public class MonetDBEmbeddedConnection { * When the database is shuts down, this method is called instead */ protected void closeConnectionImplementation() { - for(AbstractStatementResult res : this.results) { + for(AbstractConnectionResult res : this.results) { res.closeImplementation(); } this.closeConnectionInternal(this.connectionPointer); @@ -241,15 +246,15 @@ public class MonetDBEmbeddedConnection { /** * Shuts down this connection asynchronously. Any pending queries connections will be immediately closed as well. */ - public void closeConnectionAsync() { - /* CompletableFuture.supplyAsync(() -> this.closeConnection()); */ + /*public void closeConnectionAsync() { + CompletableFuture.supplyAsync(() -> this.closeConnection()); throw new UnsupportedOperationException("Must wait for Java 8 :("); - } + }*/ /** * Removes a query result from this connection. */ - protected void removeQueryResult(AbstractStatementResult res) { + protected void removeQueryResult(AbstractConnectionResult res) { this.results.remove(res); } diff --git a/src/main/java/nl/cwi/monetdb/embedded/MonetDBEmbeddedDatabase.java b/src/main/java/nl/cwi/monetdb/embedded/env/MonetDBEmbeddedDatabase.java rename from src/main/java/nl/cwi/monetdb/embedded/MonetDBEmbeddedDatabase.java rename to src/main/java/nl/cwi/monetdb/embedded/env/MonetDBEmbeddedDatabase.java --- a/src/main/java/nl/cwi/monetdb/embedded/MonetDBEmbeddedDatabase.java +++ b/src/main/java/nl/cwi/monetdb/embedded/env/MonetDBEmbeddedDatabase.java @@ -6,7 +6,7 @@ * Copyright 2016 MonetDB B.V. */ -package nl.cwi.monetdb.embedded; +package nl.cwi.monetdb.embedded.env; import java.util.HashSet; import java.util.Set; @@ -48,11 +48,11 @@ public class MonetDBEmbeddedDatabase { * @return A MonetDBEmbeddedDatabase instance * @throws MonetDBEmbeddedException If the JNI library has not been loaded yet or an error in the database occurred */ - public static MonetDBEmbeddedDatabase StartDatabaseAsync(String dbDirectory, boolean silentFlag, + /*public static MonetDBEmbeddedDatabase StartDatabaseAsync(String dbDirectory, boolean silentFlag, boolean sequentialFlag) throws MonetDBEmbeddedException { - /* CompletableFuture.supplyAsync(() -> StartDatabase(dbDirectory, silentFlag, sequentialFlag)); */ + CompletableFuture.supplyAsync(() -> StartDatabase(dbDirectory, silentFlag, sequentialFlag)); throw new UnsupportedOperationException("Must wait for Java 8 :("); - } + }*/ private final String databaseDirectory; @@ -127,10 +127,10 @@ public class MonetDBEmbeddedDatabase { * * @throws MonetDBEmbeddedException If the database is not running or an error in the database occurred */ - public void stopDatabaseAsync() throws MonetDBEmbeddedException { - /* CompletableFuture.supplyAsync(() -> this.stopDatabase()); */ + /*public void stopDatabaseAsync() throws MonetDBEmbeddedException { + CompletableFuture.supplyAsync(() -> this.stopDatabase()); throw new UnsupportedOperationException("Must wait for Java 8 :("); - } + }*/ /** * Creates a connection on the database, set on the default schema. @@ -148,10 +148,10 @@ public class MonetDBEmbeddedDatabase { * @return A MonetDBEmbeddedConnection instance * @throws MonetDBEmbeddedException If the database is not running or an error in the database occurred */ - public MonetDBEmbeddedConnection createConnectionAsync() throws MonetDBEmbeddedException { - /* CompletableFuture.supplyAsync(() -> this.createConnectionInternal()); */ + /*public MonetDBEmbeddedConnection createConnectionAsync() throws MonetDBEmbeddedException { + CompletableFuture.supplyAsync(() -> this.createConnectionInternal()); throw new UnsupportedOperationException("Must wait for Java 8 :("); - } + }*/ /** * Removes a connection from this database. diff --git a/src/main/java/nl/cwi/monetdb/embedded/MonetDBEmbeddedException.java b/src/main/java/nl/cwi/monetdb/embedded/env/MonetDBEmbeddedException.java rename from src/main/java/nl/cwi/monetdb/embedded/MonetDBEmbeddedException.java rename to src/main/java/nl/cwi/monetdb/embedded/env/MonetDBEmbeddedException.java --- a/src/main/java/nl/cwi/monetdb/embedded/MonetDBEmbeddedException.java +++ b/src/main/java/nl/cwi/monetdb/embedded/env/MonetDBEmbeddedException.java @@ -6,7 +6,7 @@ * Copyright 2016 MonetDB B.V. */ -package nl.cwi.monetdb.embedded; +package nl.cwi.monetdb.embedded.env; /** * The exception fired from embedded methods. diff --git a/src/main/java/nl/cwi/monetdb/embedded/MonetDBEmbeddedInstance.java b/src/main/java/nl/cwi/monetdb/embedded/env/MonetDBEmbeddedInstance.java rename from src/main/java/nl/cwi/monetdb/embedded/MonetDBEmbeddedInstance.java rename to src/main/java/nl/cwi/monetdb/embedded/env/MonetDBEmbeddedInstance.java --- a/src/main/java/nl/cwi/monetdb/embedded/MonetDBEmbeddedInstance.java +++ b/src/main/java/nl/cwi/monetdb/embedded/env/MonetDBEmbeddedInstance.java @@ -6,7 +6,7 @@ * Copyright 2016 MonetDB B.V. */ -package nl.cwi.monetdb.embedded; +package nl.cwi.monetdb.embedded.env; /** * The MonetDB's JNI library loader for Java. diff --git a/src/main/java/nl/cwi/monetdb/embedded/AbstractColumn.java b/src/main/java/nl/cwi/monetdb/embedded/mapping/AbstractColumn.java rename from src/main/java/nl/cwi/monetdb/embedded/AbstractColumn.java rename to src/main/java/nl/cwi/monetdb/embedded/mapping/AbstractColumn.java --- a/src/main/java/nl/cwi/monetdb/embedded/AbstractColumn.java +++ b/src/main/java/nl/cwi/monetdb/embedded/mapping/AbstractColumn.java @@ -6,7 +6,9 @@ * Copyright 2016 MonetDB B.V. */ -package nl.cwi.monetdb.embedded; +package nl.cwi.monetdb.embedded.mapping; + +import nl.cwi.monetdb.embedded.mapping.MonetDBToJavaMapping; /** * A single Java representation of a MonetDB column. @@ -14,7 +16,7 @@ package nl.cwi.monetdb.embedded; * @param <T> A Java class mapped to a MonetDB data type * @author <a href="mailto:pedro.ferre...@monetdbsolutions.com">Pedro Ferreira</a> */ -public abstract class AbstractColumn<T> implements Iterable<T> { +public abstract class AbstractColumn<T> { /** * Index on the result set. @@ -22,11 +24,6 @@ public abstract class AbstractColumn<T> protected final int resultSetIndex; /** - * The number of rows in this column. - */ - protected final int numberOfRows; - - /** * The name of the columns in the query result. */ protected final String columnName; @@ -46,10 +43,9 @@ public abstract class AbstractColumn<T> */ protected final int columnScale; - protected AbstractColumn(int resultSetIndex, int numberOfRows, String columnName, String columnType, - int columnDigits, int columnScale) { + protected AbstractColumn(int resultSetIndex, String columnName, String columnType, int columnDigits, + int columnScale) { this.resultSetIndex = resultSetIndex; - this.numberOfRows = numberOfRows; this.columnName = columnName; this.mapping = MonetDBToJavaMapping.GetJavaMappingFromMonetDBString(columnType); this.columnDigits = columnDigits; @@ -57,13 +53,6 @@ public abstract class AbstractColumn<T> } /** - * Get the number of rows in this column. - * - * @return The number of rows - */ - public int getNumberOfRows() { return numberOfRows; } - - /** * Get the result set index of the column. * * @return The index number diff --git a/src/main/java/nl/cwi/monetdb/embedded/mapping/AbstractResultTable.java b/src/main/java/nl/cwi/monetdb/embedded/mapping/AbstractResultTable.java new file mode 100644 --- /dev/null +++ b/src/main/java/nl/cwi/monetdb/embedded/mapping/AbstractResultTable.java @@ -0,0 +1,107 @@ +package nl.cwi.monetdb.embedded.mapping; + +import nl.cwi.monetdb.embedded.env.AbstractConnectionResult; +import nl.cwi.monetdb.embedded.env.MonetDBEmbeddedConnection; + +/** + * Base class for statement results with data + * + * @author <a href="mailto:pedro.ferre...@monetdbsolutions.com">Pedro Ferreira</a> + */ +public abstract class AbstractResultTable extends AbstractConnectionResult { + + public AbstractResultTable(MonetDBEmbeddedConnection connection) { + super(connection); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list