diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-01-13 17:15:28 -0500 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-01-13 17:15:28 -0500 |
commit | 2fe68fa71b2c4316c6d409cbb6d9f5af13a2342a (patch) | |
tree | ef880d8922a9717a2d0bdf8a0ccb253fa916f32c /src/third_party/wiredtiger/lang | |
parent | fb20325176b25317525b0cd6118586a386048e91 (diff) | |
download | mongo-2fe68fa71b2c4316c6d409cbb6d9f5af13a2342a.tar.gz |
Import wiredtiger-wiredtiger-2.5.0-92-gd56476d.tar.gz from wiredtiger branch mongodb-2.8
Diffstat (limited to 'src/third_party/wiredtiger/lang')
5 files changed, 115 insertions, 9 deletions
diff --git a/src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/PackFormatInputStream.java b/src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/PackFormatInputStream.java index c9d1c43d32d..c53938d0a58 100644 --- a/src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/PackFormatInputStream.java +++ b/src/third_party/wiredtiger/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/src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/PackInputStream.java b/src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/PackInputStream.java index 75bdb3119a9..a49b2e01f17 100644 --- a/src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/PackInputStream.java +++ b/src/third_party/wiredtiger/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/src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/PackOutputStream.java b/src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/PackOutputStream.java index 60f40564afd..e79b4c63498 100644 --- a/src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/PackOutputStream.java +++ b/src/third_party/wiredtiger/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/src/third_party/wiredtiger/lang/java/wiredtiger.i b/src/third_party/wiredtiger/lang/java/wiredtiger.i index a922a7a6b2e..09290a70c67 100644 --- a/src/third_party/wiredtiger/lang/java/wiredtiger.i +++ b/src/third_party/wiredtiger/lang/java/wiredtiger.i @@ -652,6 +652,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 @@ -744,6 +757,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 @@ -835,6 +861,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. @@ -920,6 +956,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. @@ -1202,6 +1248,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 @@ -1288,6 +1346,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 @@ -1377,6 +1447,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. @@ -1462,6 +1542,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. @@ -1801,7 +1891,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/src/third_party/wiredtiger/lang/python/wiredtiger.i b/src/third_party/wiredtiger/lang/python/wiredtiger.i index 974118d0f61..de5afb0a0fa 100644 --- a/src/third_party/wiredtiger/lang/python/wiredtiger.i +++ b/src/third_party/wiredtiger/lang/python/wiredtiger.i @@ -339,7 +339,9 @@ retry: if (result != 0 && result != EBUSY) SWIG_ERROR_IF_NOT_SET(result); else if (result == EBUSY) { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; __wt_sleep(0, 10000); + SWIG_PYTHON_THREAD_END_ALLOW; goto retry; } } @@ -361,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); } @@ -379,7 +390,7 @@ NOTFOUND_OK(__wt_cursor::search) NOTFOUND_OK(__wt_cursor::update) COMPARE_OK(__wt_cursor::compare) -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; |