Class: Aerospike::CDT::MapOperation
- Defined in:
- lib/aerospike/cdt/map_operation.rb
Constant Summary collapse
- SET_TYPE =
64- ADD =
65- ADD_ITEMS =
66- PUT =
67- PUT_ITEMS =
68- REPLACE =
69- REPLACE_ITEMS =
70- INCREMENT =
73- DECREMENT =
74- CLEAR =
75- REMOVE_BY_KEY =
76- REMOVE_BY_INDEX =
77- REMOVE_BY_RANK =
79- REMOVE_BY_KEY_LIST =
81- REMOVE_BY_VALUE =
82- REMOVE_BY_VALUE_LIST =
83- REMOVE_BY_KEY_INTERVAL =
84- REMOVE_BY_INDEX_RANGE =
85- REMOVE_BY_VALUE_INTERVAL =
86- REMOVE_BY_RANK_RANGE =
87- SIZE =
96- GET_BY_KEY =
97- GET_BY_INDEX =
98- GET_BY_RANK =
100- GET_BY_VALUE =
102- GET_BY_KEY_INTERVAL =
103- GET_BY_INDEX_RANGE =
104- GET_BY_VALUE_INTERVAL =
105- GET_BY_RANK_RANGE =
106
Constants inherited from Operation
Operation::APPEND, Operation::CDT_MODIFY, Operation::CDT_READ, Operation::PREPEND, Operation::READ, Operation::READ_HEADER, Operation::TOUCH, Operation::WRITE
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#map_op ⇒ Object
readonly
Returns the value of attribute map_op.
-
#policy ⇒ Object
readonly
Returns the value of attribute policy.
-
#return_type ⇒ Object
readonly
Returns the value of attribute return_type.
Attributes inherited from Operation
Class Method Summary collapse
-
.clear(bin_name) ⇒ Object
Create map clear operation.
-
.decrement(bin_name, key, decr, policy: MapPolicy::DEFAULT) ⇒ Object
Create map decrement operation.
-
.get_by_rank(bin_name, rank, return_type: MapReturnType::NONE) ⇒ Object
Create map get by rank operation.
-
.get_by_rank_range(bin_name, rank, count = nil, return_type: MapReturnType::NONE) ⇒ Object
Create map get by rank range operation.
-
.get_index(bin_name, index, return_type: MapReturnType::NONE) ⇒ Object
Create map get by index operation.
-
.get_index_range(bin_name, index, count = nil, return_type: MapReturnType::NONE) ⇒ Object
Create map get by index range operation.
-
.get_key(bin_name, key, return_type: MapReturnType::NONE) ⇒ Object
Create map get by key operation.
-
.get_key_range(bin_name, key_begin, key_end = nil, return_type: MapReturnType::NONE) ⇒ Object
Create map get by key range operation.
-
.get_value(bin_name, value, return_type: MapReturnType::NONE) ⇒ Object
Create map get by value operation.
-
.get_value_range(bin_name, value_begin, value_end = nil, return_type: MapReturnType::NONE) ⇒ Object
Create map get by value range operation.
-
.increment(bin_name, key, incr, policy: MapPolicy::DEFAULT) ⇒ Object
Create map increment operation.
-
.put(bin_name, key, value, policy: MapPolicy::DEFAULT) ⇒ Object
Create map put operation.
-
.put_items(bin_name, values, policy: MapPolicy::DEFAULT) ⇒ Object
Create map put items operation Server writes each map item to map bin and returns map size.
-
.remove_by_rank(bin_name, rank, return_type: MapReturnType::NONE) ⇒ Object
Create map remove operation.
-
.remove_by_rank_range(bin_name, rank, count = nil, return_type: MapReturnType::NONE) ⇒ Object
Create map remove operation.
-
.remove_index(bin_name, index, return_type: MapReturnType::NONE) ⇒ Object
Create map remove operation.
-
.remove_index_range(bin_name, index, count = nil, return_type: MapReturnType::NONE) ⇒ Object
Create map remove operation.
-
.remove_key_range(bin_name, key_begin, key_end = nil, return_type: MapReturnType::NONE) ⇒ Object
Create map remove operation.
-
.remove_keys(bin_name, *keys, return_type: MapReturnType::NONE) ⇒ Object
Create map remove operation.
-
.remove_value_range(bin_name, value_begin, value_end = nil, return_type: MapReturnType::NONE) ⇒ Object
Create map remove operation.
-
.remove_values(bin_name, *values, return_type: MapReturnType::NONE) ⇒ Object
Create map remove operation.
-
.set_policy(bin_name, policy) ⇒ Object
Create set map policy operation.
-
.size(bin_name) ⇒ Object
Create map size operation.
Instance Method Summary collapse
- #and_return(return_type) ⇒ Object
- #bin_value ⇒ Object
-
#initialize(op_type, map_op, bin_name, *arguments, policy: nil, return_type: nil) ⇒ MapOperation
constructor
A new instance of MapOperation.
Methods inherited from Operation
add, append, #bin, get, get_header, prepend, touch
Constructor Details
#initialize(op_type, map_op, bin_name, *arguments, policy: nil, return_type: nil) ⇒ MapOperation
Returns a new instance of MapOperation.
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/aerospike/cdt/map_operation.rb', line 54 def initialize(op_type, map_op, bin_name, *arguments, policy: nil, return_type: nil) @op_type = op_type @bin_name = bin_name @bin_value = nil @map_op = map_op @arguments = arguments @policy = policy @return_type = return_type self end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
52 53 54 |
# File 'lib/aerospike/cdt/map_operation.rb', line 52 def arguments @arguments end |
#map_op ⇒ Object (readonly)
Returns the value of attribute map_op.
52 53 54 |
# File 'lib/aerospike/cdt/map_operation.rb', line 52 def map_op @map_op end |
#policy ⇒ Object (readonly)
Returns the value of attribute policy.
52 53 54 |
# File 'lib/aerospike/cdt/map_operation.rb', line 52 def policy @policy end |
#return_type ⇒ Object (readonly)
Returns the value of attribute return_type.
52 53 54 |
# File 'lib/aerospike/cdt/map_operation.rb', line 52 def return_type @return_type end |
Class Method Details
.clear(bin_name) ⇒ Object
Create map clear operation. Server removes all items in map. Server returns null.
133 134 135 |
# File 'lib/aerospike/cdt/map_operation.rb', line 133 def self.clear(bin_name) MapOperation.new(Operation::CDT_MODIFY, CLEAR, bin_name) end |
.decrement(bin_name, key, decr, policy: MapPolicy::DEFAULT) ⇒ Object
Create map decrement operation. Server decrements values by decr for all items identified by key and returns final result. Valid only for numbers.
The map policy dictates the type of map to create when it does not exist. The map policy also specifies the mode used when writing items to the map.
126 127 128 |
# File 'lib/aerospike/cdt/map_operation.rb', line 126 def self.decrement(bin_name, key, decr, policy: MapPolicy::DEFAULT) MapOperation.new(Operation::CDT_MODIFY, DECREMENT, bin_name, key, decr, policy: policy) end |
.get_by_rank(bin_name, rank, return_type: MapReturnType::NONE) ⇒ Object
Create map get by rank operation. Server selects map item identified by rank and returns selected data specified by return_type.
300 301 302 |
# File 'lib/aerospike/cdt/map_operation.rb', line 300 def self.get_by_rank(bin_name, rank, return_type: MapReturnType::NONE) MapOperation.new(Operation::CDT_READ, GET_BY_RANK, bin_name, rank, return_type: return_type) end |
.get_by_rank_range(bin_name, rank, count = nil, return_type: MapReturnType::NONE) ⇒ Object
Create map get by rank range operation. Server selects “count” map items starting at specified rank and returns selected data specified by returnType. If “count” is not specified, server selects map items starting at specified rank to the last ranked item.
309 310 311 312 313 314 315 |
# File 'lib/aerospike/cdt/map_operation.rb', line 309 def self.get_by_rank_range(bin_name, rank, count = nil, return_type: MapReturnType::NONE) if count MapOperation.new(Operation::CDT_READ, GET_BY_RANK_RANGE, bin_name, rank, count, return_type: return_type) else MapOperation.new(Operation::CDT_READ, GET_BY_RANK_RANGE, bin_name, rank, return_type: return_type) end end |
.get_index(bin_name, index, return_type: MapReturnType::NONE) ⇒ Object
Create map get by index operation. Server selects map item identified by index and returns selected data specified by return_type.
280 281 282 |
# File 'lib/aerospike/cdt/map_operation.rb', line 280 def self.get_index(bin_name, index, return_type: MapReturnType::NONE) MapOperation.new(Operation::CDT_READ, GET_BY_INDEX, bin_name, index, return_type: return_type) end |
.get_index_range(bin_name, index, count = nil, return_type: MapReturnType::NONE) ⇒ Object
Create map get by index range operation. Server selects “count” map items starting at specified index and returns selected data specified by return_type. If “count” is not specified, server selects map items starting at specified index to the end of map.
289 290 291 292 293 294 295 |
# File 'lib/aerospike/cdt/map_operation.rb', line 289 def self.get_index_range(bin_name, index, count = nil, return_type: MapReturnType::NONE) if count MapOperation.new(Operation::CDT_READ, GET_BY_INDEX_RANGE, bin_name, index, count, return_type: return_type) else MapOperation.new(Operation::CDT_READ, GET_BY_INDEX_RANGE, bin_name, index, return_type: return_type) end end |
.get_key(bin_name, key, return_type: MapReturnType::NONE) ⇒ Object
Create map get by key operation. Server selects map item identified by key and returns selected data specified by return_type.
240 241 242 |
# File 'lib/aerospike/cdt/map_operation.rb', line 240 def self.get_key(bin_name, key, return_type: MapReturnType::NONE) MapOperation.new(Operation::CDT_READ, GET_BY_KEY, bin_name, key, return_type: return_type) end |
.get_key_range(bin_name, key_begin, key_end = nil, return_type: MapReturnType::NONE) ⇒ Object
Create map get by key range operation. Server selects map items identified by key range (key_begin inclusive, key_end exclusive). If key_begin is null, the range is less than key_end. If key_end is null, the range is greater than equal to key_begin. <p> Server returns selected data specified by return_type.
250 251 252 253 254 255 256 |
# File 'lib/aerospike/cdt/map_operation.rb', line 250 def self.get_key_range(bin_name, key_begin, key_end = nil, return_type: MapReturnType::NONE) if key_end MapOperation.new(Operation::CDT_READ, GET_BY_KEY_INTERVAL, bin_name, key_begin, key_end, return_type: return_type) else MapOperation.new(Operation::CDT_READ, GET_BY_KEY_INTERVAL, bin_name, key_begin, return_type: return_type) end end |
.get_value(bin_name, value, return_type: MapReturnType::NONE) ⇒ Object
Create map get by value operation. Server selects map items identified by value and returns selected data specified by return_type.
260 261 262 |
# File 'lib/aerospike/cdt/map_operation.rb', line 260 def self.get_value(bin_name, value, return_type: MapReturnType::NONE) MapOperation.new(Operation::CDT_READ, GET_BY_VALUE, bin_name, value, return_type: return_type) end |
.get_value_range(bin_name, value_begin, value_end = nil, return_type: MapReturnType::NONE) ⇒ Object
Create map get by value range operation. Server selects map items identified by value range (value_begin inclusive, value_end exclusive) If value_begin is null, the range is less than value_end. If value_end is null, the range is greater than equal to value_begin. <p> Server returns selected data specified by return_type.
270 271 272 273 274 275 276 |
# File 'lib/aerospike/cdt/map_operation.rb', line 270 def self.get_value_range(bin_name, value_begin, value_end = nil, return_type: MapReturnType::NONE) if value_end MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_INTERVAL, bin_name, value_begin, value_end, return_type: return_type) else MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_INTERVAL, bin_name, value_begin, return_type: return_type) end end |
.increment(bin_name, key, incr, policy: MapPolicy::DEFAULT) ⇒ Object
Create map increment operation. Server increments values by incr for all items identified by key and returns final result. Valid only for numbers.
The map policy dictates the type of map to create when it does not exist. The map policy also specifies the mode used when writing items to the map.
115 116 117 |
# File 'lib/aerospike/cdt/map_operation.rb', line 115 def self.increment(bin_name, key, incr, policy: MapPolicy::DEFAULT) MapOperation.new(Operation::CDT_MODIFY, INCREMENT, bin_name, key, incr, policy: policy) end |
.put(bin_name, key, value, policy: MapPolicy::DEFAULT) ⇒ Object
Create map put operation. Server writes key/value item to map bin and returns map size.
The map policy dictates the type of map to create when it does not exist. The map policy also specifies the mode used when writing items to the map.
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/aerospike/cdt/map_operation.rb', line 80 def self.put(bin_name, key, value, policy: MapPolicy::DEFAULT) cmd = case policy.write_mode when MapWriteMode::UPDATE then PUT when MapWriteMode::UPDATE_ONLY then REPLACE when MapWriteMode::CREATE_ONLY then ADD else PUT end MapOperation.new(Operation::CDT_MODIFY, cmd, bin_name, key, value, policy: policy) end |
.put_items(bin_name, values, policy: MapPolicy::DEFAULT) ⇒ Object
Create map put items operation Server writes each map item to map bin and returns map size.
The map policy dictates the type of map to create when it does not exist. The map policy also specifies the mode used when writing items to the map.
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/aerospike/cdt/map_operation.rb', line 97 def self.put_items(bin_name, values, policy: MapPolicy::DEFAULT) cmd = case policy.write_mode when MapWriteMode::UPDATE then PUT_ITEMS when MapWriteMode::UPDATE_ONLY then REPLACE_ITEMS when MapWriteMode::CREATE_ONLY then ADD_ITEMS else PUT_ITEMS end MapOperation.new(Operation::CDT_MODIFY, cmd, bin_name, values, policy: policy) end |
.remove_by_rank(bin_name, rank, return_type: MapReturnType::NONE) ⇒ Object
Create map remove operation. Server removes map item identified by rank and returns removed data specified by return_type.
213 214 215 |
# File 'lib/aerospike/cdt/map_operation.rb', line 213 def self.remove_by_rank(bin_name, rank, return_type: MapReturnType::NONE) MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_RANK, bin_name, rank, return_type: return_type) end |
.remove_by_rank_range(bin_name, rank, count = nil, return_type: MapReturnType::NONE) ⇒ Object
Create map remove operation. Server selects “count” map items starting at specified rank and returns selected data specified by return_type. If “count” is not specified, server removes map items starting at specified rank to the last ranked.
222 223 224 225 226 227 228 |
# File 'lib/aerospike/cdt/map_operation.rb', line 222 def self.remove_by_rank_range(bin_name, rank, count = nil, return_type: MapReturnType::NONE) if count MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_RANK_RANGE, bin_name, rank, count, return_type: return_type) else MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_RANK_RANGE, bin_name, rank, return_type: return_type) end end |
.remove_index(bin_name, index, return_type: MapReturnType::NONE) ⇒ Object
Create map remove operation. Server removes map item identified by index and returns removed data specified by return_type.
192 193 194 |
# File 'lib/aerospike/cdt/map_operation.rb', line 192 def self.remove_index(bin_name, index, return_type: MapReturnType::NONE) MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX, bin_name, index, return_type: return_type) end |
.remove_index_range(bin_name, index, count = nil, return_type: MapReturnType::NONE) ⇒ Object
Create map remove operation. Server removes “count” map items starting at specified index and returns removed data specified by return_type. If “count” is not specified, the server selects map items starting at specified index to the end of map.
202 203 204 205 206 207 208 |
# File 'lib/aerospike/cdt/map_operation.rb', line 202 def self.remove_index_range(bin_name, index, count = nil, return_type: MapReturnType::NONE) if count MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX_RANGE, bin_name, index, count, return_type: return_type) else MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX_RANGE, bin_name, index, return_type: return_type) end end |
.remove_key_range(bin_name, key_begin, key_end = nil, return_type: MapReturnType::NONE) ⇒ Object
Create map remove operation. Server removes map items identified by key range (key_begin inclusive, key_end exclusive). If key_begin is null, the range is less than key_end. If key_end is null, the range is greater than equal to key_begin.
Server returns removed data specified by return_type.
155 156 157 158 159 160 161 |
# File 'lib/aerospike/cdt/map_operation.rb', line 155 def self.remove_key_range(bin_name, key_begin, key_end = nil, return_type: MapReturnType::NONE) if key_end MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_INTERVAL, bin_name, key_begin, key_end, return_type: return_type) else MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_INTERVAL, bin_name, key_begin, return_type: return_type) end end |
.remove_keys(bin_name, *keys, return_type: MapReturnType::NONE) ⇒ Object
Create map remove operation. Server removes map item identified by key and returns removed data specified by return_type.
140 141 142 143 144 145 146 |
# File 'lib/aerospike/cdt/map_operation.rb', line 140 def self.remove_keys(bin_name, *keys, return_type: MapReturnType::NONE) if keys.length > 1 MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_LIST, bin_name, keys, return_type: return_type) else MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY, bin_name, keys.first, return_type: return_type) end end |
.remove_value_range(bin_name, value_begin, value_end = nil, return_type: MapReturnType::NONE) ⇒ Object
Create map remove operation. Server removes map items identified by value range (value_begin inclusive, value_end exclusive). If value_begin is null, the range is less than value_end. If value_end is null, the range is greater than equal to value_begin.
Server returns removed data specified by return_type.
181 182 183 184 185 186 187 |
# File 'lib/aerospike/cdt/map_operation.rb', line 181 def self.remove_value_range(bin_name, value_begin, value_end = nil, return_type: MapReturnType::NONE) if value_end MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_INTERVAL, bin_name, value_begin, value_end, return_type: return_type) else MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_INTERVAL, bin_name, value_begin, return_type: return_type) end end |
.remove_values(bin_name, *values, return_type: MapReturnType::NONE) ⇒ Object
Create map remove operation. Server removes map items identified by value and returns removed data specified by return_type.
166 167 168 169 170 171 172 |
# File 'lib/aerospike/cdt/map_operation.rb', line 166 def self.remove_values(bin_name, *values, return_type: MapReturnType::NONE) if values.length > 1 MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_LIST, bin_name, values, return_type: return_type) else MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE, bin_name, values.first, return_type: return_type) end end |
.set_policy(bin_name, policy) ⇒ Object
Create set map policy operation. Server sets map policy attributes. Server returns null.
The required map policy attributes can be changed after the map is created.
70 71 72 |
# File 'lib/aerospike/cdt/map_operation.rb', line 70 def self.set_policy(bin_name, policy) MapOperation.new(Operation::CDT_MODIFY, SET_TYPE, bin_name, policy: policy) end |
.size(bin_name) ⇒ Object
Create map size operation. Server returns size of map.
233 234 235 |
# File 'lib/aerospike/cdt/map_operation.rb', line 233 def self.size(bin_name) MapOperation.new(Operation::CDT_READ, SIZE, bin_name) end |
Instance Method Details
#and_return(return_type) ⇒ Object
317 318 319 320 321 |
# File 'lib/aerospike/cdt/map_operation.rb', line 317 def and_return(return_type) @return_type = return_type @bin_value = nil self end |
#bin_value ⇒ Object
323 324 325 |
# File 'lib/aerospike/cdt/map_operation.rb', line 323 def bin_value @bin_value ||= pack_bin_value end |