diff options
author | Michael Cahill <michael.cahill@wiredtiger.com> | 2015-01-14 02:44:49 +1100 |
---|---|---|
committer | Michael Cahill <michael.cahill@wiredtiger.com> | 2015-01-14 02:44:49 +1100 |
commit | eb1511f3f1fb3be31cce7c4b288608997dd77c3e (patch) | |
tree | 3f3ff1244c1ed1d3b1a809ba84703d28686a07f9 /lang | |
parent | 71355ac442db3e001c120fcfc398de71d34075e3 (diff) | |
parent | 9c4b6113e1bb6bc3398e32d9190ff2e5c5f415c5 (diff) | |
download | mongo-eb1511f3f1fb3be31cce7c4b288608997dd77c3e.tar.gz |
Merge branch 'develop' into cursor-reconfigure
Diffstat (limited to 'lang')
-rw-r--r-- | lang/java/src/com/wiredtiger/db/AsyncCallback.java | 1 | ||||
-rw-r--r-- | lang/java/src/com/wiredtiger/db/PackFormatInputStream.java | 2 | ||||
-rw-r--r-- | lang/java/src/com/wiredtiger/db/PackInputStream.java | 9 | ||||
-rw-r--r-- | lang/java/src/com/wiredtiger/db/PackOutputStream.java | 8 | ||||
-rw-r--r-- | lang/java/src/com/wiredtiger/db/PackUtil.java | 1 | ||||
-rw-r--r-- | lang/java/src/com/wiredtiger/db/WiredTigerException.java | 1 | ||||
-rw-r--r-- | lang/java/src/com/wiredtiger/db/WiredTigerPackingException.java | 1 | ||||
-rw-r--r-- | lang/java/src/com/wiredtiger/db/WiredTigerPanicException.java | 1 | ||||
-rw-r--r-- | lang/java/src/com/wiredtiger/db/WiredTigerRollbackException.java | 1 | ||||
-rw-r--r-- | lang/java/wiredtiger.i | 94 | ||||
-rw-r--r-- | lang/python/setup.py | 1 | ||||
-rw-r--r-- | lang/python/wiredtiger.i | 16 | ||||
-rw-r--r-- | lang/python/wiredtiger/fpacking.py | 1 | ||||
-rw-r--r-- | lang/python/wiredtiger/intpack-test.py | 1 | ||||
-rw-r--r-- | lang/python/wiredtiger/intpacking.py | 1 | ||||
-rw-r--r-- | lang/python/wiredtiger/packing-test.py | 1 | ||||
-rw-r--r-- | lang/python/wiredtiger/packing.py | 1 |
17 files changed, 132 insertions, 9 deletions
diff --git a/lang/java/src/com/wiredtiger/db/AsyncCallback.java b/lang/java/src/com/wiredtiger/db/AsyncCallback.java index 4f6fb5df133..c3640c1a47d 100644 --- a/lang/java/src/com/wiredtiger/db/AsyncCallback.java +++ b/lang/java/src/com/wiredtiger/db/AsyncCallback.java @@ -1,4 +1,5 @@ /*- + * Public Domain 2014-2015 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/lang/java/src/com/wiredtiger/db/PackFormatInputStream.java b/lang/java/src/com/wiredtiger/db/PackFormatInputStream.java index fc4b99ae435..c53938d0a58 100644 --- a/lang/java/src/com/wiredtiger/db/PackFormatInputStream.java +++ b/lang/java/src/com/wiredtiger/db/PackFormatInputStream.java @@ -1,4 +1,5 @@ /*- + * Public Domain 2014-2015 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. @@ -84,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 f0e5bb9663d..a49b2e01f17 100644 --- a/lang/java/src/com/wiredtiger/db/PackInputStream.java +++ b/lang/java/src/com/wiredtiger/db/PackInputStream.java @@ -1,4 +1,5 @@ /*- + * Public Domain 2014-2015 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. @@ -224,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') { @@ -234,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; } @@ -249,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."); } @@ -264,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 185068d2093..e79b4c63498 100644 --- a/lang/java/src/com/wiredtiger/db/PackOutputStream.java +++ b/lang/java/src/com/wiredtiger/db/PackOutputStream.java @@ -1,4 +1,5 @@ /*- + * Public Domain 2014-2015 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. @@ -173,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/src/com/wiredtiger/db/PackUtil.java b/lang/java/src/com/wiredtiger/db/PackUtil.java index c8804891da5..bfc13d9a586 100644 --- a/lang/java/src/com/wiredtiger/db/PackUtil.java +++ b/lang/java/src/com/wiredtiger/db/PackUtil.java @@ -1,4 +1,5 @@ /*- + * Public Domain 2014-2015 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/lang/java/src/com/wiredtiger/db/WiredTigerException.java b/lang/java/src/com/wiredtiger/db/WiredTigerException.java index b437ab98eee..69ce031b6ef 100644 --- a/lang/java/src/com/wiredtiger/db/WiredTigerException.java +++ b/lang/java/src/com/wiredtiger/db/WiredTigerException.java @@ -1,4 +1,5 @@ /*- + * Public Domain 2014-2015 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/lang/java/src/com/wiredtiger/db/WiredTigerPackingException.java b/lang/java/src/com/wiredtiger/db/WiredTigerPackingException.java index 4f08f60b956..2af1c5ccc9f 100644 --- a/lang/java/src/com/wiredtiger/db/WiredTigerPackingException.java +++ b/lang/java/src/com/wiredtiger/db/WiredTigerPackingException.java @@ -1,4 +1,5 @@ /*- + * Public Domain 2014-2015 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/lang/java/src/com/wiredtiger/db/WiredTigerPanicException.java b/lang/java/src/com/wiredtiger/db/WiredTigerPanicException.java index 2b10beda752..8535af5d316 100644 --- a/lang/java/src/com/wiredtiger/db/WiredTigerPanicException.java +++ b/lang/java/src/com/wiredtiger/db/WiredTigerPanicException.java @@ -1,4 +1,5 @@ /*- + * Public Domain 2014-2015 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/lang/java/src/com/wiredtiger/db/WiredTigerRollbackException.java b/lang/java/src/com/wiredtiger/db/WiredTigerRollbackException.java index 0521b43aac9..2f620d95da3 100644 --- a/lang/java/src/com/wiredtiger/db/WiredTigerRollbackException.java +++ b/lang/java/src/com/wiredtiger/db/WiredTigerRollbackException.java @@ -1,4 +1,5 @@ /*- + * Public Domain 2014-2015 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/lang/java/wiredtiger.i b/lang/java/wiredtiger.i index 0b2b4cdd1d2..09290a70c67 100644 --- a/lang/java/wiredtiger.i +++ b/lang/java/wiredtiger.i @@ -1,4 +1,5 @@ /*- + * Public Domain 2014-2015 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. @@ -651,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 @@ -743,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 @@ -834,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. @@ -919,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. @@ -1201,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 @@ -1287,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 @@ -1376,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. @@ -1461,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. @@ -1800,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/lang/python/setup.py b/lang/python/setup.py index 7d99c872bc3..28bbe4d07e8 100644 --- a/lang/python/setup.py +++ b/lang/python/setup.py @@ -1,5 +1,6 @@ #!/usr/bin/env python # +# Public Domain 2014-2015 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/lang/python/wiredtiger.i b/lang/python/wiredtiger.i index 5e88855276a..de5afb0a0fa 100644 --- a/lang/python/wiredtiger.i +++ b/lang/python/wiredtiger.i @@ -1,4 +1,5 @@ /*- + * Public Domain 2014-2015 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. @@ -338,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; } } @@ -360,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); } @@ -378,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; diff --git a/lang/python/wiredtiger/fpacking.py b/lang/python/wiredtiger/fpacking.py index 632c5c5a1c5..62d7af739b8 100644 --- a/lang/python/wiredtiger/fpacking.py +++ b/lang/python/wiredtiger/fpacking.py @@ -1,5 +1,6 @@ #!/usr/bin/env python # +# Public Domain 2014-2015 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/lang/python/wiredtiger/intpack-test.py b/lang/python/wiredtiger/intpack-test.py index 6c1c991ddfd..8855dc4e72d 100644 --- a/lang/python/wiredtiger/intpack-test.py +++ b/lang/python/wiredtiger/intpack-test.py @@ -1,5 +1,6 @@ #!/usr/bin/env python # +# Public Domain 2014-2015 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/lang/python/wiredtiger/intpacking.py b/lang/python/wiredtiger/intpacking.py index fefdb0dca1f..239bc84069d 100644 --- a/lang/python/wiredtiger/intpacking.py +++ b/lang/python/wiredtiger/intpacking.py @@ -1,5 +1,6 @@ #!/usr/bin/env python # +# Public Domain 2014-2015 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/lang/python/wiredtiger/packing-test.py b/lang/python/wiredtiger/packing-test.py index 4b06b2bc608..2eb0baa1d47 100644 --- a/lang/python/wiredtiger/packing-test.py +++ b/lang/python/wiredtiger/packing-test.py @@ -1,5 +1,6 @@ #!/usr/bin/env python # +# Public Domain 2014-2015 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/lang/python/wiredtiger/packing.py b/lang/python/wiredtiger/packing.py index ee12434cabd..103c0471724 100644 --- a/lang/python/wiredtiger/packing.py +++ b/lang/python/wiredtiger/packing.py @@ -1,5 +1,6 @@ #!/usr/bin/env python # +# Public Domain 2014-2015 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. |