Skip to content

Commit

Permalink
Documentation updated for getMany(); tests doc updated
Browse files Browse the repository at this point in the history
  • Loading branch information
rbotzer committed Sep 3, 2015
1 parent c255a55 commit d041644
Show file tree
Hide file tree
Showing 4 changed files with 198 additions and 83 deletions.
24 changes: 12 additions & 12 deletions doc/aerospike_existsmany.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down Expand Up @@ -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)
}
}
```

177 changes: 139 additions & 38 deletions doc/aerospike_getmany.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
}
}
}
```
Expand All @@ -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();
}
Expand All @@ -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"
}
}
}
```

65 changes: 32 additions & 33 deletions src/aerospike/tests/README.md
Original file line number Diff line number Diff line change
@@ -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**.
15 changes: 15 additions & 0 deletions src/aerospike/tests/aerospike.local.skeleton
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

// modify the address and port information according to your config
define("AEROSPIKE_CONFIG_NAME", "127.0.0.1");
define("AEROSPIKE_CONFIG_PORT", 3000);


// if you have more than one node in the cluster, uncomment the following
// and provide connection information for a second node in the cluster
//define("AEROSPIKE_CONFIG_NAME2", "127.0.0.1");
//define("AEROSPIKE_CONFIG_PORT2", 3010);

// if the database is Enterprise Edition, run security tests
define("AEROSPIKE_ENTERPRISE_EDITION", false);
?>

0 comments on commit d041644

Please sign in to comment.