aerospike 2.10.0 → 2.15.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 +50 -1
- data/README.md +1 -1
- data/lib/aerospike.rb +20 -4
- data/lib/aerospike/aerospike_exception.rb +7 -1
- data/lib/aerospike/atomic/atomic.rb +1 -1
- data/lib/aerospike/bin.rb +1 -1
- data/lib/aerospike/cdt/hll_operation.rb +200 -0
- data/lib/aerospike/cdt/hll_policy.rb +34 -0
- data/lib/aerospike/cdt/hll_write_flags.rb +53 -0
- data/lib/aerospike/cdt/list_operation.rb +1 -1
- data/lib/aerospike/cdt/map_operation.rb +1 -1
- data/lib/aerospike/cdt/map_order.rb +1 -1
- data/lib/aerospike/cdt/map_policy.rb +1 -1
- data/lib/aerospike/cdt/map_return_type.rb +1 -1
- data/lib/aerospike/cdt/map_write_mode.rb +1 -1
- data/lib/aerospike/client.rb +34 -18
- data/lib/aerospike/cluster.rb +139 -17
- data/lib/aerospike/cluster/partition.rb +1 -1
- data/lib/aerospike/cluster/partition_parser.rb +169 -0
- data/lib/aerospike/cluster/rack_parser.rb +117 -0
- data/lib/aerospike/command/admin_command.rb +1 -1
- data/lib/aerospike/command/batch_direct_command.rb +2 -1
- data/lib/aerospike/command/batch_direct_exists_command.rb +1 -1
- data/lib/aerospike/command/batch_direct_node.rb +3 -3
- data/lib/aerospike/command/batch_index_command.rb +11 -2
- data/lib/aerospike/command/batch_index_node.rb +2 -2
- data/lib/aerospike/command/batch_item.rb +1 -1
- data/lib/aerospike/command/command.rb +168 -11
- data/lib/aerospike/command/delete_command.rb +21 -5
- data/lib/aerospike/command/execute_command.rb +1 -1
- data/lib/aerospike/command/exists_command.rb +21 -5
- data/lib/aerospike/command/field_type.rb +3 -1
- data/lib/aerospike/command/multi_command.rb +55 -5
- data/lib/aerospike/command/operate_command.rb +6 -1
- data/lib/aerospike/command/read_command.rb +63 -20
- data/lib/aerospike/command/read_header_command.rb +18 -6
- data/lib/aerospike/command/roles.rb +1 -1
- data/lib/aerospike/command/single_command.rb +9 -3
- data/lib/aerospike/command/touch_command.rb +48 -4
- data/lib/aerospike/command/unsupported_particle_type_validator.rb +1 -1
- data/lib/aerospike/command/write_command.rb +13 -4
- data/lib/aerospike/connection/create.rb +1 -1
- data/lib/aerospike/features.rb +3 -1
- data/lib/aerospike/geo_json.rb +70 -1
- data/lib/aerospike/host.rb +1 -1
- data/lib/aerospike/info.rb +1 -1
- data/lib/aerospike/key.rb +1 -1
- data/lib/aerospike/language.rb +1 -1
- data/lib/aerospike/node.rb +21 -7
- data/lib/aerospike/node/rebalance.rb +50 -0
- data/lib/aerospike/node/refresh/info.rb +4 -1
- data/lib/aerospike/node/refresh/partitions.rb +6 -15
- data/lib/aerospike/node/refresh/racks.rb +47 -0
- data/lib/aerospike/node/refresh/reset.rb +1 -0
- data/lib/aerospike/node/verify/rebalance_generation.rb +43 -0
- data/lib/aerospike/node_validator.rb +4 -19
- data/lib/aerospike/operation.rb +8 -1
- data/lib/aerospike/policy/admin_policy.rb +1 -1
- data/lib/aerospike/policy/batch_policy.rb +1 -1
- data/lib/aerospike/policy/client_policy.rb +16 -1
- data/lib/aerospike/policy/commit_level.rb +1 -1
- data/lib/aerospike/policy/consistency_level.rb +1 -1
- data/lib/aerospike/policy/generation_policy.rb +1 -1
- data/lib/aerospike/policy/operate_policy.rb +1 -1
- data/lib/aerospike/policy/policy.rb +64 -2
- data/lib/aerospike/policy/priority.rb +1 -1
- data/lib/aerospike/policy/query_policy.rb +8 -1
- data/lib/aerospike/policy/record_bin_multiplicity.rb +1 -1
- data/lib/aerospike/policy/record_exists_action.rb +1 -1
- data/lib/aerospike/policy/replica.rb +45 -0
- data/lib/aerospike/policy/scan_policy.rb +8 -1
- data/lib/aerospike/policy/write_policy.rb +1 -1
- data/lib/aerospike/query/filter.rb +1 -1
- data/lib/aerospike/query/pred_exp.rb +192 -0
- data/lib/aerospike/query/pred_exp/and_or.rb +32 -0
- data/lib/aerospike/query/pred_exp/geo_json_value.rb +41 -0
- data/lib/aerospike/query/pred_exp/integer_value.rb +32 -0
- data/lib/aerospike/query/pred_exp/op.rb +27 -0
- data/lib/aerospike/query/pred_exp/regex.rb +32 -0
- data/lib/aerospike/query/pred_exp/regex_flags.rb +23 -0
- data/lib/aerospike/query/pred_exp/string_value.rb +29 -0
- data/lib/aerospike/query/query_command.rb +27 -1
- data/lib/aerospike/query/recordset.rb +5 -5
- data/lib/aerospike/query/scan_command.rb +1 -1
- data/lib/aerospike/query/statement.rb +12 -3
- data/lib/aerospike/query/stream_command.rb +1 -1
- data/lib/aerospike/record.rb +1 -1
- data/lib/aerospike/result_code.rb +26 -7
- data/lib/aerospike/socket/base.rb +4 -3
- data/lib/aerospike/task/execute_task.rb +1 -1
- data/lib/aerospike/task/index_task.rb +1 -1
- data/lib/aerospike/task/task.rb +1 -1
- data/lib/aerospike/task/udf_register_task.rb +1 -1
- data/lib/aerospike/task/udf_remove_task.rb +1 -1
- data/lib/aerospike/ttl.rb +1 -1
- data/lib/aerospike/udf.rb +1 -1
- data/lib/aerospike/user_role.rb +1 -1
- data/lib/aerospike/utils/buffer.rb +14 -4
- data/lib/aerospike/utils/packer.rb +1 -1
- data/lib/aerospike/utils/pool.rb +1 -1
- data/lib/aerospike/utils/unpacker.rb +7 -2
- data/lib/aerospike/value/particle_type.rb +2 -2
- data/lib/aerospike/value/value.rb +106 -29
- data/lib/aerospike/version.rb +1 -1
- metadata +22 -8
- data/lib/aerospike/cluster/partition_tokenizer_new.rb +0 -130
- data/lib/aerospike/cluster/partition_tokenizer_old.rb +0 -135
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 703f1af2ab5b0050745490618dc48f4f1135b457523ebe69b6c35d9111c67037
|
4
|
+
data.tar.gz: 9fba2d0c3a53c93a46f3fc1635f9fcabfa2e7804191cf9f20bf79c306099e6ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eba3f39bbfd7399f7e424894521aeed62cbd4b28e74f81b1d5207485eca59d236497d05c5f5dbfdfadd2e8e52c01eebcf4a06c71ea5eedf272f3ee6efd5f23b5
|
7
|
+
data.tar.gz: 3d2b651ccc051d95255acf0affdebd41822fcd0d36461653987186183bf84100a4507601eb5a640a0972827968b765645e31c6f6eb1f2f82b25f564704cb2aa7
|
data/CHANGELOG.md
CHANGED
@@ -2,7 +2,56 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
-
## [
|
5
|
+
## [2.15.0] - 2020-10-05
|
6
|
+
|
7
|
+
* **New Features**
|
8
|
+
* [CLIENT-1254] Adds support for HyperLogLog.
|
9
|
+
|
10
|
+
* **Changes**
|
11
|
+
* `Client#operate` now uses `OperatePolicy` by default.
|
12
|
+
|
13
|
+
## [2.14.0] - 2020-08-06
|
14
|
+
|
15
|
+
* **New Features**
|
16
|
+
* Adds support for rack-aware reads.
|
17
|
+
* Adds support for client-server compression.
|
18
|
+
|
19
|
+
* **Improvements**
|
20
|
+
* Adds support for `truncate-namespace` command.
|
21
|
+
|
22
|
+
## [2.13.0] - 2020-07-17
|
23
|
+
|
24
|
+
* **New Features**
|
25
|
+
* Adds support for replica policies.
|
26
|
+
|
27
|
+
* **Improvements**
|
28
|
+
* Remove support for "old" partition tokenizer.
|
29
|
+
* Refactor how partition parser is initialized and called.
|
30
|
+
* Adds support for 'replicas' and remove the old partition table queries from the server.
|
31
|
+
|
32
|
+
## [2.12.0] - 2019-04-21
|
33
|
+
|
34
|
+
* **New Features**
|
35
|
+
* Support for predicate expressions in all transaction.
|
36
|
+
* Support for `operation.delete` in `client#operate`.
|
37
|
+
|
38
|
+
* **Improvements**
|
39
|
+
* Optimize serialization for nested structures. Thanks to [@Kacper Madej](https://github.com/madejejej)! [[#94](https://github.com/aerospike/aerospike-client-ruby/pull/94)]
|
40
|
+
* Remove `Thread#abort_on_exception` from `batch_index_command`. Thanks to [@Kacper Madej](https://github.com/madejejej)! [[#94](https://github.com/aerospike/aerospike-client-ruby/pull/92)]
|
41
|
+
* Does not allow values other than Integer, Float, String, Symbol and nil to be used as keys in Maps.
|
42
|
+
|
43
|
+
* **Bug Fixes**
|
44
|
+
* Fixes tests that weren't using ENV variables for connections. This will allow the tests to be run on any server.
|
45
|
+
|
46
|
+
|
47
|
+
## [2.11.0] - 2019-05-17
|
48
|
+
|
49
|
+
* **New Features**
|
50
|
+
* Support for predicate expressions in queries. Thanks to [@Minus10Degrees](https://github.com/Minus10Degrees)! [[#78](https://github.com/aerospike/aerospike-client-ruby/issues/78)]
|
51
|
+
|
52
|
+
* **Bug Fixes**
|
53
|
+
* Client#execute\_udf\_on\_query should not modify the statement argument. [[#79](https://github.com/aerospike/aerospike-client-ruby/issues/79)]
|
54
|
+
* Encoding::UndefinedConversionError when reading blob data from CDT list/map bin. [[#84](https://github.com/aerospike/aerospike-client-ruby/issues/84)]
|
6
55
|
|
7
56
|
## [2.10.0] - 2019-05-10
|
8
57
|
|
data/README.md
CHANGED
@@ -97,7 +97,7 @@ This library is packaged with a number of tests.
|
|
97
97
|
|
98
98
|
To run all the test cases:
|
99
99
|
|
100
|
-
$ bundle exec rspec
|
100
|
+
$ AEROSPIKE_HOSTS="<host:port>[,<hoist:port>]" AEROSPIKE_USER="<user>" AEROSPIKE_PASSWORD="<pass>" bundle exec rspec
|
101
101
|
|
102
102
|
<a name="Examples"></a>
|
103
103
|
## Examples
|
data/lib/aerospike.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright 2014-
|
1
|
+
# Copyright 2014-2020 Aerospike, Inc.
|
2
2
|
#
|
3
3
|
# Portions may be licensed to Aerospike, Inc. under one or more contributor
|
4
4
|
# license agreements.
|
@@ -22,6 +22,7 @@ require "timeout"
|
|
22
22
|
require 'resolv'
|
23
23
|
require 'msgpack'
|
24
24
|
require 'bcrypt'
|
25
|
+
require 'zlib'
|
25
26
|
|
26
27
|
require 'aerospike/atomic/atomic'
|
27
28
|
|
@@ -76,6 +77,9 @@ require 'aerospike/cdt/map_return_type'
|
|
76
77
|
require 'aerospike/cdt/map_write_flags'
|
77
78
|
require 'aerospike/cdt/map_write_mode'
|
78
79
|
require 'aerospike/cdt/map_policy'
|
80
|
+
require 'aerospike/cdt/hll_operation'
|
81
|
+
require 'aerospike/cdt/hll_write_flags'
|
82
|
+
require 'aerospike/cdt/hll_policy'
|
79
83
|
require 'aerospike/geo_json'
|
80
84
|
require 'aerospike/ttl'
|
81
85
|
|
@@ -101,22 +105,25 @@ require 'aerospike/connection/create'
|
|
101
105
|
|
102
106
|
require 'aerospike/cluster'
|
103
107
|
require 'aerospike/cluster/create_connection'
|
104
|
-
require 'aerospike/cluster/partition'
|
105
108
|
require 'aerospike/cluster/find_nodes_to_remove'
|
106
109
|
require 'aerospike/cluster/find_node'
|
107
|
-
require 'aerospike/cluster/
|
108
|
-
require 'aerospike/cluster/
|
110
|
+
require 'aerospike/cluster/partition'
|
111
|
+
require 'aerospike/cluster/partition_parser'
|
112
|
+
require 'aerospike/cluster/rack_parser'
|
109
113
|
require 'aerospike/node'
|
110
114
|
require 'aerospike/node/generation'
|
115
|
+
require 'aerospike/node/rebalance'
|
111
116
|
require 'aerospike/node/refresh/failed'
|
112
117
|
require 'aerospike/node/refresh/friends'
|
113
118
|
require 'aerospike/node/refresh/info'
|
114
119
|
require 'aerospike/node/refresh/partitions'
|
120
|
+
require 'aerospike/node/refresh/racks'
|
115
121
|
require 'aerospike/node/refresh/peers'
|
116
122
|
require 'aerospike/node/refresh/reset'
|
117
123
|
require 'aerospike/node/verify/cluster_name'
|
118
124
|
require 'aerospike/node/verify/name'
|
119
125
|
require 'aerospike/node/verify/partition_generation'
|
126
|
+
require 'aerospike/node/verify/rebalance_generation'
|
120
127
|
require 'aerospike/node/verify/peers_generation'
|
121
128
|
require 'aerospike/node_validator'
|
122
129
|
require 'aerospike/peer'
|
@@ -142,6 +149,15 @@ require 'aerospike/query/stream_command'
|
|
142
149
|
require 'aerospike/query/query_command'
|
143
150
|
require 'aerospike/query/scan_command'
|
144
151
|
require 'aerospike/query/statement'
|
152
|
+
require 'aerospike/query/pred_exp'
|
153
|
+
|
154
|
+
require 'aerospike/query/pred_exp/and_or'
|
155
|
+
require 'aerospike/query/pred_exp/geo_json_value'
|
156
|
+
require 'aerospike/query/pred_exp/integer_value'
|
157
|
+
require 'aerospike/query/pred_exp/op'
|
158
|
+
require 'aerospike/query/pred_exp/regex'
|
159
|
+
require 'aerospike/query/pred_exp/regex_flags'
|
160
|
+
require 'aerospike/query/pred_exp/string_value'
|
145
161
|
|
146
162
|
module Aerospike
|
147
163
|
extend Loggable
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
# Copyright 2014-
|
2
|
+
# Copyright 2014-2020 Aerospike, Inc.
|
3
3
|
#
|
4
4
|
# Portions may be licensed to Aerospike, Inc. under one or more contributor
|
5
5
|
# license agreements.
|
@@ -90,5 +90,11 @@ module Aerospike
|
|
90
90
|
super(ResultCode::COMMAND_REJECTED, msg)
|
91
91
|
end
|
92
92
|
end
|
93
|
+
|
94
|
+
class InvalidNamespace < Aerospike
|
95
|
+
def initialize(msg=nil)
|
96
|
+
super(ResultCode::INVALID_NAMESPACE, msg)
|
97
|
+
end
|
98
|
+
end
|
93
99
|
end
|
94
100
|
end
|
data/lib/aerospike/bin.rb
CHANGED
@@ -0,0 +1,200 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Copyright 2016-2020 Aerospike, Inc.
|
3
|
+
#
|
4
|
+
# Portions may be licensed to Aerospike, Inc. under one or more contributor
|
5
|
+
# license agreements.
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
8
|
+
# use this file except in compliance with the License. You may obtain a copy of
|
9
|
+
# the License at http:#www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
13
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
14
|
+
# License for the specific language governing permissions and limitations under
|
15
|
+
# the License.
|
16
|
+
|
17
|
+
module Aerospike
|
18
|
+
module CDT
|
19
|
+
|
20
|
+
# HyperLogLog (HLL) operations.
|
21
|
+
# Requires server versions >= 4.9.
|
22
|
+
#
|
23
|
+
# HyperLogLog operations on HLL items nested in lists/maps are not currently
|
24
|
+
# supported by the server.
|
25
|
+
class HLLOperation < Operation
|
26
|
+
|
27
|
+
INIT = 0
|
28
|
+
ADD = 1
|
29
|
+
SET_UNION = 2
|
30
|
+
SET_COUNT = 3
|
31
|
+
FOLD = 4
|
32
|
+
COUNT = 50
|
33
|
+
UNION = 51
|
34
|
+
UNION_COUNT = 52
|
35
|
+
INTERSECT_COUNT = 53
|
36
|
+
SIMILARITY = 54
|
37
|
+
DESCRIBE = 55
|
38
|
+
|
39
|
+
attr_reader :hll_op, :values, :return_type, :policy, :index_bit_count, :minhash_bit_count
|
40
|
+
|
41
|
+
def initialize(op_type, hll_op, bin_name, values: nil, index_bit_count: nil, minhash_bit_count: nil, policy: nil)
|
42
|
+
@policy = policy
|
43
|
+
@op_type = op_type
|
44
|
+
@bin_name = bin_name
|
45
|
+
@bin_value = nil
|
46
|
+
@hll_op = hll_op
|
47
|
+
@index_bit_count = index_bit_count
|
48
|
+
@minhash_bit_count = minhash_bit_count
|
49
|
+
@values = values
|
50
|
+
|
51
|
+
self
|
52
|
+
end
|
53
|
+
|
54
|
+
##
|
55
|
+
# Create HLL init operation with minhash bits.
|
56
|
+
# Server creates a new HLL or resets an existing HLL.
|
57
|
+
# Server does not return a value.
|
58
|
+
#
|
59
|
+
# policy write policy, HLLPolicy::DEFAULT is default
|
60
|
+
# bin_name name of bin
|
61
|
+
# index_bit_count number of index bits. Must be between 4 and 16 inclusive.
|
62
|
+
# minhash_bit_count number of min hash bits. Must be between 4 and 58 inclusive.
|
63
|
+
def self.init(bin_name, index_bit_count, minhash_bit_count, policy = HLLPolicy::DEFAULT)
|
64
|
+
HLLOperation.new(Operation::HLL_MODIFY, INIT, bin_name, index_bit_count: index_bit_count, minhash_bit_count: minhash_bit_count, policy: policy)
|
65
|
+
end
|
66
|
+
|
67
|
+
##
|
68
|
+
# Create HLL add operation with minhash bits.
|
69
|
+
# Server adds values to HLL set. If HLL bin does not exist, use index_bit_count and minhash_bit_count
|
70
|
+
# to create HLL bin. Server returns number of entries that caused HLL to update a register.
|
71
|
+
#
|
72
|
+
# policy write policy, HLLPolicy::DEFAULT is default
|
73
|
+
# bin_name name of bin
|
74
|
+
# list list of values to be added
|
75
|
+
# index_bit_count number of index bits. Must be between 4 and 16 inclusive.
|
76
|
+
# minhash_bit_count number of min hash bits. Must be between 4 and 58 inclusive.
|
77
|
+
def self.add(bin_name, *values, policy: HLLPolicy::DEFAULT, index_bit_count: -1, minhash_bit_count: -1)
|
78
|
+
HLLOperation.new(Operation::HLL_MODIFY, ADD, bin_name, index_bit_count: index_bit_count, minhash_bit_count: minhash_bit_count, values: values, policy: policy)
|
79
|
+
end
|
80
|
+
|
81
|
+
##
|
82
|
+
# Create HLL set union operation.
|
83
|
+
# Server sets union of specified HLL objects with HLL bin.
|
84
|
+
# Server does not return a value.
|
85
|
+
#
|
86
|
+
# policy write policy, HLLPolicy::DEFAULT is default
|
87
|
+
# bin_name name of bin
|
88
|
+
# list list of HLL objects
|
89
|
+
def self.set_union(bin_name, *values, policy: HLLPolicy::DEFAULT)
|
90
|
+
HLLOperation.new(Operation::HLL_MODIFY, SET_UNION, bin_name, values: values, policy: policy)
|
91
|
+
end
|
92
|
+
|
93
|
+
##
|
94
|
+
# Create HLL refresh operation.
|
95
|
+
# Server updates the cached count (if stale) and returns the count.
|
96
|
+
#
|
97
|
+
# bin_name name of bin
|
98
|
+
def self.refresh_count(bin_name)
|
99
|
+
HLLOperation.new(Operation::HLL_MODIFY, SET_COUNT, bin_name)
|
100
|
+
end
|
101
|
+
|
102
|
+
##
|
103
|
+
# Create HLL fold operation.
|
104
|
+
# Servers folds index_bit_count to the specified value.
|
105
|
+
# This can only be applied when minhash_bit_count on the HLL bin is 0.
|
106
|
+
# Server does not return a value.
|
107
|
+
#
|
108
|
+
# bin_name name of bin
|
109
|
+
# index_bit_count number of index bits. Must be between 4 and 16 inclusive.
|
110
|
+
def self.fold(bin_name, index_bit_count)
|
111
|
+
HLLOperation.new(Operation::HLL_MODIFY, FOLD, bin_name, index_bit_count: index_bit_count)
|
112
|
+
end
|
113
|
+
|
114
|
+
##
|
115
|
+
# Create HLL getCount operation.
|
116
|
+
# Server returns estimated number of elements in the HLL bin.
|
117
|
+
#
|
118
|
+
# bin_name name of bin
|
119
|
+
def self.get_count(bin_name)
|
120
|
+
HLLOperation.new(Operation::HLL_READ, COUNT, bin_name)
|
121
|
+
end
|
122
|
+
|
123
|
+
##
|
124
|
+
# Create HLL getUnion operation.
|
125
|
+
# Server returns an HLL object that is the union of all specified HLL objects in the list
|
126
|
+
# with the HLL bin.
|
127
|
+
#
|
128
|
+
# bin_name name of bin
|
129
|
+
# list list of HLL objects
|
130
|
+
def self.get_union(bin_name, *values)
|
131
|
+
HLLOperation.new(Operation::HLL_READ, UNION, bin_name, values: values)
|
132
|
+
end
|
133
|
+
|
134
|
+
##
|
135
|
+
# Create HLL getUnionCount operation.
|
136
|
+
# Server returns estimated number of elements that would be contained by the union of these
|
137
|
+
# HLL objects.
|
138
|
+
# bin_name name of bin
|
139
|
+
# list list of HLL objects
|
140
|
+
def self.get_union_count(bin_name, *values)
|
141
|
+
HLLOperation.new(Operation::HLL_READ, UNION_COUNT, bin_name, values: values)
|
142
|
+
end
|
143
|
+
|
144
|
+
##
|
145
|
+
# Create HLL getIntersectCount operation.
|
146
|
+
# Server returns estimated number of elements that would be contained by the intersection of
|
147
|
+
# these HLL objects.
|
148
|
+
#
|
149
|
+
# bin_name name of bin
|
150
|
+
# list list of HLL objects
|
151
|
+
def self.get_intersect_count(bin_name, *values)
|
152
|
+
HLLOperation.new(Operation::HLL_READ, INTERSECT_COUNT, bin_name, values: values)
|
153
|
+
end
|
154
|
+
|
155
|
+
##
|
156
|
+
# Create HLL getSimilarity operation.
|
157
|
+
# Server returns estimated similarity of these HLL objects. Return type is a double.
|
158
|
+
#
|
159
|
+
# bin_name name of bin
|
160
|
+
# list list of HLL objects
|
161
|
+
def self.get_similarity(bin_name, *values)
|
162
|
+
HLLOperation.new(Operation::HLL_READ, SIMILARITY, bin_name, values: values)
|
163
|
+
end
|
164
|
+
|
165
|
+
##
|
166
|
+
# Create HLL describe operation.
|
167
|
+
# Server returns index_bit_count and minhash_bit_count used to create HLL bin in a list of longs.
|
168
|
+
# The list size is 2.
|
169
|
+
#
|
170
|
+
# bin_name name of bin
|
171
|
+
def self.describe(bin_name)
|
172
|
+
HLLOperation.new(Operation::HLL_READ, DESCRIBE, bin_name)
|
173
|
+
end
|
174
|
+
|
175
|
+
def bin_value
|
176
|
+
@bin_value ||= pack_bin_value
|
177
|
+
end
|
178
|
+
|
179
|
+
private
|
180
|
+
|
181
|
+
def pack_bin_value
|
182
|
+
bytes = nil
|
183
|
+
Packer.use do |packer|
|
184
|
+
args = [hll_op]
|
185
|
+
args << values if values
|
186
|
+
args << index_bit_count if index_bit_count
|
187
|
+
args << minhash_bit_count if minhash_bit_count
|
188
|
+
args << policy.flags if policy
|
189
|
+
|
190
|
+
vv = ListValue.new(args)
|
191
|
+
vv.pack(packer)
|
192
|
+
bytes = packer.bytes
|
193
|
+
end
|
194
|
+
BytesValue.new(bytes)
|
195
|
+
end
|
196
|
+
|
197
|
+
end
|
198
|
+
|
199
|
+
end
|
200
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2020 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 HLLPolicy
|
23
|
+
|
24
|
+
attr_accessor :flags
|
25
|
+
|
26
|
+
def initialize(write_flags: HLLWriteFlags::DEFAULT)
|
27
|
+
@flags = write_flags
|
28
|
+
end
|
29
|
+
|
30
|
+
DEFAULT = HLLPolicy.new
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Copyright 2020 Aerospike, Inc.
|
3
|
+
#
|
4
|
+
# Portions may be licensed to Aerospike, Inc. under one or more contributor
|
5
|
+
# license agreements.
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
8
|
+
# use this file except in compliance with the License. You may obtain a copy of
|
9
|
+
# the License at http:#www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
13
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
14
|
+
# License for the specific language governing permissions and limitations under
|
15
|
+
# the License.
|
16
|
+
|
17
|
+
module Aerospike
|
18
|
+
module CDT
|
19
|
+
|
20
|
+
##
|
21
|
+
# Map write bit flags.
|
22
|
+
# Requires server versions >= 4.3.
|
23
|
+
module HLLWriteFlags
|
24
|
+
|
25
|
+
##
|
26
|
+
# Default is Default. Allow create or update.
|
27
|
+
DEFAULT = 0
|
28
|
+
|
29
|
+
##
|
30
|
+
# CREATE_ONLY behaves like the following:
|
31
|
+
# If the bin already exists, the operation will be denied.
|
32
|
+
# If the bin does not exist, a new bin will be created.
|
33
|
+
CREATE_ONLY = 1
|
34
|
+
|
35
|
+
##
|
36
|
+
# UPDATE_ONLY behaves like the following:
|
37
|
+
# If the bin already exists, the bin will be overwritten.
|
38
|
+
# If the bin does not exist, the operation will be denied.
|
39
|
+
UPDATE_ONLY = 2
|
40
|
+
|
41
|
+
##
|
42
|
+
# NO_FAIL does not raise error if operation is denied.
|
43
|
+
NO_FAIL = 4
|
44
|
+
|
45
|
+
##
|
46
|
+
# ALLOW_FOLD allows the resulting set to be the minimum of provided index bits.
|
47
|
+
# Also, allow the usage of less precise HLL algorithms when minHash bits
|
48
|
+
# of all participating sets do not match.
|
49
|
+
ALLOW_FOLD = 8
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|