Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Create gh-pages branch via GitHub

  • Loading branch information...
commit 06228dd02722d8295d71d355bbe7e56d908f94cf 1 parent 83abcb4
Dave Parfitt authored
Showing with 6 additions and 4 deletions.
  1. +5 −3 index.html
  2. +1 −1  params.json
View
8 index.html
@@ -52,10 +52,12 @@ <h1 class="header">Riak-ocaml-client</h1>
<li><a href="OUnit">http://ounit.forge.ocamlcore.org/</a></li>
</ul><h2>Installation</h2>
-<pre><code>make
+<pre><code>cd src
+make
+# To test, run this:
export RIAK_OCAML_TEST_IP="127.0.0.1"
export RIAK_OCAML_TEST_PORT=8087
-make test
+./RiakTests
sudo make install
</code></pre>
@@ -552,7 +554,7 @@ <h1 class="header">Riak-ocaml-client</h1>
<ul>
<li>Please report all bugs and feature requests via Github Issues.</li>
-<li>Friendly pull requests accepted. </li>
+<li>Friendly pull requests accepted. Please create a new branch for your features (checkout -b my_branch).</li>
</ul><h2>TODO</h2>
<pre><code>* test search, index
View
2  params.json
@@ -1 +1 @@
-{"google":"","tagline":"An OCaml client for Riak 1.2","note":"Don't delete this file! It's used internally to help with page regeneration.","name":"Riak-ocaml-client","body":"riak-ocaml-client\r\n=====\r\n\r\n**© 2012 Dave Parfitt**\r\n\r\nriak-ocaml-client is a Riak 1.2 Protobuffs-only client for OCaml 3.12.1. Future versions may support all HTTP operations.\r\n\r\n##Dependencies\r\n\r\n* [ocamlfind](http://projects.camlcity.org/projects/findlib.html)\r\n* [Piqi](http://piqi.org/) \r\n* [http://code.google.com/p/protobuf/](Protobuffs)\r\n * On OSX, `brew install protobuf` if you are using Homebrew\r\n* [http://ounit.forge.ocamlcore.org/](OUnit)\r\n\r\n## Installation\r\n\r\n```\r\nmake \r\nexport RIAK_OCAML_TEST_IP=\"127.0.0.1\"\r\nexport RIAK_OCAML_TEST_PORT=8087\r\nmake test\r\n \r\nsudo make install\r\n```\r\n **Note**: Testing requires a running instance of Riak 1.2+. By default, it tries to connect to Riak on 127.0.0.1, port 8081. To override these values, simply export the following two environment variables:\r\n \r\n* RIAK_OCAML_TEST_IP\r\n* RIAK_OCAML_TEST_PORT\r\n\r\n## Tutorial\r\n\r\n###Hello world\r\n\r\nThe following program makes a connection to Riak and sends a ping message. \r\n\r\n```\r\nopen Riak\r\nopen Sys\r\nopen Unix\r\n\r\nlet client() =\r\n let conn = riak_connect_with_defaults \"127.0.0.1\" 8087 in\r\n let _ = match riak_ping conn with\r\n | true -> print_endline(\"Pong\")\r\n | false -> print_endline(\"Error\")\r\n in\r\n riak_disconnect conn;\r\n exit 0;;\r\n\r\nhandle_unix_error client ();;\r\n\r\n```\r\n\r\n\r\nCompile this example with the following:\r\n\r\n```\r\n \tocamlfind ocamlc -o foo -package Unix -package oUnit -package \\\r\n \t piqi.runtime -package riak -linkpkg foo.ml\r\n\r\n```\r\n\r\n**Note**: Change the IP/port to the value defined in the Riak app.config `pb_port` and `pb_ip`.\r\n\r\n**Note**: If compiling this example from the same directory as the Riak Ocaml Client source, you will see an error like this:\r\n`findlib: [WARNING] Interface Riak.cmi occurs in several directories: ., /usr/local/lib/ocaml/site-lib/riak`\r\n\r\n## Development Guide\r\n \r\n### A note on types\r\n\r\nThroughout the docs, you will find the following types. Almost all are strings:\r\n \r\n```\r\ntype riak_bucket = string\r\ntype riak_key = string\r\ntype riak_client_id = string\r\ntype riak_mr_query = string\r\ntype riak_mr_content_type = Riak_MR_Json | Riak_MR_Erlang\r\ntype riak_2i_name = string\r\ntype riak_2i_range_min = string\r\ntype riak_2i_range_max = string\r\ntype riak_search_query = string\r\ntype riak_search_index = string\r\ntype riak_node_id = string\r\ntype riak_version = string\r\ntype riak_vclock = string\r\n```\r\n\r\nSee ./src/Riak.mli for the complete interface.\r\n \r\n### Connect/Disconnect\r\n\r\n```\r\nval riak_connection_defaults : riak_connection_options\r\n\r\nval riak_connect_with_defaults : string -> int -> riak_connection\r\n\r\nval riak_connect : string -> int -> riak_connection_options -> riak_connection\r\n\r\nval riak_disconnect : riak_connection -> unit\r\n\r\n```\r\n\r\nTo connect using default connection properties: \r\n\r\n```\r\n let conn = riak_connect_with_defaults \"127.0.0.1\" 8081\r\n``` \r\n \r\n * **Note**: Pooling of connections isn't implemented, but feel free to roll your own.\r\n \r\n#####Default connection properties:\r\nThe following defaults are used when calling `riak_connect_with_defaults`.\r\n\r\n* disable Nagle's algorithm for better performance\r\n* try an operation 3 times before an exception is thrown\r\n* throw an exception if siblings are encountered \r\n\r\nTo override these values:\r\n\r\n```\r\n\tlet options = \r\n\t { riak_connection_defaults with riak_conn_retries=5 } in\r\n\tlet conn = riak_connect \"127.0.0.1\" 8081 options in\r\n\t...\r\n```\r\n\r\nTo disconnect: \r\n\r\n riak_disconnect conn\r\n\r\n### Ping\r\n\r\n```\r\n\tval riak_ping : riak_connection -> bool\r\n```\r\n\r\n**Example**\r\n\r\n```\r\n\tmatch riak_ping conn with\r\n \t| true -> ()\r\n \t| false -> assert_failure(\"Can't connect to Riak\")\r\n```\r\n\r\n### Client ID\r\n\r\n```\r\nval riak_get_client_id : riak_connection -> riak_client_id\r\n\r\nval riak_set_client_id : riak_connection -> riak_client_id -> unit\r\n```\r\n\r\n**Example**\r\n\r\n```\r\n\tlet test_client_id = \"foo\" in\r\n\tlet _ = riak_set_client_id conn test_client_id in\r\n\tlet client_id = riak_get_client_id conn in\r\n\t...\r\n```\r\n\r\n### Server Info\r\n\r\n```\r\nval riak_get_server_info : riak_connection -> riak_node_id * riak_version\r\n```\r\n\r\n**Example**\r\n\r\n```\r\n\tlet (node, version) = riak_get_server_info conn in\r\n```\r\n\r\n### Get\r\n\r\n```\r\nval riak_get :\r\n riak_connection -> \r\n riak_bucket -> \r\n riak_key -> \r\n riak_get_option list -> \r\n riak_object option\r\n```\r\n\r\n**Example**\t\r\n\r\n```\r\nlet result = riak_get conn \"my_bucket\" \"my_key\" [Get_basic_quorum false; Get_head true] in\r\n…\r\n```\r\n\r\n**type riak_get_option =**\r\n\r\n- **Get_r** of *riak_tunable_cap*\r\n \r\n Read quorum. How many replicas need to agree when retrieving the object. Default is defined per bucket. See the Tunable CAP Options section below.\r\n \r\n- **Get_pr** of *riak_tunable_cap*\r\n \r\n\tPrimary read quorum. How many primary replicas need to be available when retrieving the object. Default is defined per bucket. See the Tunable CAP Options section below.\r\n\r\n- **Get_basic_quorum** of *bool*\r\n\r\n\tWhether to return early in some failure cases (eg. when r=1 and you get 2 errors and a success basic_quorum=true would return an error). Default is defined per bucket.\r\n\r\n- **Get_notfound_ok** of *bool*\r\n \r\n\tWhether to treat notfounds as successful reads for the purposes of R (default is defined per the bucket). Default is defined per bucket.\r\n \r\n- **Get_if_modified** of *string*\r\n\r\n\tWhen a vclock is supplied as this option only return the object if the vclocks don't match\r\n \r\n- **Get_head** of *bool*\r\n\r\n\tReturn the object with the value(s) set as empty - allows you to get the metadata without a potentially large value\r\n\r\n- **Get_deleted_vclock** of *bool*\r\n \r\n\tReturn the tombstone's vclock, if applicable\r\n \r\n### Put\r\n\r\n```\r\nval riak_put :\r\n riak_connection ->\r\n riak_bucket ->\r\n riak_key option ->\r\n string ->\r\n riak_put_option list -> \r\n riak_object list\r\n\r\nval riak_put_raw :\r\n riak_connection ->\r\n riak_bucket ->\r\n riak_key option ->\r\n string ->\r\n riak_put_option list -> \r\n riak_vclock option -> \r\n riak_object list\r\n```\r\nIf you plan on inserting new key/values, use riak_put_raw. If you aren't sure if your key/value is new, use riak_put. riak_put will try and fetch the vclock before updating to limit sibling explosion\r\n\r\n**Example**\r\n\r\n\r\n\r\n```\r\n let newkey = \"foo\" in\r\n let newval = \"bar\" in\r\n riak_put conn bucket (Some newkey) newval [Put_return_body true]\r\n```\r\n\r\n```\r\n let newkey = \"foo\" in\r\n let newval = \"bar\" in\r\n let existing_vclock = (*Some vclock *)\r\n riak_put_raw conn bucket (Some newkey) newval [Put_return_body true] existing_vclock\r\n```\r\n\r\ntype riak_put_option =\r\n\r\n- **Put_w** of *riak_tunable_cap*\r\n\r\n Write quorum. How many replicas to write to before returning a successful response. Default is defined per bucket. See the Tunable CAP Options section below.\r\n \r\n- **Put_dw** of *riak_tunable_cap*\r\n\r\n\tHow many replicas to commit to durable storage before returning a successful response. Default is defined per bucket. See the Tunable CAP Options section below.\r\n\r\n- **Put_return_body** of *bool*\r\n\r\n\t Whether to return the contents of the stored object. Defaults to false.\r\n\r\n- **Put_pw** of *riak_tunable_cap*\r\n\r\n\tHow many primary nodes must be up when the write is attempted. Default is defined per bucket. See the Tunable CAP Options section below.\r\n\t\r\n- **Put_if_not_modified** of *bool*\r\n\r\n\tUpdate the value only if the vclock in the supplied object matches the one in the database.\r\n\r\n- **Put_if_none_match** of *bool*\r\n\r\n\tStore the value only if this bucket/key combination are not already defined.\r\n\r\n- **Put_return_head** of *bool*\r\n\r\n\tLike *return_body\" except that the value(s) in the object are blank to avoid returning potentially large value(s).\r\n\r\n### Delete\r\n\r\n```\r\nval riak_del :\r\n riak_connection ->\r\n riak_bucket ->\r\n riak_key -> riak_del_option list -> unit\r\n```\r\n\r\n**Example**\r\n\r\n```\r\n\triak_del conn bucket \"del_test\" [] \r\n```\r\n\r\ntype riak_del_option =\r\n\r\n- **Del_rw** of *riak_tunable_cap*\r\n\r\n\tHow many replicas to delete before returning a successful response. Default is defined per bucket. See the Tunable CAP Options section below.\r\n\r\n- **Del_vclock** of *string*\r\n\r\n\tOpaque vector clock provided by an earlier Get request. Use to prevent deleting of objects that have been modified since the last get request.\r\n \r\n- **Del_r** of *riak_tunable_cap*\r\n\r\n\tRead quorum. How many replicas need to agree when retrieving the object. Default is defined per bucket. See the Tunable CAP Options section below.\r\n \r\n- **Del_w** of *riak_tunable_cap*\r\n\r\n\tWrite quorum. How many replicas to write to before returning a successful response. Default is defined per bucket. See the Tunable CAP Options section below.\r\n \r\n- **Del_pr** of *riak_tunable_cap*\r\n\r\n\tPrimary read quorum. How many primary replicas need to be available when retrieving the object. Default is defined per bucket. See the Tunable CAP Options section below.\r\n \r\n- **Del_pw** of *riak_tunable_cap*\r\n\r\n\tHow many primary nodes must be up when the write is attempted. Default is defined per bucket. See the Tunable CAP Options section below.\r\n \r\n- **Del_dw** of *riak_tunable_cap*\r\n\r\n\tHow many replicas to commit to durable storage before returning a successful response. Default is defined per bucket. See the Tunable CAP Options section below.\r\n\r\n\r\n\r\n### Tunable CAP Options\r\n\r\n type riak_tunable_cap =\r\n\r\n- **Riak_value_one**\r\n- **Riak_value_quorum**\r\n- **Riak_value_all**\r\n- **Riak_value_default**\r\n- **Riak_value of Riak_kv_piqi.uint32**\r\n\r\n\r\n### List Buckets\r\n\r\n```\r\nval riak_list_buckets : riak_connection -> riak_bucket list\r\n```\r\n\r\n**Example**\r\n\r\n```\r\n let buckets = riak_list_buckets conn in\r\n```\r\n\r\n### List Keys\r\n\r\n```\r\nval riak_list_keys : riak_connection -> riak_bucket -> riak_key list\r\n```\r\n\r\n**Example**\r\n\r\n```\r\n let keys = riak_list_keys conn \"mybucket\" in\r\n```\r\n\r\n### Get Bucket Props (limited)\r\nAt the moment, Riak Protobuffs only implement 2 bucket properties, \r\n\r\n * n_val\r\n * allow_mult\r\n \r\n \r\n```\r\nval riak_get_bucket : \r\n\triak_connection -> \r\n\triak_bucket -> \r\n\tint32 option * bool option\r\n```\r\n\r\n**Example**\r\n\r\n```\r\n let (n, multi) = riak_get_bucket conn bucket in\r\n (match n with\r\n | Some nval -> assert_bool \"Valid bucket n value\" (nval > 0l)\r\n | None -> assert_failure \"Unexpected default N value\");\r\n (match multi with\r\n | Some multival -> assert_equal false multival\r\n | None -> assert_failure \"Unexpected default multi value\")\r\n```\r\n\r\n### Set Bucket Props (limited)\r\nAt the moment, Riak Protobuffs only implement 2 bucket properties, \r\n\r\n * n_val\r\n * allow_mult\r\n\r\n```\r\nval riak_set_bucket : \r\n riak_connection -> \r\n riak_bucket -> \r\n int32 option -> \r\n bool option -> \r\n unit\r\n```\r\n\r\n**Example**\r\n\r\n```\r\n let n_val = 2l in\r\n let allow_mult = (Some true) in\r\n riak_set_bucket conn bucket n_val allow_mult\r\n```\r\n\r\n### Map/Reduce\r\n\r\n```\r\nval riak_mapred :\r\n riak_connection ->\r\n riak_mr_query ->\r\n riak_mr_content_type ->\r\n (string option * int32 option) list\r\n\r\n```\r\n\r\n**Example**\r\n\r\nSee src/test.ml for an example.\r\n\r\n### Index Query\r\n\r\nSecondary index (2i) exact match query:\r\n\r\n```\r\nval riak_index_eq :\r\n riak_connection ->\r\n riak_bucket ->\r\n riak_2i_name ->\r\n riak_key option -> string list\r\n```\r\n\r\nSecondary index (2i) range query:\r\n\r\n```\r\nval riak_index_range :\r\n riak_connection ->\r\n riak_bucket ->\r\n riak_2i_name ->\r\n riak_2i_range_min option ->\r\n riak_2i_range_max option -> string list\r\n```\r\n\r\n### Riak Search\r\n\r\nGood luck. This probably needs a little bit of cleanup. Please don't punch me Ryan.\r\n\r\n```\r\nval riak_search_query :\r\n riak_connection ->\r\n string ->\r\n string ->\r\n riak_search_option list ->\r\n (string * string option) list list *\r\n Riak_search_piqi.Riak_search_piqi.float32 option *\r\n Riak_search_piqi.Riak_search_piqi.uint32 option\r\n```\r\n\r\n\r\ntype riak_search_option =\r\n\r\n- **Search_rows** of *Riak_kv_piqi.uint32*\r\n\r\n\t Specify the maximum number of results to return. Default is 10.\r\n\t \r\n- **Search_start** of *Riak_kv_piqi.uint32*\r\n\r\n\t Specify the starting result of the query. Useful for paging. Default is 0.\r\n\t \r\n- **Search_sort** of *string*\r\n\r\n\tSort on the specified field name. Default is “none”, which causes the results to be sorted in descending order by score.\r\n\t\r\n- **Search_filter** of *string*\r\n\r\n\tFilters the search by an additional query scoped to inline fields.\r\n\t\r\n- **Search_df** of *string*\r\n\r\n\tUse the provided field as the default. Overrides the “default_field” setting in the schema file.\r\n\t\r\n- **Search_op** of *string*\r\n\r\n\tAllowed settings are either “and” or “or”. Overrides the “default_op” setting in the schema file. Default is “or”.\r\n\t\r\n- **Search_fl** of *string list*\r\n\r\n\tReturn fields limit (for ids only, generally).\r\n\r\n- **Search_presort** of *string*\r\n\r\n\tPresort (key / score)\r\n\r\n---\r\n\r\n## Contributing\r\n\r\n* Please report all bugs and feature requests via Github Issues.\r\n* Friendly pull requests accepted. \r\n\r\n##TODO\r\n * test search, index\r\n * better error handling\r\n\t* Next version: support HTTP operations, or better yet, implement all HTTP ops as PB messages in Riak\r\n\r\n** © 2012 Dave Parfitt **\r\n\r\nPortions of the documentation are ** © 2012 Basho Technologies **\r\n\r\n"}
+{"note":"Don't delete this file! It's used internally to help with page regeneration.","name":"Riak-ocaml-client","google":"","tagline":"An OCaml client for Riak 1.2","body":"riak-ocaml-client\r\n=====\r\n\r\n**© 2012 Dave Parfitt**\r\n\r\nriak-ocaml-client is a Riak 1.2 Protobuffs-only client for OCaml 3.12.1. Future versions may support all HTTP operations.\r\n\r\n##Dependencies\r\n\r\n* [ocamlfind](http://projects.camlcity.org/projects/findlib.html)\r\n* [Piqi](http://piqi.org/) \r\n* [http://code.google.com/p/protobuf/](Protobuffs)\r\n * On OSX, `brew install protobuf` if you are using Homebrew\r\n* [http://ounit.forge.ocamlcore.org/](OUnit)\r\n\r\n## Installation\r\n\r\n```\r\ncd src\r\nmake \r\n# To test, run this:\r\nexport RIAK_OCAML_TEST_IP=\"127.0.0.1\"\r\nexport RIAK_OCAML_TEST_PORT=8087\r\n./RiakTests\r\n\r\nsudo make install\r\n```\r\n **Note**: Testing requires a running instance of Riak 1.2+. By default, it tries to connect to Riak on 127.0.0.1, port 8081. To override these values, simply export the following two environment variables:\r\n \r\n* RIAK_OCAML_TEST_IP\r\n* RIAK_OCAML_TEST_PORT\r\n\r\n## Tutorial\r\n\r\n###Hello world\r\n\r\nThe following program makes a connection to Riak and sends a ping message. \r\n\r\n```\r\nopen Riak\r\nopen Sys\r\nopen Unix\r\n\r\nlet client() =\r\n let conn = riak_connect_with_defaults \"127.0.0.1\" 8087 in\r\n let _ = match riak_ping conn with\r\n | true -> print_endline(\"Pong\")\r\n | false -> print_endline(\"Error\")\r\n in\r\n riak_disconnect conn;\r\n exit 0;;\r\n\r\nhandle_unix_error client ();;\r\n\r\n```\r\n\r\n\r\nCompile this example with the following:\r\n\r\n```\r\n \tocamlfind ocamlc -o foo -package Unix -package oUnit -package \\\r\n \t piqi.runtime -package riak -linkpkg foo.ml\r\n\r\n```\r\n\r\n**Note**: Change the IP/port to the value defined in the Riak app.config `pb_port` and `pb_ip`.\r\n\r\n**Note**: If compiling this example from the same directory as the Riak Ocaml Client source, you will see an error like this:\r\n`findlib: [WARNING] Interface Riak.cmi occurs in several directories: ., /usr/local/lib/ocaml/site-lib/riak`\r\n\r\n## Development Guide\r\n \r\n### A note on types\r\n\r\nThroughout the docs, you will find the following types. Almost all are strings:\r\n \r\n```\r\ntype riak_bucket = string\r\ntype riak_key = string\r\ntype riak_client_id = string\r\ntype riak_mr_query = string\r\ntype riak_mr_content_type = Riak_MR_Json | Riak_MR_Erlang\r\ntype riak_2i_name = string\r\ntype riak_2i_range_min = string\r\ntype riak_2i_range_max = string\r\ntype riak_search_query = string\r\ntype riak_search_index = string\r\ntype riak_node_id = string\r\ntype riak_version = string\r\ntype riak_vclock = string\r\n```\r\n\r\nSee ./src/Riak.mli for the complete interface.\r\n \r\n### Connect/Disconnect\r\n\r\n```\r\nval riak_connection_defaults : riak_connection_options\r\n\r\nval riak_connect_with_defaults : string -> int -> riak_connection\r\n\r\nval riak_connect : string -> int -> riak_connection_options -> riak_connection\r\n\r\nval riak_disconnect : riak_connection -> unit\r\n\r\n```\r\n\r\nTo connect using default connection properties: \r\n\r\n```\r\n let conn = riak_connect_with_defaults \"127.0.0.1\" 8081\r\n``` \r\n \r\n * **Note**: Pooling of connections isn't implemented, but feel free to roll your own.\r\n \r\n#####Default connection properties:\r\nThe following defaults are used when calling `riak_connect_with_defaults`.\r\n\r\n* disable Nagle's algorithm for better performance\r\n* try an operation 3 times before an exception is thrown\r\n* throw an exception if siblings are encountered \r\n\r\nTo override these values:\r\n\r\n```\r\n\tlet options = \r\n\t { riak_connection_defaults with riak_conn_retries=5 } in\r\n\tlet conn = riak_connect \"127.0.0.1\" 8081 options in\r\n\t...\r\n```\r\n\r\nTo disconnect: \r\n\r\n riak_disconnect conn\r\n\r\n### Ping\r\n\r\n```\r\n\tval riak_ping : riak_connection -> bool\r\n```\r\n\r\n**Example**\r\n\r\n```\r\n\tmatch riak_ping conn with\r\n \t| true -> ()\r\n \t| false -> assert_failure(\"Can't connect to Riak\")\r\n```\r\n\r\n### Client ID\r\n\r\n```\r\nval riak_get_client_id : riak_connection -> riak_client_id\r\n\r\nval riak_set_client_id : riak_connection -> riak_client_id -> unit\r\n```\r\n\r\n**Example**\r\n\r\n```\r\n\tlet test_client_id = \"foo\" in\r\n\tlet _ = riak_set_client_id conn test_client_id in\r\n\tlet client_id = riak_get_client_id conn in\r\n\t...\r\n```\r\n\r\n### Server Info\r\n\r\n```\r\nval riak_get_server_info : riak_connection -> riak_node_id * riak_version\r\n```\r\n\r\n**Example**\r\n\r\n```\r\n\tlet (node, version) = riak_get_server_info conn in\r\n```\r\n\r\n### Get\r\n\r\n```\r\nval riak_get :\r\n riak_connection -> \r\n riak_bucket -> \r\n riak_key -> \r\n riak_get_option list -> \r\n riak_object option\r\n```\r\n\r\n**Example**\t\r\n\r\n```\r\nlet result = riak_get conn \"my_bucket\" \"my_key\" [Get_basic_quorum false; Get_head true] in\r\n…\r\n```\r\n\r\n**type riak_get_option =**\r\n\r\n- **Get_r** of *riak_tunable_cap*\r\n \r\n Read quorum. How many replicas need to agree when retrieving the object. Default is defined per bucket. See the Tunable CAP Options section below.\r\n \r\n- **Get_pr** of *riak_tunable_cap*\r\n \r\n\tPrimary read quorum. How many primary replicas need to be available when retrieving the object. Default is defined per bucket. See the Tunable CAP Options section below.\r\n\r\n- **Get_basic_quorum** of *bool*\r\n\r\n\tWhether to return early in some failure cases (eg. when r=1 and you get 2 errors and a success basic_quorum=true would return an error). Default is defined per bucket.\r\n\r\n- **Get_notfound_ok** of *bool*\r\n \r\n\tWhether to treat notfounds as successful reads for the purposes of R (default is defined per the bucket). Default is defined per bucket.\r\n \r\n- **Get_if_modified** of *string*\r\n\r\n\tWhen a vclock is supplied as this option only return the object if the vclocks don't match\r\n \r\n- **Get_head** of *bool*\r\n\r\n\tReturn the object with the value(s) set as empty - allows you to get the metadata without a potentially large value\r\n\r\n- **Get_deleted_vclock** of *bool*\r\n \r\n\tReturn the tombstone's vclock, if applicable\r\n \r\n### Put\r\n\r\n```\r\nval riak_put :\r\n riak_connection ->\r\n riak_bucket ->\r\n riak_key option ->\r\n string ->\r\n riak_put_option list -> \r\n riak_object list\r\n\r\nval riak_put_raw :\r\n riak_connection ->\r\n riak_bucket ->\r\n riak_key option ->\r\n string ->\r\n riak_put_option list -> \r\n riak_vclock option -> \r\n riak_object list\r\n```\r\nIf you plan on inserting new key/values, use riak_put_raw. If you aren't sure if your key/value is new, use riak_put. riak_put will try and fetch the vclock before updating to limit sibling explosion\r\n\r\n**Example**\r\n\r\n\r\n\r\n```\r\n let newkey = \"foo\" in\r\n let newval = \"bar\" in\r\n riak_put conn bucket (Some newkey) newval [Put_return_body true]\r\n```\r\n\r\n```\r\n let newkey = \"foo\" in\r\n let newval = \"bar\" in\r\n let existing_vclock = (*Some vclock *)\r\n riak_put_raw conn bucket (Some newkey) newval [Put_return_body true] existing_vclock\r\n```\r\n\r\ntype riak_put_option =\r\n\r\n- **Put_w** of *riak_tunable_cap*\r\n\r\n Write quorum. How many replicas to write to before returning a successful response. Default is defined per bucket. See the Tunable CAP Options section below.\r\n \r\n- **Put_dw** of *riak_tunable_cap*\r\n\r\n\tHow many replicas to commit to durable storage before returning a successful response. Default is defined per bucket. See the Tunable CAP Options section below.\r\n\r\n- **Put_return_body** of *bool*\r\n\r\n\t Whether to return the contents of the stored object. Defaults to false.\r\n\r\n- **Put_pw** of *riak_tunable_cap*\r\n\r\n\tHow many primary nodes must be up when the write is attempted. Default is defined per bucket. See the Tunable CAP Options section below.\r\n\t\r\n- **Put_if_not_modified** of *bool*\r\n\r\n\tUpdate the value only if the vclock in the supplied object matches the one in the database.\r\n\r\n- **Put_if_none_match** of *bool*\r\n\r\n\tStore the value only if this bucket/key combination are not already defined.\r\n\r\n- **Put_return_head** of *bool*\r\n\r\n\tLike *return_body\" except that the value(s) in the object are blank to avoid returning potentially large value(s).\r\n\r\n### Delete\r\n\r\n```\r\nval riak_del :\r\n riak_connection ->\r\n riak_bucket ->\r\n riak_key -> riak_del_option list -> unit\r\n```\r\n\r\n**Example**\r\n\r\n```\r\n\triak_del conn bucket \"del_test\" [] \r\n```\r\n\r\ntype riak_del_option =\r\n\r\n- **Del_rw** of *riak_tunable_cap*\r\n\r\n\tHow many replicas to delete before returning a successful response. Default is defined per bucket. See the Tunable CAP Options section below.\r\n\r\n- **Del_vclock** of *string*\r\n\r\n\tOpaque vector clock provided by an earlier Get request. Use to prevent deleting of objects that have been modified since the last get request.\r\n \r\n- **Del_r** of *riak_tunable_cap*\r\n\r\n\tRead quorum. How many replicas need to agree when retrieving the object. Default is defined per bucket. See the Tunable CAP Options section below.\r\n \r\n- **Del_w** of *riak_tunable_cap*\r\n\r\n\tWrite quorum. How many replicas to write to before returning a successful response. Default is defined per bucket. See the Tunable CAP Options section below.\r\n \r\n- **Del_pr** of *riak_tunable_cap*\r\n\r\n\tPrimary read quorum. How many primary replicas need to be available when retrieving the object. Default is defined per bucket. See the Tunable CAP Options section below.\r\n \r\n- **Del_pw** of *riak_tunable_cap*\r\n\r\n\tHow many primary nodes must be up when the write is attempted. Default is defined per bucket. See the Tunable CAP Options section below.\r\n \r\n- **Del_dw** of *riak_tunable_cap*\r\n\r\n\tHow many replicas to commit to durable storage before returning a successful response. Default is defined per bucket. See the Tunable CAP Options section below.\r\n\r\n\r\n\r\n### Tunable CAP Options\r\n\r\n type riak_tunable_cap =\r\n\r\n- **Riak_value_one**\r\n- **Riak_value_quorum**\r\n- **Riak_value_all**\r\n- **Riak_value_default**\r\n- **Riak_value of Riak_kv_piqi.uint32**\r\n\r\n\r\n### List Buckets\r\n\r\n```\r\nval riak_list_buckets : riak_connection -> riak_bucket list\r\n```\r\n\r\n**Example**\r\n\r\n```\r\n let buckets = riak_list_buckets conn in\r\n```\r\n\r\n### List Keys\r\n\r\n```\r\nval riak_list_keys : riak_connection -> riak_bucket -> riak_key list\r\n```\r\n\r\n**Example**\r\n\r\n```\r\n let keys = riak_list_keys conn \"mybucket\" in\r\n```\r\n\r\n### Get Bucket Props (limited)\r\nAt the moment, Riak Protobuffs only implement 2 bucket properties, \r\n\r\n * n_val\r\n * allow_mult\r\n \r\n \r\n```\r\nval riak_get_bucket : \r\n\triak_connection -> \r\n\triak_bucket -> \r\n\tint32 option * bool option\r\n```\r\n\r\n**Example**\r\n\r\n```\r\n let (n, multi) = riak_get_bucket conn bucket in\r\n (match n with\r\n | Some nval -> assert_bool \"Valid bucket n value\" (nval > 0l)\r\n | None -> assert_failure \"Unexpected default N value\");\r\n (match multi with\r\n | Some multival -> assert_equal false multival\r\n | None -> assert_failure \"Unexpected default multi value\")\r\n```\r\n\r\n### Set Bucket Props (limited)\r\nAt the moment, Riak Protobuffs only implement 2 bucket properties, \r\n\r\n * n_val\r\n * allow_mult\r\n\r\n```\r\nval riak_set_bucket : \r\n riak_connection -> \r\n riak_bucket -> \r\n int32 option -> \r\n bool option -> \r\n unit\r\n```\r\n\r\n**Example**\r\n\r\n```\r\n let n_val = 2l in\r\n let allow_mult = (Some true) in\r\n riak_set_bucket conn bucket n_val allow_mult\r\n```\r\n\r\n### Map/Reduce\r\n\r\n```\r\nval riak_mapred :\r\n riak_connection ->\r\n riak_mr_query ->\r\n riak_mr_content_type ->\r\n (string option * int32 option) list\r\n\r\n```\r\n\r\n**Example**\r\n\r\nSee src/test.ml for an example.\r\n\r\n### Index Query\r\n\r\nSecondary index (2i) exact match query:\r\n\r\n```\r\nval riak_index_eq :\r\n riak_connection ->\r\n riak_bucket ->\r\n riak_2i_name ->\r\n riak_key option -> string list\r\n```\r\n\r\nSecondary index (2i) range query:\r\n\r\n```\r\nval riak_index_range :\r\n riak_connection ->\r\n riak_bucket ->\r\n riak_2i_name ->\r\n riak_2i_range_min option ->\r\n riak_2i_range_max option -> string list\r\n```\r\n\r\n### Riak Search\r\n\r\nGood luck. This probably needs a little bit of cleanup. Please don't punch me Ryan.\r\n\r\n```\r\nval riak_search_query :\r\n riak_connection ->\r\n string ->\r\n string ->\r\n riak_search_option list ->\r\n (string * string option) list list *\r\n Riak_search_piqi.Riak_search_piqi.float32 option *\r\n Riak_search_piqi.Riak_search_piqi.uint32 option\r\n```\r\n\r\n\r\ntype riak_search_option =\r\n\r\n- **Search_rows** of *Riak_kv_piqi.uint32*\r\n\r\n\t Specify the maximum number of results to return. Default is 10.\r\n\t \r\n- **Search_start** of *Riak_kv_piqi.uint32*\r\n\r\n\t Specify the starting result of the query. Useful for paging. Default is 0.\r\n\t \r\n- **Search_sort** of *string*\r\n\r\n\tSort on the specified field name. Default is “none”, which causes the results to be sorted in descending order by score.\r\n\t\r\n- **Search_filter** of *string*\r\n\r\n\tFilters the search by an additional query scoped to inline fields.\r\n\t\r\n- **Search_df** of *string*\r\n\r\n\tUse the provided field as the default. Overrides the “default_field” setting in the schema file.\r\n\t\r\n- **Search_op** of *string*\r\n\r\n\tAllowed settings are either “and” or “or”. Overrides the “default_op” setting in the schema file. Default is “or”.\r\n\t\r\n- **Search_fl** of *string list*\r\n\r\n\tReturn fields limit (for ids only, generally).\r\n\r\n- **Search_presort** of *string*\r\n\r\n\tPresort (key / score)\r\n\r\n---\r\n\r\n## Contributing\r\n\r\n* Please report all bugs and feature requests via Github Issues.\r\n* Friendly pull requests accepted. Please create a new branch for your features (checkout -b my_branch).\r\n\r\n##TODO\r\n * test search, index\r\n * better error handling\r\n\t* Next version: support HTTP operations, or better yet, implement all HTTP ops as PB messages in Riak\r\n\r\n** © 2012 Dave Parfitt **\r\n\r\nPortions of the documentation are ** © 2012 Basho Technologies **\r\n\r\n"}
Please sign in to comment.
Something went wrong with that request. Please try again.