Changeset: 5e58809cfbed for monetdb-java
URL: http://dev.monetdb.org/hg/monetdb-java?cmd=changeset;node=5e58809cfbed
Added Files:
src/main/java/nl/cwi/monetdb/embedded/QueryResultSetRows.java
Removed Files:
src/main/java/nl/cwi/monetdb/embedded/AbstractQueryResultSet.java
src/main/java/nl/cwi/monetdb/embedded/QueryRowsResultSet.java
Modified 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/MonetDBEmbeddedInstance.java
src/main/java/nl/cwi/monetdb/embedded/QueryResultSet.java
src/main/java/nl/cwi/monetdb/embedded/QueryResultSetColumn.java
Branch: embedded
Log Message:
Removed unused class.
diffs (truncated from 666 to 300 lines):
diff --git a/src/main/java/nl/cwi/monetdb/embedded/AbstractColumn.java
b/src/main/java/nl/cwi/monetdb/embedded/AbstractColumn.java
--- a/src/main/java/nl/cwi/monetdb/embedded/AbstractColumn.java
+++ b/src/main/java/nl/cwi/monetdb/embedded/AbstractColumn.java
@@ -17,27 +17,22 @@ package nl.cwi.monetdb.embedded;
public abstract class AbstractColumn<T> implements Iterable<T> {
/**
- * The pointer to the corresponding AbstractQueryResultSet
- */
- protected final long resultSetPointer;
-
- /**
- * Index on the AbstractQueryResultSet
+ * Index on the result set.
*/
protected final int resultSetIndex;
/**
- * The number of rows in this column
+ * The number of rows in this column.
*/
protected final int numberOfRows;
/**
- * The name of the columns in the query result
+ * The name of the columns in the query result.
*/
protected final String columnName;
/**
- * The Mapping between MonetDB type and the Java Class
+ * The Mapping between MonetDB type and the Java Class.
*/
protected final MonetDBToJavaMapping mapping;
@@ -51,9 +46,8 @@ public abstract class AbstractColumn<T>
*/
protected final int columnScale;
- protected AbstractColumn(long resultSetPointer, int resultSetIndex, int
numberOfRows, String columnName,
- String columnType, int columnDigits, int
columnScale) {
- this.resultSetPointer = resultSetPointer;
+ protected AbstractColumn(int resultSetIndex, int numberOfRows, String
columnName, String columnType,
+ int columnDigits, int columnScale) {
this.resultSetIndex = resultSetIndex;
this.numberOfRows = numberOfRows;
this.columnName = columnName;
@@ -63,7 +57,7 @@ public abstract class AbstractColumn<T>
}
/**
- * Get the number of rows in this column
+ * Get the number of rows in this column.
*
* @return The number of rows
*/
diff --git a/src/main/java/nl/cwi/monetdb/embedded/AbstractQueryResultSet.java
b/src/main/java/nl/cwi/monetdb/embedded/AbstractQueryResultSet.java
deleted file mode 100644
--- a/src/main/java/nl/cwi/monetdb/embedded/AbstractQueryResultSet.java
+++ /dev/null
@@ -1,155 +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;
-
-/**
- * The result set from a sendQuery method from a connection.
- *
- * @author <a href="mailto:[email protected]">Pedro
Ferreira</a>
- */
-public abstract class AbstractQueryResultSet extends AbstractStatementResult
implements Iterable {
-
- /**
- * The number of columns in the query result.
- */
- protected final int numberOfColumns;
-
- /**
- * The number of rows in the query result.
- */
- protected final int numberOfRows;
-
- protected AbstractQueryResultSet(MonetDBEmbeddedConnection connection,
long resultPointer, int numberOfColumns,
- int numberOfRows) {
- super(connection, resultPointer);
- this.numberOfColumns = numberOfColumns;
- this.numberOfRows = numberOfRows;
- }
-
- /**
- * Get the query set column values as an Iterable.
- *
- * @return An Iterable over the columns
- */
- protected abstract Iterable<AbstractColumn<?>> getIterable();
-
- /**
- * Returns the number of columns in the result set.
- *
- * @return Number of columns
- */
- public int getNumberOfColumns() {
- return this.numberOfColumns;
- }
-
- /**
- * Returns the number of rows in the result set.
- *
- * @return Number of rows
- */
- public int getNumberOfRows() {
- return this.numberOfRows;
- }
-
- /**
- * Get the columns names as a string array.
- *
- * @return The columns names array
- */
- public String[] getColumnNames() {
- int i = 0;
- String[] result = new String[this.numberOfColumns];
- for(AbstractColumn col : this.getIterable()) {
- result[i] = col.getColumnName();
- }
- return result;
- }
-
- /**
- * Get the columns types as a string array.
- *
- * @return The columns types array
- */
- public String[] getColumnTypes() {
- int i = 0;
- String[] result = new String[this.numberOfColumns];
- for(AbstractColumn col : this.getIterable()) {
- result[i] = col.getColumnType();
- }
- return result;
- }
-
- /**
- * Get the Java mappings as a MonetDBToJavaMapping array.
- *
- * @return The columns MonetDBToJavaMapping array
- */
- public MonetDBToJavaMapping[] getMappings() {
- int i = 0;
- MonetDBToJavaMapping[] result = new
MonetDBToJavaMapping[this.numberOfColumns];
- for(AbstractColumn col : this.getIterable()) {
- result[i] = col.getMapping();
- }
- return result;
- }
-
- /**
- * Get the columns digits as a int array.
- *
- * @return The columns digits array
- */
- public int[] getColumnDigits() {
- int i = 0;
- int[] result = new int[this.numberOfColumns];
- for(AbstractColumn col : this.getIterable()) {
- result[i] = col.getColumnDigits();
- }
- return result;
- }
-
- /**
- * Get the columns scales as a int array.
- *
- * @return The columns scales array
- */
- public int[] getColumnScales() {
- int i = 0;
- int[] result = new int[this.numberOfColumns];
- for(AbstractColumn col : this.getIterable()) {
- result[i] = col.getColumnScale();
- }
- return result;
- }
-
- /**
- * Get a columns' values from the result set by index.
- *
- * @param index QueryResultSetColumn index (starting from 0)
- * @return The columns, {@code null} if index not in bounds
- */
- public abstract <T> QueryResultSetColumn<T> getColumn(int index);
-
- /**
- * Get a columns from the result set by name.
- *
- * @param name QueryResultSetColumn name
- * @return The columns
- */
- public <T> QueryResultSetColumn<T> getColumn(String name) {
- int index = 0;
- for (AbstractColumn col : this.getIterable()) {
- if (col.getColumnName().equals(name)) {
- return this.getColumn(index);
- }
- index++;
- }
- throw new ArrayIndexOutOfBoundsException("The columns is not present
in the result set!");
- }
-
-}
diff --git a/src/main/java/nl/cwi/monetdb/embedded/AbstractStatementResult.java
b/src/main/java/nl/cwi/monetdb/embedded/AbstractStatementResult.java
--- a/src/main/java/nl/cwi/monetdb/embedded/AbstractStatementResult.java
+++ b/src/main/java/nl/cwi/monetdb/embedded/AbstractStatementResult.java
@@ -35,23 +35,21 @@ public abstract class AbstractStatementR
}
/**
- * Get the corresponding connection to this statement result
+ * Get the corresponding connection to this statement result.
*
* @return A MonetDBEmbeddedConnection instance
*/
- public MonetDBEmbeddedConnection getConnection() { return connection;}
+ public MonetDBEmbeddedConnection getConnection() { return connection; }
/**
- * Tells if the connection of this statement result has been closed or not
+ * Tells if the connection of this statement result has been closed or not.
*
* @return A boolean indicating if the statement result has been cleaned
or not
*/
- public boolean isStatementClosed() {
- return this.resultPointer == 0;
- }
+ public boolean isStatementClosed() { return this.resultPointer == 0; }
/**
- * Close the query data so no more new results can be retrieved
+ * Close the query data so no more new results can be retrieved.
*/
@Override
public void close() {
diff --git a/src/main/java/nl/cwi/monetdb/embedded/MonetDBEmbeddedInstance.java
b/src/main/java/nl/cwi/monetdb/embedded/MonetDBEmbeddedInstance.java
--- a/src/main/java/nl/cwi/monetdb/embedded/MonetDBEmbeddedInstance.java
+++ b/src/main/java/nl/cwi/monetdb/embedded/MonetDBEmbeddedInstance.java
@@ -22,7 +22,7 @@ public class MonetDBEmbeddedInstance {
private static final String NATIVE_LIB_NAME = "monetdb5";
/**
- * Tries to load the JNI library with MonetDBLite from the current Java
Classpath
+ * Tries to load the JNI library with MonetDBLite from the current Java
Classpath.
*
* @param libraryName The library name, if null will load the default name
"monetdb5"
* @return A boolean indicating if the load was successful
@@ -39,7 +39,7 @@ public class MonetDBEmbeddedInstance {
}
/**
- * Tries to load the JNI library with MonetDBLite from the given path
+ * Tries to load the JNI library with MonetDBLite from the given path.
*
* @param libraryPath The full library path name
* @return A boolean indicating if the load was successful
@@ -56,7 +56,7 @@ public class MonetDBEmbeddedInstance {
}
/**
- * Check if the JNI library with MonetDBLite has been loaded yet or not
+ * Check if the JNI library with MonetDBLite has been loaded yet or not.
*
* @return A boolean indicating if it is loaded
*/
diff --git a/src/main/java/nl/cwi/monetdb/embedded/QueryResultSet.java
b/src/main/java/nl/cwi/monetdb/embedded/QueryResultSet.java
--- a/src/main/java/nl/cwi/monetdb/embedded/QueryResultSet.java
+++ b/src/main/java/nl/cwi/monetdb/embedded/QueryResultSet.java
@@ -19,28 +19,117 @@ import java.util.ListIterator;
*
* @author <a href="mailto:[email protected]">Pedro
Ferreira</a>
*/
-public class QueryResultSet extends AbstractQueryResultSet {
+public class QueryResultSet extends AbstractStatementResult implements
Iterable {
+
+ /**
+ * The number of columns in the query result.
+ */
+ protected final int numberOfColumns;
+
+ /**
+ * The number of rows in the query result.
+ */
+ protected final int numberOfRows;
/**
- * The query result set columns listing
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list