summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/lang
diff options
context:
space:
mode:
authorLuke Chen <luke.chen@mongodb.com>2020-10-22 15:48:02 +1100
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-10-22 05:05:01 +0000
commit2ffbad5afadbae7d0e7ddc2dc4ab48251bdac76e (patch)
tree508fc68d64436577598c648677b76e3bb73aeae1 /src/third_party/wiredtiger/lang
parent298d4d6bbb9980b74bded06241067fe6771bef68 (diff)
downloadmongo-2ffbad5afadbae7d0e7ddc2dc4ab48251bdac76e.tar.gz
Import wiredtiger: 0d364d8731188ad80ea82d725db8f625487fbc0b from branch mongodb-5.0
ref: 11d6e7f3ac..0d364d8731 for: 4.9.0 WT-6675 Remove WiredTiger Java language API and documentation
Diffstat (limited to 'src/third_party/wiredtiger/lang')
-rw-r--r--src/third_party/wiredtiger/lang/java/Makefile.am94
-rw-r--r--src/third_party/wiredtiger/lang/java/java_doc.i67
-rw-r--r--src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/PackFormatInputStream.java196
-rw-r--r--src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/PackInputStream.java374
-rw-r--r--src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/PackOutputStream.java319
-rw-r--r--src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/PackUtil.java70
-rw-r--r--src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/WiredTigerException.java40
-rw-r--r--src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/WiredTigerPackingException.java42
-rw-r--r--src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/WiredTigerPanicException.java43
-rw-r--r--src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/WiredTigerRollbackException.java42
-rw-r--r--src/third_party/wiredtiger/lang/java/wiredtiger.i1522
11 files changed, 0 insertions, 2809 deletions
diff --git a/src/third_party/wiredtiger/lang/java/Makefile.am b/src/third_party/wiredtiger/lang/java/Makefile.am
deleted file mode 100644
index 221c08070e3..00000000000
--- a/src/third_party/wiredtiger/lang/java/Makefile.am
+++ /dev/null
@@ -1,94 +0,0 @@
-AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/src/include
-
-JAVADEST = src/com/wiredtiger/db
-JAVADESTFULL = $(srcdir)/$(JAVADEST)
-JAVAEXAMPLES = $(top_srcdir)/examples/java/com/wiredtiger/examples
-JAVATEST = $(top_srcdir)/test/java/com/wiredtiger/test
-BUILT_SOURCES = wiredtiger_wrap.c
-SWIG_SOURCES = wiredtiger.i
-
-JDOCDIR = $(top_srcdir)/docs/java
-# The Java documentation is currently generated by Doxygen - disable javadoc
-#java_DATA = $(JDOCDIR)/index.html
-
-javadir = $(datadir)/java/$(PACKAGE)-$(PACKAGE_VERSION)
-JAVA_SRC = \
- $(JAVADESTFULL)/Connection.java \
- $(JAVADESTFULL)/Cursor.java \
- $(JAVADESTFULL)/Modify.java \
- $(JAVADESTFULL)/SearchStatus.java \
- $(JAVADESTFULL)/PackFormatInputStream.java \
- $(JAVADESTFULL)/PackInputStream.java \
- $(JAVADESTFULL)/PackOutputStream.java \
- $(JAVADESTFULL)/PackUtil.java \
- $(JAVADESTFULL)/Session.java \
- $(JAVADESTFULL)/WiredTigerException.java \
- $(JAVADESTFULL)/WiredTigerPackingException.java \
- $(JAVADESTFULL)/WiredTigerPanicException.java \
- $(JAVADESTFULL)/WiredTigerRollbackException.java \
- $(JAVADESTFULL)/wiredtiger.java \
- $(JAVADESTFULL)/wiredtigerConstants.java \
- $(JAVADESTFULL)/wiredtigerJNI.java \
- $(JAVADESTFULL)/WT_MODIFY_LIST.java \
- $(JAVAEXAMPLES)/ex_access.java \
- $(JAVAEXAMPLES)/ex_all.java \
- $(JAVAEXAMPLES)/ex_call_center.java \
- $(JAVAEXAMPLES)/ex_cursor.java \
- $(JAVAEXAMPLES)/ex_log.java \
- $(JAVAEXAMPLES)/ex_schema.java \
- $(JAVAEXAMPLES)/ex_stat.java \
- $(JAVAEXAMPLES)/ex_thread.java
-
-JAVA_JUNIT = \
- $(JAVATEST)/AutoCloseTest.java \
- $(JAVATEST)/BackupCursorTest.java \
- $(JAVATEST)/ConfigTest.java \
- $(JAVATEST)/ConcurrentCloseTest.java \
- $(JAVATEST)/CursorTest.java \
- $(JAVATEST)/CursorTest02.java \
- $(JAVATEST)/CursorTest03.java \
- $(JAVATEST)/ExceptionTest.java \
- $(JAVATEST)/PackTest.java \
- $(JAVATEST)/PackTest02.java \
- $(JAVATEST)/PackTest03.java \
- $(JAVATEST)/WiredTigerSuite.java
-
-dist_java_JAVA = $(JAVA_SRC) @JAVA_JUNIT@
-dist_java_DATA = wiredtiger.jar
-
-EXTRA_JAVA = $(JAVA_JUNIT)
-
-java_LTLIBRARIES = libwiredtiger_java.la
-
-TESTS_JUNIT = AllJunitTests
-
-TESTS = @TESTS_JUNIT@
-
-AllJunitTests:
- echo "#! /bin/sh" > $@
- echo 'SCRIPT_DIR=`dirname $$0`' >> $@
- echo 'env LD_LIBRARY_PATH=$$SCRIPT_DIR/../../.libs:$$SCRIPT_DIR/.libs DYLD_LIBRARY_PATH=$$SCRIPT_DIR/../../.libs JAVA_LIBRARY_PATH=$$SCRIPT_DIR/.libs @JUNIT@ com.wiredtiger.test.WiredTigerSuite' >> $@
- chmod +x $@
- mkdir -p WT_HOME
-
-CPPFLAGS += $(JNI_CPPFLAGS)
-# Some warnings when compiling the generated code are unavoidable
-CFLAGS += -w
-libwiredtiger_java_la_SOURCES = $(BUILT_SOURCES) $(SWIG_SOURCES)
-#libwiredtiger_java_la_LDFLAGS = -module
-libwiredtiger_java_la_LIBADD = $(abs_top_builddir)/libwiredtiger.la
-
-all-local: wiredtiger.jar
-
-$(srcdir)/wiredtiger_wrap.c: $(top_srcdir)/src/include/wiredtiger.in $(SWIG_SOURCES)
- (cd $(srcdir) && \
- $(SWIG) -Wall -v -java -nodefaultctor -nodefaultdtor -package com.wiredtiger.db -I$(abs_top_builddir) -outdir $(JAVADEST) -o wiredtiger_wrap.c wiredtiger.i)
-
-$(JDOCDIR)/index.html: $(dist_java_JAVA)
- mkdir -p $(JDOCDIR)
- javadoc -public -d $(JDOCDIR) -link http://docs.oracle.com/javase/6/docs/api $(JAVADESTFULL)/wiredtiger.java $(JAVADESTFULL)/wiredtigerConstants.java $(JAVADESTFULL)/[A-Z]*.java
-
-wiredtiger.jar: $(dist_java_JAVA) classjava.stamp
- (cd $(top_builddir) && \
- $(JAR) -cf wiredtiger.jar com/)
- cp $(top_builddir)/wiredtiger.jar .
diff --git a/src/third_party/wiredtiger/lang/java/java_doc.i b/src/third_party/wiredtiger/lang/java/java_doc.i
deleted file mode 100644
index b932d91cd03..00000000000
--- a/src/third_party/wiredtiger/lang/java/java_doc.i
+++ /dev/null
@@ -1,67 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/java_doc.py. */
-
-COPYDOC(__wt_cursor, WT_CURSOR, get_key)
-COPYDOC(__wt_cursor, WT_CURSOR, get_value)
-COPYDOC(__wt_cursor, WT_CURSOR, set_key)
-COPYDOC(__wt_cursor, WT_CURSOR, set_value)
-COPYDOC(__wt_cursor, WT_CURSOR, compare)
-COPYDOC(__wt_cursor, WT_CURSOR, equals)
-COPYDOC(__wt_cursor, WT_CURSOR, next)
-COPYDOC(__wt_cursor, WT_CURSOR, prev)
-COPYDOC(__wt_cursor, WT_CURSOR, reset)
-COPYDOC(__wt_cursor, WT_CURSOR, search)
-COPYDOC(__wt_cursor, WT_CURSOR, search_near)
-COPYDOC(__wt_cursor, WT_CURSOR, insert)
-COPYDOC(__wt_cursor, WT_CURSOR, modify)
-COPYDOC(__wt_cursor, WT_CURSOR, update)
-COPYDOC(__wt_cursor, WT_CURSOR, remove)
-COPYDOC(__wt_cursor, WT_CURSOR, reserve)
-COPYDOC(__wt_cursor, WT_CURSOR, close)
-COPYDOC(__wt_cursor, WT_CURSOR, reconfigure)
-COPYDOC(__wt_cursor, WT_CURSOR, cache)
-COPYDOC(__wt_cursor, WT_CURSOR, reopen)
-COPYDOC(__wt_session, WT_SESSION, close)
-COPYDOC(__wt_session, WT_SESSION, reconfigure)
-COPYDOC(__wt_session, WT_SESSION, open_cursor)
-COPYDOC(__wt_session, WT_SESSION, alter)
-COPYDOC(__wt_session, WT_SESSION, create)
-COPYDOC(__wt_session, WT_SESSION, compact)
-COPYDOC(__wt_session, WT_SESSION, drop)
-COPYDOC(__wt_session, WT_SESSION, join)
-COPYDOC(__wt_session, WT_SESSION, log_flush)
-COPYDOC(__wt_session, WT_SESSION, log_printf)
-COPYDOC(__wt_session, WT_SESSION, rename)
-COPYDOC(__wt_session, WT_SESSION, reset)
-COPYDOC(__wt_session, WT_SESSION, salvage)
-COPYDOC(__wt_session, WT_SESSION, truncate)
-COPYDOC(__wt_session, WT_SESSION, upgrade)
-COPYDOC(__wt_session, WT_SESSION, verify)
-COPYDOC(__wt_session, WT_SESSION, begin_transaction)
-COPYDOC(__wt_session, WT_SESSION, commit_transaction)
-COPYDOC(__wt_session, WT_SESSION, prepare_transaction)
-COPYDOC(__wt_session, WT_SESSION, rollback_transaction)
-COPYDOC(__wt_session, WT_SESSION, timestamp_transaction)
-COPYDOC(__wt_session, WT_SESSION, query_timestamp)
-COPYDOC(__wt_session, WT_SESSION, checkpoint)
-COPYDOC(__wt_session, WT_SESSION, transaction_pinned_range)
-COPYDOC(__wt_session, WT_SESSION, transaction_sync)
-COPYDOC(__wt_session, WT_SESSION, breakpoint)
-COPYDOC(__wt_connection, WT_CONNECTION, close)
-COPYDOC(__wt_connection, WT_CONNECTION, debug_info)
-COPYDOC(__wt_connection, WT_CONNECTION, reconfigure)
-COPYDOC(__wt_connection, WT_CONNECTION, configure_method)
-COPYDOC(__wt_connection, WT_CONNECTION, is_new)
-COPYDOC(__wt_connection, WT_CONNECTION, open_session)
-COPYDOC(__wt_connection, WT_CONNECTION, query_timestamp)
-COPYDOC(__wt_connection, WT_CONNECTION, set_timestamp)
-COPYDOC(__wt_connection, WT_CONNECTION, rollback_to_stable)
-COPYDOC(__wt_connection, WT_CONNECTION, load_extension)
-COPYDOC(__wt_connection, WT_CONNECTION, add_data_source)
-COPYDOC(__wt_connection, WT_CONNECTION, add_collator)
-COPYDOC(__wt_connection, WT_CONNECTION, add_compressor)
-COPYDOC(__wt_connection, WT_CONNECTION, add_encryptor)
-COPYDOC(__wt_connection, WT_CONNECTION, add_extractor)
-COPYDOC(__wt_connection, WT_CONNECTION, set_file_system)
-COPYDOC(__wt_config_parser, WT_CONFIG_PARSER, close)
-COPYDOC(__wt_config_parser, WT_CONFIG_PARSER, next)
-COPYDOC(__wt_config_parser, WT_CONFIG_PARSER, get)
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
deleted file mode 100644
index b2ea8cada90..00000000000
--- a/src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/PackFormatInputStream.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*-
- * Public Domain 2014-2020 MongoDB, Inc.
- * Public Domain 2008-2014 WiredTiger, Inc.
- *
- * This is free and unencumbered software released into the public domain.
- *
- * Anyone is free to copy, modify, publish, use, compile, sell, or
- * distribute this software, either in source code form or as a compiled
- * binary, for any purpose, commercial or non-commercial, and by any
- * means.
- *
- * In jurisdictions that recognize copyright laws, the author or authors
- * of this software dedicate any and all copyright interest in the
- * software to the public domain. We make this dedication for the benefit
- * of the public at large and to the detriment of our heirs and
- * successors. We intend this dedication to be an overt act of
- * relinquishment in perpetuity of all present and future rights to this
- * software under copyright law.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-package com.wiredtiger.db;
-
-import java.io.ByteArrayInputStream;
-import java.lang.StringBuffer;
-import com.wiredtiger.db.PackUtil;
-import com.wiredtiger.db.WiredTigerPackingException;
-
-/**
- * An internal helper class for consuming pack format strings.
- *
- * Applications should not need to use this class.
- */
-public class PackFormatInputStream {
-
- protected String format;
- protected boolean isRaw;
- protected int formatOff;
- protected int formatRepeatCount;
-
- /**
- * Constructor for a format stream.
- *
- * \param format the encoded format backing string.
- */
- protected PackFormatInputStream(String format, boolean isRaw) {
- this.format = format;
- this.isRaw = isRaw;
- formatOff = 0;
- formatRepeatCount = 0;
- }
-
- /**
- * Standard toString - returns the string used during construction.
- */
- public String toString() {
- return format;
- }
-
- /**
- * Returns the approximate count of elements left in the format.
- * This method does not account for repeat counts or string length
- * encodings - so should be used as a guide only.
- */
- public int available() {
- return format.length() - formatOff + formatRepeatCount;
- }
-
- /**
- * Reset the current stream position.
- */
- public void reset() {
- formatOff = 0;
- formatRepeatCount = 0;
- }
-
- /**
- * Return the decoded type for the next entry in the format stream. Does
- * not adjust the position of the stream.
- */
- protected char getType()
- throws WiredTigerPackingException {
- if (formatOff >= format.length()) {
- throw new WiredTigerPackingException(
- "No more fields in format.");
- }
-
- String fieldName;
- boolean lenOK = false;
- int countOff = 0;
-
- while (PackUtil.PackSpecialCharacters.indexOf(
- format.charAt(formatOff + countOff)) != -1) {
- countOff++;
- }
- // Skip repeat counts and sizes
- while (Character.isDigit(format.charAt(formatOff + countOff))) {
- countOff++;
- }
- return format.charAt(formatOff + countOff);
- }
-
- /**
- * Check to see if the next entry is compatible with the requested type.
- *
- * \param asking the format type to match.
- * \param consume indicates whether to update the stream position.
- */
- protected void checkType(char asking, boolean consume)
- throws WiredTigerPackingException {
-
- char expected = getType();
- if (isRaw)
- throw new WiredTigerPackingException(
- "Format mismatch for raw mode");
- if (Character.toLowerCase(expected) != Character.toLowerCase(asking))
- throw new WiredTigerPackingException(
- "Format mismatch. Wanted: " + asking + ", got: " + expected);
- if (consume) {
- consume();
- }
- }
-
- /**
- * Move the format stream position ahead one position.
- */
- protected void consume() {
- if (formatRepeatCount > 1) {
- --formatRepeatCount;
- } else if (formatRepeatCount == 1) {
- formatRepeatCount = 0;
- ++formatOff;
- } else {
- while (PackUtil.PackSpecialCharacters.indexOf(
- format.charAt(formatOff)) != -1) {
- ++formatOff;
- }
-
- // Don't need to worry about String or byte array size counts
- // since they have already been consumed.
- formatRepeatCount = getIntFromFormat(true);
- if (formatRepeatCount == 0) {
- ++formatOff;
- }
- }
- }
-
- /**
- * Decode an integer from the format string, return zero if not starting
- * on a digit.
- *
- * \param advance whether to move the stream position.
- */
- private int getIntFromFormat(boolean advance) {
- int valueLen = 0;
- int countOff;
- for (countOff = 0;
- Character.isDigit(format.charAt(formatOff + countOff));
- countOff++) {
- valueLen *= 10;
- valueLen += Character.digit(format.charAt(formatOff + countOff), 10);
- }
- if (advance) {
- formatOff += countOff;
- }
- return valueLen;
- }
-
- /**
- * Retrieve a length from the format string. Either for a repeat count
- * or a string length. Return one if no explicit repeat count.
- *
- * \param advance whether to move the stream position.
- */
- protected int getLengthFromFormat(boolean advance) {
- int valueLen = getIntFromFormat(advance);
- if (valueLen == 0) {
- valueLen = 1;
- }
- return valueLen;
- }
-
- /**
- * Return whether there is an explicit length indicated in the format
- * string.
- */
- protected boolean hasLength() {
- return (getIntFromFormat(false) > 0);
- }
-}
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
deleted file mode 100644
index ef369b162f2..00000000000
--- a/src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/PackInputStream.java
+++ /dev/null
@@ -1,374 +0,0 @@
-/*-
- * Public Domain 2014-2020 MongoDB, Inc.
- * Public Domain 2008-2014 WiredTiger, Inc.
- *
- * This is free and unencumbered software released into the public domain.
- *
- * Anyone is free to copy, modify, publish, use, compile, sell, or
- * distribute this software, either in source code form or as a compiled
- * binary, for any purpose, commercial or non-commercial, and by any
- * means.
- *
- * In jurisdictions that recognize copyright laws, the author or authors
- * of this software dedicate any and all copyright interest in the
- * software to the public domain. We make this dedication for the benefit
- * of the public at large and to the detriment of our heirs and
- * successors. We intend this dedication to be an overt act of
- * relinquishment in perpetuity of all present and future rights to this
- * software under copyright law.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-package com.wiredtiger.db;
-
-import java.io.ByteArrayInputStream;
-import java.lang.StringBuffer;
-import com.wiredtiger.db.PackUtil;
-import com.wiredtiger.db.WiredTigerPackingException;
-
-/**
- * An internal helper class for decoding WiredTiger packed values.
- *
- * Applications should not need to use this class.
- */
-public class PackInputStream {
-
- protected PackFormatInputStream format;
- protected byte[] value;
- protected int valueOff;
- protected int valueLen;
- protected boolean isRaw;
-
- /**
- * Constructor.
- *
- * \param format A String that contains the WiredTiger format that
- * defines the layout of this packed value.
- * \param value The raw bytes that back the stream.
- */
- public PackInputStream(String format, byte[] value) {
- this(format, value, false, 0, value.length);
- }
-
- /**
- * Constructor.
- *
- * \param format A String that contains the WiredTiger format that
- * defines the layout of this packed value.
- * \param value The raw bytes that back the stream.
- * \param isRaw The stream is opened raw.
- */
- public PackInputStream(String format, byte[] value, boolean isRaw) {
- this(format, value, isRaw, 0, value.length);
- }
-
- /**
- * Constructor.
- *
- * \param format A String that contains the WiredTiger format that
- * defines the layout of this packed value.
- * \param value The raw bytes that back the stream.
- * \param isRaw The stream is opened raw.
- * \param off Offset into the value array at which the stream begins.
- * \param len Length of the value array that forms the stream.
- */
- public PackInputStream(
- String format, byte[] value, boolean isRaw, int off, int len) {
- this.format = new PackFormatInputStream(format, isRaw);
- this.value = value;
- this.valueOff = off;
- this.valueLen = len;
- this.isRaw = isRaw;
- }
-
- /**
- * Returns the raw packing format string.
- */
- public String getFormat() {
- return format.toString();
- }
-
- /**
- * Returns the raw value byte array.
- */
- public byte[] getValue() {
- return value;
- }
-
- /**
- * Retrieves a byte field from the stream.
- */
- public byte getByte()
- throws WiredTigerPackingException {
- format.checkType('b', false);
- format.consume();
- return (byte)(value[valueOff++] - 0x80);
- }
-
- /**
- * Retrieves a byte array field from the stream.
- *
- * \param dest The byte array where the returned value will be stored. The
- * array should be large enough to store the entire data item,
- * if it is not, a truncated value will be returned.
- */
- public void getByteArray(byte[] dest)
- throws WiredTigerPackingException {
- this.getByteArray(dest, 0, dest.length);
- }
-
- /**
- * Retrieves a byte array field from the stream.
- *
- * \param dest The byte array where the returned value will be stored.
- * \param off Offset into the destination buffer to start copying into.
- * \param len The length should be large enough to store the entire data
- * item, if it is not, a truncated value will be returned.
- */
- public void getByteArray(byte[] dest, int off, int len)
- throws WiredTigerPackingException {
- if (!isRaw) {
- format.checkType('U', false);
- }
- getByteArrayInternal(getByteArrayLength(), dest, off, len);
- }
-
- /**
- * Retrieves a byte array field from the stream. Creates a new byte array
- * that is the size of the object being retrieved.
- */
- public byte[] getByteArray()
- throws WiredTigerPackingException {
- if (!isRaw) {
- format.checkType('U', false);
- }
- int itemLen = getByteArrayLength();
- byte[] unpacked = new byte[itemLen];
- getByteArrayInternal(itemLen, unpacked, 0, itemLen);
- return unpacked;
- }
-
- /**
- * Finds the length of a byte array. Either by decoding the length from
- * the format or using the remaining size of the stream.
- */
- private int getByteArrayLength()
- throws WiredTigerPackingException {
- int itemLen = 0;
-
- if (isRaw) {
- // The rest of the buffer is a byte array.
- itemLen = valueLen - valueOff;
- } else if (format.hasLength()) {
- // If the format has a length, it's always used.
- itemLen = format.getLengthFromFormat(true);
- } else if (format.getType() == 'U') {
- // The 'U' format is used internally, and may be exposed to us.
- // It indicates that the size is always stored unless there
- // is a size in the format.
- itemLen = unpackInt(false);
- } else if (format.available() == 1) {
- // The rest of the buffer is a byte array.
- itemLen = valueLen - valueOff;
- } else {
- itemLen = unpackInt(false);
- }
- return itemLen;
- }
-
- /**
- * Do the work of retrieving a byte array.
- */
- private void getByteArrayInternal(
- int itemLen, byte[] dest, int off, int destLen)
- throws WiredTigerPackingException {
- int copyLen = itemLen;
- if (itemLen > destLen) {
- copyLen = destLen;
- }
- format.consume();
- System.arraycopy(value, valueOff, dest, off, copyLen);
- valueOff += itemLen;
- }
-
- /**
- * Retrieves an integer field from the stream.
- */
- public int getInt()
- throws WiredTigerPackingException {
- boolean signed = true;
- format.checkType('i', false);
- if (format.getType() == 'I' ||
- format.getType() == 'L') {
- signed = false;
- }
- format.consume();
- return unpackInt(signed);
- }
-
- /**
- * Retrieves a long field from the stream.
- */
- public long getLong()
- throws WiredTigerPackingException {
- boolean signed = true;
- format.checkType('q', false);
- if (format.getType() == 'Q') {
- signed = false;
- }
- format.consume();
- return unpackLong(signed);
- }
-
- /**
- * Retrieves a record field from the stream.
- */
- public long getRecord()
- throws WiredTigerPackingException {
- format.checkType('r', false);
- format.consume();
- return unpackLong(false);
- }
-
- /**
- * Retrieves a short field from the stream.
- */
- public short getShort()
- throws WiredTigerPackingException {
- boolean signed = true;
- format.checkType('h', false);
- if (format.getType() == 'H') {
- signed = false;
- }
- format.consume();
- return unpackShort(signed);
- }
-
- /**
- * Retrieves a string field from the stream.
- */
- 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') {
- stringLength = format.getLengthFromFormat(true);
- } else {
- // The string is null terminated, but we need to know how many
- // bytes are consumed - which won't necessarily match up to the
- // 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 + skipnull;
- return result;
- }
-
- /**
- * Decodes an encoded short from the stream. This method does bounds
- * checking, to ensure values fit, since some values may be encoded as
- * unsigned values, and Java types are all signed.
- */
- private short unpackShort(boolean signed)
- throws WiredTigerPackingException {
- long ret = unpackLong(true);
- if ((signed && (ret > Short.MAX_VALUE || ret < Short.MIN_VALUE)) ||
- (!signed && (short)ret < 0)) {
- throw new WiredTigerPackingException("Overflow unpacking short.");
- }
- return (short)ret;
- }
-
- /**
- * Decodes an encoded integer from the stream. This method does bounds
- * checking, to ensure values fit, since some values may be encoded as
- * unsigned values, and Java types are all signed.
- */
- private int unpackInt(boolean signed)
- throws WiredTigerPackingException {
- long ret = unpackLong(true);
- if ((signed && (ret > Integer.MAX_VALUE || ret < Integer.MIN_VALUE)) ||
- (!signed && (int)ret < 0)) {
- throw new WiredTigerPackingException("Overflow unpacking integer.");
- }
- return (int)ret;
- }
-
- /**
- * Decodes an encoded long from the stream. This method does bounds
- * checking, to ensure values fit, since some values may be encoded as
- * unsigned values, and Java types are all signed.
- * The packing format is defined in the WiredTiger C integer packing
- * implementation, which is at src/include/intpack.i
- */
- private long unpackLong(boolean signed)
- throws WiredTigerPackingException {
- int len;
- long unpacked = 0;
- switch (value[valueOff] & 0xf0) {
- case PackUtil.NEG_MULTI_MARKER & 0xff:
- len = (int)PackUtil.SIZEOF_LONG - (value[valueOff++] & 0xf);
-
- for (unpacked = 0xffffffff; len != 0; --len) {
- unpacked = (unpacked << 8) | value[valueOff++] & 0xff;
- }
- break;
- case PackUtil.NEG_2BYTE_MARKER & 0xff:
- case (PackUtil.NEG_2BYTE_MARKER | 0x10) & 0xff:
- unpacked = PackUtil.GET_BITS(value[valueOff++], 5, 0) << 8;
- unpacked |= value[valueOff++] & 0xff;
- unpacked += PackUtil.NEG_2BYTE_MIN;
- break;
- case PackUtil.NEG_1BYTE_MARKER & 0xff:
- case (PackUtil.NEG_1BYTE_MARKER | 0x10) & 0xff:
- case (PackUtil.NEG_1BYTE_MARKER | 0x20) & 0xff:
- case (PackUtil.NEG_1BYTE_MARKER | 0x30) & 0xff:
- unpacked = PackUtil.NEG_1BYTE_MIN +
- PackUtil.GET_BITS(value[valueOff++], 6, 0);
- break;
- case PackUtil.POS_1BYTE_MARKER & 0xff:
- case (PackUtil.POS_1BYTE_MARKER | 0x10) & 0xff:
- case (PackUtil.POS_1BYTE_MARKER | 0x20) & 0xff:
- case (PackUtil.POS_1BYTE_MARKER | 0x30) & 0xff:
- unpacked = PackUtil.GET_BITS(value[valueOff++], 6, 0);
- break;
- case PackUtil.POS_2BYTE_MARKER & 0xff:
- case (PackUtil.POS_2BYTE_MARKER | 0x10) & 0xff:
- unpacked = PackUtil.GET_BITS(value[valueOff++], 5, 0) << 8;
- unpacked |= value[valueOff++] & 0xff;
- unpacked += PackUtil.POS_1BYTE_MAX + 1;
- break;
- case PackUtil.POS_MULTI_MARKER & 0xff:
- // There are four length bits in the first byte.
- len = (value[valueOff++] & 0xf);
-
- for (unpacked = 0; len != 0; --len) {
- unpacked = (unpacked << 8) | value[valueOff++] & 0xff;
- }
- unpacked += PackUtil.POS_2BYTE_MAX + 1;
- break;
- default:
- throw new WiredTigerPackingException(
- "Error decoding packed value.");
- }
- // Check for overflow if decoding an unsigned value - since Java only
- // supports signed values.
- if (!signed && unpacked < 0) {
- throw new WiredTigerPackingException("Overflow unpacking long.");
- }
-
- return (unpacked);
- }
-}
-
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
deleted file mode 100644
index 7c836d36d61..00000000000
--- a/src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/PackOutputStream.java
+++ /dev/null
@@ -1,319 +0,0 @@
-/*-
- * Public Domain 2014-2020 MongoDB, Inc.
- * Public Domain 2008-2014 WiredTiger, Inc.
- *
- * This is free and unencumbered software released into the public domain.
- *
- * Anyone is free to copy, modify, publish, use, compile, sell, or
- * distribute this software, either in source code form or as a compiled
- * binary, for any purpose, commercial or non-commercial, and by any
- * means.
- *
- * In jurisdictions that recognize copyright laws, the author or authors
- * of this software dedicate any and all copyright interest in the
- * software to the public domain. We make this dedication for the benefit
- * of the public at large and to the detriment of our heirs and
- * successors. We intend this dedication to be an overt act of
- * relinquishment in perpetuity of all present and future rights to this
- * software under copyright law.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-package com.wiredtiger.db;
-
-import java.io.ByteArrayOutputStream;
-import java.lang.StringBuffer;
-import com.wiredtiger.db.WiredTigerPackingException;
-
-/**
- * An internal helper class for encoding WiredTiger packed values.
- *
- * Applications should not need to use this class.
- */
-public class PackOutputStream {
-
- final static int MAX_INT_BYTES = 21;
- protected PackFormatInputStream format;
- protected ByteArrayOutputStream packed;
- protected byte[] intBuf;
- protected boolean isRaw;
-
- /**
- * Constructor.
- *
- * \param format A String that contains the WiredTiger format that
- * defines the layout of this packed value.
- */
- public PackOutputStream(String format) {
- this(format, false);
- }
-
- /**
- * Constructor.
- *
- * \param format A String that contains the WiredTiger format that
- * defines the layout of this packed value.
- * \param isRaw The stream is opened raw.
- */
- public PackOutputStream(String format, boolean isRaw) {
- this.format = new PackFormatInputStream(format, isRaw);
- this.intBuf = new byte[MAX_INT_BYTES];
- this.packed = new ByteArrayOutputStream(100);
- this.isRaw = isRaw;
- }
-
- /**
- * Returns the raw packing format string.
- */
- public String getFormat() {
- return format.toString();
- }
-
- /**
- * Returns the current packed value.
- */
- public byte[] getValue() {
- return packed.toByteArray();
- }
-
- /**
- * Reset the stream position.
- */
- public void reset() {
- format.reset();
- packed.reset();
- }
-
- /**
- * Add a byte field to the stream.
- *
- * \param value The byte value to be added.
- */
- public void addByte(byte value)
- throws WiredTigerPackingException {
- format.checkType('b', true);
- /* Translate to maintain ordering with the sign bit. */
- byte input = (byte)(value + 0x80);
- packed.write(input);
- }
-
- /**
- * Add a byte array field to the stream.
- *
- * \param value The byte array value to be added.
- */
- public void addByteArray(byte[] value)
- throws WiredTigerPackingException {
- this.addByteArray(value, 0, value.length);
- }
-
- /**
- * Add a byte array field to the stream.
- *
- * \param value The byte array value to be added.
- * \param off The offset from the start of value to begin using the array.
- * \param len The length of the value to encode.
- */
- public void addByteArray(byte[] value, int off, int len)
- throws WiredTigerPackingException {
- int padBytes = 0;
-
- if (!isRaw) {
- format.checkType('U', false);
- }
- boolean havesize = format.hasLength();
- char type = format.getType();
- if (havesize) {
- int size = format.getLengthFromFormat(true);
- if (len > size) {
- len = size;
- } else if (size > len) {
- padBytes = size - len;
- }
- }
- // We're done pulling information from the field now.
- format.consume();
-
- // If this is not the last item and the format does not have the
- // size, or we're using the internal 'U' format, store the size.
- if (!havesize && (format.available() > 0 || type == 'U')) {
- packLong(len, false);
- }
- packed.write(value, off, len);
- while(padBytes-- > 0) {
- packed.write(0);
- }
- }
-
- /**
- * Add an integer field to the stream.
- *
- * \param value The integer value to be added.
- */
- public void addInt(int value)
- throws WiredTigerPackingException {
- format.checkType('i', true);
- packLong(value, true);
- }
-
- /**
- * Add a long field to the stream.
- *
- * \param value The long value to be added.
- */
- public void addLong(long value)
- throws WiredTigerPackingException {
- format.checkType('q', true);
- packLong(value, true);
- }
-
- /**
- * Add a record field to the stream.
- *
- * \param value The record value to be added.
- */
- public void addRecord(long value)
- throws WiredTigerPackingException {
- format.checkType('r', true);
- packLong(value, true);
- }
-
- /**
- * Add a short field to the stream.
- *
- * \param value The short value to be added.
- */
- public void addShort(short value)
- throws WiredTigerPackingException {
- format.checkType('h', true);
- packLong(value, true);
- }
-
- /**
- * Add a string field to the stream.
- *
- * \param value The string value to be added.
- */
- public void addString(String value)
- throws WiredTigerPackingException {
- format.checkType('s', false);
- 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.
-
- // Logic from python packing.py:
- boolean havesize = format.hasLength();
- int nullpos = value.indexOf('\0');
- int size = 0;
-
- if (fieldFormat == 'S' && nullpos >= 0) {
- stringLen = nullpos;
- } else {
- stringLen = value.length();
- }
- if (havesize || fieldFormat == 's') {
- size = format.getLengthFromFormat(true);
- if (stringLen > size) {
- stringLen = size;
- }
- }
-
- if (fieldFormat == 'S' && !havesize) {
- padBytes = 1;
- } else if (size > stringLen) {
- padBytes = size - stringLen;
- }
-
- // We're done pulling information from the field now.
- format.consume();
-
- // Use the default Charset.
- packed.write(value.getBytes(), 0, stringLen);
- while(padBytes-- > 0) {
- packed.write(0);
- }
- }
-
- /**
- * Add a long field to the stream.
- * The packing format is defined in the WiredTiger C integer packing
- * implementation, which is at src/include/intpack.i
- *
- * \param x The long value to be added.
- * \param signed Whether the value is signed or unsigned.
- */
- private void packLong(long x, boolean signed)
- throws WiredTigerPackingException {
- int offset = 0;
-
- if (!signed && x < 0) {
- throw new WiredTigerPackingException("Overflow packing long.");
- }
-
- if (x < PackUtil.NEG_2BYTE_MIN) {
- intBuf[offset] = PackUtil.NEG_MULTI_MARKER;
- int lz = Long.numberOfLeadingZeros(~x) / 8;
- int len = PackUtil.SIZEOF_LONG - lz;
-
- //
- // There are four size bits we can use in the first
- // byte. For negative numbers, we store the number of
- // leading 0xff byes to maintain ordering (if this is
- // not obvious, it may help to remember that -1 is the
- // largest negative number).
- intBuf[offset++] |= (lz & 0xf);
-
- for (int shift = (len - 1) << 3;
- len != 0; shift -= 8, --len) {
- intBuf[offset++] = (byte)(x >> shift);
- }
- } else if (x < PackUtil.NEG_1BYTE_MIN) {
- x -= PackUtil.NEG_2BYTE_MIN;
- intBuf[offset++] =
- (byte)(PackUtil.NEG_2BYTE_MARKER | PackUtil.GET_BITS(x, 13, 8));
- intBuf[offset++] = PackUtil.GET_BITS(x, 8, 0);
- } else if (x < 0) {
- x -= PackUtil.NEG_1BYTE_MIN;
- intBuf[offset++] =
- (byte)(PackUtil.NEG_1BYTE_MARKER | PackUtil.GET_BITS(x, 6, 0));
- } else if (x <= PackUtil.POS_1BYTE_MAX) {
- intBuf[offset++] =
- (byte)(PackUtil.POS_1BYTE_MARKER | PackUtil.GET_BITS(x, 6, 0));
- } else if (x <= PackUtil.POS_2BYTE_MAX) {
- x -= PackUtil.POS_1BYTE_MAX + 1;
- intBuf[offset++] =
- (byte)(PackUtil.POS_2BYTE_MARKER | PackUtil.GET_BITS(x, 13, 8));
- intBuf[offset++] = PackUtil.GET_BITS(x, 8, 0);
- } else if (x == PackUtil.POS_2BYTE_MAX + 1) {
- // This is a special case where we could store the value with
- // just a single byte, but we append a zero byte so that the
- // encoding doesn't get shorter for this one value.
- intBuf[offset++] = (byte)(PackUtil.POS_MULTI_MARKER | 0x01);
- intBuf[offset++] = 0;
- } else {
- x -= PackUtil.POS_2BYTE_MAX + 1;
- intBuf[offset] = PackUtil.POS_MULTI_MARKER;
- int lz = Long.numberOfLeadingZeros(x) / 8;
- int len = PackUtil.SIZEOF_LONG - lz;
-
- // There are four bits we can use in the first byte.
- intBuf[offset++] |= (len & 0xf);
-
- for (int shift = (len - 1) << 3;
- len != 0; --len, shift -= 8) {
- intBuf[offset++] = (byte)(x >> shift);
- }
- }
- packed.write(intBuf, 0, offset);
- }
-}
diff --git a/src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/PackUtil.java b/src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/PackUtil.java
deleted file mode 100644
index aa5112304c6..00000000000
--- a/src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/PackUtil.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*-
- * Public Domain 2014-2020 MongoDB, Inc.
- * Public Domain 2008-2014 WiredTiger, Inc.
- *
- * This is free and unencumbered software released into the public domain.
- *
- * Anyone is free to copy, modify, publish, use, compile, sell, or
- * distribute this software, either in source code form or as a compiled
- * binary, for any purpose, commercial or non-commercial, and by any
- * means.
- *
- * In jurisdictions that recognize copyright laws, the author or authors
- * of this software dedicate any and all copyright interest in the
- * software to the public domain. We make this dedication for the benefit
- * of the public at large and to the detriment of our heirs and
- * successors. We intend this dedication to be an overt act of
- * relinquishment in perpetuity of all present and future rights to this
- * software under copyright law.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-package com.wiredtiger.db;
-
-import java.lang.String;
-
-/**
- * An internal helper class with utilities for packing and unpacking values.
- *
- * Applications should not need to use this class.
- */
-class PackUtil {
- /* Contants. */
- final static byte NEG_MULTI_MARKER = (byte)0x10;
- final static byte NEG_2BYTE_MARKER = (byte)0x20;
- final static byte NEG_1BYTE_MARKER = (byte)0x40;
- final static byte POS_1BYTE_MARKER = (byte)0x80;
- final static byte POS_2BYTE_MARKER = (byte)0xc0;
- final static byte POS_MULTI_MARKER = (byte)0xe0;
-
- final static int NEG_1BYTE_MIN = ((-1) << 6);
- final static int NEG_2BYTE_MIN = (((-1) << 13) + NEG_1BYTE_MIN);
- final static int POS_1BYTE_MAX = ((1 << 6) - 1);
- final static int POS_2BYTE_MAX = ((1 << 13) + POS_1BYTE_MAX);
-
- // See: http://docs.python.org/2/library/struct.html for an explanation
- // of what these special characters mean.
- // TODO: Care about byte ordering and padding in packed formats.
- final static String PackSpecialCharacters = "@=<>!x";
-
- final static int SIZEOF_LONG = 8;
-
- /**
- * Extract bits from a value, counting from LSB == 0.
- *
- * \param x The value to extract bits from.
- * \param start The first bit to extract.
- * \param end The last bit to extract.
- */
- public static byte GET_BITS(long x, int start, int end) {
- return (byte)((x & ((1 << start) - 1)) >> end);
- }
-
-
-}
diff --git a/src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/WiredTigerException.java b/src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/WiredTigerException.java
deleted file mode 100644
index 2f8bee8f5f0..00000000000
--- a/src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/WiredTigerException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*-
- * Public Domain 2014-2020 MongoDB, Inc.
- * Public Domain 2008-2014 WiredTiger, Inc.
- *
- * This is free and unencumbered software released into the public domain.
- *
- * Anyone is free to copy, modify, publish, use, compile, sell, or
- * distribute this software, either in source code form or as a compiled
- * binary, for any purpose, commercial or non-commercial, and by any
- * means.
- *
- * In jurisdictions that recognize copyright laws, the author or authors
- * of this software dedicate any and all copyright interest in the
- * software to the public domain. We make this dedication for the benefit
- * of the public at large and to the detriment of our heirs and
- * successors. We intend this dedication to be an overt act of
- * relinquishment in perpetuity of all present and future rights to this
- * software under copyright law.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-package com.wiredtiger.db;
-
-/**
- * An exception that is generated by the WiredTiger application.
- */
-public class WiredTigerException extends RuntimeException {
- /**
- * Constructor.
- */
- public WiredTigerException(String msg) {
- super(msg);
- }
-}
diff --git a/src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/WiredTigerPackingException.java b/src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/WiredTigerPackingException.java
deleted file mode 100644
index 7c7286ecb4b..00000000000
--- a/src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/WiredTigerPackingException.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*-
- * Public Domain 2014-2020 MongoDB, Inc.
- * Public Domain 2008-2014 WiredTiger, Inc.
- *
- * This is free and unencumbered software released into the public domain.
- *
- * Anyone is free to copy, modify, publish, use, compile, sell, or
- * distribute this software, either in source code form or as a compiled
- * binary, for any purpose, commercial or non-commercial, and by any
- * means.
- *
- * In jurisdictions that recognize copyright laws, the author or authors
- * of this software dedicate any and all copyright interest in the
- * software to the public domain. We make this dedication for the benefit
- * of the public at large and to the detriment of our heirs and
- * successors. We intend this dedication to be an overt act of
- * relinquishment in perpetuity of all present and future rights to this
- * software under copyright law.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-package com.wiredtiger.db;
-
-/**
- * An exception that is generated by the WiredTiger application during
- * encoding or decoding of packed values.
- */
-public class WiredTigerPackingException extends WiredTigerException {
- /**
- * Constructor.
- */
- public WiredTigerPackingException(String msg) {
- super(msg);
- }
-}
-
diff --git a/src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/WiredTigerPanicException.java b/src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/WiredTigerPanicException.java
deleted file mode 100644
index e0d44faa174..00000000000
--- a/src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/WiredTigerPanicException.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*-
- * Public Domain 2014-2020 MongoDB, Inc.
- * Public Domain 2008-2014 WiredTiger, Inc.
- *
- * This is free and unencumbered software released into the public domain.
- *
- * Anyone is free to copy, modify, publish, use, compile, sell, or
- * distribute this software, either in source code form or as a compiled
- * binary, for any purpose, commercial or non-commercial, and by any
- * means.
- *
- * In jurisdictions that recognize copyright laws, the author or authors
- * of this software dedicate any and all copyright interest in the
- * software to the public domain. We make this dedication for the benefit
- * of the public at large and to the detriment of our heirs and
- * successors. We intend this dedication to be an overt act of
- * relinquishment in perpetuity of all present and future rights to this
- * software under copyright law.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-package com.wiredtiger.db;
-
-/**
- * An exception that is generated by the WiredTiger application when
- * there is an underlying problem that requires the application exit
- * and restart.
- */
-public class WiredTigerPanicException extends WiredTigerException {
- /**
- * Constructor.
- */
- public WiredTigerPanicException(String msg) {
- super(msg);
- }
-}
-
diff --git a/src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/WiredTigerRollbackException.java b/src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/WiredTigerRollbackException.java
deleted file mode 100644
index 47e0ae8688d..00000000000
--- a/src/third_party/wiredtiger/lang/java/src/com/wiredtiger/db/WiredTigerRollbackException.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*-
- * Public Domain 2014-2020 MongoDB, Inc.
- * Public Domain 2008-2014 WiredTiger, Inc.
- *
- * This is free and unencumbered software released into the public domain.
- *
- * Anyone is free to copy, modify, publish, use, compile, sell, or
- * distribute this software, either in source code form or as a compiled
- * binary, for any purpose, commercial or non-commercial, and by any
- * means.
- *
- * In jurisdictions that recognize copyright laws, the author or authors
- * of this software dedicate any and all copyright interest in the
- * software to the public domain. We make this dedication for the benefit
- * of the public at large and to the detriment of our heirs and
- * successors. We intend this dedication to be an overt act of
- * relinquishment in perpetuity of all present and future rights to this
- * software under copyright law.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-package com.wiredtiger.db;
-
-/**
- * An exception that is generated by the WiredTiger application
- * when there is a conflict between concurrent operations.
- */
-public class WiredTigerRollbackException extends WiredTigerException {
- /**
- * Constructor.
- */
- public WiredTigerRollbackException(String msg) {
- super(msg);
- }
-}
-
diff --git a/src/third_party/wiredtiger/lang/java/wiredtiger.i b/src/third_party/wiredtiger/lang/java/wiredtiger.i
deleted file mode 100644
index 1e6c1770b89..00000000000
--- a/src/third_party/wiredtiger/lang/java/wiredtiger.i
+++ /dev/null
@@ -1,1522 +0,0 @@
-/*-
- * Public Domain 2014-2020 MongoDB, Inc.
- * Public Domain 2008-2014 WiredTiger, Inc.
- *
- * This is free and unencumbered software released into the public domain.
- *
- * Anyone is free to copy, modify, publish, use, compile, sell, or
- * distribute this software, either in source code form or as a compiled
- * binary, for any purpose, commercial or non-commercial, and by any
- * means.
- *
- * In jurisdictions that recognize copyright laws, the author or authors
- * of this software dedicate any and all copyright interest in the
- * software to the public domain. We make this dedication for the benefit
- * of the public at large and to the detriment of our heirs and
- * successors. We intend this dedication to be an overt act of
- * relinquishment in perpetuity of all present and future rights to this
- * software under copyright law.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * wiredtiger.i
- * The SWIG interface file defining the wiredtiger Java API.
- */
-
-%module wiredtiger
-
-%include "enums.swg"
-%include "typemaps.i"
-%include "stdint.i"
-
-%pragma(java) jniclasscode=%{
- static {
- try {
- System.loadLibrary("wiredtiger_java");
- } catch (UnsatisfiedLinkError e) {
- System.err.println("Native code library failed to load. \n" + e);
- System.exit(1);
- }
- }
-%}
-
-%{
-#include "wiredtiger.h"
-#include "src/include/wt_internal.h"
-
-/*
- * Closed handle checking:
- *
- * The typedef WT_CURSOR_NULLABLE used in wiredtiger.h is only made
- * visible to the SWIG parser and is used to identify arguments of
- * Cursor type that are permitted to be null. Likewise, typedefs
- * WT_{CURSOR,SESSION,CONNECTION}_CLOSED identify 'close' calls that
- * need explicit nulling of the swigCPtr. These typedefs permit
- * special casing in typemaps for input args.
- *
- * We want SWIG to see these 'fake' typenames, but not the compiler.
- */
-#define WT_CURSOR_NULLABLE WT_CURSOR
-#define WT_CURSOR_CLOSED WT_CURSOR
-#define WT_SESSION_CLOSED WT_SESSION
-#define WT_CONNECTION_CLOSED WT_CONNECTION
-
-/*
- * For Connections, Sessions and Cursors created in Java, each of
- * WT_CONNECTION_IMPL, WT_SESSION_IMPL and WT_CURSOR have a
- * lang_private field that store a pointer to a JAVA_CALLBACK, alloced
- * during the various open calls. {conn,session,cursor}CloseHandler()
- * functions reach into the associated java object, set the swigCPtr
- * to 0, and free the JAVA_CALLBACK. Typemaps matching Connection,
- * Session, Cursor args use the NULL_CHECK macro, which checks if
- * swigCPtr is 0.
- */
-typedef struct {
- JNIEnv *jnienv; /* jni env that created the Session/Cursor */
- WT_SESSION_IMPL *session; /* session used for alloc/free */
- bool cursor_raw; /* is the cursor opened raw? */
- jobject jobj; /* the java Session/Cursor object */
- jfieldID cptr_fid; /* cached Cursor.swigCPtr field id in session */
-} JAVA_CALLBACK;
-
-static void throwWiredTigerException(JNIEnv *jenv, int err) {
- const char *clname;
- jclass excep;
-
- clname = NULL;
- excep = NULL;
- if (err == WT_PANIC)
- clname = "com/wiredtiger/db/WiredTigerPanicException";
- else if (err == WT_ROLLBACK)
- clname = "com/wiredtiger/db/WiredTigerRollbackException";
- else
- clname = "com/wiredtiger/db/WiredTigerException";
- if (clname)
- excep = (*jenv)->FindClass(jenv, clname);
- if (excep)
- (*jenv)->ThrowNew(jenv, excep, wiredtiger_strerror(err));
-}
-
-struct __wt_java_modify_impl;
-struct __wt_java_modify_list;
-typedef struct __wt_java_modify_impl WT_MODIFY_IMPL;
-typedef struct __wt_java_modify_list WT_MODIFY_LIST;
-static void modify_impl_release(WT_MODIFY_IMPL *impl);
-static void modify_list_release(WT_MODIFY_LIST *impl);
-
-/*
- * An extension to the WT_MODIFY struct, so we can associate some Java-specific
- * information with it.
- */
-typedef struct __wt_java_modify_impl {
- WT_MODIFY modify;
- JNIEnv *jnienv;
- jobject ref;
-} WT_MODIFY_IMPL;
-
-%}
-
-/* No finalizers */
-%typemap(javafinalize) SWIGTYPE ""
-
-/* Event handlers are not supported in Java. */
-%typemap(in, numinputs=0) WT_EVENT_HANDLER * %{ $1 = NULL; %}
-
-/* Allow silently passing the Java object and JNIEnv into our code. */
-%typemap(in, numinputs=0) jobject *jthis %{ $1 = jarg1_; %}
-%typemap(in, numinputs=0) JNIEnv * %{ $1 = jenv; %}
-
-/* 64 bit typemaps. */
-%typemap(jni) uint64_t "jlong"
-%typemap(jtype) uint64_t "long"
-%typemap(jstype) uint64_t "long"
-
-%typemap(javain) uint64_t "$javainput"
-%typemap(javaout) uint64_t {
- return ($jnicall);
-}
-
-/* Return byte[] from cursor.get_value */
-%typemap(jni) WT_ITEM, WT_ITEM * "jbyteArray"
-%typemap(jtype) WT_ITEM, WT_ITEM * "byte[]"
-%typemap(jstype) WT_ITEM, WT_ITEM * "byte[]"
-
-%typemap(javain) WT_ITEM, WT_ITEM * "$javainput"
-%typemap(javaout) WT_ITEM, WT_ITEM * {
- return ($jnicall);
-}
-
-%typemap(in) WT_ITEM * (WT_ITEM item) %{
- $1 = &item;
- $1->data = (*jenv)->GetByteArrayElements(jenv, $input, 0);
- $1->size = (size_t)(*jenv)->GetArrayLength(jenv, $input);
-%}
-
-%typemap(argout) WT_ITEM * %{
- (*jenv)->ReleaseByteArrayElements(jenv, $input, (void *)$1->data, 0);
-%}
-
-%typemap(out) WT_ITEM %{
- if ($1.data == NULL)
- $result = NULL;
- else if (($result = (*jenv)->NewByteArray(jenv, (jsize)$1.size)) != NULL) {
- (*jenv)->SetByteArrayRegion(jenv,
- $result, 0, (jsize)$1.size, $1.data);
- }
-%}
-
-/*
- * In some cases, for an internal interface, we need something like a WT_ITEM,
- * but we need to hold onto the memory past the method call, and release it
- * later. A WT_ITEM_HOLD serves the purpose, it retains the java object
- * for the byte array that we make into a global reference.
- */
-%typemap(jni) WT_ITEM_HOLD, WT_ITEM_HOLD * "jbyteArray"
-%typemap(jtype) WT_ITEM_HOLD, WT_ITEM_HOLD * "byte[]"
-%typemap(jstype) WT_ITEM_HOLD, WT_ITEM_HOLD * "byte[]"
-
-%typemap(javain) WT_ITEM_HOLD, WT_ITEM_HOLD * "$javainput"
-%typemap(javaout) WT_ITEM_HOLD, WT_ITEM_HOLD * {
- return ($jnicall);
-}
-%typemap(in) WT_ITEM_HOLD * (WT_ITEM_HOLD item) %{
- $1 = &item;
- $1->data = (*jenv)->GetByteArrayElements(jenv, $input, 0);
- $1->size = (size_t)(*jenv)->GetArrayLength(jenv, $input);
- $1->jnienv = jenv;
- $1->ref = (*jenv)->NewGlobalRef(jenv, $input);
-%}
-
-%typemap(argout) WT_ITEM_HOLD * %{
- /* Explicitly don't release the byte array elements here. */
-%}
-
-/* Don't require empty config strings. */
-%typemap(default) const char *config %{ $1 = NULL; %}
-
-%typemap(out) int %{
- if ($1 != 0 && $1 != WT_NOTFOUND) {
- throwWiredTigerException(jenv, $1);
- return ($null);
- }
- $result = $1;
-%}
-
-%define NULL_CHECK(val, name)
- if (!val) {
- SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException,
- #name " is null");
- return ($null);
- }
-%enddef
-
-/*
- * 'Declare' a WiredTiger class. This sets up boilerplate typemaps.
- */
-%define WT_CLASS(type, class, name)
-/*
- * Extra 'self' elimination.
- * The methods we're wrapping look like this:
- * struct __wt_xxx {
- * int method(WT_XXX *, ...otherargs...);
- * };
- * To SWIG, that is equivalent to:
- * int method(struct __wt_xxx *self, WT_XXX *, ...otherargs...);
- * and we use consecutive argument matching of typemaps to convert two args to
- * one.
- */
-%typemap(in, numinputs=0) type *name {
- $1 = *(type **)&jarg1;
- NULL_CHECK($1, $1_name)
-}
-
-%typemap(in) class ## _NULLABLE * {
- $1 = *(type **)&$input;
-}
-
-%typemap(in) type * {
- $1 = *(type **)&$input;
- NULL_CHECK($1, $1_name)
-}
-
-%typemap(javaimports) type "
-/**
- * @copydoc class
- * @ingroup wt_java
- */"
-%enddef
-
-/*
- * Declare a WT_CLASS so that close methods call a specified closeHandler,
- * after the WT core close function has completed. Arguments to the
- * closeHandler are saved in advance since, as macro args, they may refer to
- * values that are freed/zeroed by the close.
- */
-%define WT_CLASS_WITH_CLOSE_HANDLER(type, class, name, closeHandler,
- sess, priv)
-WT_CLASS(type, class, name)
-
-/*
- * This typemap recognizes a close function via a special declaration on its
- * first argument. See WT_HANDLE_CLOSED in wiredtiger.h . Like
- * WT_CURSOR_NULLABLE, the WT_{CURSOR,SESSION,CONNECTION}_CLOSED typedefs
- * are only visible to the SWIG parser.
- */
-%typemap(in, numinputs=0) class ## _CLOSED *name (
- WT_SESSION *savesess, JAVA_CALLBACK *jcb) {
- $1 = *(type **)&jarg1;
- NULL_CHECK($1, $1_name)
- savesess = sess;
- jcb = (JAVA_CALLBACK *)(priv);
-}
-
-%typemap(freearg, numinputs=0) class ## _CLOSED *name {
- closeHandler(jenv, savesess2, jcb2);
-}
-
-%enddef
-
-%pragma(java) moduleimports=%{
-/**
- * @defgroup wt_java WiredTiger Java API
- *
- * Java wrappers around the WiredTiger C API.
- */
-
-/**
- * @ingroup wt_java
- */
-%}
-
-WT_CLASS_WITH_CLOSE_HANDLER(struct __wt_connection, WT_CONNECTION, connection,
- closeHandler, NULL, ((WT_CONNECTION_IMPL *)$1)->lang_private)
-WT_CLASS_WITH_CLOSE_HANDLER(struct __wt_session, WT_SESSION, session,
- closeHandler, $1, ((WT_SESSION_IMPL *)$1)->lang_private)
-WT_CLASS_WITH_CLOSE_HANDLER(struct __wt_cursor, WT_CURSOR, cursor,
- cursorCloseHandler, $1->session, ((WT_CURSOR *)$1)->lang_private)
-
-%define COPYDOC(SIGNATURE_CLASS, CLASS, METHOD)
-%javamethodmodifiers SIGNATURE_CLASS::METHOD "
- /**
- * @copydoc CLASS::METHOD
- */
- public ";
-%enddef
-
-%include "java_doc.i"
-
-/* WT_CURSOR customization. */
-/* First, replace the varargs get / set methods with Java equivalents. */
-%ignore __wt_cursor::get_key;
-%ignore __wt_cursor::get_value;
-%ignore __wt_cursor::set_key;
-%ignore __wt_cursor::set_value;
-%ignore __wt_cursor::insert;
-%ignore __wt_cursor::remove;
-%ignore __wt_cursor::reset;
-%ignore __wt_cursor::search;
-%ignore __wt_cursor::search_near;
-%ignore __wt_cursor::update;
-%javamethodmodifiers __wt_cursor::next "protected";
-%rename (next_wrap) __wt_cursor::next;
-%javamethodmodifiers __wt_cursor::prev "protected";
-%rename (prev_wrap) __wt_cursor::prev;
-%javamethodmodifiers __wt_cursor::key_format "protected";
-%javamethodmodifiers __wt_cursor::value_format "protected";
-%ignore __wt_modify::data;
-%ignore __wt_modify::position;
-%ignore __wt_modify::size;
-%ignore __wt_cursor::modify;
-%ignore wiredtiger_calc_modify;
-
-%ignore __wt_cursor::compare(WT_CURSOR *, WT_CURSOR *, int *);
-%rename (compare_wrap) __wt_cursor::compare;
-%ignore __wt_cursor::equals(WT_CURSOR *, WT_CURSOR *, int *);
-%rename (equals_wrap) __wt_cursor::equals;
-
-/*
- * Special cases: override the out typemap, return checking is done in the
- * wrapper.
- */
-%typemap(out) int __wt_cursor::compare_wrap,
- int __wt_cursor::equals_wrap %{
- $result = $1;
-%}
-
-/* SWIG magic to turn Java byte strings into data / size. */
-%apply (char *STRING, int LENGTH) { (char *data, int size) };
-
-/* Status from search_near */
-%javaconst(1);
-%inline %{
-enum SearchStatus { FOUND, NOTFOUND, SMALLER, LARGER };
-%}
-
-%wrapper %{
-/* Zero out SWIG's pointer to the C object,
- * equivalent to 'jobj.swigCPtr = 0;' in java.
- * We expect that either env in non-null (if called
- * via an explicit session/cursor close() call), or
- * that session is non-null (if called implicitly
- * as part of connection/session close).
- */
-static int
-javaClose(JNIEnv *env, WT_SESSION *session, JAVA_CALLBACK *jcb, jfieldID *pfid)
-{
- jclass cls;
- jfieldID fid;
- WT_CONNECTION_IMPL *conn;
-
- /* If we were not called via an implicit close call,
- * we won't have a JNIEnv yet. Get one from the connection,
- * since the thread that started the session may have
- * terminated.
- */
- if (env == NULL) {
- conn = (WT_CONNECTION_IMPL *)session->connection;
- env = ((JAVA_CALLBACK *)conn->lang_private)->jnienv;
- }
- if (pfid == NULL || *pfid == NULL) {
- cls = (*env)->GetObjectClass(env, jcb->jobj);
- fid = (*env)->GetFieldID(env, cls, "swigCPtr", "J");
- if (pfid != NULL)
- *pfid = fid;
- } else
- fid = *pfid;
-
- (*env)->SetLongField(env, jcb->jobj, fid, 0L);
- (*env)->DeleteGlobalRef(env, jcb->jobj);
- __wt_free(jcb->session, jcb);
- return (0);
-}
-
-/* Connection and Session close handler. */
-static int
-closeHandler(JNIEnv *env, WT_SESSION *session, JAVA_CALLBACK *jcb)
-{
- return (javaClose(env, session, jcb, NULL));
-}
-
-/* Cursor specific close handler. */
-static int
-cursorCloseHandler(JNIEnv *env, WT_SESSION *wt_session, JAVA_CALLBACK *jcb)
-{
- int ret;
- JAVA_CALLBACK *sess_jcb;
- WT_SESSION_IMPL *session;
-
- session = (WT_SESSION_IMPL *)wt_session;
- sess_jcb = (JAVA_CALLBACK *)session->lang_private;
- ret = javaClose(env, wt_session, jcb,
- sess_jcb ? &sess_jcb->cptr_fid : NULL);
-
- return (ret);
-}
-
-/* Add event handler support. */
-static int
-javaCloseHandler(WT_EVENT_HANDLER *handler, WT_SESSION *session,
- WT_CURSOR *cursor)
-{
- int ret;
- JAVA_CALLBACK *jcb;
-
- WT_UNUSED(handler);
-
- ret = 0;
- if (cursor != NULL) {
- if ((jcb = (JAVA_CALLBACK *)cursor->lang_private) != NULL) {
- ret = cursorCloseHandler(NULL, session, jcb);
- cursor->lang_private = NULL;
- }
- } else if ((jcb = ((WT_SESSION_IMPL *)session)->lang_private) != NULL) {
- ret = closeHandler(NULL, session, jcb);
- ((WT_SESSION_IMPL *)session)->lang_private = NULL;
- }
- return (ret);
-}
-
-WT_EVENT_HANDLER javaApiEventHandler = {NULL, NULL, NULL, javaCloseHandler};
-%}
-
-%extend __wt_cursor {
-
- %javamethodmodifiers get_key_wrap "protected";
- WT_ITEM get_key_wrap(JNIEnv *jenv) {
- WT_ITEM k;
- int ret;
- k.data = NULL;
- if ((ret = $self->get_key($self, &k)) != 0)
- throwWiredTigerException(jenv, ret);
- return (k);
- }
-
- %javamethodmodifiers get_value_wrap "protected";
- WT_ITEM get_value_wrap(JNIEnv *jenv) {
- WT_ITEM v;
- int ret;
- v.data = NULL;
- if ((ret = $self->get_value($self, &v)) != 0)
- throwWiredTigerException(jenv, ret);
- return (v);
- }
-
- %javamethodmodifiers insert_wrap "protected";
- int insert_wrap(WT_ITEM *k, WT_ITEM *v) {
- $self->set_key($self, k);
- $self->set_value($self, v);
- return ($self->insert($self));
- }
-
- %javamethodmodifiers remove_wrap "protected";
- int remove_wrap(WT_ITEM *k) {
- $self->set_key($self, k);
- return ($self->remove($self));
- }
-
- %javamethodmodifiers reset_wrap "protected";
- int reset_wrap() {
- return $self->reset($self);
- }
-
- %javamethodmodifiers search_wrap "protected";
- int search_wrap(WT_ITEM *k) {
- $self->set_key($self, k);
- return ($self->search($self));
- }
-
- %javamethodmodifiers search_near_wrap "protected";
- enum SearchStatus search_near_wrap(JNIEnv *jenv, WT_ITEM *k) {
- int cmp, ret;
-
- $self->set_key($self, k);
- ret = $self->search_near(self, &cmp);
- if (ret != 0 && ret != WT_NOTFOUND)
- throwWiredTigerException(jenv, ret);
- if (ret == 0)
- return (cmp == 0 ? FOUND : cmp < 0 ? SMALLER : LARGER);
- return (NOTFOUND);
- }
-
- %javamethodmodifiers update_wrap "protected";
- int update_wrap(WT_ITEM *k, WT_ITEM *v) {
- $self->set_key($self, k);
- $self->set_value($self, v);
- return ($self->update($self));
- }
-
- %javamethodmodifiers compare_wrap "protected";
- int compare_wrap(JNIEnv *jenv, WT_CURSOR *other) {
- int cmp, ret = $self->compare($self, other, &cmp);
- if (ret != 0)
- throwWiredTigerException(jenv, ret);
- return (cmp);
- }
-
- %javamethodmodifiers equals_wrap "protected";
- int equals_wrap(JNIEnv *jenv, WT_CURSOR *other) {
- int cmp, ret = $self->equals($self, other, &cmp);
- if (ret != 0)
- throwWiredTigerException(jenv, ret);
- return (cmp);
- }
-
- %javamethodmodifiers _java_raw "protected";
- bool _java_raw(JNIEnv *jenv) {
- (void)jenv;
- JAVA_CALLBACK *jcb = (JAVA_CALLBACK *)$self->lang_private;
- return (jcb->cursor_raw);
- }
-
- %javamethodmodifiers _java_init "protected";
- int _java_init(jobject jcursor) {
- JAVA_CALLBACK *jcb = (JAVA_CALLBACK *)$self->lang_private;
- jcb->jobj = JCALL1(NewGlobalRef, jcb->jnienv, jcursor);
- JCALL1(DeleteLocalRef, jcb->jnienv, jcursor);
- return (0);
- }
-
- int modify_wrap(WT_MODIFY_LIST *list, WT_ITEM *k) {
- int ret;
-
- $self->set_key($self, k);
- ret = $self->modify(self, list->mod_array, list->count);
- modify_list_release(list);
- return (ret);
- }
-
- /*
- * Called internally after a new call. The artificial constructor for
- * WT_MODIFY_LIST has no opportunity to throw an exception on a memory
- * allocation failure, so the the null check must be made within a
- * method on WT_CURSOR.
- */
- bool _new_check_modify_list(WT_MODIFY_LIST *list) {
- JAVA_CALLBACK *jcb;
- if (list == NULL) {
- jcb = (JAVA_CALLBACK *)$self->lang_private;
- throwWiredTigerException(jcb->jnienv, ENOMEM);
- return (false);
- }
- return (true);
- }
-
- /*
- * Called internally after a new call. The artificial constructor for
- * WT_MODIFY has no opportunity to throw an exception on a memory
- * allocation failure, so the the null check must be made within a
- * method on WT_CURSOR.
- */
- bool _new_check_modify(WT_MODIFY *mod) {
- JAVA_CALLBACK *jcb;
- if (mod == NULL) {
- jcb = (JAVA_CALLBACK *)$self->lang_private;
- throwWiredTigerException(jcb->jnienv, ENOMEM);
- return (false);
- }
- return (true);
- }
-}
-
-/* Cache key/value formats in Cursor */
-%typemap(javabody) struct __wt_cursor %{
- private long swigCPtr;
- protected boolean swigCMemOwn;
- protected String keyFormat;
- protected String valueFormat;
- protected PackOutputStream keyPacker;
- protected PackOutputStream valuePacker;
- protected PackInputStream keyUnpacker;
- protected PackInputStream valueUnpacker;
-
- protected $javaclassname(long cPtr, boolean cMemoryOwn) {
- swigCMemOwn = cMemoryOwn;
- swigCPtr = cPtr;
- keyFormat = getKey_format();
- valueFormat = getValue_format();
- keyPacker = new PackOutputStream(keyFormat, _java_raw());
- valuePacker = new PackOutputStream(valueFormat, _java_raw());
- wiredtigerJNI.Cursor__java_init(swigCPtr, this, this);
- }
-
- protected static long getCPtr($javaclassname obj) {
- return (obj == null) ? 0 : obj.swigCPtr;
- }
-%}
-
-%typemap(javacode) struct __wt_cursor %{
-
- /**
- * Retrieve the format string for this cursor's key.
- */
- public String getKeyFormat() {
- return keyFormat;
- }
-
- /**
- * Retrieve the format string for this cursor's value.
- */
- public String getValueFormat() {
- return valueFormat;
- }
-
- /**
- * Append a byte to the cursor's key.
- *
- * \param value The value to append.
- * \return This cursor object, so put calls can be chained.
- */
- public Cursor putKeyByte(byte value)
- throws WiredTigerPackingException {
- keyPacker.addByte(value);
- return this;
- }
-
- /**
- * Append a byte array to the cursor's key.
- *
- * \param value The value to append.
- * \return This cursor object, so put calls can be chained.
- */
- public Cursor putKeyByteArray(byte[] value)
- throws WiredTigerPackingException {
- this.putKeyByteArray(value, 0, value.length);
- return this;
- }
-
- /**
- * Append a byte array to the cursor's key.
- *
- * \param value The value to append.
- * \param off The offset into value at which to start.
- * \param len The length of the byte array.
- * \return This cursor object, so put calls can be chained.
- */
- public Cursor putKeyByteArray(byte[] value, int off, int len)
- throws WiredTigerPackingException {
- keyPacker.addByteArray(value, off, len);
- return this;
- }
-
- /**
- * Append an integer to the cursor's key.
- *
- * \param value The value to append
- * \return This cursor object, so put calls can be chained.
- */
- public Cursor putKeyInt(int value)
- throws WiredTigerPackingException {
- keyPacker.addInt(value);
- return this;
- }
-
- /**
- * Append a long to the cursor's key.
- *
- * \param value The value to append
- * \return This cursor object, so put calls can be chained.
- */
- public Cursor putKeyLong(long value)
- throws WiredTigerPackingException {
- keyPacker.addLong(value);
- return this;
- }
-
- /**
- * 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
- * \return This cursor object, so put calls can be chained.
- */
- public Cursor putKeyShort(short value)
- throws WiredTigerPackingException {
- keyPacker.addShort(value);
- return this;
- }
-
- /**
- * Append a string to the cursor's key.
- *
- * \param value The value to append
- * \return This cursor object, so put calls can be chained.
- */
- public Cursor putKeyString(String value)
- throws WiredTigerPackingException {
- keyPacker.addString(value);
- return this;
- }
-
- /**
- * Append a byte to the cursor's value.
- *
- * \param value The value to append
- * \return This cursor object, so put calls can be chained.
- */
- public Cursor putValueByte(byte value)
- throws WiredTigerPackingException {
- valuePacker.addByte(value);
- return this;
- }
-
- /**
- * Append a byte array to the cursor's value.
- *
- * \param value The value to append
- * \return This cursor object, so put calls can be chained.
- */
- public Cursor putValueByteArray(byte[] value)
- throws WiredTigerPackingException {
- this.putValueByteArray(value, 0, value.length);
- return this;
- }
-
- /**
- * Append a byte array to the cursor's value.
- *
- * \param value The value to append
- * \param off The offset into value at which to start.
- * \param len The length of the byte array.
- * \return This cursor object, so put calls can be chained.
- */
- public Cursor putValueByteArray(byte[] value, int off, int len)
- throws WiredTigerPackingException {
- valuePacker.addByteArray(value, off, len);
- return this;
- }
-
- /**
- * Append an integer to the cursor's value.
- *
- * \param value The value to append
- * \return This cursor object, so put calls can be chained.
- */
- public Cursor putValueInt(int value)
- throws WiredTigerPackingException {
- valuePacker.addInt(value);
- return this;
- }
-
- /**
- * Append a long to the cursor's value.
- *
- * \param value The value to append
- * \return This cursor object, so put calls can be chained.
- */
- public Cursor putValueLong(long value)
- throws WiredTigerPackingException {
- valuePacker.addLong(value);
- return this;
- }
-
- /**
- * 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
- * \return This cursor object, so put calls can be chained.
- */
- public Cursor putValueShort(short value)
- throws WiredTigerPackingException {
- valuePacker.addShort(value);
- return this;
- }
-
- /**
- * Append a string to the cursor's value.
- *
- * \param value The value to append
- * \return This cursor object, so put calls can be chained.
- */
- public Cursor putValueString(String value)
- throws WiredTigerPackingException {
- valuePacker.addString(value);
- return this;
- }
-
- /**
- * Retrieve a byte from the cursor's key.
- *
- * \return The requested value.
- */
- public byte getKeyByte()
- throws WiredTigerPackingException {
- return keyUnpacker.getByte();
- }
-
- /**
- * Retrieve a byte array from the cursor's key.
- *
- * \param output The byte array where the returned value will be stored.
- * The array should be large enough to store the entire
- * data item, if not a truncated value will be returned.
- */
- public void getKeyByteArray(byte[] output)
- throws WiredTigerPackingException {
- this.getKeyByteArray(output, 0, output.length);
- }
-
- /**
- * Retrieve a byte array from the cursor's key.
- *
- * \param output The byte array where the returned value will be stored.
- * \param off Offset into the destination buffer to start copying into.
- * \param len The length should be large enough to store the entire
- * data item, if not a truncated value will be returned.
- */
- public void getKeyByteArray(byte[] output, int off, int len)
- throws WiredTigerPackingException {
- keyUnpacker.getByteArray(output, off, len);
- }
-
- /**
- * Retrieve a byte array from the cursor's key.
- *
- * \return The requested value.
- */
- public byte[] getKeyByteArray()
- throws WiredTigerPackingException {
- return keyUnpacker.getByteArray();
- }
-
- /**
- * Retrieve an integer from the cursor's key.
- *
- * \return The requested value.
- */
- public int getKeyInt()
- throws WiredTigerPackingException {
- return keyUnpacker.getInt();
- }
-
- /**
- * Retrieve a long from the cursor's key.
- *
- * \return The requested value.
- */
- public long getKeyLong()
- throws WiredTigerPackingException {
- return keyUnpacker.getLong();
- }
-
- /**
- * 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.
- */
- public short getKeyShort()
- throws WiredTigerPackingException {
- return keyUnpacker.getShort();
- }
-
- /**
- * Retrieve a string from the cursor's key.
- *
- * \return The requested value.
- */
- public String getKeyString()
- throws WiredTigerPackingException {
- return keyUnpacker.getString();
- }
-
- /**
- * Retrieve a byte from the cursor's value.
- *
- * \return The requested value.
- */
- public byte getValueByte()
- throws WiredTigerPackingException {
- return valueUnpacker.getByte();
- }
-
- /**
- * Retrieve a byte array from the cursor's value.
- *
- * \param output The byte array where the returned value will be stored.
- * The array should be large enough to store the entire
- * data item, if not a truncated value will be returned.
- */
- public void getValueByteArray(byte[] output)
- throws WiredTigerPackingException {
- this.getValueByteArray(output, 0, output.length);
- }
-
- /**
- * Retrieve a byte array from the cursor's value.
- *
- * \param output The byte array where the returned value will be stored.
- * \param off Offset into the destination buffer to start copying into.
- * \param len The length should be large enough to store the entire
- * data item, if not a truncated value will be returned.
- */
- public void getValueByteArray(byte[] output, int off, int len)
- throws WiredTigerPackingException {
- valueUnpacker.getByteArray(output, off, len);
- }
-
- /**
- * Retrieve a byte array from the cursor's value.
- *
- * \return The requested value.
- */
- public byte[] getValueByteArray()
- throws WiredTigerPackingException {
- return valueUnpacker.getByteArray();
- }
-
- /**
- * Retrieve an integer from the cursor's value.
- *
- * \return The requested value.
- */
- public int getValueInt()
- throws WiredTigerPackingException {
- return valueUnpacker.getInt();
- }
-
- /**
- * Retrieve a long from the cursor's value.
- *
- * \return The requested value.
- */
- public long getValueLong()
- throws WiredTigerPackingException {
- return valueUnpacker.getLong();
- }
-
- /**
- * 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.
- */
- public short getValueShort()
- throws WiredTigerPackingException {
- return valueUnpacker.getShort();
- }
-
- /**
- * Retrieve a string from the cursor's value.
- *
- * \return The requested value.
- */
- public String getValueString()
- throws WiredTigerPackingException {
- return valueUnpacker.getString();
- }
-
- /**
- * Insert the cursor's current key/value into the table.
- *
- * \return The status of the operation.
- */
- public int insert()
- throws WiredTigerException {
- byte[] key = keyPacker.getValue();
- byte[] value = valuePacker.getValue();
- keyPacker.reset();
- valuePacker.reset();
- return insert_wrap(key, value);
- }
-
- /**
- * Update the cursor's current key/value into the table.
- *
- * \return The status of the operation.
- */
- public int update()
- throws WiredTigerException {
- byte[] key = keyPacker.getValue();
- byte[] value = valuePacker.getValue();
- keyPacker.reset();
- valuePacker.reset();
- return update_wrap(key, value);
- }
-
- /**
- * Remove the cursor's current key/value into the table.
- *
- * \return The status of the operation.
- */
- public int remove()
- throws WiredTigerException {
- byte[] key = keyPacker.getValue();
- keyPacker.reset();
- return remove_wrap(key);
- }
-
- /**
- * Compare this cursor's position to another Cursor.
- *
- * \return The result of the comparison.
- */
- public int compare(Cursor other)
- throws WiredTigerException {
- return compare_wrap(other);
- }
-
- /**
- * Compare this cursor's position to another Cursor.
- *
- * \return The result of the comparison.
- */
- public int equals(Cursor other)
- throws WiredTigerException {
- return equals_wrap(other);
- }
-
- /**
- * Retrieve the next item in the table.
- *
- * \return The result of the comparison.
- */
- public int next()
- throws WiredTigerException {
- int ret = next_wrap();
- keyPacker.reset();
- valuePacker.reset();
- keyUnpacker = initKeyUnpacker(ret == 0);
- valueUnpacker = initValueUnpacker(ret == 0);
- return ret;
- }
-
- /**
- * Retrieve the previous item in the table.
- *
- * \return The result of the comparison.
- */
- public int prev()
- throws WiredTigerException {
- int ret = prev_wrap();
- keyPacker.reset();
- valuePacker.reset();
- keyUnpacker = initKeyUnpacker(ret == 0);
- valueUnpacker = initValueUnpacker(ret == 0);
- return ret;
- }
-
- /**
- * Reset a cursor.
- *
- * \return The status of the operation.
- */
- public int reset()
- throws WiredTigerException {
- int ret = reset_wrap();
- keyPacker.reset();
- valuePacker.reset();
- keyUnpacker = null;
- valueUnpacker = null;
- return ret;
- }
-
- /**
- * Search for an item in the table.
- *
- * \return The result of the comparison.
- */
- public int search()
- throws WiredTigerException {
- int ret = search_wrap(keyPacker.getValue());
- keyPacker.reset();
- valuePacker.reset();
- keyUnpacker = initKeyUnpacker(ret == 0);
- valueUnpacker = initValueUnpacker(ret == 0);
- return ret;
- }
-
- /**
- * Search for an item in the table.
- *
- * \return The result of the comparison.
- */
- public SearchStatus search_near()
- throws WiredTigerException {
- SearchStatus ret = search_near_wrap(keyPacker.getValue());
- keyPacker.reset();
- valuePacker.reset();
- keyUnpacker = initKeyUnpacker(ret != SearchStatus.NOTFOUND);
- valueUnpacker = initValueUnpacker(ret != SearchStatus.NOTFOUND);
- return ret;
- }
-
- /**
- * Initialize a key unpacker after an operation that changes
- * the cursor position.
- *
- * \param success Whether the associated operation succeeded.
- * \return The key unpacker.
- */
- private PackInputStream initKeyUnpacker(boolean success)
- throws WiredTigerException {
- if (!success || keyFormat.equals(""))
- return null;
- else
- return new PackInputStream(keyFormat,
- get_key_wrap(), _java_raw());
- }
-
- /**
- * Initialize a value unpacker after an operation that changes
- * the cursor position.
- *
- * \param success Whether the associated operation succeeded.
- * \return The value unpacker.
- */
- private PackInputStream initValueUnpacker(boolean success)
- throws WiredTigerException {
- if (!success || valueFormat.equals(""))
- return null;
- else
- return new PackInputStream(valueFormat,
- get_value_wrap(), _java_raw());
- }
-
- /**
- * Modify an existing record.
- *
- * The cursor must already be positioned, and the key's value will be
- * updated.
- *
- * \param mods an array of modifications.
- * \return 0 on success, errno on error.
- */
- public int modify(Modify mods[])
- throws WiredTigerException {
- byte[] key = keyPacker.getValue();
- keyPacker.reset();
-
- WT_MODIFY_LIST l = new WT_MODIFY_LIST(mods.length);
- if (!_new_check_modify_list(l))
- return (0); // exception is already thrown
- int pos = 0;
-
- for (Modify m : mods) {
- if (!_new_check_modify(m))
- return (0); // exception is already thrown
- l.set(pos, m);
- pos++;
- }
- return modify_wrap(l, key);
- }
-%}
-
-/*
- * Support for WT_CURSOR.modify.
- */
-
-%inline %{
-typedef struct __wt_java_item_hold {
-#ifndef SWIG
- void *data;
- size_t size;
- JNIEnv *jnienv;
- jobject ref;
-#endif
-} WT_ITEM_HOLD;
-
-/*
- * An internal Java class encapsulates a list of Modify objects (stored as a
- * WT_MODIFY array in C).
- */
-typedef struct __wt_java_modify_list {
-#ifndef SWIG
- WT_MODIFY *mod_array;
- jobject *ref_array;
- JNIEnv *jnienv;
- int count;
-#endif
-} WT_MODIFY_LIST;
-%}
-%extend __wt_java_modify_list {
- __wt_java_modify_list(int count) {
- WT_MODIFY_LIST *self;
- if (__wt_calloc_def(NULL, 1, &self) != 0)
- return (NULL);
- if (__wt_calloc_def(NULL, (size_t)count,
- &self->mod_array) != 0) {
- __wt_free(NULL, self);
- return (NULL);
- }
- if (__wt_calloc_def(NULL, (size_t)count,
- &self->ref_array) != 0) {
- __wt_free(NULL, self->mod_array);
- __wt_free(NULL, self);
- return (NULL);
- }
- self->count = count;
- return (self);
- }
- ~__wt_java_modify_list() {
- modify_list_release(self);
- __wt_free(NULL, self);
- }
- void set(int i, WT_MODIFY *m) {
- WT_MODIFY_IMPL *impl = (WT_MODIFY_IMPL *)m;
- self->mod_array[i] = *m;
- self->ref_array[i] = impl->ref;
- impl->ref = (jobject)0;
- self->jnienv = impl->jnienv;
- }
-};
-
-%extend __wt_modify {
- __wt_modify() {
- WT_MODIFY_IMPL *self;
- if (__wt_calloc_def(NULL, 1, &self) != 0)
- return (NULL);
- self->modify.data.data = NULL;
- self->modify.data.size = 0;
- self->modify.offset = 0;
- self->modify.size = 0;
- return (&self->modify);
- }
- __wt_modify(WT_ITEM_HOLD *itemdata,
- size_t offset, size_t size) {
- WT_MODIFY_IMPL *self;
- if (__wt_calloc_def(NULL, 1, &self) != 0)
- return (NULL);
- self->modify.data.data = itemdata->data;
- self->modify.data.size = itemdata->size;
- self->modify.offset = offset;
- self->modify.size = size;
- self->ref = itemdata->ref;
- self->jnienv = itemdata->jnienv;
- return (&self->modify);
- }
- ~__wt_modify() {
- modify_impl_release((WT_MODIFY_IMPL *)self);
- __wt_free(NULL, self);
- }
-};
-
-%{
-static void modify_list_release(WT_MODIFY_LIST *list) {
- for (int i = 0; i < list->count; i++)
- if (list->ref_array[i] != (jobject)0) {
- (*list->jnienv)->ReleaseByteArrayElements(
- list->jnienv, list->ref_array[i],
- (jbyte *)list->mod_array[i].data.data, 0);
- (*list->jnienv)->DeleteGlobalRef(
- list->jnienv, list->ref_array[i]);
- }
- __wt_free(NULL, list->ref_array);
- __wt_free(NULL, list->mod_array);
- list->count = 0;
-}
-
-static void modify_impl_release(WT_MODIFY_IMPL *impl) {
- if (impl->ref != (jobject)0) {
- (*impl->jnienv)->ReleaseByteArrayElements(
- impl->jnienv, impl->ref,
- (jbyte *)impl->modify.data.data, 0);
- (*impl->jnienv)->DeleteGlobalRef(impl->jnienv, impl->ref);
- impl->ref = (jobject)0;
- }
-}
-%}
-
-/* Put a WiredTigerException on all wrapped methods. We'd like this
- * to only apply to methods returning int. SWIG doesn't have a way
- * to do this, so we remove the exception for simple getters and such.
- */
-%javaexception("com.wiredtiger.db.WiredTigerException") { $action; }
-%javaexception("") wiredtiger_strerror { $action; }
-%javaexception("") __wt_connection::_java_init { $action; }
-%javaexception("") __wt_connection::get_home { $action; }
-%javaexception("") __wt_connection::is_new { $action; }
-%javaexception("") __wt_cursor::_java_raw { $action; }
-%javaexception("") __wt_cursor::key_format { $action; }
-%javaexception("") __wt_cursor::session { $action; }
-%javaexception("") __wt_cursor::uri { $action; }
-%javaexception("") __wt_cursor::value_format { $action; }
-%javaexception("") __wt_session::_java_init { $action; }
-%javaexception("") __wt_session::connection { $action; }
-
-/* Remove / rename parts of the C API that we don't want in Java. */
-%immutable __wt_cursor::session;
-%immutable __wt_cursor::uri;
-%immutable __wt_cursor::key_format;
-%immutable __wt_cursor::value_format;
-%immutable __wt_session::connection;
-
-%ignore __wt_collator;
-%ignore __wt_connection::add_collator;
-%ignore __wt_compressor;
-%ignore __wt_connection::add_compressor;
-%ignore __wt_data_source;
-%ignore __wt_connection::add_data_source;
-%ignore __wt_encryptor;
-%ignore __wt_connection::add_encryptor;
-%ignore __wt_event_handler;
-%ignore __wt_extractor;
-%ignore __wt_connection::add_extractor;
-%ignore __wt_file_system;
-%ignore __wt_file_handle;
-%ignore __wt_connection::set_file_system;
-%ignore __wt_item;
-%ignore __wt_lsn;
-%ignore __wt_session::msg_printf;
-
-%ignore wiredtiger_struct_pack;
-%ignore wiredtiger_struct_size;
-%ignore wiredtiger_struct_unpack;
-
-%ignore wiredtiger_version;
-
-%ignore __wt_connection::get_extension_api;
-%ignore wiredtiger_extension_init;
-%ignore wiredtiger_extension_terminate;
-
-%define REQUIRE_WRAP(typedefname, name, javaname)
-%ignore name;
-%javamethodmodifiers name##_wrap "
- /**
- * @copydoc typedefname
- */
- public ";
-%rename(javaname) name##_wrap;
-%enddef
-
-REQUIRE_WRAP(::wiredtiger_open, wiredtiger_open, open)
-REQUIRE_WRAP(WT_CONNECTION::open_session,
- __wt_connection::open_session, open_session)
-REQUIRE_WRAP(WT_SESSION::transaction_pinned_range,
- __wt_session::transaction_pinned_range, transaction_pinned_range)
-REQUIRE_WRAP(WT_SESSION::open_cursor, __wt_session::open_cursor, open_cursor)
-
-%rename(Cursor) __wt_cursor;
-%rename(Modify) __wt_modify;
-%rename(Session) __wt_session;
-%rename(Connection) __wt_connection;
-
-%define TRACKED_CLASS(jclassname, ctypename, java_init_fcn, implclass)
-%ignore jclassname::jclassname();
-
-%typemap(javabody) struct ctypename %{
- private long swigCPtr;
- protected boolean swigCMemOwn;
-
- protected $javaclassname(long cPtr, boolean cMemoryOwn) {
- swigCMemOwn = cMemoryOwn;
- swigCPtr = cPtr;
- java_init_fcn(swigCPtr, this, this);
- }
-
- protected static long getCPtr($javaclassname obj) {
- return (obj == null) ? 0 : obj.swigCPtr;
- }
-%}
-
-%extend ctypename {
- %javamethodmodifiers _java_init "protected";
- int _java_init(jobject jsess) {
- implclass *session = (implclass *)$self;
- JAVA_CALLBACK *jcb = (JAVA_CALLBACK *)session->lang_private;
- jcb->jobj = JCALL1(NewGlobalRef, jcb->jnienv, jsess);
- JCALL1(DeleteLocalRef, jcb->jnienv, jsess);
- return (0);
- }
-}
-%enddef
-
-TRACKED_CLASS(Session, __wt_session, wiredtigerJNI.Session__java_init, WT_SESSION_IMPL)
-TRACKED_CLASS(Connection, __wt_connection, wiredtigerJNI.Connection__java_init, WT_CONNECTION_IMPL)
-/* Note: Cursor incorporates the elements of TRACKED_CLASS into its
- * custom constructor and %extend clause.
- */
-
-%include "wiredtiger.h"
-
-/* Return new connections, sessions and cursors. */
-%inline {
-WT_CONNECTION *wiredtiger_open_wrap(JNIEnv *jenv, const char *home, const char *config) {
- extern WT_EVENT_HANDLER javaApiEventHandler;
- WT_CONNECTION *conn = NULL;
- WT_CONNECTION_IMPL *connimpl;
- JAVA_CALLBACK *jcb;
- int ret;
- if ((ret = wiredtiger_open(home, &javaApiEventHandler, config, &conn)) != 0)
- goto err;
-
- connimpl = (WT_CONNECTION_IMPL *)conn;
- if ((ret = __wt_calloc_def(connimpl->default_session, 1, &jcb)) != 0)
- goto err;
-
- jcb->jnienv = jenv;
- connimpl->lang_private = jcb;
-
-err: if (ret != 0)
- throwWiredTigerException(jenv, ret);
- return (conn);
-}
-}
-
-%extend __wt_connection {
- WT_SESSION *open_session_wrap(JNIEnv *jenv, const char *config) {
- extern WT_EVENT_HANDLER javaApiEventHandler;
- WT_SESSION *session = NULL;
- WT_SESSION_IMPL *sessionimpl;
- JAVA_CALLBACK *jcb;
- int ret;
-
- if ((ret = $self->open_session($self, &javaApiEventHandler, config, &session)) != 0)
- goto err;
-
- sessionimpl = (WT_SESSION_IMPL *)session;
- if ((ret = __wt_calloc_def(sessionimpl, 1, &jcb)) != 0)
- goto err;
-
- jcb->jnienv = jenv;
- sessionimpl->lang_private = jcb;
-
-err: if (ret != 0)
- throwWiredTigerException(jenv, ret);
- return (session);
- }
-}
-
-%extend __wt_session {
- WT_CURSOR *open_cursor_wrap(JNIEnv *jenv, const char *uri, WT_CURSOR_NULLABLE *to_dup, const char *config) {
- WT_CURSOR *cursor = NULL;
- JAVA_CALLBACK *jcb;
- int ret;
-
- if ((ret = $self->open_cursor($self, uri, to_dup, config, &cursor)) != 0)
- goto err;
-
- if ((ret = __wt_calloc_def(CUR2S(cursor), 1, &jcb)) != 0)
- goto err;
-
- if ((cursor->flags & WT_CURSTD_RAW) != 0)
- jcb->cursor_raw = true;
- if ((cursor->flags & WT_CURSTD_DUMP_JSON) == 0)
- cursor->flags |= WT_CURSTD_RAW;
-
- jcb->jnienv = jenv;
- jcb->session = CUR2S(cursor);
- cursor->lang_private = jcb;
-
-err: if (ret != 0)
- throwWiredTigerException(jenv, ret);
- return (cursor);
- }
-}
-
-%extend __wt_session {
- long transaction_pinned_range_wrap(JNIEnv *jenv) {
- int ret;
- uint64_t range = 0;
- ret = self->transaction_pinned_range(self, &range);
- if (ret != 0)
- throwWiredTigerException(jenv, ret);
- return ((long)range);
- }
-}