http://zorba.io/modules/oracle-nosqldb

View as XML or JSON.

This module provides minimal functionality to interact with an Oracle NoSQL Database. Oracle NoSQL Database is built upon the proven Oracle Berkeley DB Java Edition high-availability storage engine, which is in widespread use in enterprises across industries. In addition to that it adds a layer of services for use in distributed environments. The resulting solution provides distributed, highly available key/value storage that is well suited to large-volume, latency-sensitive applications.
The kvclient library is used to implement these functions. Set the NOSQLDB_HOME environment variable when compilling this module.


Note: Since this module has a Java library dependency a JVM required to be installed on the system. For Windows: jvm.dll is required on the system path ( usually located in "C:\Program Files\Java\jre6\bin\client".

Function Summary

connect ($options as object()) as xs:anyURI

Connect to a NoSQL Database KVStore

delete ($db as xs:anyURI, $key as xs:string) as xs:boolean

Delete the key/value pair associated with the key.

get-binary ($db as xs:anyURI, $key as object()) as object()? external

Get the value as base64Binary and version associated with the key.

get-text ($db as xs:anyURI, $key as object()) as object()?

Get the value as string and version associated with the key.

get ($db as xs:anyURI, $key as xs:string) as xs:string

Get the value as string and version associated with the key.

multi-get-binary ($db as xs:anyURI, $parent-key as object(), $sub-range as object(), $depth as xs:string, $direction as xs:string) as object()* external

Returns the descendant key/value pairs associated with the $parent-key.

multi-get-text ($db as xs:anyURI, $parent-key as object(), $sub-range as object(), $depth as xs:string, $direction as xs:string) as object()*

Returns the descendant key/value pairs associated with the $parent-key.

multi-remove ($db as xs:anyURI, $parent-key as object(), $sub-range as object(), $depth as xs:string) as xs:int external

Removes the descendant Key/Value pairs associated with the $parent-key.

put-binary ($db as xs:anyURI, $key as object(), $value as xs:base64Binary) as xs:long external

Put a key/value pair, inserting or overwriting as appropriate.

put-text ($db as xs:anyURI, $key as object(), $string-value as xs:string) as xs:long

Put a key/value pair, inserting or overwriting as appropriate.

put ($db as xs:anyURI, $key as xs:string, $value as xs:string) as xs:long

Put a key/value pair, inserting or overwriting as appropriate.

remove ($db as xs:anyURI, $key as object()) as xs:boolean external

Removes the key/value pair associated with the key.

Functions

connect#1

declare  %an:sequential function nosql:connect($options as object()) as xs:anyURI
Connect to a NoSQL Database KVStore

Parameters

options as object()
JSON object that contains "store-name" and "helper-host-ports". For example:
{ "store-name" : "kvstore", "helper-host-ports" : ["localhost:5000"]}

Returns

xs:anyURI
the function has side-effects and returns an identifier for a connection to the KVStore

delete#2

declare  %an:sequential function nosql:delete($db as xs:anyURI, $key as xs:string) as xs:boolean
Delete the key/value pair associated with the key.

Parameters

db as xs:anyURI
the KVStore reference
key as xs:string
the key used to look up the key/value pair.

Returns

xs:boolean
true if the delete is successful, or false if no existing value is present.

get-binary#2

declare  %an:sequential function nosql:get-binary($db as xs:anyURI, $key as object()) as object()? external
Get the value as base64Binary and version associated with the key.
Ex:
{ "value":"value as base64Binary", "version":"xs:long" }

Parameters

db as xs:anyURI
the KVStore reference
key as object()
the key used to look up the key/value pair.

Returns

object()?
the value and version associated with the key, or empty sequence if no associated value was found.

get-text#2

declare  %an:sequential function nosql:get-text($db as xs:anyURI, $key as object()) as object()?
Get the value as string and version associated with the key.
Ex:
{ "value":"value as string", "version":"xs:long" }

Parameters

db as xs:anyURI
the KVStore reference
key as object()
the key used to look up the key/value pair.

Returns

object()?
the value and version associated with the key, or empty sequence if no associated value was found.

get#2

declare  %an:sequential function nosql:get($db as xs:anyURI, $key as xs:string) as xs:string
Get the value as string and version associated with the key.
Ex:
{ "value":"value as string", "version":"xs:long" }

Parameters

db as xs:anyURI
the KVStore reference
key as xs:string
the key used to look up the key/value pair.

Returns

xs:string
the value and version associated with the key, or empty sequence if no associated value was found.

multi-get-binary#5

declare  %an:sequential function nosql:multi-get-binary($db as xs:anyURI, $parent-key as object(), $sub-range as object(), $depth as xs:string, $direction as xs:string) as object()* external
Returns the descendant key/value pairs associated with the $parent-key. The $sub-range and $depth arguments can be used to further limit the key/value pairs that are retrieved. The key/value pairs are fetched within the scope of a single transaction that effectively provides serializable isolation.
This API should be used with caution since it could result in an OutOfMemoryError, or excessive GC activity, if the results cannot all be held in memory at one time.
This method only allows fetching key/value pairs that are descendants of a $parent-key that has a complete major path.
Ex:
{ "value":"value as base64Binary", "version":"xs:long" }

Parameters

db as xs:anyURI
the KVStore reference
parent-key as object()
the parent key whose "child" KV pairs are to be fetched. It must not be null. The major key path must be complete. The minor key path may be omitted or may be a partial path.
sub-range as object()
further restricts the range under the $parent-key to the minor path components in this sub-range. It may be null.
depth as xs:string
specifies whether the parent and only children or all descendants are returned. Values are: CHILDREN_ONLY, DESCENDANTS_ONLY, PARENT_AND_CHILDREN, PARENT_AND_DESCENDANTS. If anything else PARENT_AND_DESCENDANTS is implied.
direction as xs:string
FORWARD or REVERSE. Specify the order of results, REVERSE for reverse or anything else for forward.

Returns

object()*
a list of objects containing key, value as base64Binary and version or empty sequence if no key was found.

multi-get-text#5

declare  %an:sequential function nosql:multi-get-text($db as xs:anyURI, $parent-key as object(), $sub-range as object(), $depth as xs:string, $direction as xs:string) as object()*
Returns the descendant key/value pairs associated with the $parent-key. The $sub-range and $depth arguments can be used to further limit the key/value pairs that are retrieved. The key/value pairs are fetched within the scope of a single transaction that effectively provides serializable isolation.
This API should be used with caution since it could result in an OutOfMemoryError, or excessive GC activity, if the results cannot all be held in memory at one time.
This method only allows fetching key/value pairs that are descendants of a $parent-key that has a complete major path.
Ex:
{ "value":"value as base64Binary", "version":"xs:long" }

Parameters

db as xs:anyURI
the KVStore reference
parent-key as object()
the parent key whose "child" KV pairs are to be fetched. It must not be null. The major key path must be complete. The minor key path may be omitted or may be a partial path.
sub-range as object()
further restricts the range under the $parent-key to the minor path components in this sub-range. It may be null.
depth as xs:string
specifies whether the parent and only children or all descendants are returned. Values are: CHILDREN_ONLY, DESCENDANTS_ONLY, PARENT_AND_CHILDREN, PARENT_AND_DESCENDANTS. If anything else PARENT_AND_DESCENDANTS is implied.
direction as xs:string
FORWARD or REVERSE. Specify the order of results, REVERSE for reverse or anything else for forward.

Returns

object()*
a list of objects containing key, value as string and version or empty sequence if no key was found.

multi-remove#4

declare  %an:sequential function nosql:multi-remove($db as xs:anyURI, $parent-key as object(), $sub-range as object(), $depth as xs:string) as xs:int external
Removes the descendant Key/Value pairs associated with the $parent-key. The $sub-range and $depth arguments can be used to further limit the key/value pairs that are deleted.

Parameters

db as xs:anyURI
the KVStore reference
parent-key as object()
the parent key whose "child" KV pairs are to be fetched. It must not be null. The major key path must be complete. The minor key path may be omitted or may be a partial path.
sub-range as object()
further restricts the range under the $parent-key to the minor path components in this sub-range. It may be null. There are two ways to specify a sub-range: - by prefix: { "prefix" : "a" } or by start-end: {"start": "a", "start-inclusive": true, "end" : "z", "end-inclusive": true}. For this case start-inclusive and end-inclusive are optional and they default to true.
depth as xs:string
specifies whether the parent and only children or all descendants are returned. Values are: CHILDREN_ONLY, DESCENDANTS_ONLY, PARENT_AND_CHILDREN, PARENT_AND_DESCENDANTS. If null, PARENT_AND_DESCENDANTS is implied.

Returns

xs:int
the count of deleted keys.

put-binary#3

declare  %an:sequential function nosql:put-binary($db as xs:anyURI, $key as object(), $value as xs:base64Binary) as xs:long external
Put a key/value pair, inserting or overwriting as appropriate.

Parameters

db as xs:anyURI
the KVStore reference
key as object()
the key used to look up the key/value pair.
{ "major": ["major-key1","major-key2","major-key3"], "minor": ["minor-key1","minor-key2","minor-key3"] }
value as xs:base64Binary
the value part of the key/value pair as base64Binary.

Returns

xs:long
the version of the new value.

put-text#3

declare  %an:sequential function nosql:put-text($db as xs:anyURI, $key as object(), $string-value as xs:string) as xs:long
Put a key/value pair, inserting or overwriting as appropriate.

Parameters

db as xs:anyURI
the KVStore reference
key as object()
the key used to look up the key/value pair.
{ "major": ["major-key1","major-key2","major-key3"], "minor": ["minor-key1","minor-key2","minor-key3"] }
string-value as xs:string

Returns

xs:long
the version of the new value.

put#3

declare  %an:sequential function nosql:put($db as xs:anyURI, $key as xs:string, $value as xs:string) as xs:long
Put a key/value pair, inserting or overwriting as appropriate.

Parameters

db as xs:anyURI
the KVStore reference
key as xs:string
the key used to look up the key/value pair.
value as xs:string
the value part of the key/value pair as string.

Returns

xs:long
the version of the new value.

remove#2

declare  %an:sequential function nosql:remove($db as xs:anyURI, $key as object()) as xs:boolean external
Removes the key/value pair associated with the key.

Parameters

db as xs:anyURI
the KVStore reference
key as object()
the key used to look up the key/value pair.

Returns

xs:boolean
true if the remove is successful, or false if no existing value is present.

Variables

$nosql:depth-CHILDREN_ONLY as xs:string
The CHILDREN_ONLY depth.
$nosql:depth-DESCENDANTS_ONLY as xs:string
The DESCENDANTS_ONLY depth.
$nosql:depth-PARENT_AND_CHILDREN as xs:string
The PARENT_AND_CHILDREN depth.
$nosql:depth-PARENT_AND_DESCENDANTS as xs:string
The PARENT_AND_DESCENDANTS depth.
$nosql:direction-REVERSE as xs:string
The REVERSE direction.
$nosql:direction-FORWARD as xs:string
The FORWARD direction.