Various fixes related to java examples. Refs #1526.

Don't turn on cursor RAW flag for a JSON dump cursor.

Fixed unpacking a fixed length string: unpack cur position was not being updated.

Fixed packing a fixed length string: String array bounds check was firing.

Fixed unpacking short/int: range check was incorrect.

Added methods to put/get record numbers (e.g. getKeyRecord) in Cursor and AsyncOp.

Remove stray println.
This commit is contained in:
Don Anderson
2015-01-09 09:54:21 -05:00
parent 374e7e9cb7
commit c8bad02860
4 changed files with 102 additions and 7 deletions

View File

@@ -224,6 +224,7 @@ public class PackInputStream {
public String getString()
throws WiredTigerPackingException {
int stringLength = 0;
int skipnull = 0;
format.checkType('S', false);
// Get the length for a fixed length string
if (format.getType() != 'S') {
@@ -234,10 +235,11 @@ public class PackInputStream {
// string length.
for (; valueOff + stringLength < value.length &&
value[valueOff + stringLength] != 0; stringLength++) {}
skipnull = 1;
}
format.consume();
String result = new String(value, valueOff, stringLength);
valueOff += stringLength + 1;
valueOff += stringLength + skipnull;
return result;
}
@@ -249,7 +251,7 @@ public class PackInputStream {
private short unpackShort(boolean signed)
throws WiredTigerPackingException {
long ret = unpackLong(true);
if ((signed && (ret > Short.MAX_VALUE || ret > Short.MIN_VALUE)) ||
if ((signed && (ret > Short.MAX_VALUE || ret < Short.MIN_VALUE)) ||
(!signed && (short)ret < 0)) {
throw new WiredTigerPackingException("Overflow unpacking short.");
}
@@ -264,7 +266,7 @@ public class PackInputStream {
private int unpackInt(boolean signed)
throws WiredTigerPackingException {
long ret = unpackLong(true);
if ((signed && (ret > Integer.MAX_VALUE || ret > Integer.MIN_VALUE)) ||
if ((signed && (ret > Integer.MAX_VALUE || ret < Integer.MIN_VALUE)) ||
(!signed && (int)ret < 0)) {
throw new WiredTigerPackingException("Overflow unpacking integer.");
}