diff options
author | Michael Cahill <michael.cahill@wiredtiger.com> | 2015-01-17 07:33:37 +1100 |
---|---|---|
committer | Michael Cahill <michael.cahill@wiredtiger.com> | 2015-01-17 07:33:37 +1100 |
commit | a30db47d03f48220553922422950273a14118160 (patch) | |
tree | 745e1c364a5610f6de3ed21cbef2f7e28f75324c /lang | |
parent | 76addf73581c53f24462ab5fd724048aec36eaf3 (diff) | |
parent | 38b6b25fb7e825b234a17ad1fb9269c5f48cb129 (diff) | |
download | mongo-a30db47d03f48220553922422950273a14118160.tar.gz |
Merge branch 'develop' into cursor-equal
Conflicts:
lang/python/wiredtiger.i
Diffstat (limited to 'lang')
-rw-r--r-- | lang/java/src/com/wiredtiger/db/PackFormatInputStream.java | 1 | ||||
-rw-r--r-- | lang/java/src/com/wiredtiger/db/PackInputStream.java | 8 | ||||
-rw-r--r-- | lang/java/src/com/wiredtiger/db/PackOutputStream.java | 7 | ||||
-rw-r--r-- | lang/java/wiredtiger.i | 93 | ||||
-rw-r--r-- | lang/python/wiredtiger.i | 15 |
5 files changed, 114 insertions, 10 deletions
diff --git a/lang/java/src/com/wiredtiger/db/PackFormatInputStream.java b/lang/java/src/com/wiredtiger/db/PackFormatInputStream.java index c9d1c43d32d..c53938d0a58 100644 --- a/lang/java/src/com/wiredtiger/db/PackFormatInputStream.java +++ b/lang/java/src/com/wiredtiger/db/PackFormatInputStream.java @@ -85,7 +85,6 @@ public class PackFormatInputStream { protected char getType() throws WiredTigerPackingException { if (formatOff >= format.length()) { - System.err.println("Raw format is: " + format); throw new WiredTigerPackingException( "No more fields in format."); } diff --git a/lang/java/src/com/wiredtiger/db/PackInputStream.java b/lang/java/src/com/wiredtiger/db/PackInputStream.java index 75bdb3119a9..a49b2e01f17 100644 --- a/lang/java/src/com/wiredtiger/db/PackInputStream.java +++ b/lang/java/src/com/wiredtiger/db/PackInputStream.java @@ -225,6 +225,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') { @@ -235,10 +236,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; } @@ -250,7 +252,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."); } @@ -265,7 +267,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."); } diff --git a/lang/java/src/com/wiredtiger/db/PackOutputStream.java b/lang/java/src/com/wiredtiger/db/PackOutputStream.java index 60f40564afd..e79b4c63498 100644 --- a/lang/java/src/com/wiredtiger/db/PackOutputStream.java +++ b/lang/java/src/com/wiredtiger/db/PackOutputStream.java @@ -174,13 +174,16 @@ public class PackOutputStream { char fieldFormat = format.getType(); int stringLen = 0; int padBytes = 0; + int valLen = 0; // Strings have two possible encodings. A lower case 's' is not null // terminated, and has a length define in the format (default 1). An // upper case 'S' is variable length and has a null terminator. if (fieldFormat == 's') { stringLen = format.getLengthFromFormat(true); - if (stringLen > value.length()) { - padBytes = stringLen - value.length(); + valLen = value.length(); + if (stringLen > valLen) { + padBytes = stringLen - valLen; + stringLen = valLen; } } else { stringLen = value.length(); diff --git a/lang/java/wiredtiger.i b/lang/java/wiredtiger.i index 19569aecf1d..a92247c7ebf 100644 --- a/lang/java/wiredtiger.i +++ b/lang/java/wiredtiger.i @@ -654,6 +654,19 @@ WT_ASYNC_CALLBACK javaApiAsyncHandler = {javaAsyncHandler}; } /** + * Append a record number to the async_op's key. + * + * \param value The value to append + * \return This async_op object, so put calls can be chained. + */ + public AsyncOp putKeyRecord(long value) + throws WiredTigerPackingException { + keyUnpacker = null; + keyPacker.addRecord(value); + return this; + } + + /** * Append a short integer to the async_op's key. * * \param value The value to append @@ -746,6 +759,19 @@ WT_ASYNC_CALLBACK javaApiAsyncHandler = {javaAsyncHandler}; } /** + * Append a record number to the async_op's value. + * + * \param value The value to append + * \return This async_op object, so put calls can be chained. + */ + public AsyncOp putValueRecord(long value) + throws WiredTigerPackingException { + valueUnpacker = null; + valuePacker.addRecord(value); + return this; + } + + /** * Append a short integer to the async_op's value. * * \param value The value to append @@ -837,6 +863,16 @@ WT_ASYNC_CALLBACK javaApiAsyncHandler = {javaAsyncHandler}; } /** + * Retrieve a record number from the async_op's key. + * + * \return The requested value. + */ + public long getKeyRecord() + throws WiredTigerPackingException { + return getKeyUnpacker().getRecord(); + } + + /** * Retrieve a short integer from the async_op's key. * * \return The requested value. @@ -922,6 +958,16 @@ WT_ASYNC_CALLBACK javaApiAsyncHandler = {javaAsyncHandler}; } /** + * Retrieve a record number from the async_op's value. + * + * \return The requested value. + */ + public long getValueRecord() + throws WiredTigerPackingException { + return getValueUnpacker().getRecord(); + } + + /** * Retrieve a short integer from the async_op's value. * * \return The requested value. @@ -1211,6 +1257,18 @@ WT_ASYNC_CALLBACK javaApiAsyncHandler = {javaAsyncHandler}; } /** + * Append a record number to the cursor's key. + * + * \param value The value to append + * \return This cursor object, so put calls can be chained. + */ + public Cursor putKeyRecord(long value) + throws WiredTigerPackingException { + keyPacker.addRecord(value); + return this; + } + + /** * Append a short integer to the cursor's key. * * \param value The value to append @@ -1297,6 +1355,18 @@ WT_ASYNC_CALLBACK javaApiAsyncHandler = {javaAsyncHandler}; } /** + * Append a record number to the cursor's value. + * + * \param value The value to append + * \return This cursor object, so put calls can be chained. + */ + public Cursor putValueRecord(long value) + throws WiredTigerPackingException { + valuePacker.addRecord(value); + return this; + } + + /** * Append a short integer to the cursor's value. * * \param value The value to append @@ -1386,6 +1456,16 @@ WT_ASYNC_CALLBACK javaApiAsyncHandler = {javaAsyncHandler}; } /** + * Retrieve a record number from the cursor's key. + * + * \return The requested value. + */ + public long getKeyRecord() + throws WiredTigerPackingException { + return keyUnpacker.getRecord(); + } + + /** * Retrieve a short integer from the cursor's key. * * \return The requested value. @@ -1471,6 +1551,16 @@ WT_ASYNC_CALLBACK javaApiAsyncHandler = {javaAsyncHandler}; } /** + * Retrieve a record number from the cursor's value. + * + * \return The requested value. + */ + public long getValueRecord() + throws WiredTigerPackingException { + return valueUnpacker.getRecord(); + } + + /** * Retrieve a short integer from the cursor's value. * * \return The requested value. @@ -1820,7 +1910,8 @@ err: if (ret != 0) if ((ret = $self->open_cursor($self, uri, to_dup, config, &cursor)) != 0) goto err; - cursor->flags |= WT_CURSTD_RAW; + if ((cursor->flags & WT_CURSTD_DUMP_JSON) == 0) + cursor->flags |= WT_CURSTD_RAW; if ((ret = __wt_calloc_def((WT_SESSION_IMPL *)cursor->session, 1, &jcb)) != 0) diff --git a/lang/python/wiredtiger.i b/lang/python/wiredtiger.i index 7963b5b74c9..bf726ceac0a 100644 --- a/lang/python/wiredtiger.i +++ b/lang/python/wiredtiger.i @@ -363,10 +363,19 @@ retry: } %enddef -/* Cursor compare can return any of -1, 0, 1 or WT_NOTFOUND. */ +/* Cursor compare can return any of -1, 0, 1. */ %define COMPARE_OK(m) %exception m { $action + if (result < -1 || result > 1) + SWIG_ERROR_IF_NOT_SET(result); +} +%enddef + +/* Cursor compare can return any of -1, 0, 1 or WT_NOTFOUND. */ +%define COMPARE_NOTFOUND_OK(m) +%exception m { + $action if ((result < -1 || result > 1) && result != WT_NOTFOUND) SWIG_ERROR_IF_NOT_SET(result); } @@ -382,7 +391,7 @@ NOTFOUND_OK(__wt_cursor::update) COMPARE_OK(__wt_cursor::compare) COMPARE_OK(__wt_cursor::equals) -COMPARE_OK(__wt_cursor::search_near) +COMPARE_NOTFOUND_OK(__wt_cursor::search_near) /* Lastly, some methods need no (additional) error checking. */ %exception __wt_connection::get_home; @@ -724,7 +733,7 @@ typedef int int_void; int ret = $self->search_near($self, &cmp); /* * Map less-than-zero to -1 and greater-than-zero to 1 to avoid - * colliding with WT_NOTFOUND. + * colliding with other errors. */ return ((ret != 0) ? ret : (cmp < 0) ? -1 : (cmp == 0) ? 0 : 1); } |