Class: Aerospike::CDT::HLLOperation
- Defined in:
- lib/aerospike/cdt/hll_operation.rb
Overview
HyperLogLog (HLL) operations. Requires server versions >= 4.9.
HyperLogLog operations on HLL items nested in lists/maps are not currently supported by the server.
Constant Summary collapse
- INIT =
0
- ADD =
1
- SET_UNION =
2
- SET_COUNT =
3
- FOLD =
4
- COUNT =
50
- UNION =
51
- UNION_COUNT =
52
- INTERSECT_COUNT =
53
- SIMILARITY =
54
- DESCRIBE =
55
Constants inherited from Operation
Operation::APPEND, Operation::BIT_MODIFY, Operation::BIT_READ, Operation::CDT_MODIFY, Operation::CDT_READ, Operation::DELETE, Operation::EXP_MODIFY, Operation::EXP_READ, Operation::HLL_MODIFY, Operation::HLL_READ, Operation::PREPEND, Operation::READ, Operation::READ_HEADER, Operation::TOUCH, Operation::WRITE
Instance Attribute Summary collapse
-
#hll_op ⇒ Object
readonly
Returns the value of attribute hll_op.
-
#index_bit_count ⇒ Object
readonly
Returns the value of attribute index_bit_count.
-
#minhash_bit_count ⇒ Object
readonly
Returns the value of attribute minhash_bit_count.
-
#policy ⇒ Object
readonly
Returns the value of attribute policy.
-
#return_type ⇒ Object
readonly
Returns the value of attribute return_type.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Attributes inherited from Operation
Class Method Summary collapse
-
.add(bin_name, *values, policy: HLLPolicy::DEFAULT, index_bit_count: -1,, minhash_bit_count: -1)) ⇒ Object
Create HLL add operation with minhash bits.
-
.describe(bin_name) ⇒ Object
Create HLL describe operation.
-
.fold(bin_name, index_bit_count) ⇒ Object
Create HLL fold operation.
-
.get_count(bin_name) ⇒ Object
Create HLL getCount operation.
-
.get_intersect_count(bin_name, *values) ⇒ Object
Create HLL getIntersectCount operation.
-
.get_similarity(bin_name, *values) ⇒ Object
Create HLL getSimilarity operation.
-
.get_union(bin_name, *values) ⇒ Object
Create HLL getUnion operation.
-
.get_union_count(bin_name, *values) ⇒ Object
Create HLL getUnionCount operation.
-
.init(bin_name, index_bit_count, minhash_bit_count, policy = HLLPolicy::DEFAULT) ⇒ Object
Create HLL init operation with minhash bits.
-
.refresh_count(bin_name) ⇒ Object
Create HLL refresh operation.
-
.set_union(bin_name, *values, policy: HLLPolicy::DEFAULT) ⇒ Object
Create HLL set union operation.
Instance Method Summary collapse
- #bin_value ⇒ Object
-
#initialize(op_type, hll_op, bin_name, values: nil, index_bit_count: nil, minhash_bit_count: nil, policy: nil) ⇒ HLLOperation
constructor
A new instance of HLLOperation.
Methods inherited from Operation
append, #bin, delete, get, get_header, #is_write?, prepend, put, touch
Constructor Details
#initialize(op_type, hll_op, bin_name, values: nil, index_bit_count: nil, minhash_bit_count: nil, policy: nil) ⇒ HLLOperation
Returns a new instance of HLLOperation.
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/aerospike/cdt/hll_operation.rb', line 41 def initialize(op_type, hll_op, bin_name, values: nil, index_bit_count: nil, minhash_bit_count: nil, policy: nil) @policy = policy @op_type = op_type @bin_name = bin_name @bin_value = nil @hll_op = hll_op @index_bit_count = index_bit_count @minhash_bit_count = minhash_bit_count @values = values self end |
Instance Attribute Details
#hll_op ⇒ Object (readonly)
Returns the value of attribute hll_op.
39 40 41 |
# File 'lib/aerospike/cdt/hll_operation.rb', line 39 def hll_op @hll_op end |
#index_bit_count ⇒ Object (readonly)
Returns the value of attribute index_bit_count.
39 40 41 |
# File 'lib/aerospike/cdt/hll_operation.rb', line 39 def index_bit_count @index_bit_count end |
#minhash_bit_count ⇒ Object (readonly)
Returns the value of attribute minhash_bit_count.
39 40 41 |
# File 'lib/aerospike/cdt/hll_operation.rb', line 39 def minhash_bit_count @minhash_bit_count end |
#policy ⇒ Object (readonly)
Returns the value of attribute policy.
39 40 41 |
# File 'lib/aerospike/cdt/hll_operation.rb', line 39 def policy @policy end |
#return_type ⇒ Object (readonly)
Returns the value of attribute return_type.
39 40 41 |
# File 'lib/aerospike/cdt/hll_operation.rb', line 39 def return_type @return_type end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
39 40 41 |
# File 'lib/aerospike/cdt/hll_operation.rb', line 39 def values @values end |
Class Method Details
.add(bin_name, *values, policy: HLLPolicy::DEFAULT, index_bit_count: -1,, minhash_bit_count: -1)) ⇒ Object
Create HLL add operation with minhash bits. Server adds values to HLL set. If HLL bin does not exist, use index_bit_count and minhash_bit_count to create HLL bin. Server returns number of entries that caused HLL to update a register.
policy write policy, HLLPolicy::DEFAULT is default bin_name name of bin list list of values to be added index_bit_count number of index bits. Must be between 4 and 16 inclusive. minhash_bit_count number of min hash bits. Must be between 4 and 58 inclusive.
77 78 79 |
# File 'lib/aerospike/cdt/hll_operation.rb', line 77 def self.add(bin_name, *values, policy: HLLPolicy::DEFAULT, index_bit_count: -1, minhash_bit_count: -1) HLLOperation.new(Operation::HLL_MODIFY, ADD, bin_name, index_bit_count: index_bit_count, minhash_bit_count: minhash_bit_count, values: values, policy: policy) end |
.describe(bin_name) ⇒ Object
Create HLL describe operation. Server returns index_bit_count and minhash_bit_count used to create HLL bin in a list of longs. The list size is 2.
bin_name name of bin
171 172 173 |
# File 'lib/aerospike/cdt/hll_operation.rb', line 171 def self.describe(bin_name) HLLOperation.new(Operation::HLL_READ, DESCRIBE, bin_name) end |
.fold(bin_name, index_bit_count) ⇒ Object
Create HLL fold operation. Servers folds index_bit_count to the specified value. This can only be applied when minhash_bit_count on the HLL bin is 0. Server does not return a value.
bin_name name of bin index_bit_count number of index bits. Must be between 4 and 16 inclusive.
110 111 112 |
# File 'lib/aerospike/cdt/hll_operation.rb', line 110 def self.fold(bin_name, index_bit_count) HLLOperation.new(Operation::HLL_MODIFY, FOLD, bin_name, index_bit_count: index_bit_count) end |
.get_count(bin_name) ⇒ Object
Create HLL getCount operation. Server returns estimated number of elements in the HLL bin.
bin_name name of bin
119 120 121 |
# File 'lib/aerospike/cdt/hll_operation.rb', line 119 def self.get_count(bin_name) HLLOperation.new(Operation::HLL_READ, COUNT, bin_name) end |
.get_intersect_count(bin_name, *values) ⇒ Object
Create HLL getIntersectCount operation. Server returns estimated number of elements that would be contained by the intersection of these HLL objects.
bin_name name of bin list list of HLL objects
151 152 153 |
# File 'lib/aerospike/cdt/hll_operation.rb', line 151 def self.get_intersect_count(bin_name, *values) HLLOperation.new(Operation::HLL_READ, INTERSECT_COUNT, bin_name, values: values) end |
.get_similarity(bin_name, *values) ⇒ Object
Create HLL getSimilarity operation. Server returns estimated similarity of these HLL objects. Return type is a double.
bin_name name of bin list list of HLL objects
161 162 163 |
# File 'lib/aerospike/cdt/hll_operation.rb', line 161 def self.get_similarity(bin_name, *values) HLLOperation.new(Operation::HLL_READ, SIMILARITY, bin_name, values: values) end |
.get_union(bin_name, *values) ⇒ Object
Create HLL getUnion operation. Server returns an HLL object that is the union of all specified HLL objects in the list with the HLL bin.
bin_name name of bin list list of HLL objects
130 131 132 |
# File 'lib/aerospike/cdt/hll_operation.rb', line 130 def self.get_union(bin_name, *values) HLLOperation.new(Operation::HLL_READ, UNION, bin_name, values: values) end |
.get_union_count(bin_name, *values) ⇒ Object
Create HLL getUnionCount operation. Server returns estimated number of elements that would be contained by the union of these HLL objects. bin_name name of bin list list of HLL objects
140 141 142 |
# File 'lib/aerospike/cdt/hll_operation.rb', line 140 def self.get_union_count(bin_name, *values) HLLOperation.new(Operation::HLL_READ, UNION_COUNT, bin_name, values: values) end |
.init(bin_name, index_bit_count, minhash_bit_count, policy = HLLPolicy::DEFAULT) ⇒ Object
Create HLL init operation with minhash bits. Server creates a new HLL or resets an existing HLL. Server does not return a value.
policy write policy, HLLPolicy::DEFAULT is default bin_name name of bin index_bit_count number of index bits. Must be between 4 and 16 inclusive. minhash_bit_count number of min hash bits. Must be between 4 and 58 inclusive.
63 64 65 |
# File 'lib/aerospike/cdt/hll_operation.rb', line 63 def self.init(bin_name, index_bit_count, minhash_bit_count, policy = HLLPolicy::DEFAULT) HLLOperation.new(Operation::HLL_MODIFY, INIT, bin_name, index_bit_count: index_bit_count, minhash_bit_count: minhash_bit_count, policy: policy) end |
.refresh_count(bin_name) ⇒ Object
Create HLL refresh operation. Server updates the cached count (if stale) and returns the count.
bin_name name of bin
98 99 100 |
# File 'lib/aerospike/cdt/hll_operation.rb', line 98 def self.refresh_count(bin_name) HLLOperation.new(Operation::HLL_MODIFY, SET_COUNT, bin_name) end |
.set_union(bin_name, *values, policy: HLLPolicy::DEFAULT) ⇒ Object
Create HLL set union operation. Server sets union of specified HLL objects with HLL bin. Server does not return a value.
policy write policy, HLLPolicy::DEFAULT is default bin_name name of bin list list of HLL objects
89 90 91 |
# File 'lib/aerospike/cdt/hll_operation.rb', line 89 def self.set_union(bin_name, *values, policy: HLLPolicy::DEFAULT) HLLOperation.new(Operation::HLL_MODIFY, SET_UNION, bin_name, values: values, policy: policy) end |
Instance Method Details
#bin_value ⇒ Object
175 176 177 |
# File 'lib/aerospike/cdt/hll_operation.rb', line 175 def bin_value @bin_value ||= pack_bin_value end |