aerospike 2.7.0 → 2.8.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +52 -60
- data/lib/aerospike.rb +7 -0
- data/lib/aerospike/cdt/list_operation.rb +372 -56
- data/lib/aerospike/cdt/list_order.rb +37 -0
- data/lib/aerospike/cdt/list_policy.rb +35 -0
- data/lib/aerospike/cdt/list_return_type.rb +75 -0
- data/lib/aerospike/cdt/list_sort_flags.rb +33 -0
- data/lib/aerospike/cdt/list_write_flags.rb +47 -0
- data/lib/aerospike/cdt/map_operation.rb +347 -103
- data/lib/aerospike/cdt/map_policy.rb +8 -8
- data/lib/aerospike/cdt/map_write_flags.rb +51 -0
- data/lib/aerospike/cdt/map_write_mode.rb +7 -1
- data/lib/aerospike/cluster.rb +4 -0
- data/lib/aerospike/key.rb +1 -1
- data/lib/aerospike/node.rb +1 -13
- data/lib/aerospike/socket/base.rb +45 -18
- data/lib/aerospike/socket/ssl.rb +2 -0
- data/lib/aerospike/utils/buffer.rb +1 -1
- data/lib/aerospike/utils/connection_pool.rb +45 -0
- data/lib/aerospike/utils/packer.rb +1 -1
- data/lib/aerospike/utils/pool.rb +35 -12
- data/lib/aerospike/utils/unpacker.rb +11 -7
- data/lib/aerospike/version.rb +1 -1
- metadata +10 -3
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2018 Aerospike, Inc.
|
4
|
+
#
|
5
|
+
# Portions may be licensed to Aerospike, Inc. under one or more contributor
|
6
|
+
# license agreements.
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
9
|
+
# use this file except in compliance with the License. You may obtain a copy of
|
10
|
+
# the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
16
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
17
|
+
# License for the specific language governing permissions and limitations under
|
18
|
+
# the License.
|
19
|
+
|
20
|
+
module Aerospike
|
21
|
+
module CDT
|
22
|
+
module ListOrder
|
23
|
+
|
24
|
+
##
|
25
|
+
# List is not ordered. This is the default.
|
26
|
+
UNORDERED = 0
|
27
|
+
|
28
|
+
##
|
29
|
+
# List is ordered
|
30
|
+
ORDERED = 1
|
31
|
+
|
32
|
+
##
|
33
|
+
# Default order
|
34
|
+
DEFAULT = UNORDERED
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2018 Aerospike, Inc.
|
4
|
+
#
|
5
|
+
# Portions may be licensed to Aerospike, Inc. under one or more contributor
|
6
|
+
# license agreements.
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
9
|
+
# use this file except in compliance with the License. You may obtain a copy of
|
10
|
+
# the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
16
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
17
|
+
# License for the specific language governing permissions and limitations under
|
18
|
+
# the License.
|
19
|
+
|
20
|
+
module Aerospike
|
21
|
+
module CDT
|
22
|
+
class ListPolicy
|
23
|
+
|
24
|
+
attr_accessor :order, :flags
|
25
|
+
|
26
|
+
def initialize(order: ListOrder::DEFAULT, write_flags: ListWriteFlags::DEFAULT)
|
27
|
+
@order = order
|
28
|
+
@flags = write_flags
|
29
|
+
end
|
30
|
+
|
31
|
+
DEFAULT = ListPolicy.new
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2018 Aerospike, Inc.
|
4
|
+
#
|
5
|
+
# Portions may be licensed to Aerospike, Inc. under one or more contributor
|
6
|
+
# license agreements.
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
9
|
+
# use this file except in compliance with the License. You may obtain a copy of
|
10
|
+
# the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
16
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
17
|
+
# License for the specific language governing permissions and limitations under
|
18
|
+
# the License.
|
19
|
+
|
20
|
+
module Aerospike
|
21
|
+
module CDT
|
22
|
+
module ListReturnType
|
23
|
+
|
24
|
+
##
|
25
|
+
# Do not return a result.
|
26
|
+
NONE = 0
|
27
|
+
|
28
|
+
##
|
29
|
+
# Return key index order.
|
30
|
+
# 0 = first key
|
31
|
+
# N = Nth key
|
32
|
+
# -1 = last key
|
33
|
+
INDEX = 1
|
34
|
+
|
35
|
+
##
|
36
|
+
# Return reverse key order.
|
37
|
+
# 0 = last key
|
38
|
+
# -1 = first key
|
39
|
+
REVERSE_INDEX = 2
|
40
|
+
|
41
|
+
##
|
42
|
+
# Return value order.
|
43
|
+
# 0 = smalles value
|
44
|
+
# N = Nth smalles value
|
45
|
+
# -1 = largest value
|
46
|
+
RANK = 3
|
47
|
+
|
48
|
+
##
|
49
|
+
# Return reverse value order.
|
50
|
+
# 0 = largest value
|
51
|
+
# N = Nth largest value
|
52
|
+
# -1 = smallest values
|
53
|
+
REVERSE_RANK = 4
|
54
|
+
|
55
|
+
##
|
56
|
+
# Return count of items selected.
|
57
|
+
COUNT = 5
|
58
|
+
|
59
|
+
##
|
60
|
+
# Return value for single key read and value list for range read.
|
61
|
+
VALUE = 7
|
62
|
+
|
63
|
+
##
|
64
|
+
# :private
|
65
|
+
#
|
66
|
+
# See ListOperation#invert_selection
|
67
|
+
INVERTED = 0x10000
|
68
|
+
|
69
|
+
##
|
70
|
+
# Default return type: NONE
|
71
|
+
DEFAULT = NONE
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2018 Aerospike, Inc.
|
4
|
+
#
|
5
|
+
# Portions may be licensed to Aerospike, Inc. under one or more contributor
|
6
|
+
# license agreements.
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
9
|
+
# use this file except in compliance with the License. You may obtain a copy of
|
10
|
+
# the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
16
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
17
|
+
# License for the specific language governing permissions and limitations under
|
18
|
+
# the License.
|
19
|
+
|
20
|
+
module Aerospike
|
21
|
+
module CDT
|
22
|
+
module ListSortFlags
|
23
|
+
|
24
|
+
##
|
25
|
+
# Default. Preserve duplicate values when sorting list.
|
26
|
+
DEFAULT = 0
|
27
|
+
|
28
|
+
##
|
29
|
+
# Drop duplicate values when sorting list.
|
30
|
+
DROP_DUPLICATES = 2
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2018 Aerospike, Inc.
|
4
|
+
#
|
5
|
+
# Portions may be licensed to Aerospike, Inc. under one or more contributor
|
6
|
+
# license agreements.
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
9
|
+
# use this file except in compliance with the License. You may obtain a copy of
|
10
|
+
# the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
16
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
17
|
+
# License for the specific language governing permissions and limitations under
|
18
|
+
# the License.
|
19
|
+
|
20
|
+
module Aerospike
|
21
|
+
module CDT
|
22
|
+
module ListWriteFlags
|
23
|
+
|
24
|
+
##
|
25
|
+
# Default. Allow duplicate values and insertion at any index.
|
26
|
+
DEFAULT = 0
|
27
|
+
|
28
|
+
##
|
29
|
+
# Only add unique values.
|
30
|
+
ADD_UNIQUE = 1
|
31
|
+
|
32
|
+
##
|
33
|
+
# Enforce list boundaries when inserting. Do not allow values to be
|
34
|
+
# inserted at index outside current list boundaries.
|
35
|
+
INSERT_BOUNED = 2
|
36
|
+
|
37
|
+
##
|
38
|
+
# Do not raise error if a list item fails due to write flag constraints.
|
39
|
+
NO_FAIL = 4
|
40
|
+
|
41
|
+
##
|
42
|
+
# Allow other valid list items to be committed if a list item fails due
|
43
|
+
# to write flag constraints.
|
44
|
+
PARTIAL = 8
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
# Copyright 2016-
|
2
|
+
# Copyright 2016-2018 Aerospike, Inc.
|
3
3
|
#
|
4
4
|
# Portions may be licensed to Aerospike, Inc. under one or more contributor
|
5
5
|
# license agreements.
|
@@ -19,45 +19,50 @@ module Aerospike
|
|
19
19
|
|
20
20
|
class MapOperation < Operation
|
21
21
|
|
22
|
-
SET_TYPE
|
23
|
-
ADD
|
24
|
-
ADD_ITEMS
|
25
|
-
PUT
|
26
|
-
PUT_ITEMS
|
27
|
-
REPLACE
|
28
|
-
REPLACE_ITEMS
|
29
|
-
INCREMENT
|
30
|
-
DECREMENT
|
31
|
-
CLEAR
|
32
|
-
REMOVE_BY_KEY
|
33
|
-
REMOVE_BY_INDEX
|
34
|
-
REMOVE_BY_RANK
|
35
|
-
REMOVE_BY_KEY_LIST
|
36
|
-
REMOVE_BY_VALUE
|
37
|
-
REMOVE_BY_VALUE_LIST
|
38
|
-
REMOVE_BY_KEY_INTERVAL
|
39
|
-
REMOVE_BY_INDEX_RANGE
|
40
|
-
REMOVE_BY_VALUE_INTERVAL
|
41
|
-
REMOVE_BY_RANK_RANGE
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
22
|
+
SET_TYPE = 64
|
23
|
+
ADD = 65
|
24
|
+
ADD_ITEMS = 66
|
25
|
+
PUT = 67
|
26
|
+
PUT_ITEMS = 68
|
27
|
+
REPLACE = 69
|
28
|
+
REPLACE_ITEMS = 70
|
29
|
+
INCREMENT = 73
|
30
|
+
DECREMENT = 74
|
31
|
+
CLEAR = 75
|
32
|
+
REMOVE_BY_KEY = 76
|
33
|
+
REMOVE_BY_INDEX = 77
|
34
|
+
REMOVE_BY_RANK = 79
|
35
|
+
REMOVE_BY_KEY_LIST = 81
|
36
|
+
REMOVE_BY_VALUE = 82
|
37
|
+
REMOVE_BY_VALUE_LIST = 83
|
38
|
+
REMOVE_BY_KEY_INTERVAL = 84
|
39
|
+
REMOVE_BY_INDEX_RANGE = 85
|
40
|
+
REMOVE_BY_VALUE_INTERVAL = 86
|
41
|
+
REMOVE_BY_RANK_RANGE = 87
|
42
|
+
REMOVE_BY_KEY_REL_INDEX_RANGE = 88
|
43
|
+
REMOVE_BY_VALUE_REL_RANK_RANGE = 89
|
44
|
+
SIZE = 96
|
45
|
+
GET_BY_KEY = 97
|
46
|
+
GET_BY_INDEX = 98
|
47
|
+
GET_BY_RANK = 100
|
48
|
+
GET_BY_VALUE = 102
|
49
|
+
GET_BY_KEY_INTERVAL = 103
|
50
|
+
GET_BY_INDEX_RANGE = 104
|
51
|
+
GET_BY_VALUE_INTERVAL = 105
|
52
|
+
GET_BY_RANK_RANGE = 106
|
53
|
+
GET_BY_KEY_LIST = 107
|
54
|
+
GET_BY_VALUE_LIST = 108
|
55
|
+
GET_BY_KEY_REL_INDEX_RANGE = 109
|
56
|
+
GET_BY_VALUE_REL_RANK_RANGE = 110
|
57
|
+
|
58
|
+
attr_reader :map_op, :arguments, :return_type
|
59
|
+
|
60
|
+
def initialize(op_type, map_op, bin_name, *arguments, return_type: nil)
|
55
61
|
@op_type = op_type
|
56
62
|
@bin_name = bin_name
|
57
63
|
@bin_value = nil
|
58
64
|
@map_op = map_op
|
59
65
|
@arguments = arguments
|
60
|
-
@policy = policy
|
61
66
|
@return_type = return_type
|
62
67
|
self
|
63
68
|
end
|
@@ -68,7 +73,7 @@ module Aerospike
|
|
68
73
|
#
|
69
74
|
# The required map policy attributes can be changed after the map is created.
|
70
75
|
def self.set_policy(bin_name, policy)
|
71
|
-
MapOperation.new(Operation::CDT_MODIFY, SET_TYPE, bin_name, policy
|
76
|
+
MapOperation.new(Operation::CDT_MODIFY, SET_TYPE, bin_name, policy.order)
|
72
77
|
end
|
73
78
|
|
74
79
|
##
|
@@ -76,16 +81,21 @@ module Aerospike
|
|
76
81
|
# Server writes key/value item to map bin and returns map size.
|
77
82
|
#
|
78
83
|
# The map policy dictates the type of map to create when it does not exist.
|
79
|
-
# The map policy also specifies the
|
84
|
+
# The map policy also specifies the flags used when writing items to the map.
|
80
85
|
def self.put(bin_name, key, value, policy: MapPolicy::DEFAULT)
|
81
|
-
|
86
|
+
if policy.flags != MapWriteFlags::DEFAULT
|
87
|
+
MapOperation.new(Operation::CDT_MODIFY, PUT, bin_name, key, value, policy.order, policy.flags)
|
88
|
+
else
|
82
89
|
case policy.write_mode
|
83
|
-
when MapWriteMode::
|
84
|
-
|
85
|
-
|
86
|
-
|
90
|
+
when MapWriteMode::UPDATE_ONLY
|
91
|
+
# Replace doesn't allow map order because it does not create on non-existing key.
|
92
|
+
MapOperation.new(Operation::CDT_MODIFY, REPLACE, bin_name, key, value)
|
93
|
+
when MapWriteMode::CREATE_ONLY
|
94
|
+
MapOperation.new(Operation::CDT_MODIFY, ADD, bin_name, key, value, policy.order)
|
95
|
+
else
|
96
|
+
MapOperation.new(Operation::CDT_MODIFY, PUT, bin_name, key, value, policy.order)
|
87
97
|
end
|
88
|
-
|
98
|
+
end
|
89
99
|
end
|
90
100
|
|
91
101
|
##
|
@@ -93,16 +103,21 @@ module Aerospike
|
|
93
103
|
# Server writes each map item to map bin and returns map size.
|
94
104
|
#
|
95
105
|
# The map policy dictates the type of map to create when it does not exist.
|
96
|
-
# The map policy also specifies the
|
106
|
+
# The map policy also specifies the flags used when writing items to the map.
|
97
107
|
def self.put_items(bin_name, values, policy: MapPolicy::DEFAULT)
|
98
|
-
|
108
|
+
if policy.flags != MapWriteFlags::DEFAULT
|
109
|
+
MapOperation.new(Operation::CDT_MODIFY, PUT_ITEMS, bin_name, values, policy.order, policy.flags)
|
110
|
+
else
|
99
111
|
case policy.write_mode
|
100
|
-
when MapWriteMode::
|
101
|
-
|
102
|
-
|
103
|
-
|
112
|
+
when MapWriteMode::UPDATE_ONLY
|
113
|
+
# Replace doesn't allow map order because it does not create on non-existing key.
|
114
|
+
MapOperation.new(Operation::CDT_MODIFY, REPLACE_ITEMS, bin_name, values)
|
115
|
+
when MapWriteMode::CREATE_ONLY
|
116
|
+
MapOperation.new(Operation::CDT_MODIFY, ADD_ITEMS, bin_name, values, policy.order)
|
117
|
+
else
|
118
|
+
MapOperation.new(Operation::CDT_MODIFY, PUT_ITEMS, bin_name, values, policy.order)
|
104
119
|
end
|
105
|
-
|
120
|
+
end
|
106
121
|
end
|
107
122
|
|
108
123
|
##
|
@@ -113,7 +128,7 @@ module Aerospike
|
|
113
128
|
# The map policy dictates the type of map to create when it does not exist.
|
114
129
|
# The map policy also specifies the mode used when writing items to the map.
|
115
130
|
def self.increment(bin_name, key, incr, policy: MapPolicy::DEFAULT)
|
116
|
-
MapOperation.new(Operation::CDT_MODIFY, INCREMENT, bin_name, key, incr, policy
|
131
|
+
MapOperation.new(Operation::CDT_MODIFY, INCREMENT, bin_name, key, incr, policy.order)
|
117
132
|
end
|
118
133
|
|
119
134
|
##
|
@@ -124,7 +139,7 @@ module Aerospike
|
|
124
139
|
# The map policy dictates the type of map to create when it does not exist.
|
125
140
|
# The map policy also specifies the mode used when writing items to the map.
|
126
141
|
def self.decrement(bin_name, key, decr, policy: MapPolicy::DEFAULT)
|
127
|
-
MapOperation.new(Operation::CDT_MODIFY, DECREMENT, bin_name, key, decr, policy
|
142
|
+
MapOperation.new(Operation::CDT_MODIFY, DECREMENT, bin_name, key, decr, policy.order)
|
128
143
|
end
|
129
144
|
|
130
145
|
##
|
@@ -136,89 +151,217 @@ module Aerospike
|
|
136
151
|
|
137
152
|
##
|
138
153
|
# Create map remove operation.
|
139
|
-
#
|
154
|
+
#
|
155
|
+
# Server removes map item identified by key and returns removed data
|
156
|
+
# specified by return_type.
|
157
|
+
def self.remove_by_key(bin_name, key, return_type: nil)
|
158
|
+
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY, bin_name, key, return_type: return_type)
|
159
|
+
end
|
160
|
+
|
161
|
+
##
|
162
|
+
# Create map remove operation.
|
163
|
+
#
|
164
|
+
# Server removes map items identified by keys.
|
165
|
+
#
|
166
|
+
# Server returns removed data specified by return_type.
|
167
|
+
def self.remove_by_key_list(bin_name, keys, return_type: MapReturnType::NONE)
|
168
|
+
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_LIST, bin_name, keys, return_type: return_type)
|
169
|
+
end
|
170
|
+
|
171
|
+
##
|
172
|
+
# Create map remove operation.
|
173
|
+
#
|
174
|
+
# Server removes map items identified by keys.
|
175
|
+
#
|
176
|
+
# Server returns removed data specified by return_type.
|
177
|
+
#
|
178
|
+
# Deprecated. Use remove_by_key / remove_by_key_list instead.
|
140
179
|
def self.remove_keys(bin_name, *keys, return_type: MapReturnType::NONE)
|
141
180
|
if keys.length > 1
|
142
|
-
|
181
|
+
remove_by_key_list(bin_name, keys, return_type: return_type)
|
143
182
|
else
|
144
|
-
|
183
|
+
remove_by_key(bin_name, keys.first, return_type: return_type)
|
145
184
|
end
|
146
185
|
end
|
147
186
|
|
148
187
|
##
|
149
188
|
# Create map remove operation.
|
189
|
+
#
|
150
190
|
# Server removes map items identified by key range (key_begin inclusive, key_end exclusive).
|
151
191
|
# If key_begin is null, the range is less than key_end.
|
152
192
|
# If key_end is null, the range is greater than equal to key_begin.
|
153
193
|
#
|
154
194
|
# Server returns removed data specified by return_type.
|
155
|
-
def self.
|
195
|
+
def self.remove_by_key_range(bin_name, key_begin, key_end = nil, return_type: MapReturnType::NONE)
|
156
196
|
if key_end
|
157
197
|
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_INTERVAL, bin_name, key_begin, key_end, return_type: return_type)
|
158
198
|
else
|
159
199
|
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_INTERVAL, bin_name, key_begin, return_type: return_type)
|
160
200
|
end
|
161
201
|
end
|
202
|
+
singleton_class.send(:alias_method, :remove_key_range, :remove_by_key_range)
|
203
|
+
|
204
|
+
##
|
205
|
+
# Create map remove by key relative to index range operation.
|
206
|
+
#
|
207
|
+
# Server removes map items nearest to key and greater by relative index,
|
208
|
+
# with a count limit.
|
209
|
+
#
|
210
|
+
# Server returns removed data specified by return_type.
|
211
|
+
#
|
212
|
+
# Examples for map [{0=17},{4=2},{5=15},{9=10}]:
|
213
|
+
#
|
214
|
+
# * (value, index, count) = [removed items]
|
215
|
+
# * (5, 0, 1) = [{5=15}]
|
216
|
+
# * (5, 1, 2) = [{9=10}]
|
217
|
+
# * (5, -1, 1) = [{4=2}]
|
218
|
+
# * (3, 2, 1) = [{9=10}]
|
219
|
+
# * (3, -2, 2) = [{0=17}]
|
220
|
+
#
|
221
|
+
# Without count:
|
222
|
+
#
|
223
|
+
# * (value, index) = [removed items]
|
224
|
+
# * (5, 0) = [{5=15}, {9=10}]
|
225
|
+
# * (5, 1) = [{9=10}]
|
226
|
+
# * (5, -1) = [{4=2}, {5=15}, {9=10}]
|
227
|
+
# * (3, 2) = [{9=10}]
|
228
|
+
# * (3, -2) = [{0=17}, {4=2}, {5=15}, {9=10}]
|
229
|
+
def self.remove_by_key_rel_index_range(bin_name, key, index, count = nil, return_type: nil)
|
230
|
+
if count
|
231
|
+
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_REL_INDEX_RANGE, bin_name, key, index, count, return_type: return_type)
|
232
|
+
else
|
233
|
+
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_REL_INDEX_RANGE, bin_name, key, index, return_type: return_type)
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
##
|
238
|
+
# Create map remove operation.
|
239
|
+
#
|
240
|
+
# Server removes map item identified by value.
|
241
|
+
#
|
242
|
+
# Server returns removed data specified by return_type.
|
243
|
+
def self.remove_by_value(bin_name, value, return_type: MapReturnType::NONE)
|
244
|
+
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE, bin_name, value, return_type: return_type)
|
245
|
+
end
|
246
|
+
|
247
|
+
##
|
248
|
+
# Create map remove operation.
|
249
|
+
#
|
250
|
+
# Server removes map items identified by value.
|
251
|
+
#
|
252
|
+
# Server returns removed data specified by return_type.
|
253
|
+
def self.remove_by_value_list(bin_name, values, return_type: MapReturnType::NONE)
|
254
|
+
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_LIST, bin_name, values, return_type: return_type)
|
255
|
+
end
|
162
256
|
|
163
257
|
##
|
164
258
|
# Create map remove operation.
|
165
|
-
#
|
259
|
+
#
|
260
|
+
# Server removes map items identified by value.
|
261
|
+
#
|
262
|
+
# Server returns removed data specified by return_type.
|
263
|
+
#
|
264
|
+
# Deprecated. Use remove_by_value / remove_by_value_list instead.
|
166
265
|
def self.remove_values(bin_name, *values, return_type: MapReturnType::NONE)
|
167
266
|
if values.length > 1
|
168
|
-
|
267
|
+
remove_by_value_list(bin_name, values, return_type: return_type)
|
169
268
|
else
|
170
|
-
|
269
|
+
remove_by_value(bin_name, values.first, return_type: return_type)
|
171
270
|
end
|
172
271
|
end
|
173
272
|
|
174
273
|
##
|
175
274
|
# Create map remove operation.
|
176
|
-
#
|
177
|
-
#
|
178
|
-
#
|
275
|
+
#
|
276
|
+
# Server removes map items identified by value range (value_begin
|
277
|
+
# inclusive, value_end exclusive). If value_begin is null, the range is
|
278
|
+
# less than value_end. If value_end is null, the range is greater than
|
279
|
+
# equal to value_begin.
|
179
280
|
#
|
180
281
|
# Server returns removed data specified by return_type.
|
181
|
-
def self.
|
282
|
+
def self.remove_by_value_range(bin_name, value_begin, value_end = nil, return_type: MapReturnType::NONE)
|
182
283
|
if value_end
|
183
284
|
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_INTERVAL, bin_name, value_begin, value_end, return_type: return_type)
|
184
285
|
else
|
185
286
|
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_INTERVAL, bin_name, value_begin, return_type: return_type)
|
186
287
|
end
|
187
288
|
end
|
289
|
+
singleton_class.send(:alias_method, :remove_value_range, :remove_by_value_range)
|
290
|
+
|
291
|
+
##
|
292
|
+
# Create map remove by value relative to rank range operation.
|
293
|
+
#
|
294
|
+
# Server removes "count" map items nearest to value and greater by relative rank.
|
295
|
+
# If "count" is not specified, server removes map items nearest to value
|
296
|
+
# and greater by relative rank, until the end of the map.
|
297
|
+
#
|
298
|
+
# Server returns removed data specified by return_type.
|
299
|
+
#
|
300
|
+
# Examples for map [{4=2},{9=10},{5=15},{0=17}]:
|
301
|
+
#
|
302
|
+
# * (value, rank, count) = [removed items]
|
303
|
+
# * (11, 1, 1) = [{0=17}]
|
304
|
+
# * (11, -1, 1) = [{9=10}]
|
305
|
+
#
|
306
|
+
# Without count:
|
307
|
+
#
|
308
|
+
# * (value, rank) = [removed items]
|
309
|
+
# * (11, 1) = [{0=17}]
|
310
|
+
# * (11, -1) = [{9=10}, {5=15}, {0=17}]
|
311
|
+
def self.remove_by_value_rel_rank_range(bin_name, value, rank, count = nil, return_type: nil)
|
312
|
+
if count
|
313
|
+
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, count, return_type: return_type)
|
314
|
+
else
|
315
|
+
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, return_type: return_type)
|
316
|
+
end
|
317
|
+
end
|
188
318
|
|
189
319
|
##
|
190
320
|
# Create map remove operation.
|
191
|
-
#
|
192
|
-
|
321
|
+
#
|
322
|
+
# Server removes map item identified by index.
|
323
|
+
#
|
324
|
+
# Server returns removed data specified by return_type.
|
325
|
+
def self.remove_by_index(bin_name, index, return_type: MapReturnType::NONE)
|
193
326
|
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX, bin_name, index, return_type: return_type)
|
194
327
|
end
|
328
|
+
singleton_class.send(:alias_method, :remove_index, :remove_by_index)
|
195
329
|
|
196
330
|
##
|
197
331
|
# Create map remove operation.
|
198
|
-
#
|
199
|
-
#
|
200
|
-
# specified, the server selects map items starting at
|
201
|
-
# the end of map.
|
202
|
-
|
332
|
+
#
|
333
|
+
# Server removes "count" map items starting at specified index. If
|
334
|
+
# "count" is not specified, the server selects map items starting at
|
335
|
+
# specified index to the end of map.
|
336
|
+
#
|
337
|
+
# Server returns removed data specified by return_type.
|
338
|
+
def self.remove_by_index_range(bin_name, index, count = nil, return_type: MapReturnType::NONE)
|
203
339
|
if count
|
204
340
|
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX_RANGE, bin_name, index, count, return_type: return_type)
|
205
341
|
else
|
206
342
|
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX_RANGE, bin_name, index, return_type: return_type)
|
207
343
|
end
|
208
344
|
end
|
345
|
+
singleton_class.send(:alias_method, :remove_index_range, :remove_by_index_range)
|
209
346
|
|
210
347
|
##
|
211
348
|
# Create map remove operation.
|
212
|
-
#
|
349
|
+
#
|
350
|
+
# Server removes map item identified by rank.
|
351
|
+
#
|
352
|
+
# Server returns removed data specified by return_type.
|
213
353
|
def self.remove_by_rank(bin_name, rank, return_type: MapReturnType::NONE)
|
214
354
|
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_RANK, bin_name, rank, return_type: return_type)
|
215
355
|
end
|
216
356
|
|
217
357
|
##
|
218
358
|
# Create map remove operation.
|
219
|
-
#
|
220
|
-
#
|
221
|
-
# server removes map items starting at specified rank
|
359
|
+
#
|
360
|
+
# Server selects "count" map items starting at specified rank. If "count"
|
361
|
+
# is not specified, server removes map items starting at specified rank
|
362
|
+
# to the last ranked.
|
363
|
+
#
|
364
|
+
# Server returns removed data specified by return_type.
|
222
365
|
def self.remove_by_rank_range(bin_name, rank, count = nil, return_type: MapReturnType::NONE)
|
223
366
|
if count
|
224
367
|
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_RANK_RANGE, bin_name, rank, count, return_type: return_type)
|
@@ -237,75 +380,179 @@ module Aerospike
|
|
237
380
|
##
|
238
381
|
# Create map get by key operation.
|
239
382
|
# Server selects map item identified by key and returns selected data specified by return_type.
|
240
|
-
def self.
|
383
|
+
def self.get_by_key(bin_name, key, return_type: MapReturnType::NONE)
|
241
384
|
MapOperation.new(Operation::CDT_READ, GET_BY_KEY, bin_name, key, return_type: return_type)
|
242
385
|
end
|
386
|
+
singleton_class.send(:alias_method, :get_key, :get_by_key)
|
387
|
+
|
388
|
+
##
|
389
|
+
# Create map get by key list operation.
|
390
|
+
#
|
391
|
+
# Server selects map items identified by keys.
|
392
|
+
#
|
393
|
+
# Server returns selected data specified by return_type.
|
394
|
+
def self.get_by_key_list(bin_name, keys, return_type: MapReturnType::NONE)
|
395
|
+
MapOperation.new(Operation::CDT_READ, GET_BY_KEY_LIST, bin_name, keys, return_type: return_type)
|
396
|
+
end
|
243
397
|
|
244
398
|
# Create map get by key range operation.
|
245
|
-
#
|
246
|
-
#
|
247
|
-
# If
|
248
|
-
#
|
399
|
+
#
|
400
|
+
# Server selects map items identified by key range (key_begin inclusive,
|
401
|
+
# key_end exclusive). If key_begin is null, the range is less than
|
402
|
+
# key_end. If key_end is null, the range is greater than equal to
|
403
|
+
# key_begin.
|
404
|
+
#
|
249
405
|
# Server returns selected data specified by return_type.
|
250
|
-
def self.
|
406
|
+
def self.get_by_key_range(bin_name, key_begin, key_end = nil, return_type: MapReturnType::NONE)
|
251
407
|
if key_end
|
252
408
|
MapOperation.new(Operation::CDT_READ, GET_BY_KEY_INTERVAL, bin_name, key_begin, key_end, return_type: return_type)
|
253
409
|
else
|
254
410
|
MapOperation.new(Operation::CDT_READ, GET_BY_KEY_INTERVAL, bin_name, key_begin, return_type: return_type)
|
255
411
|
end
|
256
412
|
end
|
413
|
+
singleton_class.send(:alias_method, :get_key_range, :get_by_key_range)
|
414
|
+
|
415
|
+
##
|
416
|
+
# Create map get by key relative to index range operation.
|
417
|
+
#
|
418
|
+
# Server selects "count" map items nearest to key and greater by relative
|
419
|
+
# index. If "count" is not specified, server selects map items nearest to
|
420
|
+
# key and greater by relative index, until the end of the map.
|
421
|
+
#
|
422
|
+
# Server returns selected data specified by return_type.
|
423
|
+
#
|
424
|
+
# Examples for map [{0=17},{4=2},{5=15},{9=10}]:
|
425
|
+
#
|
426
|
+
# * (value, index, count) = [selected items]
|
427
|
+
# * (5, 0, 1) = [{5=15}]
|
428
|
+
# * (5, 1, 2) = [{9=10}]
|
429
|
+
# * (5, -1, 1) = [{4=2}]
|
430
|
+
# * (3, 2, 1) = [{9=10}]
|
431
|
+
# * (3, -2, 2) = [{0=17}]
|
432
|
+
#
|
433
|
+
# Without count:
|
434
|
+
#
|
435
|
+
# * (value, index) = [selected items]
|
436
|
+
# * (5, 0) = [{5=15}, {9=10}]
|
437
|
+
# * (5, 1) = [{9=10}]
|
438
|
+
# * (5, -1) = [{4=2}, {5=15}, {9=10}]
|
439
|
+
# * (3, 2) = [{9=10}]
|
440
|
+
# * (3, -2) = [{0=17}, {4=2}, {5=15}, {9=10}]
|
441
|
+
def self.get_by_key_rel_index_range(bin_name, key, index, count = nil, return_type: nil)
|
442
|
+
if count
|
443
|
+
MapOperation.new(Operation::CDT_READ, GET_BY_KEY_REL_INDEX_RANGE, bin_name, key, index, count, return_type: return_type)
|
444
|
+
else
|
445
|
+
MapOperation.new(Operation::CDT_READ, GET_BY_KEY_REL_INDEX_RANGE, bin_name, key, index, return_type: return_type)
|
446
|
+
end
|
447
|
+
end
|
257
448
|
|
258
449
|
# Create map get by value operation.
|
259
|
-
#
|
260
|
-
|
450
|
+
#
|
451
|
+
# Server selects map items identified by value.
|
452
|
+
#
|
453
|
+
# Server returns selected data specified by return_type.
|
454
|
+
def self.get_by_value(bin_name, value, return_type: MapReturnType::NONE)
|
261
455
|
MapOperation.new(Operation::CDT_READ, GET_BY_VALUE, bin_name, value, return_type: return_type)
|
262
456
|
end
|
457
|
+
singleton_class.send(:alias_method, :get_value, :get_by_value)
|
458
|
+
|
459
|
+
# Create map get by value list operation.
|
460
|
+
#
|
461
|
+
# Server selects map items identified by value list.
|
462
|
+
#
|
463
|
+
# Server returns selected data specified by return_type.
|
464
|
+
def self.get_by_value_list(bin_name, values, return_type: MapReturnType::NONE)
|
465
|
+
MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_LIST, bin_name, values, return_type: return_type)
|
466
|
+
end
|
263
467
|
|
264
468
|
# Create map get by value range operation.
|
265
|
-
#
|
266
|
-
#
|
267
|
-
#
|
268
|
-
#
|
469
|
+
#
|
470
|
+
# Server selects map items identified by value range (value_begin
|
471
|
+
# inclusive, value_end exclusive). If value_begin is null, the range is
|
472
|
+
# less than value_end. If value_end is null, the range is greater than
|
473
|
+
# equal to value_begin.
|
474
|
+
#
|
269
475
|
# Server returns selected data specified by return_type.
|
270
|
-
def self.
|
476
|
+
def self.get_by_value_range(bin_name, value_begin, value_end = nil, return_type: MapReturnType::NONE)
|
271
477
|
if value_end
|
272
478
|
MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_INTERVAL, bin_name, value_begin, value_end, return_type: return_type)
|
273
479
|
else
|
274
480
|
MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_INTERVAL, bin_name, value_begin, return_type: return_type)
|
275
481
|
end
|
276
482
|
end
|
483
|
+
singleton_class.send(:alias_method, :get_value_range, :get_by_value_range)
|
484
|
+
|
485
|
+
##
|
486
|
+
# Create map get by value relative to rank range operation.
|
487
|
+
#
|
488
|
+
# Server selects "count" map items nearest to value and greater by relative rank.
|
489
|
+
# If "count" is not specified, server selects map items nearest to value
|
490
|
+
# and greater by relative rank, until the end of the map.
|
491
|
+
#
|
492
|
+
# Server returns selected data specified by return_type.
|
493
|
+
#
|
494
|
+
# Examples for map [{4=2},{9=10},{5=15},{0=17}]:
|
495
|
+
#
|
496
|
+
# * (value, rank, count) = [selected items]
|
497
|
+
# * (11, 1, 1) = [{0=17}]
|
498
|
+
# * (11, -1, 1) = [{9=10}]
|
499
|
+
#
|
500
|
+
# Without count:
|
501
|
+
#
|
502
|
+
# * (value, rank) = [selected items]
|
503
|
+
# * (11, 1) = [{0=17}]
|
504
|
+
# * (11, -1) = [{9=10}, {5=15}, {0=17}]
|
505
|
+
def self.get_by_value_rel_rank_range(bin_name, value, rank, count = nil, return_type: nil)
|
506
|
+
if count
|
507
|
+
MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, count, return_type: return_type)
|
508
|
+
else
|
509
|
+
MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, return_type: return_type)
|
510
|
+
end
|
511
|
+
end
|
512
|
+
|
277
513
|
|
278
514
|
# Create map get by index operation.
|
279
|
-
#
|
280
|
-
|
515
|
+
#
|
516
|
+
# Server selects map item identified by index.
|
517
|
+
#
|
518
|
+
# Server returns selected data specified by return_type.
|
519
|
+
def self.get_by_index(bin_name, index, return_type: MapReturnType::NONE)
|
281
520
|
MapOperation.new(Operation::CDT_READ, GET_BY_INDEX, bin_name, index, return_type: return_type)
|
282
521
|
end
|
522
|
+
singleton_class.send(:alias_method, :get_index, :get_by_index)
|
283
523
|
|
284
524
|
# Create map get by index range operation.
|
285
|
-
#
|
286
|
-
#
|
287
|
-
# specified, server selects map items starting at
|
288
|
-
# end of map.
|
289
|
-
|
525
|
+
#
|
526
|
+
# Server selects "count" map items starting at specified index. If
|
527
|
+
# "count" is not specified, server selects map items starting at
|
528
|
+
# specified index to the end of map.
|
529
|
+
#
|
530
|
+
# Server returns selected data specified by return_type.
|
531
|
+
def self.get_by_index_range(bin_name, index, count = nil, return_type: MapReturnType::NONE)
|
290
532
|
if count
|
291
533
|
MapOperation.new(Operation::CDT_READ, GET_BY_INDEX_RANGE, bin_name, index, count, return_type: return_type)
|
292
534
|
else
|
293
535
|
MapOperation.new(Operation::CDT_READ, GET_BY_INDEX_RANGE, bin_name, index, return_type: return_type)
|
294
536
|
end
|
295
537
|
end
|
538
|
+
singleton_class.send(:alias_method, :get_index_range, :get_by_index_range)
|
296
539
|
|
297
540
|
# Create map get by rank operation.
|
298
|
-
#
|
299
|
-
#
|
541
|
+
#
|
542
|
+
# Server selects map item identified by rank.
|
543
|
+
#
|
544
|
+
# Server returns selected data specified by return_type.
|
300
545
|
def self.get_by_rank(bin_name, rank, return_type: MapReturnType::NONE)
|
301
546
|
MapOperation.new(Operation::CDT_READ, GET_BY_RANK, bin_name, rank, return_type: return_type)
|
302
547
|
end
|
303
548
|
|
304
549
|
# Create map get by rank range operation.
|
305
|
-
#
|
306
|
-
#
|
307
|
-
# server selects map items starting at specified rank
|
308
|
-
# item.
|
550
|
+
#
|
551
|
+
# Server selects "count" map items starting at specified rank. If "count"
|
552
|
+
# is not specified, server selects map items starting at specified rank
|
553
|
+
# to the last ranked item.
|
554
|
+
#
|
555
|
+
# Server returns selected data specified by return_type.
|
309
556
|
def self.get_by_rank_range(bin_name, rank, count = nil, return_type: MapReturnType::NONE)
|
310
557
|
if count
|
311
558
|
MapOperation.new(Operation::CDT_READ, GET_BY_RANK_RANGE, bin_name, rank, count, return_type: return_type)
|
@@ -332,9 +579,6 @@ module Aerospike
|
|
332
579
|
packer.write_raw_short(map_op)
|
333
580
|
args = arguments.dup
|
334
581
|
args.unshift(return_type) if return_type
|
335
|
-
if policy && policy.write_mode != MapWriteMode::UPDATE_ONLY
|
336
|
-
args << policy.value
|
337
|
-
end
|
338
582
|
if args.length > 0
|
339
583
|
packer.write_array_header(args.length)
|
340
584
|
args.each do |value|
|