Changeset: 8a813f5cef1b for monetdb-java
URL: https://dev.monetdb.org/hg/monetdb-java?cmd=changeset;node=8a813f5cef1b
Modified Files:
src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.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/parser/StartOfHeaderParser.java
Branch: default
Log Message:
Extend StartOfHeaderParser with method getNextAsLong() and change type of
tuplecount to long.
diffs (152 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
@@ -2063,7 +2063,7 @@ public class MonetConnection
/** The number of columns in this result */
public final int columncount;
/** The total number of rows this result set has */
- public final int tuplecount;
+ public final long tuplecount;
/** The numbers of rows to retrieve per DataBlockResponse */
private int cacheSize;
/** The table ID of this result */
@@ -2119,7 +2119,7 @@ public class MonetConnection
*/
ResultSetResponse(
final int id,
- final int tuplecount,
+ final long tuplecount,
final int columncount,
final int rowcount,
final MonetConnection.ResponseList parent,
@@ -2156,7 +2156,7 @@ public class MonetConnection
this.id = id;
this.tuplecount = tuplecount;
this.columncount = columncount;
- this.resultBlocks = new DataBlockResponse[(tuplecount /
cacheSize) + 1];
+ this.resultBlocks = new
DataBlockResponse[(int)(tuplecount / cacheSize) + 1];
hlp = new HeaderLineParser(columncount);
@@ -2887,12 +2887,12 @@ public class MonetConnection
case
StartOfHeaderParser.Q_TABLE:
case
StartOfHeaderParser.Q_PREPARE: {
final
int id = sohp.getNextAsInt();
- int
tuplecount = sohp.getNextAsInt(); // TODO implement
StartOfHeaderParser.getNextAsLong() and change tuplecount to long
+ long
tuplecount = sohp.getNextAsLong();
final
int columncount = sohp.getNextAsInt();
final
int rowcount = sohp.getNextAsInt();
//
enforce the maxrows setting
if
(maxrows != 0 && tuplecount > maxrows)
-
tuplecount = (int)maxrows;
+
tuplecount = maxrows;
res =
new ResultSetResponse(id, tuplecount, columncount, rowcount, this, seqnr);
// only
add this resultset to the hashmap if it can possibly have an additional
datablock
if
(rowcount < tuplecount) {
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
@@ -126,7 +126,7 @@ public class MonetPreparedStatement
// cheat a bit to get the ID and the number of columns
id = ((MonetConnection.ResultSetResponse)header).id;
- size = ((MonetConnection.ResultSetResponse)header).tuplecount;
+ size =
(int)((MonetConnection.ResultSetResponse)header).tuplecount;
rscolcnt =
((MonetConnection.ResultSetResponse)header).columncount;
// initialise blank finals
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
@@ -88,7 +88,7 @@ public class MonetResultSet
/** The current line of the buffer split in columns */
protected final TupleLineParser tlp;
/** The number of rows in this ResultSet */
- protected final int tupleCount;
+ protected final long tupleCount;
/** The current position of the cursor for this ResultSet object */
protected int curRow = 0;
@@ -252,13 +252,13 @@ public class MonetResultSet
// first calculate what the JDBC row is
if (row < 0) {
// calculate the negatives...
- row = tupleCount + row + 1;
+ row = (int) tupleCount + row + 1;
}
// now place the row not farther than just before or after the
result
if (row < 0)
row = 0; // before first
else if (row > tupleCount + 1)
- row = tupleCount + 1; // after last
+ row = (int) tupleCount + 1; // after last
// store it
curRow = row;
@@ -285,7 +285,7 @@ public class MonetResultSet
*/
@Override
public void afterLast() throws SQLException {
- absolute(tupleCount + 1);
+ absolute((int)tupleCount + 1);
}
/**
diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetStatement.java
b/src/main/java/nl/cwi/monetdb/jdbc/MonetStatement.java
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetStatement.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetStatement.java
@@ -1544,13 +1544,13 @@ final class MonetVirtualResultSet extend
// first calculate what the JDBC row is
if (row < 0) {
// calculate the negatives...
- row = tupleCount + row + 1;
+ row = (int) tupleCount + row + 1;
}
// now place the row not farther than just before or after the
result
if (row < 0)
row = 0; // before first
else if (row > tupleCount + 1)
- row = tupleCount + 1; // after last
+ row = (int) tupleCount + 1; // after last
// store it
curRow = row;
diff --git a/src/main/java/nl/cwi/monetdb/mcl/parser/StartOfHeaderParser.java
b/src/main/java/nl/cwi/monetdb/mcl/parser/StartOfHeaderParser.java
--- a/src/main/java/nl/cwi/monetdb/mcl/parser/StartOfHeaderParser.java
+++ b/src/main/java/nl/cwi/monetdb/mcl/parser/StartOfHeaderParser.java
@@ -89,13 +89,24 @@ public final class StartOfHeaderParser {
/**
* Returns the next token in the CharBuffer as integer. The value is
* considered to end at the end of the CharBuffer or at a space. If
- * a non-numeric character is encountered an MCLParseException is
- * thrown.
+ * a non-numeric character is encountered an MCLParseException is
thrown.
*
* @return The next token in the CharBuffer as integer
* @throws MCLParseException if no numeric value could be read
*/
public final int getNextAsInt() throws MCLParseException {
+ return (int) getNextAsLong();
+ }
+
+ /**
+ * Returns the next token in the CharBuffer as long integer. The value
+ * is considered to end at the end of the CharBuffer or at a space.
+ * If a non-numeric character is encountered an MCLParseException is
thrown.
+ *
+ * @return The next token in the CharBuffer as long integer
+ * @throws MCLParseException if no numeric value could be read
+ */
+ public final long getNextAsLong() throws MCLParseException {
pos++;
if (!soh.hasRemaining())
throw new MCLParseException("unexpected end of string",
soh.position() - 1);
@@ -111,7 +122,7 @@ public final class StartOfHeaderParser {
chr = soh.get();
}
- int tmp = 0;
+ long tmp = 0;
if (chr >= '0' && chr <= '9') {
tmp = (int)chr - (int)'0';
} else {
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list