summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAlex Gorrod <alexg@wiredtiger.com>2014-11-18 16:32:14 +1100
committerAlex Gorrod <alexg@wiredtiger.com>2014-11-18 16:32:14 +1100
commit299c3cefbbfaf2476b580298f972295e55ac2b5e (patch)
treeefdce835d7ab322cd2a023b47611c2b4a541ad54 /examples
parent83cfd8774e9a2732c0a50f26d43064d11bcabd2d (diff)
downloadmongo-299c3cefbbfaf2476b580298f972295e55ac2b5e.tar.gz
Add support for immutable indices.
Refs #1344
Diffstat (limited to 'examples')
-rw-r--r--examples/c/ex_schema.c18
-rw-r--r--examples/java/com/wiredtiger/examples/ex_schema.java6
2 files changed, 24 insertions, 0 deletions
diff --git a/examples/c/ex_schema.c b/examples/c/ex_schema.c
index bc2f3b6c2d9..3a9e619d39c 100644
--- a/examples/c/ex_schema.c
+++ b/examples/c/ex_schema.c
@@ -126,6 +126,13 @@ main(void)
"index:poptable:country_plus_year", "columns=(country,year)");
/*! [Create an index with a composite key] */
+
+ /*! [Create an immutable index] */
+ /* Create an immutable index. */
+ ret = session->create(session,
+ "index:poptable:immutable_year", "columns=(year),immutable");
+ /*! [Create an immutable index] */
+
/* Insert the records into the table. */
ret = session->open_cursor(
session, "table:poptable", NULL, "append", &cursor);
@@ -135,6 +142,17 @@ main(void)
}
ret = cursor->close(cursor);
+ /* Update records in the table. */
+ ret = session->open_cursor(session,
+ "table:poptable", NULL, NULL, &cursor);
+ while ((ret = cursor->next(cursor)) == 0) {
+ ret = cursor->get_key(cursor, &recno);
+ ret = cursor->get_value(cursor, &country, &year, &population);
+ cursor->set_value(cursor, country, year, population + 1);
+ ret = cursor->update(cursor);
+ }
+ ret = cursor->close(cursor);
+
/* List the records in the table. */
ret = session->open_cursor(session,
"table:poptable", NULL, NULL, &cursor);
diff --git a/examples/java/com/wiredtiger/examples/ex_schema.java b/examples/java/com/wiredtiger/examples/ex_schema.java
index 9b84912e0f0..18926f47008 100644
--- a/examples/java/com/wiredtiger/examples/ex_schema.java
+++ b/examples/java/com/wiredtiger/examples/ex_schema.java
@@ -135,6 +135,12 @@ public class ex_schema {
"columns=(country)");
/*! [Create an index] */
+ /*! [Create an immutable index] */
+ /* Create an index with a simple key. */
+ ret = session.create("index:poptable:immutable_year",
+ "columns=(year),immutable");
+ /*! [Create an immutable index] */
+
/*! [Create an index with a composite key] */
/* Create an index with a composite key (country,year). */
ret = session.create("index:poptable:country_plus_year",