diff options
author | Don Anderson <dda@ddanderson.com> | 2014-10-06 13:49:13 -0400 |
---|---|---|
committer | Don Anderson <dda@ddanderson.com> | 2014-10-06 13:58:18 -0400 |
commit | 84be8984da331e0b67b0003eb67108ad34ba0bd5 (patch) | |
tree | 2f495854ea321408b17ae0347d233ddf8fa91888 | |
parent | b00bec14807eccfddf28e0080872cefa3bdeefdd (diff) | |
download | mongo-84be8984da331e0b67b0003eb67108ad34ba0bd5.tar.gz |
Multiple language doc support. refs #1130.
doxfilter modified to know about new macros: @m_page, @m_if, @m_else, @m_endif.
Pages with @m_page have all its snippets/subpages point to the language
specific example/subpage.
The java examples directory added to EXAMPLE_PATH in Doxyfile.
Added @m_page to any doc page that also needs a Java version.
Added cast to wiredtiger.i for stricter compiler checking.
31 files changed, 366 insertions, 60 deletions
diff --git a/lang/java/wiredtiger.i b/lang/java/wiredtiger.i index fdcc0144508..71aed8b7866 100644 --- a/lang/java/wiredtiger.i +++ b/lang/java/wiredtiger.i @@ -127,7 +127,7 @@ static void throwWiredTigerException(JNIEnv *jenv, const char *msg) { %typemap(in) WT_ITEM * (WT_ITEM item) %{ $1 = &item; $1->data = (*jenv)->GetByteArrayElements(jenv, $input, 0); - $1->size = (*jenv)->GetArrayLength(jenv, $input); + $1->size = (size_t)(*jenv)->GetArrayLength(jenv, $input); %} %typemap(argout) WT_ITEM * %{ diff --git a/src/docs/Doxyfile b/src/docs/Doxyfile index 5492905f7e9..4df85496566 100644 --- a/src/docs/Doxyfile +++ b/src/docs/Doxyfile @@ -776,6 +776,7 @@ EXCLUDE_SYMBOLS = __F \ # the \include command). EXAMPLE_PATH = ../../examples/c \ + ../../examples/java/com/wiredtiger/examples/ \ ../../ext/compressors/nop \ ./examples diff --git a/src/docs/async.dox b/src/docs/async.dox index 9eed1bab5b4..fcc0e590369 100644 --- a/src/docs/async.dox +++ b/src/docs/async.dox @@ -1,4 +1,4 @@ -/*! @page async Asynchronous operations +/*! @m_page{{c,java},async,Asynchronous operations} WiredTiger supports asynchronous operations; as an example of where this can be useful, a server application handling requests from a network as @@ -81,6 +81,10 @@ the example program @ex_ref{ex_async.c}: @snippet ex_async.c async example callback implementation +@m_if{java} +@snippet ex_async.c async example callback implementation part 2 +@m_endif + @section async_operations Executing asynchronous operations The WT_ASYNC_OP handle behaves similarly to the WT_CURSOR handle, that diff --git a/src/docs/backup.dox b/src/docs/backup.dox index 3ac32c30d26..5926d0cc72b 100644 --- a/src/docs/backup.dox +++ b/src/docs/backup.dox @@ -10,7 +10,7 @@ apply to data files which don't appear in the backup. */ -/*! @page backup Backups +/*! @m_page{{c,java},backup,Backups} WiredTiger cursors provide access to data from a variety of sources. One of these sources is the list of files required to perform a backup diff --git a/src/docs/basic-api.dox b/src/docs/basic-api.dox index 9fe52517a21..ab02769fbfa 100644 --- a/src/docs/basic-api.dox +++ b/src/docs/basic-api.dox @@ -1,4 +1,4 @@ -/*! @page basic_api Getting Started with the API +/*! @m_page{{c,java},basic_api,Getting Started with the API} WiredTiger applications will generally use the following classes to access and manage data: @@ -27,7 +27,12 @@ application. WiredTiger supports the C, C++, Java and Python programming languages (among others). By default, WiredTiger works as a traditional key/value store, where the -keys and values are raw byte arrays accessed using a WT_ITEM structure. +keys and values are +@m_if{c} +raw byte arrays accessed using a WT_ITEM structure. +@m_else +raw byte arrays. +@m_endif Keys and values may be up to (4GB - 512B) bytes in size, but depending on how @ref WT_SESSION::create "maximum item sizes" are configured, large key and value items will be stored on overflow pages. @@ -51,11 +56,17 @@ for the single thread accessing the database: The configuration string @c "create" is passed to ::wiredtiger_open to indicate the database should be created if it does not already exist. +@m_if{c} The code block above also shows simple error handling with ::wiredtiger_strerror (a function that returns a string describing an error code passed as its argument). More complex error handling can be configured by passing an implementation of WT_EVENT_HANDLER to ::wiredtiger_open or WT_CONNECTION::open_session. +@m_endif +@m_if{java} +The code block above also shows simple error handling by catching +WiredTigerException. +@m_endif @section basic_create_table Creating a table diff --git a/src/docs/checkpoint.dox b/src/docs/checkpoint.dox index 55fa44e38f2..523c0887859 100644 --- a/src/docs/checkpoint.dox +++ b/src/docs/checkpoint.dox @@ -1,4 +1,4 @@ -/*! @page checkpoint Checkpoint durability +/*! @m_page{{c,java},checkpoint,Checkpoint durability} WiredTiger supports checkpoint durability by default, and optionally commit-level durability when logging is enabled. In most applications, diff --git a/src/docs/compact.dox b/src/docs/compact.dox index 46ff42b114f..9d37bf77214 100644 --- a/src/docs/compact.dox +++ b/src/docs/compact.dox @@ -1,4 +1,4 @@ -/*! @page compact Compaction +/*! @m_page{{c,java},compact,Compaction} The WT_SESSION::compact method can be used to compact data sources. diff --git a/src/docs/compression.dox b/src/docs/compression.dox index 92f5c27f25e..a97ba484a14 100644 --- a/src/docs/compression.dox +++ b/src/docs/compression.dox @@ -1,4 +1,4 @@ -/*! @page compression Compressors +/*! @m_page{{c,java},compression,Compressors} This section explains how to configure WiredTiger's builtin support for the snappy and bzip2 compression engines. diff --git a/src/docs/config-strings.dox b/src/docs/config-strings.dox index 295316fe039..b78f6d21372 100644 --- a/src/docs/config-strings.dox +++ b/src/docs/config-strings.dox @@ -1,4 +1,4 @@ -/*! @page config_strings Configuration Strings +/*! @m_page{{c,java},config_strings,Configuration Strings} @section config_intro Introduction @@ -74,8 +74,14 @@ Superfluous commas and whitespace in the configuration string are ignored combine two configuration strings by concatenating them with a comma in between. +@m_if{c} Empty configuration strings may be represented in C or C++ by passing <code>NULL</code>. +@m_endif +@m_if{java} +Empty configuration strings may be represented in Java by passing +<code>null</code>. +@m_endif @section config_json JavaScript Object Notation (JSON) compatibility diff --git a/src/docs/cursor-log.dox b/src/docs/cursor-log.dox index 81e98203c39..46e978c46ca 100644 --- a/src/docs/cursor-log.dox +++ b/src/docs/cursor-log.dox @@ -1,4 +1,4 @@ -/*! @page cursor_log Log cursors +/*! @m_page{{c,java},cursor_log,Log cursors} WiredTiger cursors provide access to data from a variety of sources, and one of these sources is the records in the transaction log files. Log @@ -22,7 +22,12 @@ To open a log cursor on the database: @snippet ex_log.c log cursor open -A log cursor's key is a unique log record identifier, plus a uint32_t +A log cursor's key is a unique log record identifier, plus a +@m_if{c} +uint32_t +@m_else +int +@m_endif operation counter within that log record. When a log record maps one-to-one to a transaction (in other words, the returned log record has the only database operation the transaction made), the operation counter @@ -38,10 +43,17 @@ Here is an example of getting the log cursor's key: The log cursor's value is comprised of six fields: -- a uint64_t transaction ID (set for commit records only, otherwise 0), -- a uint32_t record type -- a uint32_t operation type (set for commit records only, otherwise 0) -- a uint32_t file id (if applicable, otherwise 0) +@m_if{c} +- a \c uint64_t transaction ID (set for commit records only, otherwise 0), +- a \c uint32_t record type +- a \c uint32_t operation type (set for commit records only, otherwise 0) +- a \c uint32_t file id (if applicable, otherwise 0) +@m_else +- a \c long transaction ID (set for commit records only, otherwise 0), +- a \c int record type +- a \c int operation type (set for commit records only, otherwise 0) +- a \c int file id (if applicable, otherwise 0) +@m_endif - the operation key (commit records only, otherwise empty) - the operation value diff --git a/src/docs/cursor-ops.dox b/src/docs/cursor-ops.dox index ef8a7b20499..d9d8f19868c 100644 --- a/src/docs/cursor-ops.dox +++ b/src/docs/cursor-ops.dox @@ -1,4 +1,4 @@ -/*! @page cursor_ops Cursor operations +/*! @m_page{{c,java},cursor_ops,Cursor operations} Common operations in WiredTiger are performed using WT_CURSOR handles. A cursor includes: @@ -131,6 +131,7 @@ it may be retried without calling WT_CURSOR::set_key or WT_CURSOR::set_value again. That is, the cursor may still reference the application-supplied memory until it is successfully positioned. +@m_if{c} Any pointers returned by WT_CURSOR::get_key or WT_CURSOR::get_value are only valid until the cursor is positioned. These pointers may reference private WiredTiger data structures that must not be modified or freed by the @@ -141,4 +142,5 @@ The comments in this example code explain when the application can safely modify memory passed to WT_CURSOR::set_key or WT_CURSOR::set_value: @snippet ex_scope.c cursor scope operation +@m_endif */ diff --git a/src/docs/cursor-random.dox b/src/docs/cursor-random.dox index abb6e53571e..70a28407ea5 100644 --- a/src/docs/cursor-random.dox +++ b/src/docs/cursor-random.dox @@ -1,4 +1,4 @@ -/*! @page cursor_random Cursor random +/*! @m_page{{c,java},cursor_random,Cursor random} The \c next_random configuration to the WT_SESSION::open_cursor method configures the cursor to return a pseudo-random record from a row-store diff --git a/src/docs/cursors.dox b/src/docs/cursors.dox index 0dcfe44e4d2..046597455f2 100644 --- a/src/docs/cursors.dox +++ b/src/docs/cursors.dox @@ -1,4 +1,4 @@ -/*! @page cursors Cursors +/*! @m_page{{c,java},cursors,Cursors} Common operations in WiredTiger are performed using WT_CURSOR handles. A cursor includes: @@ -77,9 +77,16 @@ See @ref transactions for more information. Cursors can be configured for raw mode by specifying the \c "raw" config keyword to WT_SESSION::open_cursor. In this mode, the methods WT_CURSOR::get_key, WT_CURSOR::get_value, WT_CURSOR::set_key and -WT_CURSOR::set_value all take a single WT_ITEM in the variable-length +WT_CURSOR::set_value all take a single +@m_if{c} +WT_ITEM +@m_else +byte array +@m_endif +in the variable-length argument list instead of a separate argument for each column. +@m_if{c} WT_ITEM structures do not need to be cleared before use. For WT_CURSOR::get_key and WT_CURSOR::get_value in raw mode, the WT_ITEM @@ -91,7 +98,9 @@ cursor's \c key_format or \c value_format, respectively. The @ex_ref{ex_schema.c} example creates a table where the value format is \c "5sHq", where the initial string is the country, the short is a year, -and the long is a population. The following example lists the table record +and the long is a population. +@m_endif +The following example lists the table record values, using raw mode: @snippet ex_schema.c List the records in the table using raw mode. diff --git a/src/docs/data-sources.dox b/src/docs/data-sources.dox index cde5f6a3087..9cf6c716096 100644 --- a/src/docs/data-sources.dox +++ b/src/docs/data-sources.dox @@ -53,7 +53,7 @@ Advanced applications may also open the following low-level cursor types: /* ----------------- */ -/*! @page data_sources Data Sources +/*! @m_page{{c,java},data_sources,Data Sources} WiredTiger provides access to data from a variety of sources. At the lowest level, data may be stored in a file using a tree structure. A diff --git a/src/docs/durability.dox b/src/docs/durability.dox index 0085e17a51b..78a17b83f57 100644 --- a/src/docs/durability.dox +++ b/src/docs/durability.dox @@ -1,4 +1,4 @@ -/*! @page durability Commit-level durability +/*! @m_page{{c,java},durability,Commit-level durability} WiredTiger supports checkpoint durability by default, and optionally commit-level durability when logging is enabled. In most applications, diff --git a/src/docs/error-handling.dox b/src/docs/error-handling.dox index f0af35a7111..956dc499bd1 100644 --- a/src/docs/error-handling.dox +++ b/src/docs/error-handling.dox @@ -1,4 +1,4 @@ -/*! @page error_handling Error handling +/*! @m_page{{c,java},error_handling,Error handling} WiredTiger operations return a value of 0 on success and a non-zero value on error. Error codes may be either positive or negative: @@ -9,25 +9,42 @@ are WiredTiger-specific (for example, WT_DEADLOCK). WiredTiger-specific error codes always appear in the -31,800 to -31,999 range. +@m_if{java} +Informational return values, like <code>wiredtiger.WT_NOTFOUND</code> +or <code>wiredtiger.WT_DUPLICATE_KEY</code> or 0 (success), +are directly returned by APIs. More severe errors +are thrown as \c WiredTigerException, which must be caught by the +application. + +The following is a complete list of possible WiredTiger-specific +return values, all constants defined in the com.wiredtiger.db.wiredtiger class: +@m_else The following is a list of possible WiredTiger-specific errors: +@m_endif @if IGNORE_BUILT_BY_API_ERR_BEGIN @endif +@m_if{c} @par <code>WT_DEADLOCK</code> This error is generated when an operation cannot be completed due to a conflict with concurrent operations. The operation may be retried; if a transaction is in progress, it should be rolled back and the operation retried in a new transaction. +@m_endif @par <code>WT_DUPLICATE_KEY</code> This error is generated when the application attempts to insert a record with the same key as an existing record without the 'overwrite' configuration to WT_SESSION::open_cursor. +@m_if{c} @par <code>WT_ERROR</code> This error is returned when an error is not covered by a specific error return. +@m_endif @par <code>WT_NOTFOUND</code> This error indicates an operation did not find a value to return. This includes cursor search and other operations where no record matched the cursor's search key such as WT_CURSOR::update or WT_CURSOR::remove. +@m_if{c} @par <code>WT_PANIC</code> This error indicates an underlying problem that requires the application exit and restart. +@m_endif @if IGNORE_BUILT_BY_API_ERR_END @endif @@ -37,7 +54,9 @@ associated with any WiredTiger, ISO C99, or POSIX 1003.1-2001 function: @snippet ex_all.c Display an error +@m_if{c} More complex error handling can be configured by passing an implementation of WT_EVENT_HANDLER to ::wiredtiger_open or WT_CONNECTION::open_session. +@m_endif */ diff --git a/src/docs/file-formats.dox b/src/docs/file-formats.dox index bc747433172..f346ee70593 100644 --- a/src/docs/file-formats.dox +++ b/src/docs/file-formats.dox @@ -1,4 +1,4 @@ -/*! @page file_formats File formats and compression +/*! @m_page{{c,java},file_formats,File formats and compression} @section file_formats_formats File formats @@ -101,7 +101,7 @@ additional CPU and memory use when searching the in-memory tree (if keys are encoded), and additional CPU and memory use when returning values from the in-memory tree and when writing pages to disk. Note the additional CPU cost of Huffman encoding can be high, and should be -considered. (See @subpage huffman for details.) +considered. (See @m_single_subpage huffman for details.) Huffman encoding is disabled by default. diff --git a/src/docs/introduction.dox b/src/docs/introduction.dox index 7191540ec1d..8e8c0d9e7cf 100644 --- a/src/docs/introduction.dox +++ b/src/docs/introduction.dox @@ -31,6 +31,7 @@ For more information about building and installing WiredTiger, see: For more information about writing WiredTiger applications, see: - @subpage programming +- @subpage programming_lang_java - @ref wt "WiredTiger API reference manual" - @subpage performance diff --git a/src/docs/lsm.dox b/src/docs/lsm.dox index b71fccd7151..08512f27c92 100644 --- a/src/docs/lsm.dox +++ b/src/docs/lsm.dox @@ -1,4 +1,4 @@ -/*! @page lsm Log-Structured Merge Trees +/*! @m_page{{c,java},lsm,Log-Structured Merge Trees} @section lsm_background Background @@ -42,21 +42,34 @@ An LSM tree can be created as follows, in much the same way as a WiredTiger btree file: @code +@m_if{c} session->create(session, "table:bucket", "type=lsm,key_format=S,value_format=S"); +@m_else +session.create("table:bucket", "type=lsm,key_format=S,value_format=S"); +@m_endif @endcode Once created, the LSM tree can be accessed using the same cursor interface as other data sources in WiredTiger: @code +@m_if{c} WT_CURSOR *c; session->open_cursor(session, "table:bucket", NULL, NULL, &c); for(;;) { - c->set_key("key"); - c->set_value("value"); - c->insert(); + c->set_key(c, "key"); + c->set_value(c, "value"); + c->insert(c); } +@m_else +Cursor c = session.open_cursor("table:bucket", null, null); +for(;;) { + c.putKeyString("key"); + c.putValueString("value"); + c.insert(); +} +@m_endif @endcode If an LSM cursor is configured with \c "overwrite=false" passed to @@ -91,7 +104,11 @@ Tables or indices can be stored using LSM trees. Schema support is provided for LSM as an extension to the WT_SESSION::create method: @code +@m_if{c} session->create(session, "table:T", "type=lsm"); +@m_else +session.create("table:T", "type=lsm"); +@m_endif @endcode The default type for all schema objects will continue to be btree. diff --git a/src/docs/namespace.dox b/src/docs/namespace.dox index 2fb90d33002..8657338e369 100644 --- a/src/docs/namespace.dox +++ b/src/docs/namespace.dox @@ -1,9 +1,10 @@ -/*! @page namespace Name spaces +/*! @m_page{{c,java},namespace,Name spaces} @section namespace_env Process' environment name space WiredTiger's environment variables begin with the string "WIREDTIGER". +@m_if{c} @section namespace_c C language name space WiredTiger's public function names begin with the string "wiredtiger". @@ -12,15 +13,27 @@ WiredTiger's public \c \#define and structure \c typedef declarations begin with the string "WT_". WiredTiger's private function names begin with the string "__wt_". +@m_endif + +@m_if{java} +@section namespace_c Java language name space + +WiredTiger's public classes are in the \c com.wiredtiger.db package. + +The \c com.wiredtiger.db.wiredtiger class contains static methods +and inherited constants. +@m_endif @section namespace_filesystem File system name space WiredTiger's files begin with the string "WiredTiger"; applications should not create files in the WiredTiger file system name space. +@m_if{c} @section namespace_error Error return name space WiredTiger reserves all values from -31,800 to -31,999 as possible error return values. +@m_endif */ diff --git a/src/docs/packing.dox b/src/docs/packing.dox index ca857d1b90d..aca9cd72b46 100644 --- a/src/docs/packing.dox +++ b/src/docs/packing.dox @@ -1,4 +1,4 @@ -/*! @page packing Packing and Unpacking Data +/*! @m_page{{c,java},packing,Packing and Unpacking Data} WiredTiger's data packing uses format strings similar to those specified in the Python struct module: @@ -27,6 +27,7 @@ The remaining characters in the format string specify the type of each field to be packed into or unpacked from a byte array. See @ref schema_column_types for the list of supported types. +@m_if{c} @todo Describe the variable-length integer packing in sufficient detail that it can be re-implemented in other programming languages or in network clients. @section config_examples Code samples @@ -34,5 +35,10 @@ for the list of supported types. The code below is taken from the complete example program @ex_ref{ex_pack.c}. It demonstrates how to pack three integer values into a buffer and then unpack them again. @snippet ex_pack.c packing +@m_else +In Java, data is packed and unpacked using cursor put* and get* operations, +for example: +@snippet ex_schema.c Insert and list records +@m_endif */ diff --git a/src/docs/programming.dox b/src/docs/programming.dox index 4add19c833b..c16fc86657d 100644 --- a/src/docs/programming.dox +++ b/src/docs/programming.dox @@ -1,7 +1,11 @@ -/*! @page programming Writing WiredTiger applications +/*! @m_page{{c,java},programming,Writing WiredTiger applications} This section covers topics of interest for programmers writing +@m_if{c} WiredTiger applications. +@m_else +WiredTiger applications in Java. +@m_endif We follow SQL terminology: a database is set of tables managed together. Tables consist of rows, where each row is a key and its associated @@ -18,14 +22,16 @@ each of which is ordered by one or more columns. <h2>Storage options</h2> - @subpage schema -- @subpage file_formats - @subpage lsm +- @subpage file_formats - @subpage compression <h2>Programming notes</h2> - @subpage threads - @subpage namespace +@m_if{c} - @subpage signals +@m_endif <h2>Advanced features</h2> - @subpage checkpoint @@ -37,9 +43,11 @@ each of which is ordered by one or more columns. - @subpage shared_cache - @subpage cursor_log +@m_if{c} <h2>Extending WiredTiger</h2> - @subpage extensions - @subpage custom_data_sources - @subpage helium +@m_endif */ diff --git a/src/docs/schema.dox b/src/docs/schema.dox index de6aaa8cb55..fad98059813 100644 --- a/src/docs/schema.dox +++ b/src/docs/schema.dox @@ -1,4 +1,4 @@ -/*! @page schema Schema, Columns, Column Groups, Indices and Projections +/*! @m_page{{c,java},schema,Schema, Columns, Column Groups, Indices and Projections} While many tables have simple key/value pairs for records, WiredTiger also supports more complex data patterns. @@ -57,7 +57,7 @@ Key and value types may also be chosen from a list, or composed of multiple columns with any combination of types. Keys and values may be up to (<code>4GB - 512B</code>) bytes in size. -See @subpage keyvalue for more details on raw key / value items. +See @m_single_subpage keyvalue for more details on raw key / value items. @section schema_format_types Format types @@ -91,14 +91,20 @@ otherwise identical to the \c 'Q' type. The \c 'S' type is encoded as a C language string terminated by a NUL character. +@m_if{java} +Because of this, the associated Java String may not contain the NUL character. +@m_endif The \c 't' type is used for fixed-length bit field values. If it is preceded by a size, that indicates the number of bits to store, between 1 and 8. That number of low-order bits will be stored in the -table. The default is a size of 1 bit: that is, a boolean. C applications -must always use a \c uint8_t type (or equivalently, +table. The default is a size of 1 bit: that is, a boolean. +@m_if{c} +C applications must always use a \c uint8_t type (or equivalently, <code>unsigned char</code>) for calls to WT_CURSOR::set_value, and a -pointer to the same for calls to WT_CURSOR::get_value. If a bit field +pointer to the same for calls to WT_CURSOR::get_value. +@m_endif +If a bit field value is combined with other types in a packing format, it is equivalent to \c 'B', and a full byte is used to store it. @@ -127,7 +133,11 @@ natural integer ordering under the default collator. See @subpage packing for details of WiredTiger's packing format. WiredTiger can also be extended with custom collators by implementing the +@m_if{c} WT_COLLATOR interface. +@m_else +WT_COLLATOR interface (C only). +@m_endif @section schema_key_and_value_formats Key and value formats @@ -148,10 +158,17 @@ follows: @section schema_cursor_formats Cursor formats -Cursors for a table have the same key format as the table itself. The key -columns of a cursor are set with WT_CURSOR::set_key and accessed with -WT_CURSOR::get_key. WT_CURSOR::set_key is analogous to \c printf, and takes -a list of values in the order the key columns are configured in \c +Cursors for a table have the same key format as the table itself. +@m_if{c} +The key columns of a cursor are set with WT_CURSOR::set_key and accessed with +WT_CURSOR::get_key. WT_CURSOR::set_key is analogous to \c printf, +and takes a list of value +@m_else +The key columns of a cursor are set with the \c Cursor.putKey* methods +and accessed with the \c Cursor.getKey* methods. \c Cursor.putKey* methods +must be called +@m_endif +in the order the key columns are configured in \c key_format. For example, setting the key for a row-store table with strings as keys @@ -169,8 +186,13 @@ the key_format was \c "SiH", would be done as follows: @snippet ex_all.c Set the cursor's composite key -The key's values are accessed with WT_CURSOR::get_key, which is analogous +The key's values are accessed with +@m_if{c} +WT_CURSOR::get_key, which is analogous to \c scanf, and takes a list of pointers to values in the same order: +@m_else +successive calls to \c Cursor.getKey* methods: +@m_endif @snippet ex_all.c Get the cursor's string key @snippet ex_all.c Get the cursor's record number key @@ -180,9 +202,15 @@ Cursors for a table have the same value format as the table, unless a projection is configured with WT_SESSION::open_cursor. See @ref cursor_projections for more information. +@m_if{c} WT_CURSOR::set_value is used to set value columns, and WT_CURSOR::get_value is used to get value columns, in the same way as described for WT_CURSOR::set_key and WT_CURSOR::get_key. +@m_else +\c The Cursor.putValue* methods are used to set value columns, and +\c Cursor.getValue* are used to get value columns, in the same way as +described for \c Cursor.putKey* and \c Cursor.getKey*. +@m_endif @section schema_columns Columns @@ -271,8 +299,13 @@ Continuing the example, we might open an index on the \c country column: Cursors are opened on indices by passing the index's URI to the WT_SESSION::open_cursor method. -Index cursors use the specified index key columns for WT_CURSOR::get_key -and WT_CURSOR::set_key. For example, we can retrieve information from +Index cursors use the specified index key columns for +@m_if{c} +WT_CURSOR::get_key and WT_CURSOR::set_key. +@m_else +\c Cursor.getKey* and \c Cursor.putKey* calls. +@m_endif +For example, we can retrieve information from the \c country index as follows: @snippet ex_schema.c Search in a simple index @@ -282,17 +315,32 @@ to the WT_SESSION::create call: @snippet ex_schema.c Create an index with a composite key -To retrieve information from a composite index requires a more -complicated WT_CURSOR::set_key call, but is otherwise the same: +To retrieve information from a composite index requires a more complicated +@m_if{c} +WT_CURSOR::set_key call, +@m_else +set of \c Cursor.putKey* calls, +@m_endif +but is otherwise the same: @snippet ex_schema.c Search in a composite index @section schema_index_projections Index cursor projections By default, index cursors return all of the table's value columns from -WT_CURSOR::get_value. The application can specify that a subset of the -usual columns should be returned in calls to WT_CURSOR::get_value by -appending a list of columns to the \c uri parameter of the +@m_if{c} +WT_CURSOR::get_value. +@m_else +\c Cursor.getValue* calls. +@m_endif +The application can specify that a subset of the +usual columns should be returned in calls to +@m_if{c} +WT_CURSOR::get_value +@m_else +\c Cursor.getValue +@m_endif +by appending a list of columns to the \c uri parameter of the WT_SESSION::open_cursor call. This is called a \em projection, see @ref cursor_projections for more details. diff --git a/src/docs/shared-cache.dox b/src/docs/shared-cache.dox index 1cb6a58a644..95422caabda 100644 --- a/src/docs/shared-cache.dox +++ b/src/docs/shared-cache.dox @@ -1,10 +1,10 @@ -/*! @page shared_cache Per-process shared caches +/*! @m_page{{c,java},shared_cache,Per-process shared caches} WiredTiger supports sharing a single cache among multiple databases within a process. An application configures a shared cache by specifying a shared_cache name -to the @ref wiredtiger_open function. Applications can optionally +to the ::wiredtiger_open function. Applications can optionally set a minimum amount of cache any connection in the pool will be assigned and the granularity at which the cache pool is redistributed among connections - called the chunk size. @@ -35,7 +35,7 @@ period. When a database is closed any resources it is using are distributed among the other databases. WiredTiger shared cache tuning options can be configured when first opening a -database via @ref wiredtiger_open or changed after open using the +database via ::wiredtiger_open or changed after open using the WT_CONNECTION::reconfigure method. */ diff --git a/src/docs/spell.ok b/src/docs/spell.ok index 790d108c9e9..218db0c8f3a 100644 --- a/src/docs/spell.ok +++ b/src/docs/spell.ok @@ -72,6 +72,7 @@ Vv WiredTiger WiredTiger's WiredTigerCheckpoint +WiredTigerException WiredTigerLog WiredTigerTestCase Za @@ -196,6 +197,8 @@ freelist fsync gcc gdbm +getKey +getValue getopt getter gid @@ -230,6 +233,7 @@ keyfmt keyname keyvalue kvs +lang lastname len leveldb @@ -329,6 +333,10 @@ priv proc pthread pthreads +putKey +putKeyString +putValue +putValueString py qnx rdbms diff --git a/src/docs/statistics.dox b/src/docs/statistics.dox index e07e594a72a..067cf342111 100644 --- a/src/docs/statistics.dox +++ b/src/docs/statistics.dox @@ -1,4 +1,4 @@ -/*! @page statistics Statistics +/*! @m_page{{c,java},statistics,Statistics} WiredTiger can be configured to maintain a variety of run-time and data-source statistics. As maintaining statistics may involve updating diff --git a/src/docs/threads.dox b/src/docs/threads.dox index b5cca7911a3..16b0d7940da 100644 --- a/src/docs/threads.dox +++ b/src/docs/threads.dox @@ -1,4 +1,4 @@ -/*! @page threads Multithreading +/*! @m_page{{c,java},threads,Multithreading} All WT_CONNECTION methods are thread safe, and WT_CONNECTION handles can be shared between threads. Applications typically open a single diff --git a/src/docs/tools/doxfilter b/src/docs/tools/doxfilter index 9b63982913c..298e23f6cbb 100755 --- a/src/docs/tools/doxfilter +++ b/src/docs/tools/doxfilter @@ -27,4 +27,4 @@ tooldir=`dirname $0` -cat "$@" | python $tooldir/doxfilter.py +python $tooldir/doxfilter.py "$@" diff --git a/src/docs/tools/doxfilter.py b/src/docs/tools/doxfilter.py index b742be16e18..99a65575d89 100755 --- a/src/docs/tools/doxfilter.py +++ b/src/docs/tools/doxfilter.py @@ -30,11 +30,152 @@ # WiredTiger reference manual. It changes comments to Javadoc style # (i.e., from "/*!" to "/**"), because the latter are configured to not # search for brief descriptions at the beginning of pages. +# It also processes any page marked with @m_page specially to create +# multiple per-language versions of the page. import re, sys +progname = 'doxfilter.py' +linenum = 0 +filename = '<unknown>' + +def err(arg): + sys.stderr.write(filename + ':' + str(linenum) + + ': ERROR: ' + arg + '\n') + sys.exit(1) + +def java_post_substitutions(source): + result = source + for datatype in [['WT_CONNECTION', 'Connection'], + ['WT_CURSOR', 'Cursor'], + ['WT_SESSION', 'Session'], + ['WT_ASYNC_OPTYPE', 'AsyncOpType'], + ['WT_ASYNC_OP', 'AsyncOp']]: + fromdt = datatype[0] + todt = datatype[1] + + # e.g. replace("WT_CONNECTION::", "Connection."). + # replace("WT_CONNECTION", "Connection") + # replace("::WT_CONNECTION", "Connection") + # etc. + result = result.replace(fromdt + '::', todt + '.') + result = re.sub(r':*' + fromdt, todt, result) + + # We fix back any 'ref' entries, since we don't have + # many java versions of these refered-to pages. + # + # Ideally, we'd have a way ('@m_ref'?) to indicate which + # ones could refer to a Java version. + result = result.replace('ref ' + todt + '.', 'ref ' + fromdt + '::') + result = result.replace('::wiredtiger_open', '\c wiredtiger.open') + return result + +def process_lang(lang, lines): + result = '' + lang_ext = '.' + lang + class_suffix = None + if lang == 'c': + lang_suffix = "" + lang_desc="" + elif lang == 'java': + lang_suffix = "_lang_java" + lang_desc=" in Java" + else: + err('@m_page contains illegal lang: ' + lang) + condstack = [True] + linenum = 0 + mif_pat = re.compile('^\s*@m_if{([^,}]*)}') + melse_pat = re.compile('^\s*@m_else\s*$') + mendif_pat = re.compile('^\s*@m_endif\s*$') + mpage_pat = re.compile('@m_page{{([^}]*)},([^,}]*),([^}]*)}') + mpage_rep = r'@page \2' + lang_suffix + r' \3 ' + lang_desc + snip_pat = re.compile('@snippet ex_([^.]*)[.]c\s*(.*)') + snip_rep = r'@snippet ex_\1' + lang_ext + r' \2' + subpage_pat = re.compile('@subpage\s*([^\s]*)') + subpage_rep = r'@subpage \1' + lang_suffix + msinglesubpage_pat = re.compile('@m_single_subpage\s*([^\s]*)') + msinglesubpage_rep = r'\\subpage \1' + exref_pat = re.compile('@ex_ref{ex_([^.]*)[.]c}') + if lang == 'c': + exref_rep = r'@ex_ref{ex_\1' + lang_ext + '}' + else: + # Though we have java examples, we don't have references + # to them working yet, so strip the @ex_ref. + exref_rep = r'ex_\1' + lang_ext + + # Any remaining @m_foo{...} aliases are + # diverted to @c_foo{...} or @java_foo{...} + mgeneric_pat = re.compile('@m_([^ }]*)') + mgeneric_rep = r'@' + lang + r'_\1' + for line in lines: + linenum += 1 + if lang != 'c': + line = re.sub(snip_pat, snip_rep, line) + line = re.sub(exref_pat, exref_rep, line) + line = re.sub(mpage_pat, mpage_rep, line) + line = re.sub(subpage_pat, subpage_rep, line) + # msinglesubpage must be performed after subpage + line = re.sub(msinglesubpage_pat, msinglesubpage_rep, line) + if '@m_if' in line: + m = re.search(mif_pat, line) + if not m: + err('@m_if incorrect syntax') + iflang = m.groups()[0] + if iflang != 'java' and iflang != 'c': + err('@m_if unknown language') + condstack.append(iflang == lang) + elif '@m_else' in line: + if not re.search(melse_pat, line): + err('@m_else has extraneous stuff') + if len(condstack) <= 1: + err('@m_else missing if') + condstack[-1] = not condstack[-1] + elif '@m_endif' in line: + if not re.search(mendif_pat, line): + err('@m_endif has extraneous stuff') + if len(condstack) <= 1: + err('@m_endif missing if') + condstack.pop() + else: + if condstack[-1]: + # Do generic @m_... macros last + line = re.sub(mgeneric_pat, + mgeneric_rep, line) + result += line + '\n' + if lang == 'java': + result = java_post_substitutions(result) + if len(condstack) != 1: + err('non matching @m_if/@m_endif') + return result + +def process_multilang(source): + n = source.count('@m_page') + if n > 1: + err('multiple @m_page in file not allowed') + if n == 0: + err('missing @m_page in file that uses @m_ macros') + else: + m = re.search(r'@m_page{{([^}]*)},([^,}]*),([^}]*)}', + source, re.M) + if not m: + err('@m_page incorrect syntax') + groups = m.groups() + langs = groups[0].split(',') + lines = source.split('\n') + result = '' + for lang in langs: + result += process_lang(lang, lines) + return result + def process(source): - return source.replace(r'/*!', r'/**') + source = source.replace(r'/*!', r'/**') + if '@m_' in source: + source = process_multilang(source) + return source if __name__ == '__main__': - sys.stdout.write(process(sys.stdin.read())) + for f in sys.argv[1:]: + filename = f + with open(f, 'r') as infile: + sys.stdout.write(process(infile.read())) + sys.exit(0) diff --git a/src/docs/transactions.dox b/src/docs/transactions.dox index 610932d7cdf..7f3acaa245d 100644 --- a/src/docs/transactions.dox +++ b/src/docs/transactions.dox @@ -1,4 +1,4 @@ -/*! @page transactions Transactions +/*! @m_page{{c,java},transactions,Transactions} @section transactions_acid ACID properties diff --git a/src/docs/tune-cache.dox b/src/docs/tune-cache.dox index 9183fe8a25a..9f4d1a6406f 100644 --- a/src/docs/tune-cache.dox +++ b/src/docs/tune-cache.dox @@ -56,7 +56,7 @@ eviction configuration settings can reduce latency spikes in application threads and can improve throughput in some applications. WiredTiger eviction tuning options can be configured when first opening -a database via @ref wiredtiger_open, or changed after open with +a database via ::wiredtiger_open, or changed after open with WT_CONNECTION::reconfigure. The \c eviction_trigger configuration value is the occupied percentage |