aerospike
Advanced tools
Comparing version 1.0.29 to 1.0.30
@@ -40,2 +40,5 @@ # Policies | ||
global default timeout value | ||
- `commitLevel` - Commit Level of the operation. Specifies whether to be commited | ||
only in Master replica copy or all the replica copies. | ||
For values, see [Commit Level Policy Values](policies.md#commitLevel). | ||
@@ -92,12 +95,21 @@ <!-- | ||
- `key` – Specifies the behavior for the key. | ||
- `key` – Specifies the behavior for the key. | ||
For values, see [Key Policy Values](policies.md#key). | ||
- `gen` – Specifies the behavior for the generation value. | ||
For values, see [Generation Policy Values](policies.md#gen). | ||
- `retry` – Specifies the behavior for failed operations. | ||
For values, see [Retry Policy Values](policies.md#retry). | ||
- `timeout` – Maximum time in milliseconds to wait for the operation to | ||
complete. If 0 (zero), then the value will default to | ||
global default timeout value | ||
- `gen` – Specifies the behavior for the generation value. | ||
For values, see [Generation Policy Values](policies.md#gen). | ||
- `retry` – Specifies the behavior for failed operations. | ||
For values, see [Retry Policy Values](policies.md#retry). | ||
- `timeout` – Maximum time in milliseconds to wait for the operation to | ||
complete. If 0 (zero), then the value will default to | ||
global default timeout value | ||
- `commitLevel` - Commit Level of the operation. Specifies whether to be commited | ||
only in Master replica copy or all the replica copies. | ||
For values, see [Commit Level Policy Values](policies.md#commitLevel). | ||
- `replica` - Specifies which partition replica to read from. | ||
For values, see [Replica Policy](policies.md#replica). | ||
- `consistencyLevel` - Specifies the number of replicas to be consulted in a read operation | ||
to provide the desired consistency guarantee. | ||
For values, see [Consistency Level Policy Values](policies.md#consistencyLevel). | ||
<!-- | ||
@@ -116,7 +128,12 @@ ################################################################################ | ||
- `key` – Specifies the behavior for the key. | ||
For values, see [Key Policy Values](policies.md#key). | ||
- `timeout` – Integer datatype. Maximum time in milliseconds to wait for | ||
the operation to complete. If 0 (zero), then the value | ||
will default to global default timeout value. | ||
- `key` – Specifies the behavior for the key. | ||
For values, see [Key Policy Values](policies.md#key). | ||
- `timeout` – Integer datatype. Maximum time in milliseconds to wait for | ||
the operation to complete. If 0 (zero), then the value | ||
will default to global default timeout value. | ||
- `replica` - Specifies which partition replica to read from. | ||
For values, see [Replica Policy](policies.md#replica). | ||
- `consistencyLevel` - Specifies the number of replicas to be consulted in a read operation | ||
to provide the desired consistency guarantee. | ||
For values, see [Consistency Level Policy Values](policies.md#consistencyLevel). | ||
@@ -144,2 +161,5 @@ | ||
For values, see [Retry Policy Values](policies.md#retry). | ||
- `commitLevel` - Commit Level of the operation. Specifies whether to be commited | ||
only in Master replica copy or all the replica copies. | ||
For values, see [Commit Level Policy Values](policies.md#commitLevel). | ||
@@ -170,2 +190,5 @@ <!-- | ||
global default values. | ||
- `commitLevel` - Commit Level of the operation. Specifies whether to be commited | ||
only in Master replica copy or all the replica copies. | ||
For values, see [Commit Level Policy Values](policies.md#commitLevel). | ||
@@ -302,1 +325,76 @@ | ||
``` | ||
<!-- | ||
################################################################################ | ||
replica | ||
################################################################################ | ||
--> | ||
<a name="replica"></a> | ||
### Replica Policy Values | ||
#### MASTER | ||
Read only from Master Replica node. | ||
```js | ||
aerospike.policy.replica.MASTER | ||
``` | ||
#### ANY | ||
Read from an unspecified Replica node. | ||
```js | ||
aerospike.policy.replica.ANY | ||
``` | ||
<!-- | ||
################################################################################ | ||
consistencyLevel | ||
################################################################################ | ||
--> | ||
<a name="consistencyLevel"></a> | ||
### ConsistencyLevel Policy Values | ||
#### ONE | ||
Involve a single replica in the operation. | ||
```js | ||
aerospike.policy.consistencyLevel.ONE | ||
``` | ||
#### ALL | ||
Involve all replicas in the operation. | ||
```js | ||
aerospike.policy.consistencyLevel.ALL | ||
``` | ||
<!-- | ||
################################################################################ | ||
commitLevel | ||
################################################################################ | ||
--> | ||
<a name="commitLevel"></a> | ||
### CommitLevel Policy Values | ||
#### ALL | ||
Return succcess only after successfully committing all replicas | ||
```js | ||
aerospike.policy.commitLevel.ALL | ||
``` | ||
#### MASTER | ||
Return succcess after successfully committing the master replica | ||
```js | ||
aerospike.policy.commitLevel.MASTER | ||
``` | ||
@@ -90,5 +90,11 @@ # Query Class | ||
var dataCallback = function(record) { //do something} | ||
var errorCallback = function(error) { //do something} | ||
var endCallback = function() { //do something} | ||
var dataCallback = function(record) { | ||
// process the scanned record | ||
} | ||
var errorCallback = function(error) { | ||
// process the error | ||
} | ||
var endCallback = function() { | ||
//process the end of query results. | ||
} | ||
var stream = query.execute(); // returns a stream object. | ||
@@ -109,2 +115,5 @@ stream.on('data', dataCallback); | ||
Query Aggregation executes a Map-Reduce job on all the records returned by a given query. | ||
The Map-Reduce job is in written in LUA using UDF. The UDF used by the aggregation | ||
job must be registered prior to using the given UDF in aggregation. | ||
To do an aggregation on data by a query, the `Query` object has to be instantiated. | ||
@@ -127,5 +136,11 @@ Query on execution returns a stream object, which emits 'data', 'error' and 'end' events. | ||
var dataCallback = function(result) { //do something} | ||
var errorCallback = function(error) { //do something} | ||
var endCallback = function() { //do something} | ||
var dataCallback = function(result) { | ||
//process the result of aggregation | ||
} | ||
var errorCallback = function(error) { | ||
//process the error | ||
} | ||
var endCallback = function() { | ||
//process the end of aggregation | ||
} | ||
var stream = query.execute(); // returns a stream object. | ||
@@ -143,3 +158,3 @@ stream.on('data', dataCallback); | ||
<a name="ScanForeground"></a> | ||
###scanForeground | ||
###ScanForeground | ||
@@ -157,7 +172,13 @@ To do full scan of Aerospike database which returns all the records, the `Query` object has to be instantiated. | ||
var statement = { nobins: false, concurrent: true, select: ['a', 'b']} | ||
var query = client.query(ns, set, statement); // returns a query object. | ||
var query = client.query(ns, set ); // returns a query object. | ||
var dataCallback = function(record) { //do something} | ||
var errorCallback = function(error) { //do something} | ||
var endCallback = function() { //do something} | ||
var dataCallback = function(record) { | ||
//process the record | ||
} | ||
var errorCallback = function(error) { | ||
//do something | ||
} | ||
var endCallback = function() { | ||
//process the end of scan | ||
} | ||
var stream = query.execute(); // returns a stream object. | ||
@@ -171,2 +192,45 @@ stream.on('data', dataCallback); | ||
################################################################################ | ||
ScanAggregate() | ||
################################################################################ | ||
--> | ||
<a name="ScanAggregate"></a> | ||
###ScanAggregate | ||
Scan Aggregation executes a Map-Reduce job on all the records in the Aerospike database. | ||
The Map-Reduce job is in written in LUA using UDF. The UDF used by the aggregation | ||
job must be registered prior to using the given UDF in aggregation. | ||
To do an aggregation on data , the `Query` object has to be instantiated. | ||
Query on execution returns a stream object, which emits 'data', 'error' and 'end' events. | ||
'data' event is emitted for every result returned by scan aggregation. | ||
'errror' is emitted in an event of error. | ||
'end' marks the end of resultset returned by scan aggregation. | ||
NOTE: Query aggregation without any filter becomes scan aggregation. | ||
```js | ||
var statement = { | ||
aggregationUDF: {module: 'agg_module', funcname: 'agg_func'} | ||
} | ||
var query = client.query(ns, set ); // returns a query object. | ||
var dataCallback = function(result) { | ||
//process the result of aggregation | ||
} | ||
var errorCallback = function(error) { | ||
//process the error | ||
} | ||
var endCallback = function() { | ||
//process the end of aggregation | ||
} | ||
var stream = query.execute(); // returns a stream object. | ||
stream.on('data', dataCallback); | ||
stream.on('error', errorCallback); | ||
stream.on('end', endCallback); | ||
``` | ||
<!-- | ||
################################################################################ | ||
ScanBackground() | ||
@@ -179,5 +243,7 @@ ################################################################################ | ||
To do full scan of Aerospike database and apply an UDF through a background job, | ||
the `Query` object has to be instantiated and background scan does not return any data. | ||
To do full scan of Aerospike database and apply an UDF on each record in Aerospike database | ||
through a background job,the `Query` object has to be instantiated. The background scan | ||
does not return any data. | ||
Query on execution returns a stream object, which emits 'error' and 'end' events. | ||
The UDF used by scan background job must already be registered in the system. | ||
'errror' is emitted in an event of error. | ||
@@ -192,3 +258,2 @@ 'end' signifies that a scan background job has been fired successfully.. | ||
var statement = { concurrent: true, | ||
select: ['a', 'b'], | ||
UDF: {module:'scanUdf', funcname: 'scanFunc'} | ||
@@ -198,4 +263,8 @@ } | ||
var errorCallback = function(error) { //do something} | ||
var endCallback = function() { //do something} | ||
var errorCallback = function(error) { | ||
//process the error | ||
} | ||
var endCallback = function() { | ||
//signals that the scan background job has been successfully fired. | ||
} | ||
var stream = query.execute(); // returns a stream object. | ||
@@ -202,0 +271,0 @@ stream.on('error', errorCallback); |
@@ -162,6 +162,2 @@ /******************************************************************************* | ||
}); | ||
/******************************************************************************* | ||
* | ||
* Perform the operation | ||
* | ||
******************************************************************************/ | ||
@@ -141,3 +141,3 @@ /******************************************************************************* | ||
var options = { select: ['i', 's'], | ||
var options = { | ||
UDF : {module: 'scan', funcname: 'updateRecord'} | ||
@@ -144,0 +144,0 @@ } |
@@ -21,2 +21,8 @@ var as = require('../build/Release/aerospike.node') | ||
// wrapper function around query_foreach function. | ||
// This wrapper receives results from V8 layer and emits 'data' event | ||
// to node.js layer. | ||
// On error, emits 'error' event. | ||
// When all the results are consumed it emits 'end' event. | ||
execute = function() { | ||
@@ -28,5 +34,2 @@ | ||
var onRecord = function(record, meta, key) { | ||
rs.emit('data', {'bins': record, 'meta': meta, 'key': key}); | ||
}; | ||
@@ -52,19 +55,29 @@ var onResult = function( res, key) { | ||
if(self.isQuery && !self.hasUDF) // query | ||
if(self.isQuery) // it is a query request. | ||
{ | ||
self.foreach(onRecord, onError, onEnd); | ||
if(self.hasUDF) | ||
{ | ||
// query UDF is not supported currently. | ||
return null; | ||
} | ||
else | ||
{ | ||
// normal query and query aggregation is invoked here. | ||
self.foreach(onResult, onError, onEnd); | ||
} | ||
} | ||
else if( self.isQuery && self.hasUDF) // query aggregation | ||
else // it is a scan request | ||
{ | ||
self.foreach(onResult, onError, onEnd); | ||
if(self.hasUDF) // scan with a UDF - so background scan. | ||
{ | ||
// background scan does not return records. So callback for record is NULL. | ||
self.foreach(null, onError, onEnd); | ||
} | ||
else // it is a foreground scan or scan aggregation. | ||
{ | ||
self.foreach(onResult, onError, onEnd); | ||
} | ||
} | ||
else if( !self.isQuery && self.hasUDF) // scan background | ||
{ | ||
self.foreach(null, onError, onEnd); | ||
} | ||
else //scan foreground | ||
{ | ||
self.foreach(onRecord, onError, onEnd); | ||
} | ||
return rs; | ||
@@ -89,4 +102,6 @@ | ||
queryObj.isQuery = false; | ||
queryObj.isQuery = false; // true implies it is query instance. | ||
// false implies it is an instance of scan. | ||
queryObj.hasUDF = false; | ||
queryObj.hasAggregation = false; | ||
@@ -108,3 +123,3 @@ if( options && options.select) { | ||
queryObj.apply(options.aggregationUDF); | ||
queryObj.hasUDF = true; | ||
queryObj.hasAggregation = true; | ||
} | ||
@@ -133,3 +148,38 @@ | ||
if(queryObj.isQuery) | ||
{ // it is a query instance. | ||
if(queryObj.hasUDF) | ||
{ | ||
// query and has a UDF, implies query UDF - this is currently not supported. | ||
queryObj.setQueryType(as.queryType.QUERYUDF); | ||
return null; | ||
} | ||
else if(queryObj.hasAggregation) | ||
{ | ||
// query and has aggregationUDF, this is query Aggregation | ||
queryObj.setQueryType(as.queryType.QUERYAGGREGATION); | ||
} | ||
else | ||
{ | ||
// query and does not have UDF or aggregationUDF. | ||
// It is a normal query. | ||
queryObj.setQueryType(as.queryType.QUERY); | ||
} | ||
} | ||
else | ||
{ | ||
if(queryObj.hasUDF) | ||
{ | ||
query.setQueryType(as.queryType.SCANUDF); | ||
} | ||
else if(queryObj.hasAggregation) | ||
{ | ||
queryObj.setQueryType(as.queryType.SCANAGGREGATION); | ||
} | ||
else | ||
{ | ||
queryObj.setQueryType(as.queryType.SCAN); | ||
} | ||
} | ||
var queryProto = Object.getPrototypeOf(queryObj); | ||
@@ -136,0 +186,0 @@ |
{ | ||
"name" : "aerospike", | ||
"version" : "1.0.29", | ||
"version" : "1.0.30", | ||
"description" : "Aerospike Client Library", | ||
@@ -5,0 +5,0 @@ "tags" : [ "aerospike", "database", "nosql" ], |
@@ -212,3 +212,2 @@ /******************************************************************************* | ||
var args = { filters: [filter.equal('queryBinString', 'querystringvalue')], | ||
select: ['queryBinString', 'queryBinInt'], | ||
aggregationUDF: {module:'aggregate', funcname:'sum_test_bin'}} | ||
@@ -233,2 +232,29 @@ var query = client.query(options.namespace, options.set, args); | ||
}); | ||
it.skip('should scan aerospike database and apply aggregation user defined function', function(done) { | ||
// counters | ||
var total = 100; | ||
var count = 0; | ||
var err = 0; | ||
var args = { aggregationUDF: {module:'aggregate', funcname:'sum_test_bin'}} | ||
var query = client.query(options.namespace, options.set, args); | ||
var stream = query.execute(); | ||
stream.on('data', function(result){ | ||
expect(result).to.be.ok(); | ||
count++; | ||
}); | ||
stream.on('error', function(error){ | ||
expect(error).to.be.ok(); | ||
expect(error.code).to.equal(status.AEROSPIKE_OK); | ||
err++; | ||
}); | ||
stream.on('end', function(end){ | ||
expect(count).to.be.equal(1); | ||
expect(err).to.equal(0); | ||
done(); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
809846
129
8901
31