Skip to content

Commit 451580b

Browse files
author
Jan Hecking
authored
Refactor: Separate list & map operations (#360)
* Refactor: split off list operations * Refactor: split off map operations * Refactor: Split off scalar operations
1 parent 56add63 commit 451580b

11 files changed

Lines changed: 2239 additions & 2815 deletions

binding.gyp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@
5151
'src/main/events.cc',
5252
'src/main/cdt_ctx.cc',
5353
'src/main/operations.cc',
54+
'src/main/scalar_operations.cc',
55+
'src/main/list_operations.cc',
56+
'src/main/map_operations.cc',
5457
'src/main/bit_operations.cc',
5558
'src/main/policy.cc',
5659
'src/main/query.cc',

lib/lists.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// *****************************************************************************
2-
// Copyright 2013-2019 Aerospike, Inc.
2+
// Copyright 2013-2020 Aerospike, Inc.
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License")
55
// you may not use this file except in compliance with the License.
@@ -49,7 +49,7 @@
4949
*/
5050

5151
const as = require('bindings')('aerospike.node')
52-
const opcodes = as.operations
52+
const opcodes = as.listOperations
5353
const Context = require('./cdt_context')
5454
const AerospikeError = require('./error')
5555
const Operation = require('./operations').Operation

lib/maps.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// *****************************************************************************
2-
// Copyright 2013-2019 Aerospike, Inc.
2+
// Copyright 2013-2020 Aerospike, Inc.
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License")
55
// you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
1717
'use strict'
1818

1919
const as = require('bindings')('aerospike.node')
20-
const opcodes = as.operations
20+
const opcodes = as.mapOperations
2121
const policy = require('./policy')
2222
const Context = require('./cdt_context')
2323
const Operation = require('./operations').Operation

lib/operations.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
*/
5151

5252
const as = require('bindings')('aerospike.node')
53-
const ops = as.operations
53+
const ops = as.scalarOperations
5454

5555
/**
5656
* @class module:aerospike/operations~Operation

src/include/operations.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,19 @@ extern "C" {
2525
#include "log.h"
2626

2727
int operations_from_jsarray(as_operations* ops, v8::Local<v8::Array> arr, LogInfo* log);
28-
int add_bit_op(as_operations* ops, int64_t opcode, v8::Local<v8::Object> op, LogInfo* log);
28+
int add_scalar_op(as_operations* ops, uint32_t opcode, v8::Local<v8::Object> op, LogInfo* log);
29+
int add_list_op(as_operations* ops, uint32_t opcode, v8::Local<v8::Object> op, LogInfo* log);
30+
int add_map_op(as_operations* ops, uint32_t opcode, v8::Local<v8::Object> op, LogInfo* log);
31+
int add_bit_op(as_operations* ops, uint32_t opcode, v8::Local<v8::Object> op, LogInfo* log);
2932
int get_optional_cdt_context(as_cdt_ctx* context, bool* has_context, v8::Local<v8::Object> obj, LogInfo* log);
3033

31-
v8::Local<v8::Object> opcode_values();
34+
v8::Local<v8::Object> scalar_opcode_values();
35+
v8::Local<v8::Object> list_opcode_values();
36+
v8::Local<v8::Object> map_opcode_values();
3237
v8::Local<v8::Object> bit_opcode_values();
3338

3439
const uint32_t OPS_MASK = 0xFF00;
40+
const uint32_t SCALAR_OPS_OFFSET = 0x0000;
41+
const uint32_t LIST_OPS_OFFSET = 0x0100;
42+
const uint32_t MAP_OPS_OFFSET = 0x0200;
3543
const uint32_t BIT_OPS_OFFSET = 0x0300;

src/main/aerospike.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ NAN_MODULE_INIT(Aerospike)
123123
export("predexp", predexp_codes());
124124
export("scanPriority", scanPriority());
125125
export("log", log_enum_values());
126-
export("operations", opcode_values());
126+
export("scalarOperations", scalar_opcode_values());
127+
export("listOperations", list_opcode_values());
128+
export("mapOperations", map_opcode_values());
127129
export("bitOperations", bit_opcode_values());
128130
export("policy", policy());
129131
export("status", status());

src/main/bit_operations.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ const ops_table_entry ops_table[] = {
410410
};
411411

412412
int
413-
add_bit_op(as_operations* ops, int64_t opcode, Local<Object> op, LogInfo* log)
413+
add_bit_op(as_operations* ops, uint32_t opcode, Local<Object> op, LogInfo* log)
414414
{
415415
opcode = opcode ^ BIT_OPS_OFFSET;
416416
const ops_table_entry *entry = &ops_table[opcode];

0 commit comments

Comments
 (0)