aerospike 4.0.2 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/binding.gyp +7 -4
  2. package/examples/batch.js +1 -1
  3. package/examples/put_test.js +72 -0
  4. package/lib/aerospike.js +11 -16
  5. package/lib/binding/node-v102-darwin-x64/aerospike.node +0 -0
  6. package/lib/binding/node-v102-linux-x64/aerospike.node +0 -0
  7. package/lib/binding/node-v102-win32-x64/aerospike.node +0 -0
  8. package/lib/binding/node-v108-darwin-x64/aerospike.node +0 -0
  9. package/lib/binding/node-v108-linux-x64/aerospike.node +0 -0
  10. package/lib/binding/node-v108-win32-x64/aerospike.node +0 -0
  11. package/lib/binding/node-v64-darwin-x64/aerospike.node +0 -0
  12. package/lib/binding/node-v64-linux-x64/aerospike.node +0 -0
  13. package/lib/binding/node-v64-win32-x64/aerospike.node +0 -0
  14. package/lib/binding/node-v72-darwin-x64/aerospike.node +0 -0
  15. package/lib/binding/node-v72-linux-x64/aerospike.node +0 -0
  16. package/lib/binding/node-v72-win32-x64/aerospike.node +0 -0
  17. package/lib/binding/node-v83-darwin-x64/aerospike.node +0 -0
  18. package/lib/binding/node-v83-linux-x64/aerospike.node +0 -0
  19. package/lib/binding/node-v83-win32-x64/aerospike.node +0 -0
  20. package/lib/binding/node-v93-darwin-x64/aerospike.node +0 -0
  21. package/lib/binding/node-v93-linux-x64/aerospike.node +0 -0
  22. package/lib/binding/node-v93-win32-x64/aerospike.node +0 -0
  23. package/lib/client.js +250 -6
  24. package/lib/commands/index.js +3 -0
  25. package/lib/commands/query_background_command.js +1 -1
  26. package/lib/exp.js +0 -1
  27. package/lib/exp_operations.js +1 -1
  28. package/lib/policies/base_policy.js +19 -44
  29. package/lib/policies/batch_apply_policy.js +75 -0
  30. package/lib/policies/batch_policy.js +75 -20
  31. package/lib/policies/batch_read_policy.js +58 -0
  32. package/lib/policies/batch_remove_policy.js +84 -0
  33. package/lib/policies/batch_write_policy.js +84 -0
  34. package/lib/policies/command_queue_policy.js +1 -1
  35. package/lib/policies/query_policy.js +0 -8
  36. package/lib/policies/scan_policy.js +0 -8
  37. package/lib/policy.js +112 -48
  38. package/lib/query.js +40 -65
  39. package/lib/record.js +45 -1
  40. package/lib/scan.js +32 -0
  41. package/lib/status.js +1 -1
  42. package/package.json +3 -2
  43. package/scripts/build-commands.sh +57 -35
  44. package/scripts/build-package.sh +1 -1
  45. package/scripts/build-package.sh-cclient-output.log +482 -462
  46. package/src/include/async.h +15 -11
  47. package/src/include/client.h +64 -58
  48. package/src/include/command.h +41 -32
  49. package/src/include/config.h +2 -1
  50. package/src/include/conversions.h +115 -52
  51. package/src/include/enums.h +4 -3
  52. package/src/include/events.h +3 -2
  53. package/src/include/expressions.h +2 -1
  54. package/src/include/log.h +27 -20
  55. package/src/include/operations.h +17 -8
  56. package/src/include/policy.h +35 -10
  57. package/src/include/query.h +4 -2
  58. package/src/include/scan.h +3 -1
  59. package/src/main/aerospike.cc +18 -13
  60. package/src/main/async.cc +51 -51
  61. package/src/main/bit_operations.cc +195 -145
  62. package/src/main/cdt_ctx.cc +55 -45
  63. package/src/main/client.cc +44 -27
  64. package/src/main/command.cc +27 -26
  65. package/src/main/commands/apply_async.cc +30 -18
  66. package/src/main/commands/batch_apply.cc +259 -0
  67. package/src/main/commands/batch_exists.cc +65 -53
  68. package/src/main/commands/batch_get.cc +66 -55
  69. package/src/main/commands/batch_read_async.cc +21 -14
  70. package/src/main/commands/batch_remove.cc +219 -0
  71. package/src/main/commands/batch_select.cc +76 -60
  72. package/src/main/commands/batch_write_async.cc +76 -0
  73. package/src/main/commands/exists_async.cc +19 -11
  74. package/src/main/commands/get_async.cc +18 -11
  75. package/src/main/commands/index_create.cc +63 -44
  76. package/src/main/commands/index_remove.cc +43 -32
  77. package/src/main/commands/info_any.cc +55 -42
  78. package/src/main/commands/info_foreach.cc +75 -60
  79. package/src/main/commands/info_host.cc +63 -47
  80. package/src/main/commands/info_node.cc +60 -46
  81. package/src/main/commands/job_info.cc +40 -34
  82. package/src/main/commands/operate_async.cc +20 -12
  83. package/src/main/commands/put_async.cc +26 -15
  84. package/src/main/commands/query_apply.cc +44 -38
  85. package/src/main/commands/query_async.cc +39 -14
  86. package/src/main/commands/query_background.cc +41 -30
  87. package/src/main/commands/query_foreach.cc +67 -62
  88. package/src/main/commands/remove_async.cc +19 -11
  89. package/src/main/commands/scan_async.cc +40 -15
  90. package/src/main/commands/scan_background.cc +41 -30
  91. package/src/main/commands/select_async.cc +23 -13
  92. package/src/main/commands/truncate.cc +44 -31
  93. package/src/main/commands/udf_register.cc +67 -46
  94. package/src/main/commands/udf_remove.cc +32 -25
  95. package/src/main/config.cc +227 -91
  96. package/src/{include/predexp.h → main/enums/batch_type.cc} +17 -7
  97. package/src/main/enums/bitwise_enum.cc +2 -1
  98. package/src/main/enums/config_enum.cc +4 -2
  99. package/src/main/enums/exp_enum.cc +4 -2
  100. package/src/main/enums/hll_enum.cc +2 -1
  101. package/src/main/enums/index.cc +2 -1
  102. package/src/main/enums/job_status.cc +2 -1
  103. package/src/main/enums/lists.cc +8 -4
  104. package/src/main/enums/maps.cc +35 -28
  105. package/src/main/enums/policy_enum.cc +20 -15
  106. package/src/main/enums/predicates.cc +2 -1
  107. package/src/main/enums/scanPriority.cc +2 -1
  108. package/src/main/enums/status.cc +36 -18
  109. package/src/main/enums/ttl.cc +2 -1
  110. package/src/main/enums/udf_languages.cc +6 -5
  111. package/src/main/events.cc +71 -70
  112. package/src/main/exp_operations.cc +22 -26
  113. package/src/main/expressions.cc +76 -42
  114. package/src/main/hll_operations.cc +108 -76
  115. package/src/main/list_operations.cc +354 -241
  116. package/src/main/map_operations.cc +352 -239
  117. package/src/main/operations.cc +17 -18
  118. package/src/main/policy.cc +479 -115
  119. package/src/main/query.cc +135 -95
  120. package/src/main/scalar_operations.cc +105 -79
  121. package/src/main/scan.cc +30 -18
  122. package/src/main/stats.cc +32 -23
  123. package/src/main/util/conversions.cc +1465 -1306
  124. package/src/main/util/conversions_batch.cc +463 -0
  125. package/src/main/util/log.cc +22 -27
  126. package/test/batch_apply.js +86 -0
  127. package/test/batch_read.js +8 -8
  128. package/test/batch_remove.js +76 -0
  129. package/test/batch_write.js +189 -0
  130. package/test/client.js +0 -17
  131. package/test/query.js +28 -0
  132. package/test/remove_bin.js +48 -0
  133. package/test/scan.js +14 -2
  134. package/typings/index.d.ts +1549 -0
  135. package/CHANGELOG.md +0 -717
  136. package/benchmarks/.npmignore +0 -1
  137. package/benchmarks/package-lock.json +0 -4554
  138. package/examples/.npmignore +0 -1
  139. package/examples/package-lock.json +0 -173
  140. package/lib/predexp.js +0 -1123
  141. package/scripts/build-c-client.sh-cclient-output.log +0 -485
  142. package/scripts/build-c-client.sh-libuv-output.log +0 -115
  143. package/scripts/build-package.sh-libuv-output.log +0 -118
  144. package/src/main/predexp.cc +0 -139
package/binding.gyp CHANGED
@@ -71,7 +71,6 @@
71
71
  'src/main/query.cc',
72
72
  'src/main/scan.cc',
73
73
  'src/main/expressions.cc',
74
- 'src/main/predexp.cc',
75
74
  'src/main/async.cc',
76
75
  'src/main/command.cc',
77
76
  'src/main/commands/apply_async.cc',
@@ -79,6 +78,9 @@
79
78
  'src/main/commands/batch_get.cc',
80
79
  'src/main/commands/batch_select.cc',
81
80
  'src/main/commands/batch_read_async.cc',
81
+ 'src/main/commands/batch_remove.cc',
82
+ 'src/main/commands/batch_apply.cc',
83
+ 'src/main/commands/batch_write_async.cc',
82
84
  'src/main/commands/exists_async.cc',
83
85
  'src/main/commands/get_async.cc',
84
86
  'src/main/commands/info_any.cc',
@@ -114,8 +116,10 @@
114
116
  'src/main/enums/ttl.cc',
115
117
  'src/main/enums/config_enum.cc',
116
118
  'src/main/enums/exp_enum.cc',
119
+ 'src/main/enums/batch_type.cc',
117
120
  'src/main/stats.cc',
118
121
  'src/main/util/conversions.cc',
122
+ 'src/main/util/conversions_batch.cc',
119
123
  'src/main/util/log.cc'
120
124
  ],
121
125
  'configurations': {
@@ -134,7 +138,6 @@
134
138
  'conditions': [
135
139
  ['OS=="linux"',{
136
140
  'libraries': [
137
- '../libuv-v1.8.0/.libs/libuv.a',
138
141
  '../aerospike-client-c/target/Linux-x86_64/lib/libaerospike.a',
139
142
  '-lz',
140
143
  '-lssl'
@@ -152,9 +155,9 @@
152
155
  }],
153
156
  ['OS=="mac"',{
154
157
  'libraries': [
155
- '../libuv-v1.8.0/.libs/libuv.a',
156
158
  '../aerospike-client-c/target/Darwin-x86_64/lib/libaerospike.a',
157
- '-lz'
159
+ '-lz',
160
+ '-lssl'
158
161
  ],
159
162
  'defines': [
160
163
  'AS_USE_LIBUV'
package/examples/batch.js CHANGED
@@ -28,7 +28,7 @@ async function batchRead (client, argv) {
28
28
  if (argv.bins) {
29
29
  request.bins = argv.bins
30
30
  } else {
31
- request.read_all_bins = true
31
+ request.readAllBins = true
32
32
  }
33
33
  return request
34
34
  })
@@ -0,0 +1,72 @@
1
+ const Aerospike = require('aerospike')
2
+
3
+ const config = {
4
+ hosts: '172.17.0.3:3000',
5
+ log: {
6
+ level: Aerospike.log.DEBUG,
7
+ file: process.stdout.fd
8
+ }
9
+ }
10
+ const key = new Aerospike.Key('test', 'demo', 'demo')
11
+
12
+ // process.on('uncaughtException', (err, origin) => {
13
+ // fs.writeSync(
14
+ // process.stderr.fd,
15
+ // `Caught exception: ${err}\n` +
16
+ // `Exception origin: ${origin}`
17
+ // );
18
+ // });
19
+
20
+ console.log('Connect')
21
+ Aerospike.connect(config)
22
+ .then(client => {
23
+ const bins = {
24
+ i: 123,
25
+ s: 'hello',
26
+ b: Buffer.from('world'),
27
+ d: new Aerospike.Double(3.1415),
28
+ g: new Aerospike.GeoJSON({ type: 'Point', coordinates: [103.913, 1.308] }),
29
+ l: [1, 'a', { x: 'y' }],
30
+ m: { foo: 4, bar: 7 }
31
+ }
32
+ const meta = { ttl: 0 }
33
+ const policy = new Aerospike.WritePolicy({
34
+ exists: Aerospike.policy.exists.CREATE_OR_REPLACE,
35
+ timeout: 20000
36
+ })
37
+
38
+ console.log('Put')
39
+ return client.put(key, bins, meta, policy)
40
+ .then(() => {
41
+ const ops = [
42
+ Aerospike.operations.incr('i', 1),
43
+ Aerospike.operations.read('i'),
44
+ Aerospike.lists.append('l', 'z'),
45
+ Aerospike.maps.removeByKey('m', 'bar')
46
+ ]
47
+
48
+ console.log('Operate')
49
+ return client.operate(key, ops)
50
+ })
51
+ .then(result => {
52
+ console.log(result.bins) // => { c: 4, i: 124, m: null }
53
+
54
+ return client.get(key)
55
+ })
56
+ .then(record => {
57
+ console.log(record.bins) // => { i: 124,
58
+ // s: 'hello',
59
+ // b: <Buffer 77 6f 72 6c 64>,
60
+ // d: 3.1415,
61
+ // g: '{"type":"Point","coordinates":[103.913,1.308]}',
62
+ // l: [ 1, 'a', { x: 'y' }, 'z' ],
63
+ // m: { foo: 4 } }
64
+ })
65
+ .then(() => client.close())
66
+ .catch(error => {
67
+ console.log('Error')
68
+ client.close()
69
+ return Promise.reject(error)
70
+ })
71
+ })
72
+ .catch(error => console.log(error))
package/lib/aerospike.js CHANGED
@@ -42,15 +42,6 @@ const utils = require('./utils')
42
42
  */
43
43
  exports.filter = require('./filter')
44
44
 
45
- /**
46
- * The {@link module:aerospike/predexp|predexp} module provides functions to
47
- * create predicate expressions for use in query operations via the {@link
48
- * Client#query} command.
49
- *
50
- * @summary {@link module:aerospike/predexp|aerospike/predexp} module
51
- */
52
- exports.predexp = require('./predexp')
53
-
54
45
  /**
55
46
  * The {@link module:aerospike/exp|exp} module provides functions to
56
47
  * create expressions for use in key operations via the {@link
@@ -66,7 +57,6 @@ exp.type = as.exp.type
66
57
  * @readonly
67
58
  * @enum {number}
68
59
  *
69
- * @see {@link module:aerospike/predexp.stringRegex} for usage.
70
60
  */
71
61
  exports.regex = {
72
62
  /** Use basic regular expression syntax. */
@@ -150,12 +140,12 @@ exports.bitwise = require('./bitwise')
150
140
  exports.operations = require('./operations')
151
141
 
152
142
  /**
153
- * The {@link module:aerospike/expoperations|ExpOperations} module provides functions
143
+ * The {@link module:aerospike/exp_operations|ExpOperation} module provides functions
154
144
  * to create operations using <a href="https://docs.aerospike.com/guide/expressions">&uArr;Aerospike Expressions</a>
155
145
  * for the {@link Client#operate} command.
156
146
  *
157
147
  *
158
- * @summary {@link module:aerospike/operations|aerospike/exp_operations} module
148
+ * @summary {@link module:aerospike/exp_operations|aerospike/exp_operations} module
159
149
  */
160
150
  exp.operations = require('./exp_operations')
161
151
 
@@ -169,18 +159,23 @@ exp.operations = require('./exp_operations')
169
159
  const policy = exports.policy = require('./policy')
170
160
 
171
161
  // short-cuts to the policy classes defined under the policy module
162
+ exports.BasePolicy = policy.BasePolicy
172
163
  exports.ApplyPolicy = policy.ApplyPolicy
173
164
  exports.BatchPolicy = policy.BatchPolicy
174
- exports.CommandQueuePolicy = policy.CommandQueuePolicy
175
- exports.InfoPolicy = policy.InfoPolicy
176
- exports.ListPolicy = policy.ListPolicy
177
- exports.MapPolicy = policy.MapPolicy
178
165
  exports.OperatePolicy = policy.OperatePolicy
179
166
  exports.QueryPolicy = policy.QueryPolicy
180
167
  exports.ReadPolicy = policy.ReadPolicy
181
168
  exports.RemovePolicy = policy.RemovePolicy
182
169
  exports.ScanPolicy = policy.ScanPolicy
183
170
  exports.WritePolicy = policy.WritePolicy
171
+ exports.BatchApplyPolicy = policy.BatchApplyPolicy
172
+ exports.BatchReadPolicy = policy.BatchReadPolicy
173
+ exports.BatchRemovePolicy = policy.BatchRemovePolicy
174
+ exports.BatchWritePolicy = policy.BatchWritePolicy
175
+ exports.CommandQueuePolicy = policy.CommandQueuePolicy
176
+ exports.InfoPolicy = policy.InfoPolicy
177
+ exports.ListPolicy = policy.ListPolicy
178
+ exports.MapPolicy = policy.MapPolicy
184
179
 
185
180
  /**
186
181
  * The {@link module:aerospike/status|status} module contains a list of the
package/lib/client.js CHANGED
@@ -346,10 +346,11 @@ Client.prototype.batchGet = function (keys, policy, callback) {
346
346
  * This method allows different namespaces/bins to be requested for each key in
347
347
  * the batch. This method requires server >= 3.6.0.
348
348
  *
349
- * @param {object[]} records - List of keys and bins to retrieve.
350
- * @param {Key} records[].key - Key to retrieve.
349
+ * @param {object[]} records - {@link Record} List of keys and bins to retrieve.
350
+ * @param {type} records[].type - {@link Record#type} Batch type.
351
+ * @param {Key} records[].key - Record Key.
351
352
  * @param {string[]} [records[].bins] - List of bins to retrieve.
352
- * @param {boolean} [records[].read_all_bins] - Whether to retrieve all bins or
353
+ * @param {boolean} [records[].readAllBins] - Whether to retrieve all bins or
353
354
  * just the meta data of the record. If true, ignore <code>bins</code> and read
354
355
  * all bins; if false and <code>bins</code> is specified, read specified bins;
355
356
  * if false and <code>bins</code> is not specified, read only record meta data
@@ -367,9 +368,12 @@ Client.prototype.batchGet = function (keys, policy, callback) {
367
368
  *
368
369
  * const Aerospike = require('aerospike')
369
370
  * var batchRecords = [
370
- * { key: new Aerospike.Key('test', 'demo', 'key1'), bins: ['i', 's'] },
371
- * { key: new Aerospike.Key('test', 'demo', 'key2'), read_all_bins: true },
372
- * { key: new Aerospike.Key('test', 'demo', 'key3') }
371
+ * { type: batchType.BATCH_READ,
372
+ * key: new Aerospike.Key('test', 'demo', 'key1'), bins: ['i', 's'] },
373
+ * { type: batchType.BATCH_READ,
374
+ * key: new Aerospike.Key('test', 'demo', 'key2'), readAllBins: true },
375
+ * { type: batchType.BATCH_READ,
376
+ * key: new Aerospike.Key('test', 'demo', 'key3') }
373
377
  * ]
374
378
  * Aerospike.connect(function (error, client) {
375
379
  * if (error) throw error
@@ -391,6 +395,246 @@ Client.prototype.batchRead = function (records, policy, callback) {
391
395
  return cmd.execute()
392
396
  }
393
397
 
398
+ /**
399
+ * @function Client#batchWrite
400
+ *
401
+ * @summary Read/Write multiple records for specified batch keys in one batch call.
402
+ *
403
+ * @description
404
+ *
405
+ * This method allows different sub-commands for each key in the batch.
406
+ * This method requires server >= 6.0.0.
407
+ *
408
+ * @param {object[]} records - {@link Record} List of batch sub-commands to perform.
409
+ * @param {type} records[].type - {@link Record#type} Batch type.
410
+ * @param {Key} records[].key - Record Key.
411
+ * @param {BatchPolicy} [policy] - The Batch Policy to use for this operation.
412
+ * @param {batchRecordsCallback} [callback] - The function to call when
413
+ * the operation completes, with the results of the batch operation.
414
+ *
415
+ * @returns {?Promise} - If no callback function is passed, the function
416
+ * returns a Promise that resolves to the results of the batch operation.
417
+ *
418
+ * @since v5.0.0
419
+ *
420
+ * @example
421
+ * const Aerospike = require('aerospike')
422
+ * const batchType = as.batchTypes
423
+ * var batchRecords = [
424
+ * { type: batchType.BATCH_READ,
425
+ * key: new Aerospike.Key('test', 'demo', 'key1'),
426
+ * bins: ['i', 's'] },
427
+ * { type: batchType.BATCH_READ,
428
+ * key: new Aerospike.Key('test', 'demo', 'key2'),
429
+ * readAllBins: true },
430
+ * { type: batchType.BATCH_WRITE,
431
+ * key: new Aerospike.Key('test', 'demo', 'key3'),
432
+ * ops:[
433
+ * op.write('geo', new GeoJSON({ type: 'Point', coordinates: [123.456, 1.308] })),
434
+ * op.write('blob', Buffer.from('bar'))
435
+ * ],
436
+ * policy: new Aerospike.BatchWritePolicy({
437
+ * filterExpression: exp.eq(exp.binInt('i'), exp.int(37)),
438
+ * key: Aerospike.policy.key.SEND,
439
+ * commitLevel: Aerospike.policy.commitLevel.ALL,
440
+ * gen: Aerospike.policy.gen.EQ,
441
+ * exists: Aerospike.policy.exists.CREATE,
442
+ * durableDelete: true
443
+ * })},
444
+ * { type: batchType.BATCH_REMOVE,
445
+ * key: new Aerospike.Key('test', 'demo', 'key5'),
446
+ * policy: new Aerospike.BatchRemovePolicy({
447
+ * filterExpression: exp.eq(exp.binInt('i'), exp.int(37)),
448
+ * key: Aerospike.policy.key.SEND,
449
+ * commitLevel: Aerospike.policy.commitLevel.ALL,
450
+ * gen: Aerospike.policy.gen.EQ,
451
+ * durableDelete: true
452
+ * })},
453
+ * }
454
+ * ]
455
+ * Aerospike.connect(function (error, client) {
456
+ * if (error) throw error
457
+ * client.batchWrite(batchRecords, function (error, results) {
458
+ * if (error) throw error
459
+ * results.forEach(function (result) {
460
+ * console.log(result)
461
+ * })
462
+ * })
463
+ * })
464
+ */
465
+ Client.prototype.batchWrite = function (records, policy, callback) {
466
+ if (typeof policy === 'function') {
467
+ callback = policy
468
+ policy = null
469
+ }
470
+
471
+ const cmd = new Commands.BatchWrite(this, [records, policy], callback)
472
+ return cmd.execute()
473
+ }
474
+
475
+ /**
476
+ * @function Client#batchApply
477
+ *
478
+ * @summary Apply UDF (user defined function) on multiple keys.
479
+ *
480
+ * @description
481
+ *
482
+ * This method allows multiple sub-commands for each key in the batch.
483
+ * This method requires server >= 6.0.0.
484
+ *
485
+ * @param {object[]} records - {@link Record} List of batch sub-commands to perform.
486
+ * @param {type} records[].type - {@link Record#type} Batch type.
487
+ * @param {Key} records[].key - Record Key.
488
+ * @param {object[]} udf - Server UDF module/function and argList to apply.
489
+ * @param {BatchPolicy} [batchPolicy] - The Batch Policy to use for this operation.
490
+ * @param {BatchApplyPolicy} [batchApplyPolicy] UDF policy configuration parameters.
491
+ * @param {batchRecordsCallback} [callback] - The function to call when
492
+ * the operation completes, with the results of the batch operation.
493
+ *
494
+ * @returns {?Promise} - If no callback function is passed, the function
495
+ * returns a Promise that resolves to the results of the batch operation.
496
+ *
497
+ * @since v5.0.0
498
+ *
499
+ * @example
500
+ * const Aerospike = require('aerospike')
501
+ * const batchType = as.batchTypes
502
+ * var batchRecords = [
503
+ * { type: batchType.BATCH_READ,
504
+ * key: new Aerospike.Key('test', 'demo', 'key1'),
505
+ * bins: ['i', 's'] },
506
+ * { type: batchType.BATCH_READ,
507
+ * key: new Aerospike.Key('test', 'demo', 'key2'),
508
+ * readAllBins: true },
509
+ * { type: batchType.BATCH_APPLY,
510
+ * key: new Aerospike.Key('test', 'demo', 'key4'),
511
+ * policy: new Aerospike.BatchApplyPolicy({
512
+ * filterExpression: exp.eq(exp.binInt('i'), exp.int(37)),
513
+ * key: Aerospike.policy.key.SEND,
514
+ * commitLevel: Aerospike.policy.commitLevel.ALL,
515
+ * durableDelete: true
516
+ * }),
517
+ * udf: {
518
+ * module: 'udf',
519
+ * funcname: 'function1',
520
+ * args: [[1, 2, 3]]
521
+ * }
522
+ * },
523
+ * { type: batchType.BATCH_APPLY,
524
+ * key: new Aerospike.Key('test', 'demo', 'key5'),
525
+ * policy: new Aerospike.BatchApplyPolicy({
526
+ * filterExpression: exp.eq(exp.binInt('i'), exp.int(37)),
527
+ * key: Aerospike.policy.key.SEND,
528
+ * commitLevel: Aerospike.policy.commitLevel.ALL,
529
+ * durableDelete: true
530
+ * }),
531
+ * udf: {
532
+ * module: 'udf',
533
+ * funcname: 'function2',
534
+ * args: [[1, 2, 3]]
535
+ * }
536
+ * }
537
+ * ]
538
+ * Aerospike.connect(function (error, client) {
539
+ * if (error) throw error
540
+ * client.batchApply(batchRecords, udf, function (error, results) {
541
+ * if (error) throw error
542
+ * results.forEach(function (result) {
543
+ * console.log(result)
544
+ * })
545
+ * })
546
+ * })
547
+ */
548
+ Client.prototype.batchApply = function (records, udf, batchPolicy, batchApplyPolicy, callback) {
549
+ if (typeof batchPolicy === 'function') {
550
+ callback = batchPolicy
551
+ batchPolicy = null
552
+ batchApplyPolicy = null
553
+ } else {
554
+ if (typeof batchApplyPolicy === 'function') {
555
+ callback = batchApplyPolicy
556
+ batchApplyPolicy = null
557
+ }
558
+ }
559
+
560
+ const cmd = new Commands.BatchApply(this, [records, udf, batchPolicy, batchApplyPolicy], callback)
561
+ return cmd.execute()
562
+ }
563
+
564
+ /**
565
+ * @function Client#batchRemove
566
+ *
567
+ * @summary Remove multiple records.
568
+ *
569
+ * @description
570
+ *
571
+ * This method allows multi sub-commands for each key in the batch.
572
+ * This method requires server >= 6.0.0.
573
+ *
574
+ * @param {object[]} records - {@link Record} List of batch sub-commands to perform.
575
+ * @param {type} records[].type - {@link Record#type} Batch type.
576
+ * @param {Key} records[].key - Record Key.
577
+ * @param {BatchPolicy} [batchPolicy] - The Batch Policy to use for this operation.
578
+ * @param {BatchRemovePolicy} [batchRemovePolicy] Remove policy configuration parameters.
579
+ * @param {batchRecordsCallback} [callback] - The function to call when
580
+ * the operation completes, with the results of the batch operation.
581
+ *
582
+ * @returns {?Promise} - If no callback function is passed, the function
583
+ * returns a Promise that resolves to the results of the batch operation.
584
+ *
585
+ * @since v5.0.0
586
+ *
587
+ * @example
588
+ * const Aerospike = require('aerospike')
589
+ * const batchType = as.batchTypes
590
+ * var batchRecords = [
591
+ * { type: batchType.BATCH_REMOVE,
592
+ * key: new Aerospike.Key('test', 'demo', 'key5'),
593
+ * policy: new Aerospike.BatchRemovePolicy({
594
+ * filterExpression: exp.eq(exp.binInt('i'), exp.int(37)),
595
+ * key: Aerospike.policy.key.SEND,
596
+ * commitLevel: Aerospike.policy.commitLevel.ALL,
597
+ * gen: Aerospike.policy.gen.EQ,
598
+ * durableDelete: true
599
+ * })},
600
+ * },
601
+ * { type: batchType.BATCH_REMOVE,
602
+ * key: new Aerospike.Key('test', 'demo', 'key6'),
603
+ * policy: new Aerospike.BatchRemovePolicy({
604
+ * filterExpression: exp.eq(exp.binInt('i'), exp.int(37)),
605
+ * key: Aerospike.policy.key.SEND,
606
+ * commitLevel: Aerospike.policy.commitLevel.ALL,
607
+ * gen: Aerospike.policy.gen.EQ,
608
+ * durableDelete: true
609
+ * })},
610
+ * }
611
+ * ]
612
+ * Aerospike.connect(function (error, client) {
613
+ * if (error) throw error
614
+ * client.batchRemove(batchRecords, function (error, results) {
615
+ * if (error) throw error
616
+ * results.forEach(function (result) {
617
+ * console.log(result)
618
+ * })
619
+ * })
620
+ * })
621
+ */
622
+ Client.prototype.batchRemove = function (records, batchPolicy, batchRemovePolicy, callback) {
623
+ if (typeof batchPolicy === 'function') {
624
+ callback = batchPolicy
625
+ batchPolicy = null
626
+ batchRemovePolicy = null
627
+ } else {
628
+ if (typeof batchRemovePolicy === 'function') {
629
+ callback = batchRemovePolicy
630
+ batchRemovePolicy = null
631
+ }
632
+ }
633
+
634
+ const cmd = new Commands.BatchRemove(this, [records, batchPolicy, batchRemovePolicy], callback)
635
+ return cmd.execute()
636
+ }
637
+
394
638
  /**
395
639
  * @function Client#batchSelect
396
640
  *
@@ -29,6 +29,9 @@ exports.Apply = class ApplyCommand extends Command('applyAsync') { }
29
29
  exports.BatchExists = class BatchExistsCommand extends BatchCommand('batchExists') { }
30
30
  exports.BatchGet = class BatchGetCommand extends BatchCommand('batchGet') { }
31
31
  exports.BatchRead = class BatchReadCommand extends BatchCommand('batchRead') { }
32
+ exports.BatchWrite = class BatchWriteCommand extends BatchCommand('batchWrite') { }
33
+ exports.BatchApply = class BatchApplyCommand extends BatchCommand('batchApply') { }
34
+ exports.BatchRemove = class BatchRemoveCommand extends BatchCommand('batchRemove') { }
32
35
  exports.BatchSelect = class BatchSelectCommand extends BatchCommand('batchSelect') { }
33
36
  exports.Connect = class ConnectCommand extends ConnectCommandBase('connect') { }
34
37
  exports.Exists = class ExistsCommand extends ExistsCommandBase('existsAsync') { }
@@ -24,7 +24,7 @@ function notEmpty (value) {
24
24
  }
25
25
 
26
26
  function hasFilter (queryOrScan) {
27
- return notEmpty(queryOrScan.filters) || notEmpty(queryOrScan.predexp)
27
+ return notEmpty(queryOrScan.filters)
28
28
  }
29
29
 
30
30
  function moduleName (queryOrScan) {
package/lib/exp.js CHANGED
@@ -99,7 +99,6 @@ const BIN_TYPE_UNDEF = 0
99
99
  * })
100
100
  * })
101
101
  * })
102
-
103
102
  */
104
103
 
105
104
  /*********************************************************************************
@@ -60,7 +60,7 @@ const as = require('bindings')('aerospike.node')
60
60
  const ops = as.expOperations
61
61
 
62
62
  /**
63
- * @class module:aerospike/expoperations~ExpOperation
63
+ * @class module:aerospike/exp_operations~ExpOperation
64
64
  *
65
65
  * @classdesc class for all expression operations executed with the {@link
66
66
  * Client#operate} command.
@@ -20,6 +20,8 @@
20
20
  * Base class for all client policies. The base policy defines general policy
21
21
  * values that are supported by all client policies, including timeout and
22
22
  * retry handling.
23
+ * Applies to {@link ApplyPolicy}, {@link BatchPolicy}, {@link OperatePolicy},
24
+ * {@link QueryPolicy}, {@link ReadPolicy}, {@link RemovePolicy}, {@link ScanPolicy} and {@link WritePolicy}.
23
25
  *
24
26
  * @since v3.0.0
25
27
  */
@@ -86,55 +88,11 @@ class BasePolicy {
86
88
  */
87
89
  this.maxRetries = props.maxRetries
88
90
 
89
- /**
90
- * Use zlib compression on write or batch read commands when the command
91
- * buffer size is greater than 128 bytes. In addition, tell the server to
92
- * compress it's response on read commands. The server response compression
93
- * threshold is also 128 bytes.
94
- *
95
- * This option will increase cpu and memory usage (for extra compressed
96
- * buffers), but decrease the size of data sent over the network.
97
- *
98
- * Requires Enterprise Server version >= 4.8.
99
- *
100
- * @type boolean
101
- * @default: false
102
- * @since v3.14.0
103
- */
104
- this.compress = props.compress
105
-
106
- /**
107
- * Optional predicate expression filter list in postfix notation. If the
108
- * predicate expression exists and evaluates to false on the server, the
109
- * transaction is ignored. This can be used to eliminate a client/server
110
- * roundtrip in some cases.
111
- *
112
- * Predicate expression filters can only be applied to the following commands:
113
- * * {@link Client#apply}
114
- * * {@link Client#batchExists}
115
- * * {@link Client#batchGet}
116
- * * {@link Client#batchRead}
117
- * * {@link Client#batchSelect}
118
- * * {@link Client#exists}
119
- * * {@link Client#get}
120
- * * {@link Client#operate}
121
- * * {@link Client#put}
122
- * * {@link Client#remove}
123
- * * {@link Client#select}
124
- *
125
- * @type Predicate[]
126
- * @since v3.14.0
127
- */
128
- this.predexp = props.predexp
129
-
130
91
  /**
131
92
  * Optional expression filter. If filter exp exists and evaluates to false, the
132
93
  * transaction is ignored. This can be used to eliminate a client/server roundtrip
133
94
  * in some cases.
134
95
  *
135
- * predexp and filter_exp are mutually exclusive. If both are defined, predexp
136
- * will be ignored.
137
- *
138
96
  * expression filters can only be applied to the following commands:
139
97
  * * {@link Client#apply}
140
98
  * * {@link Client#batchExists}
@@ -149,6 +107,23 @@ class BasePolicy {
149
107
  * * {@link Client#select}
150
108
  */
151
109
  this.filterExpression = props.filterExpression
110
+
111
+ /**
112
+ * Use zlib compression on write or batch read commands when the command
113
+ * buffer size is greater than 128 bytes. In addition, tell the server to
114
+ * compress it's response on read commands. The server response compression
115
+ * threshold is also 128 bytes.
116
+ *
117
+ * This option will increase cpu and memory usage (for extra compressed
118
+ * buffers), but decrease the size of data sent over the network.
119
+ *
120
+ * Requires Enterprise Server version >= 4.8.
121
+ *
122
+ * @type boolean
123
+ * @default: false
124
+ * @since v3.14.0
125
+ */
126
+ this.compress = props.compress
152
127
  }
153
128
  }
154
129