From d041644482b597aefecde7e761e4012eefa7afbc Mon Sep 17 00:00:00 2001 From: Ronen Botzer Date: Thu, 3 Sep 2015 15:23:12 -0700 Subject: [PATCH] Documentation updated for getMany(); tests doc updated --- doc/aerospike_existsmany.md | 24 +-- doc/aerospike_getmany.md | 177 +++++++++++++++---- src/aerospike/tests/README.md | 65 ++++--- src/aerospike/tests/aerospike.local.skeleton | 15 ++ 4 files changed, 198 insertions(+), 83 deletions(-) create mode 100644 src/aerospike/tests/aerospike.local.skeleton diff --git a/doc/aerospike_existsmany.md b/doc/aerospike_existsmany.md index b65e4b6..88957fa 100644 --- a/doc/aerospike_existsmany.md +++ b/doc/aerospike_existsmany.md @@ -9,16 +9,17 @@ Aerospike::existsMany - check if a batch of records exist in the Aerospike datab public int Aerospike::existsMany ( array $keys, array &$metadata [, array $options ] ) ``` -**Aerospike::existsMany()** will check if a batch of records from a list of given *keys* -exists in the database. +**Aerospike::existsMany()** will check if a batch of records from a list of given +*keys* exists in the database, and returned an indexed array matching the order +of the *keys*. If the key exists its metadata will be returned in the *metadata* variable, -and non-existent records will return as NULL. +and non-existent records will have a NULL. ## Parameters **keys** an array of initialized keys, each an array with keys ['ns','set','key'] or ['ns','set','digest']. -**metadata** filled by an array of metadata. +**metadata** filled by an array of metadata arrays. **[options](aerospike.md)** including - **Aerospike::OPT_READ_TIMEOUT** @@ -59,22 +60,21 @@ We expect to see: ``` array(3) { - [1234]=> + [0]=> array(2) { ["generation"]=> - int(4) + int(6) ["ttl"]=> - int(1337) + int(4294967295) } - [12345]=> + [1]=> NULL - [1236]=> + [2]=> array(2) { ["generation"]=> - int(3) + int(6) ["ttl"]=> - int(505) + int(4294967295) } } ``` - diff --git a/doc/aerospike_getmany.md b/doc/aerospike_getmany.md index 16b7175..730311b 100644 --- a/doc/aerospike_getmany.md +++ b/doc/aerospike_getmany.md @@ -10,16 +10,16 @@ public int Aerospike::getMany ( array $keys, array &$records [, array $filter [, ``` **Aerospike::getMany()** will read a batch of *records* from a list of given *keys* -Each of the *records* is filled with an array of bins and values. -Non-existent bins will appear in the *record* with a NULL value. Non-existent -records will return as NULL. -The bins returned can be filtered by passing an array of the bins needed. +Each of the *records* is filled with an array of records. Each of those records +is an array with keys *key*, *meta*, *bins* (see: [get()](aerospike_get.md)). +Non-existent records will have NULL for their *meta* and *bins* fields. +The bins returned can be filtered by passing the array of needed bin names. ## Parameters **keys** an array of initialized keys, each an array with keys ['ns','set','key'] or ['ns','set','digest']. -**record** filled by an array of bins and values. +**records** filled by an array of [records](aerospike_get.md). **filter** an array of bin names @@ -64,25 +64,87 @@ We expect to see: ``` array(3) { - [1234]=> + [0]=> array(3) { - ["email"]=> - string(15) "hey@example.com" - ["name"]=> - string(9) "You There" - ["age"]=> - int(33) + ["key"]=> + array(4) { + ["ns"]=> + string(4) "test" + ["set"]=> + string(5) "users" + ["key"]=> + int(1234) + ["digest"]=> + string(20) "M?v2Kp??? + +?[??4?v + } + ["metadata"]=> + array(2) { + ["ttl"]=> + int(4294967295) + ["generation"]=> + int(1) + } + ["bins"]=> + array(3) { + ["email"]=> + string(15) "hey@example.com" + ["name"]=> + string(9) "You There" + ["age"]=> + int(33) + } } - [12345]=> - NULL - [1236]=> + [1]=> array(3) { - ["email"]=> - string(19) "thisguy@example.com" - ["name"]=> - string(8) "This Guy" - ["age"]=> - int(42) + ["key"]=> + array(4) { + ["ns"]=> + string(4) "test" + ["set"]=> + string(5) "users" + ["key"]=> + int(1235) + ["digest"]=> + string(20) "?C??[?vwS??ƨ?????" + } + ["metadata"]=> + NULL + ["bins"]=> + NULL + } + [2]=> + array(3) { + ["key"]=> + array(4) { + ["ns"]=> + string(4) "test" + ["set"]=> + string(5) "users" + ["key"]=> + int(1236) + ["digest"]=> + string(20) "'?9? + ?????? +? ?" + } + ["metadata"]=> + array(2) { + ["ttl"]=> + int(4294967295) + ["generation"]=> + int(1) + } + ["bins"]=> + array(3) { + ["email"]=> + string(19) "thisguy@example.com" + ["name"]=> + string(8) "This Guy" + ["age"]=> + int(42) + } } } ``` @@ -95,11 +157,11 @@ array(3) { // assuming this follows Example #1 // Getting a filtered record -$filter = array("email", "manager"); -unset($record); +$filter = array("email"); +$keys = array($key1, $key3); $status = $db->getMany($keys, $records, $filter); if ($status == Aerospike::OK) { - var_dump($record); + var_dump($records); } else { echo "[{$db->errorno()}] ".$db->error(); } @@ -110,23 +172,62 @@ if ($status == Aerospike::OK) { We expect to see: ``` -array(3) { - [1234]=> +array(2) { + [0]=> array(3) { - ["email"]=> - string(15) "hey@example.com" - ["manager"]=> - NULL + ["key"]=> + array(4) { + ["ns"]=> + string(4) "test" + ["set"]=> + string(5) "users" + ["key"]=> + int(1234) + ["digest"]=> + string(20) "M?v2Kp??? + +?[??4?v + } + ["metadata"]=> + array(2) { + ["ttl"]=> + int(4294967295) + ["generation"]=> + int(4) + } + ["bins"]=> + array(1) { + ["email"]=> + string(15) "hey@example.com" + } } - [12345]=> - NULL - [1236]=> + [1]=> array(3) { - ["email"]=> - string(19) "thisguy@example.com" - ["manager"]=> - string(8) "The Boss" + ["key"]=> + array(4) { + ["ns"]=> + string(4) "test" + ["set"]=> + string(5) "users" + ["key"]=> + int(1236) + ["digest"]=> + string(20) "'?9? + ?????? +? ?" + } + ["metadata"]=> + array(2) { + ["ttl"]=> + int(4294967295) + ["generation"]=> + int(4) + } + ["bins"]=> + array(1) { + ["email"]=> + string(19) "thisguy@example.com" + } } } ``` - diff --git a/src/aerospike/tests/README.md b/src/aerospike/tests/README.md index 807370d..3c9c969 100644 --- a/src/aerospike/tests/README.md +++ b/src/aerospike/tests/README.md @@ -1,57 +1,56 @@ # Aerospike PHP Client PHPT Tests -## Source Code - -PHPT scripts are grouped by functionality inside `src/aerospike/tests/`. -Each *.inc* file contains the methods used by individual *.phpt* within -the respective `src/aerospike/tests/phpt/*/` subdirectory. - -For example, the Put test cases are described by the list of -`src/aerospike/tests/phpt/Put/*.phpt` files, which make use of methods from `src/aerospike/tests/Put.inc`. - -## Expected Values -The structure of PHPT tests is explained at the [PHP QA site](http://qa.php.net/write-test.php#writing-phpt). - -The expected value for a test is the name of one of the Aerospike class -constants, such as **OK** or **ERR_RECORD_NOT_FOUND** as listed in -`src/aerospike/tests/astestframework/astest-phpt-loader.inc`. - ## Build Instructions -Follow the build and installation steps described in this repository's main [README.md](../../../README.md) file. Please use a standard build (without the **-l** flag), as a debug build will cause the tests to fail. +Follow the build and installation steps described in this repository's main +[README.md](../../../README.md) file. Please use a standard build +(without the **-l** flag), as a debug build will cause the tests to fail. ## Configuration: -Edit the file `src/aerospike/tests/aerospike.inc` with the IP address and port configuration of your Aerospike database server(s) before running the phpt -scripts. +Use the config file skeleton to create a local configuration file for the tests, +and configure the correct IP address and port for your server. -## Running Tests: +``` +cd src/aerospike/ +cp tests/aerospike.local.skeleton tests/aerospike.local.inc +# edit tests/aerospike.local.inc +``` -Change directory to `src/aerospike/` and run: +## Running Tests: - $ make test TESTS=tests/phpt +``` +make test TESTS=tests/phpt +``` To run only the phpt test cases for Put: - $ make test TESTS=tests/phpt/Put +``` +make test TESTS=tests/phpt/Put +``` ## Cleanup To clean up artifacts created by the tests you can run: - $ test-cleanup +``` +./srcipts/test-cleanup.sh +``` -##Secondary Index Dependency - -For the following testcases of aggregate to pass you need to first create Secondary Index. +## Source Code - $ tests/phpt/Aggregate/TestAggregatePositiveEmptyAggregationResult.phpt +PHPT scripts are grouped by functionality inside `src/aerospike/tests/`. +Each *.inc* file contains the methods used by individual *.phpt* within +the respective `src/aerospike/tests/phpt/*/` subdirectory. -You can create secondary index using aql tool. -The steps are, +For example, the Put test cases are described by the list of +`src/aerospike/tests/phpt/Put/*.phpt` files, which make use of methods from `src/aerospike/tests/Put.inc`. - $ CREATE INDEX ix2 ON user_profile.west (location) string +## Expected Values +The structure of PHPT tests is explained at the +[PHP QA site](http://qa.php.net/write-test.php#writing-phpt). -Above aql script creates a string index 'ix2' on the namespace called -'user_profile', set-name 'west', bin-name 'location'. +The expected value for a test is the name of one of the +[Aerospike class](../../../doc/aerospike.md) constants, such as **OK** +or **ERR_RECORD_NOT_FOUND**. diff --git a/src/aerospike/tests/aerospike.local.skeleton b/src/aerospike/tests/aerospike.local.skeleton new file mode 100644 index 0000000..70d3b1c --- /dev/null +++ b/src/aerospike/tests/aerospike.local.skeleton @@ -0,0 +1,15 @@ +