Socket
Socket
Sign inDemoInstall

aerospike

Package Overview
Dependencies
Maintainers
3
Versions
135
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aerospike - npm Package Compare versions

Comparing version 2.1.1 to 2.2.0

src/main/client/query_foreach.cc

9

History.md

@@ -0,1 +1,8 @@

v2.2.0 / 2016-07-13
===================
* **Improvements**
* Added back support for applying stream UDF to query results w/o aggregation.
* Added `maxConnsPerNode` config setting to address [#130](https://github.com/aerospike/aerospike-client-nodejs/issues/130).
v2.1.1 / 2016-06-29

@@ -6,3 +13,3 @@ ===================

* Prevent segfault processing query/scan record stream if client object goes out of scope. [CLIENT-735]
* Update C client to v4.0.6 with fix to complete scan on empty sets. [#135](https://github.com/aerospike/aerospike-client-nodejs/issues/132)
* Update C client to v4.0.6 with fix to complete scan on empty sets. [#132](https://github.com/aerospike/aerospike-client-nodejs/issues/132)

@@ -9,0 +16,0 @@ v2.1.0 / 2016-06-03

@@ -196,2 +196,14 @@ // *****************************************************************************

/**
* @name Config#maxConnsPerNode
* @summary Maximum number of asynchronous connections allowed for each node.
* @description New transactions will be rejected with an
* <code>AEROSPIKE_ERR_NO_MORE_CONNECTIONS</code> error if the limit would be
* exceeded. Default is 300.
* @type {number}
*/
if (Number.isInteger(config.maxConnsPerNode)) {
this.maxConnsPerNode = config.maxConnsPerNode
}
/**

@@ -198,0 +210,0 @@ * @name Config#modlua

7

lib/maps.js

@@ -20,4 +20,7 @@ // *****************************************************************************

*
* @description This module defines operations on the Map data type. Create map
* operations used by the {@link Client#operate} command.
* @description This module defines operations on the Sorted Map data type that
* can be used with the {@link Client#operate} command. Operations on Sorted
* Maps require Aerospike Server
* <a href="http://www.aerospike.com/download/server/notes.html#3.8.4">&uArr;version 3.8.4</a>
* or later.
*

@@ -24,0 +27,0 @@ * For more information, please refer to the

@@ -73,2 +73,16 @@ // *****************************************************************************

*
* #### Applying User-Defined Functions
*
* User-defined functions (UDFs) can be used to filter, transform, and
* aggregate query results. Stream UDFs can process a stream of data by
* defining a sequence of operations to perform. Stream UDFs perform read-only
* operations on a collection of records. Use {@link Query#setUdf} to set the
* UDF parameters (module name, function name and optional list of arguments)
* before executing the query using {@link Query#foreach}.
*
* The feature guides on
* <a href="http://www.aerospike.com/docs/guide/udf.html">&uArr;User-Defined Functions</a> and
* <a href="http://www.aerospike.com/docs/guide/stream_udf.html">&uArr;Stream UDFs</a>
* contain more detailed information and examples.
*
* #### Query Aggregation using Stream UDFs

@@ -82,6 +96,5 @@ *

*
* Please refer to the feature guides on
* <a href="http://www.aerospike.com/docs/guide/aggregation.html">&uArr;Aggregation</a> and
* <a href="http://www.aerospike.com/docs/guide/stream_udf.html">&uArr;Stream UDFs</a>
* in the Aerospike technical documentation for more information.
* Please refer to the technical documentation on
* <a href="http://www.aerospike.com/docs/guide/aggregation.html">&uArr;Aggregation</a>
* for more information.
*

@@ -194,2 +207,10 @@ * #### Executing Record UDFs using Background Queries

this.selected = options.select
/**
* User-defined function parameters to be applied to the query executed using
* {@link Query#foreach}.
*
* @member {Object} Query#udf
*/
this.udf = options.udf
}

@@ -202,4 +223,4 @@

*
* If a query specifies bins to be selected, then only those bins will be
* returned. If no bins are selected, then all bins will be returned.
* @description If a query specifies bins to be selected, then only those bins
* will be returned. If no bins are selected, then all bins will be returned.
*

@@ -221,5 +242,6 @@ * @param {...string} bins - List of bin names to return.

*
* *Note:* Currently, a single filter predicate is supported. To do more
* advanced filtering, you need to use a user-defined function (UDF) to
* process the result set on the server.
* @description *Note:* Currently, a single filter predicate is supported. To
* do more advanced filtering, you can apply a User-Defined Function (UDF) to
* filter, transform and aggregate the query results. See {@link Query#foreach}
* for further information.
*

@@ -248,2 +270,19 @@ * @param {FilterPredicate} predicate - The filter predicate to apply to the function.

/**
* @function Query#setUdf
*
* @summary Set user-defined function parameters to be applied to the query.
*
* @param {string} udfModule - UDF module name.
* @param {string} udfFunction - UDF function name.
* @param {Array<*>} [udfArgs] - Arguments for the function.
*/
Query.prototype.setUdf = function (udfModule, udfFunction, udfArgs) {
this.udf = {
module: udfModule,
funcname: udfFunction,
args: udfArgs
}
}
/**
* @function Query#foreach

@@ -254,5 +293,17 @@ *

*
* Standard secondary index queries are supported. For aggregation queries you
* need to use the {@link Query#apply} method.
* @description
*
* *Applying a Stream UDF to the query results*
*
* A stream UDF can be applied to the query to filter, transform and aggregate
* the query results. The UDF parameters need to be set on the query object
* using {@link Query#setUdf} before the query is executed.
*
* If a UDF is applied to the query, the resulting stream will return
* the results of the UDF stream function. Record meta data and the record keys
* will not be returned.
*
* For aggregation queries that return a single result value instead of a
* stream of values, you should use the {@link Query#apply} method instead.
*
* @param {Client~QueryPolicy} [policy] - The Query Policy to use for this operation.

@@ -263,3 +314,2 @@ *

Query.prototype.foreach = function (policy, dataCb, errorCb, endCb) {
if (this.udf) throw new Error('UDF not supported by foreach() - use apply() for Stream UDF or background() for Record UDF.')
var stream = new RecordStream(this.client)

@@ -269,3 +319,5 @@ if (dataCb) stream.on('data', dataCb)

if (endCb) stream.on('end', endCb)
this.client.as_client.queryAsync(this.ns, this.set, this, policy, function (error, record, meta, key) {
var asClient = this.client.as_client
var queryFn = this.udf ? asClient.queryForeach : asClient.queryAsync
queryFn.call(asClient, this.ns, this.set, this, policy, function (error, record, meta, key) {
if (error && error.code !== as.status.AEROSPIKE_OK) {

@@ -276,3 +328,5 @@ stream.emit('error', error)

} else {
key = new Key(key.ns, key.set, key.key, key.digest)
if (key) {
key = new Key(key.ns, key.set, key.key, key.digest)
}
stream.emit('data', record, meta, key)

@@ -290,4 +344,6 @@ }

*
* @summary Applies a user defined function (UDF) to aggregate the query results.
* @summary Applies a user-defined function (UDF) to aggregate the query results.
*
* @description The aggregation function is called on both server and client (final reduce). Therefore, the Lua script files must also reside on both server and client.
*
* @param {string} udfModule - UDF module name.

@@ -323,3 +379,3 @@ * @param {string} udfFunction - UDF function name.

*
* @summary Apply user defined function on records that match the query filter.
* @summary Applies a user-defined function (UDF) on records that match the query filter.
* Records are not returned to the client.

@@ -326,0 +382,0 @@ *

{
"name": "aerospike",
"version": "2.1.1",
"version": "2.2.0",
"description": "Aerospike Client Library",

@@ -27,2 +27,5 @@ "tags": [

},
"bugs": {
"url": "https://github.com/aerospike/aerospike-client-nodejs/issues"
},
"scripts": {

@@ -29,0 +32,0 @@ "test": "standard && ./scripts/shuffle_tests",

@@ -652,3 +652,2 @@ // *****************************************************************************

it('returns reverse index', function (done) {
this.skip('reverse index results broken in AS 3.8.4 - re-enable spec once fix is released')
helper.cluster.supports_feature('cdt-map') || this.skip('cdt-maps feature not supported')

@@ -655,0 +654,0 @@ var record = { map: { a: 1, b: 2, c: 3 } }

@@ -72,3 +72,7 @@ // *****************************************************************************

{ name: 'aggregate', value: 20 },
{ name: 'aggregate', value: 30 }
{ name: 'aggregate', value: 30 },
{ name: 'filter', value: 1 },
{ name: 'filter', value: 2 },
{ name: 'filter', value: 3 },
{ name: 'filter', value: 4 }
]

@@ -181,2 +185,22 @@ const numberOfSamples = samples.length

describe('query.foreach()', function () {
it('should apply a stream UDF to filter the results', function (done) {
var args = {
filters: [filter.equal('name', 'filter')]
}
var query = client.query(helper.namespace, testSet, args)
query.setUdf('udf', 'even')
var stream = query.foreach()
var results = []
stream.on('error', function (error) {
throw error
})
stream.on('data', function (data) {
results.push(data)
})
stream.on('end', function () {
expect(results.sort()).to.eql([2, 4])
done()
})
})
it('returns the key if it was stored on the server', function (done) {

@@ -183,0 +207,0 @@ var uniqueKey = 'test/query/record_with_stored_key'

@@ -83,3 +83,3 @@ // *****************************************************************************

var job = this.createIndex(index)
deasync(job.waitUntilDone).bind(job)(10)
deasync(job.waitUntilDone).bind(job)(100)
}

@@ -86,0 +86,0 @@

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc