HyperLogLog expressions
For the complete documentation index see: llms.txt
All documentation pages available in markdown.
HyperLogLog (HLL) expressions run the same read and modify operations as the HLL data type — estimated cardinality, union, intersection, similarity, describe, may-contain — inside an expression tree rather than against a named bin.
Read expressions (hll_get_count, hll_get_union, …) evaluate to an integer, float, list, or HLL value. That makes them projection: they shape what a command returns for each record, in operate, in a batch, and in a query. Wrap one in comparison or logic to get the Boolean a record filter needs.
Modify expressions (hll_add, hll_update, …) evaluate to a new HLL value and leave the record untouched. Storing that value takes a write operation expression; see Operations and expressions for how the two APIs differ.
An HLL operand is a bin, read with bin_hll, or any expression that evaluates to an HLL. Reading stored data can evaluate to unknown; see Unknown results.
The Developer SDK’s AEL text syntax exposes the same HLL read functions as path methods, for example $.h.hllCount() > 1000000.
Composing expressions
An expression evaluates to a value, and that value is what the next expression operates on — see Expressions compose.
hll_add is the clearest case: it evaluates to an HLL value, and hll_get_count counts that value, neither of them touching the record. Most HLL operations take a nested expression as their bin operand the same way, including the union and intersection reads.
hll_describe composes in the other direction. It evaluates to a two-element list, so pair it with a list read such as list_get_by_index to pull out the index bit count or the MinHash bit count on its own.
Each operation’s Example shows the code in nine tabs: Aerospike Expression Language (AEL) text on the Java SDK and Python SDK tabs, and the Exp builder on the other seven. See the AEL reference for AEL grammar.
Modify
hll_add(policy, items, index_bit_count, bin)Returns the HLL that bin evaluates to, with items added. It cannot bring a sketch into existence: if bin names a record bin that does not exist, the expression returns AS_ERR_OP_NOT_APPLICABLE.
| Name | Type | Description |
|---|---|---|
policy | HLL policy | Write policy for the transform. Supplied by your client as an HLL policy object. |
items | list | Elements to add to the sketch. |
index_bit_count | integer | Number of index bits, between 4 and 16. It has no effect here: it sizes a sketch at creation, and this expression cannot create one. Use |
bin | hll | HLL bin to operate on, or any expression that evaluates to an HLL. |
hll Add string ids from list bin new_user_ids into the existing visitors sketch, then require a non-zero estimated count.
String exp = "$.visitors.hllAdd($.new_user_ids, indexBits: 10).hllCount() > 0";exp = "$.visitors.hllAdd($.new_user_ids, indexBits: 10).hllCount() > 0"use aerospike::expressions::hll as hll_exp;use aerospike::expressions::{gt, hll_bin, int_val, list_bin};use aerospike::operations::hll::HLLPolicy;
let exp = gt( hll_exp::get_count( hll_exp::add_with_index( HLLPolicy::default(), list_bin("new_user_ids".into()), int_val(10), hll_bin("visitors".into()))), int_val(0));Expression exp = Exp.Build( Exp.GT( HLLExp.GetCount( HLLExp.Add( HLLPolicy.Default, Exp.ListBin("new_user_ids"), Exp.Val(10), Exp.HLLBin("visitors"))), Exp.Val(0)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"added := as.ExpHLLAddWithIndex( as.DefaultHLLPolicy(), as.ExpListBin("new_user_ids"), as.ExpIntVal(10), as.ExpHLLBin("visitors"),)exp := as.ExpGreater(as.ExpHLLGetCount(added), as.ExpIntVal(0))const exp = Aerospike.exp
const added = exp.hll.add( exp.binHll('visitors'), 10, exp.binList('new_user_ids'), null,)const filterExp = exp.gt(exp.hll.getCount(added), exp.int(0))as_exp_build(predexp, as_exp_cmp_gt( as_exp_hll_get_count( as_exp_hll_add( NULL, as_exp_bin_list("new_user_ids"), 10, as_exp_bin_hll("visitors"))), as_exp_int(0)));import com.aerospike.client.operation.HLLPolicy;import com.aerospike.client.exp.Exp;import com.aerospike.client.exp.HLLExp;
Expression exp = Exp.build( Exp.gt( HLLExp.getCount( HLLExp.add( HLLPolicy.Default, Exp.listBin("new_user_ids"), Exp.val(10), Exp.hllBin("visitors"))), Exp.val(0)));from aerospike_helpers.expressions import GT, HLLBin, ListBinfrom aerospike_helpers.expressions.hll import HLLAdd, HLLGetCount
added = HLLAdd(None, ListBin("new_user_ids"), 10, None, HLLBin("visitors"))exp = GT(HLLGetCount(added), 0).compile()hll_add_mh(policy, items, index_bit_count, minhash_bit_count, bin)Returns the HLL that bin evaluates to, with items added. Like hll_add, it requires the operand to already be an HLL. MinHash bits make hll_get_intersect_count and hll_get_similarity reliable, but they belong to the sketch being operated on — set them where it is created, with the Operate API add_mh or init.
| Name | Type | Description |
|---|---|---|
policy | HLL policy | Write policy for the transform. Supplied by your client as an HLL policy object. |
items | list | Elements to add to the sketch. |
index_bit_count | integer | Number of index bits, between 4 and 16. It has no effect here: it sizes a sketch at creation, and this expression cannot create one. Use |
minhash_bit_count | integer | Number of MinHash bits, between 4 and 51, summing with the index bits to 64 or fewer. Like |
bin | hll | HLL bin to operate on, or any expression that evaluates to an HLL. |
hll Same as hll_add, taking both bit counts. Neither has an effect on an existing sketch.
String exp = "$.visitors.hllAdd($.new_user_ids, indexBits: 10, minHashBits: 20)" + ".hllCount() > 0";exp = ("$.visitors.hllAdd($.new_user_ids, indexBits: 10, minHashBits: 20)" ".hllCount() > 0")use aerospike::expressions::hll as hll_exp;use aerospike::expressions::{gt, hll_bin, int_val, list_bin};use aerospike::operations::hll::HLLPolicy;
let exp = gt( hll_exp::get_count( hll_exp::add_with_index_and_min_hash( HLLPolicy::default(), list_bin("new_user_ids".into()), int_val(10), int_val(20), hll_bin("visitors".into()))), int_val(0));Expression exp = Exp.Build( Exp.GT( HLLExp.GetCount( HLLExp.Add( HLLPolicy.Default, Exp.ListBin("new_user_ids"), Exp.Val(10), Exp.Val(20), Exp.HLLBin("visitors"))), Exp.Val(0)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"added := as.ExpHLLAddWithIndexAndMinHash( as.DefaultHLLPolicy(), as.ExpListBin("new_user_ids"), as.ExpIntVal(10), as.ExpIntVal(20), as.ExpHLLBin("visitors"),)exp := as.ExpGreater(as.ExpHLLGetCount(added), as.ExpIntVal(0))const exp = Aerospike.exp
const added = exp.hll.addMH( exp.binHll('visitors'), 20, 10, exp.binList('new_user_ids'), null,)const filterExp = exp.gt(exp.hll.getCount(added), exp.int(0))as_exp_build(predexp, as_exp_cmp_gt( as_exp_hll_get_count( as_exp_hll_add_mh( NULL, as_exp_bin_list("new_user_ids"), 10, 20, as_exp_bin_hll("visitors"))), as_exp_int(0)));import com.aerospike.client.operation.HLLPolicy;import com.aerospike.client.exp.Exp;import com.aerospike.client.exp.HLLExp;
Expression exp = Exp.build( Exp.gt( HLLExp.getCount( HLLExp.add( HLLPolicy.Default, Exp.listBin("new_user_ids"), Exp.val(10), Exp.val(20), Exp.hllBin("visitors"))), Exp.val(0)));from aerospike_helpers.expressions import GT, HLLBin, ListBinfrom aerospike_helpers.expressions.hll import HLLAdd, HLLGetCount
added = HLLAdd(None, ListBin("new_user_ids"), 10, 20, HLLBin("visitors"))exp = GT(HLLGetCount(added), 0).compile()hll_init(policy, index_bit_count[, minhash_bit_count], bin)Returns a new, empty HLL sized by index_bit_count and, where given, minhash_bit_count. Unlike hll_add, the bit counts take effect here, because this expression is the one that builds the sketch. The record is not touched: storing the result takes a write operation expression.
| Name | Type | Description |
|---|---|---|
policy | HLL policy | Write policy for the transform. Supplied by your client as an HLL policy object. |
index_bit_count | integer | Number of index bits, between 4 and 16. More bits give a more accurate estimate and a larger sketch. |
minhash_bit_count | integer | Number of MinHash bits, between 4 and 51, summing with the index bits to 64 or fewer. MinHash bits improve intersection and similarity estimates. Optional; omit them for a plain HyperLogLog. |
bin | hll | HLL bin to operate on, or any expression that evaluates to an HLL. |
hll Size a fresh sketch at index_bit_count 12 and confirm it is empty. Because hll_init discards whatever the operand held, the count is 0 however many values visitors contains.
String exp = "$.visitors.hllInit(indexBits: 12).hllCount() == 0";exp = "$.visitors.hllInit(indexBits: 12).hllCount() == 0"use aerospike::expressions::hll as hll_exp;use aerospike::expressions::{eq, hll_bin, int_val};use aerospike::operations::hll::HLLPolicy;
let exp = eq( hll_exp::get_count( hll_exp::init(HLLPolicy::default(), int_val(12), hll_bin("visitors".into()))), int_val(0));Expression exp = Exp.Build( Exp.EQ( HLLExp.GetCount( HLLExp.Init(HLLPolicy.Default, Exp.Val(12), Exp.HLLBin("visitors"))), Exp.Val(0)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpEq( as.ExpHLLGetCount( as.ExpHLLInit(as.DefaultHLLPolicy(), as.ExpIntVal(12), as.ExpHLLBin("visitors"))), as.ExpIntVal(0))const exp = Aerospike.exp
const filterExp = exp.eq( exp.hll.getCount( exp.hll.init(exp.binHll('visitors'), 12)), exp.int(0))as_exp_build(predexp, as_exp_cmp_eq( as_exp_hll_get_count( as_exp_hll_init(NULL, 12, as_exp_bin_hll("visitors"))), as_exp_int(0)));import com.aerospike.client.operation.HLLPolicy;import com.aerospike.client.exp.Exp;import com.aerospike.client.exp.HLLExp;
Expression exp = Exp.build( Exp.eq( HLLExp.getCount( HLLExp.init(HLLPolicy.Default, Exp.val(12), Exp.hllBin("visitors"))), Exp.val(0)));from aerospike_helpers.expressions import Eq, HLLBinfrom aerospike_helpers.expressions.hll import HLLGetCount, HLLInit
fresh = HLLInit(None, 12, None, HLLBin("visitors"))exp = Eq(HLLGetCount(fresh), 0).compile()hll_update(policy, items, bin)Returns the HLL that bin evaluates to, with items added. It differs from hll_add only in taking no bit counts.
| Name | Type | Description |
|---|---|---|
policy | HLL policy | Write policy for the transform. Supplied by your client as an HLL policy object. |
items | list | Elements to add to the sketch. |
bin | hll | HLL bin to operate on, or any expression that evaluates to an HLL. |
hll Add values from list bin new_user_ids to an existing HLL visitors (no index/minhash creation path).
String exp = "$.visitors.hllAdd($.new_user_ids).hllCount() > 0";exp = "$.visitors.hllAdd($.new_user_ids).hllCount() > 0"use aerospike::expressions::hll as hll_exp;use aerospike::expressions::{gt, hll_bin, int_val, list_bin};use aerospike::operations::hll::HLLPolicy;
let exp = gt( hll_exp::get_count( hll_exp::add( HLLPolicy::default(), list_bin("new_user_ids".into()), hll_bin("visitors".into()))), int_val(0));Expression exp = Exp.Build( Exp.GT( HLLExp.GetCount( HLLExp.Add( HLLPolicy.Default, Exp.ListBin("new_user_ids"), Exp.HLLBin("visitors"))), Exp.Val(0)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"updated := as.ExpHLLAdd( as.DefaultHLLPolicy(), as.ExpListBin("new_user_ids"), as.ExpHLLBin("visitors"),)exp := as.ExpGreater(as.ExpHLLGetCount(updated), as.ExpIntVal(0))const exp = Aerospike.exp
const updated = exp.hll.update( exp.binHll('visitors'), exp.binList('new_user_ids'), null,)const filterExp = exp.gt(exp.hll.getCount(updated), exp.int(0))as_exp_build(predexp, as_exp_cmp_gt( as_exp_hll_get_count( as_exp_hll_update( NULL, as_exp_bin_list("new_user_ids"), as_exp_bin_hll("visitors"))), as_exp_int(0)));import com.aerospike.client.operation.HLLPolicy;import com.aerospike.client.exp.Exp;import com.aerospike.client.exp.HLLExp;
Expression exp = Exp.build( Exp.gt( HLLExp.getCount( HLLExp.add( HLLPolicy.Default, Exp.listBin("new_user_ids"), Exp.hllBin("visitors"))), Exp.val(0)));from aerospike_helpers.expressions import GT, HLLBin, ListBinfrom aerospike_helpers.expressions.hll import HLLAdd, HLLGetCount
updated = HLLAdd(None, ListBin("new_user_ids"), None, None, HLLBin("visitors"))exp = GT(HLLGetCount(updated), 0).compile()Read
hll_describe(bin)Returns a two-element list holding the HLL’s index bit count and MinHash bit count. Pair it with a list read such as list_get_by_index to pull out one of the two.
| Name | Type | Description |
|---|---|---|
bin | hll | HLL bin to operate on, or any expression that evaluates to an HLL. |
list The HLL’s index bit count (describe result index 0) is fewer than 16; uses a list read on the describe list.
String exp = "($.visitors.hllDescribe()).[0] < 16";exp = "($.visitors.hllDescribe()).[0] < 16"use aerospike::expressions::hll as hll_exp;use aerospike::expressions::lists as list_exp;use aerospike::expressions::{ExpType, hll_bin, int_val, lt};use aerospike::ListReturnType;
let exp = lt( list_exp::get_by_index( ListReturnType::Values, ExpType::INT, int_val(0), hll_exp::describe(hll_bin("visitors".into())), &[]), int_val(16));Expression exp = Exp.Build( Exp.LT( ListExp.GetByIndex( ListReturnType.VALUE, Exp.Type.INT, Exp.Val(0), HLLExp.Describe(Exp.HLLBin("visitors"))), Exp.Val(16)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpLess( as.ExpListGetByIndex( as.ListReturnTypeValue, as.ExpTypeINT, as.ExpIntVal(0), as.ExpHLLDescribe(as.ExpHLLBin("visitors")), ), as.ExpIntVal(16),)const exp = Aerospike.expconst lists = Aerospike.lists
const filterExp = exp.lt( exp.lists.getByIndex( exp.hll.describe(exp.binHll('visitors')), exp.int(0), exp.type.INT, lists.returnType.VALUE, ), exp.int(16),)as_exp_build(predexp, as_exp_cmp_lt( as_exp_list_get_by_index( NULL, AS_LIST_RETURN_VALUE, AS_EXP_TYPE_INT, as_exp_int(0), as_exp_hll_describe(as_exp_bin_hll("visitors"))), as_exp_int(16)));import com.aerospike.client.cdt.ListReturnType;import com.aerospike.client.exp.Exp;import com.aerospike.client.exp.HLLExp;import com.aerospike.client.exp.ListExp;
Expression exp = Exp.build( Exp.lt( ListExp.getByIndex( ListReturnType.VALUE, Exp.Type.INT, Exp.val(0), HLLExp.describe(Exp.hllBin("visitors"))), Exp.val(16)));import aerospikefrom aerospike_helpers.expressions import HLLBin, LTfrom aerospike_helpers.expressions.hll import HLLDescribefrom aerospike_helpers.expressions.list import ListGetByIndexfrom aerospike_helpers.expressions.resources import ResultType
desc = HLLDescribe(HLLBin("visitors"))exp = LT( ListGetByIndex( None, aerospike.LIST_RETURN_VALUE, ResultType.INTEGER, 0, desc, ), 16,).compile()hll_get_count(bin)Returns the estimated number of distinct elements in the HLL. The error depends on the index bit count the sketch was built with; see Error bounds.
| Name | Type | Description |
|---|---|---|
bin | hll | HLL bin to operate on, or any expression that evaluates to an HLL. |
integer Filter to records whose HLL visitors sketch estimates more than 100 unique ids.
String exp = "$.visitors.hllCount() > 100";exp = "$.visitors.hllCount() > 100"use aerospike::expressions::hll as hll_exp;use aerospike::expressions::{gt, hll_bin, int_val};
let exp = gt(hll_exp::get_count(hll_bin("visitors".into())), int_val(100));Expression exp = Exp.Build( Exp.GT(HLLExp.GetCount(Exp.HLLBin("visitors")), Exp.Val(100)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpGreater( as.ExpHLLGetCount(as.ExpHLLBin("visitors")), as.ExpIntVal(100),)const exp = Aerospike.exp
const filterExp = exp.gt( exp.hll.getCount(exp.binHll('visitors')), exp.int(100),)as_exp_build(predexp, as_exp_cmp_gt( as_exp_hll_get_count(as_exp_bin_hll("visitors")), as_exp_int(100)));import com.aerospike.client.exp.Exp;import com.aerospike.client.exp.HLLExp;
Expression exp = Exp.build( Exp.gt(HLLExp.getCount(Exp.hllBin("visitors")), Exp.val(100)));from aerospike_helpers.expressions import GT, HLLBinfrom aerospike_helpers.expressions.hll import HLLGetCount
exp = GT(HLLGetCount(HLLBin("visitors")), 100).compile()hll_get_intersect_count(hll_list, bin)Returns the estimated number of distinct elements common to hll_list and the HLL that bin evaluates to. Accuracy depends on MinHash bits: the estimate is stable when the sketches carry them and unstable when they do not. See Error bounds.
| Name | Type | Description |
|---|---|---|
hll_list | list | HLLs to intersect with the operand. |
bin | hll | HLL bin to operate on, or any expression that evaluates to an HLL. |
integer Estimated intersection size between cohort_a and visitors is at least 50.
String exp = "$.visitors.hllIntersectCount($.cohort_a) >= 50";exp = "$.visitors.hllIntersectCount($.cohort_a) >= 50"use aerospike::expressions::hll as hll_exp;use aerospike::expressions::{ge, hll_bin, int_val};
let exp = ge( hll_exp::get_intersect_count( hll_bin("cohort_a".into()), hll_bin("visitors".into())), int_val(50));Expression exp = Exp.Build( Exp.GE( HLLExp.GetIntersectCount(Exp.HLLBin("cohort_a"), Exp.HLLBin("visitors")), Exp.Val(50)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpGreaterEq( as.ExpHLLGetIntersectCount(as.ExpHLLBin("cohort_a"), as.ExpHLLBin("visitors")), as.ExpIntVal(50),)const exp = Aerospike.exp
const filterExp = exp.ge( exp.hll.getIntersectCount( exp.binHll('visitors'), exp.binHll('cohort_a'), ), exp.int(50),)as_exp_build(predexp, as_exp_cmp_ge( as_exp_hll_get_intersect_count( as_exp_bin_hll("cohort_a"), as_exp_bin_hll("visitors")), as_exp_int(50)));import com.aerospike.client.exp.Exp;import com.aerospike.client.exp.HLLExp;
Expression exp = Exp.build( Exp.ge( HLLExp.getIntersectCount(Exp.hllBin("cohort_a"), Exp.hllBin("visitors")), Exp.val(50)));from aerospike_helpers.expressions import GE, HLLBinfrom aerospike_helpers.expressions.hll import HLLGetIntersectCount
exp = GE( HLLGetIntersectCount(HLLBin("cohort_a"), HLLBin("visitors")), 50,).compile()hll_get_similarity(hll_list, bin)Returns the estimated Jaccard index of hll_list and the HLL that bin evaluates to — the size of their intersection over the size of their union, from 0.0 for disjoint sets to 1.0 for identical ones. See Error bounds.
| Name | Type | Description |
|---|---|---|
hll_list | list | HLLs to compare against the operand. |
bin | hll | HLL bin to operate on, or any expression that evaluates to an HLL. |
float Jaccard-style similarity between cohort_a and visitors is at least 0.5.
String exp = "$.visitors.hllSimilarity($.cohort_a) >= 0.5";exp = "$.visitors.hllSimilarity($.cohort_a) >= 0.5"use aerospike::expressions::hll as hll_exp;use aerospike::expressions::{float_val, ge, hll_bin};
let exp = ge( hll_exp::get_similarity(hll_bin("cohort_a".into()), hll_bin("visitors".into())), float_val(0.5));Expression exp = Exp.Build( Exp.GE( HLLExp.GetSimilarity(Exp.HLLBin("cohort_a"), Exp.HLLBin("visitors")), Exp.Val(0.5)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpGreaterEq( as.ExpHLLGetSimilarity(as.ExpHLLBin("cohort_a"), as.ExpHLLBin("visitors")), as.ExpFloatVal(0.5),)const exp = Aerospike.exp
const filterExp = exp.ge( exp.hll.getSimilarity( exp.binHll('visitors'), exp.binHll('cohort_a'), ), exp.float(0.5),)as_exp_build(predexp, as_exp_cmp_ge( as_exp_hll_get_similarity( as_exp_bin_hll("cohort_a"), as_exp_bin_hll("visitors")), as_exp_float(0.5)));import com.aerospike.client.exp.Exp;import com.aerospike.client.exp.HLLExp;
Expression exp = Exp.build( Exp.ge( HLLExp.getSimilarity(Exp.hllBin("cohort_a"), Exp.hllBin("visitors")), Exp.val(0.5)));from aerospike_helpers.expressions import GE, HLLBinfrom aerospike_helpers.expressions.hll import HLLGetSimilarity
exp = GE( HLLGetSimilarity(HLLBin("cohort_a"), HLLBin("visitors")), 0.5,).compile()hll_get_union(hll_list, bin)Returns an HLL representing the union of hll_list and the HLL that bin evaluates to.
| Name | Type | Description |
|---|---|---|
hll_list | list | HLLs to union with the operand. |
bin | hll | HLL bin to operate on, or any expression that evaluates to an HLL. |
hll Union of HLL cohort_a with visitors, then require a non-empty estimate (via hll_get_count on the union result).
String exp = "$.visitors.hllUnion($.cohort_a).hllCount() > 0";exp = "$.visitors.hllUnion($.cohort_a).hllCount() > 0"use aerospike::expressions::hll as hll_exp;use aerospike::expressions::{gt, hll_bin, int_val};
let exp = gt( hll_exp::get_count( hll_exp::get_union(hll_bin("cohort_a".into()), hll_bin("visitors".into()))), int_val(0));Expression exp = Exp.Build( Exp.GT( HLLExp.GetCount( HLLExp.GetUnion(Exp.HLLBin("cohort_a"), Exp.HLLBin("visitors"))), Exp.Val(0)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"union := as.ExpHLLGetUnion(as.ExpHLLBin("cohort_a"), as.ExpHLLBin("visitors"))exp := as.ExpGreater(as.ExpHLLGetCount(union), as.ExpIntVal(0))const exp = Aerospike.exp
const unionHll = exp.hll.getUnion( exp.binHll('visitors'), exp.binHll('cohort_a'),)const filterExp = exp.gt(exp.hll.getCount(unionHll), exp.int(0))as_exp_build(predexp, as_exp_cmp_gt( as_exp_hll_get_count( as_exp_hll_get_union( as_exp_bin_hll("cohort_a"), as_exp_bin_hll("visitors"))), as_exp_int(0)));import com.aerospike.client.exp.Exp;import com.aerospike.client.exp.HLLExp;
Expression exp = Exp.build( Exp.gt( HLLExp.getCount( HLLExp.getUnion(Exp.hllBin("cohort_a"), Exp.hllBin("visitors"))), Exp.val(0)));from aerospike_helpers.expressions import GT, HLLBinfrom aerospike_helpers.expressions.hll import HLLGetCount, HLLGetUnion
u = HLLGetUnion(HLLBin("cohort_a"), HLLBin("visitors"))exp = GT(HLLGetCount(u), 0).compile()hll_get_union_count(hll_list, bin)Returns the estimated number of distinct elements in the union of hll_list and the HLL that bin evaluates to.
| Name | Type | Description |
|---|---|---|
hll_list | list | HLLs to union with the operand. |
bin | hll | HLL bin to operate on, or any expression that evaluates to an HLL. |
integer Estimated cardinality of the union of cohort_a and visitors exceeds 500.
String exp = "$.visitors.hllUnionCount($.cohort_a) > 500";exp = "$.visitors.hllUnionCount($.cohort_a) > 500"use aerospike::expressions::hll as hll_exp;use aerospike::expressions::{gt, hll_bin, int_val};
let exp = gt( hll_exp::get_union_count(hll_bin("cohort_a".into()), hll_bin("visitors".into())), int_val(500));Expression exp = Exp.Build( Exp.GT( HLLExp.GetUnionCount(Exp.HLLBin("cohort_a"), Exp.HLLBin("visitors")), Exp.Val(500)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpGreater( as.ExpHLLGetUnionCount(as.ExpHLLBin("cohort_a"), as.ExpHLLBin("visitors")), as.ExpIntVal(500),)const exp = Aerospike.exp
const filterExp = exp.gt( exp.hll.getUnionCount( exp.binHll('visitors'), exp.binHll('cohort_a'), ), exp.int(500),)as_exp_build(predexp, as_exp_cmp_gt( as_exp_hll_get_union_count( as_exp_bin_hll("cohort_a"), as_exp_bin_hll("visitors")), as_exp_int(500)));import com.aerospike.client.exp.Exp;import com.aerospike.client.exp.HLLExp;
Expression exp = Exp.build( Exp.gt( HLLExp.getUnionCount(Exp.hllBin("cohort_a"), Exp.hllBin("visitors")), Exp.val(500)));from aerospike_helpers.expressions import GT, HLLBinfrom aerospike_helpers.expressions.hll import HLLGetUnionCount
exp = GT( HLLGetUnionCount(HLLBin("cohort_a"), HLLBin("visitors")), 500,).compile()hll_may_contain(values, bin)Returns 1 if the HLL that bin evaluates to may contain every element of values, otherwise 0. A positive answer is probabilistic; a negative answer is certain.
| Name | Type | Description |
|---|---|---|
values | list | Elements to look for; the result is 1 only when the HLL may contain every one. |
bin | hll | HLL bin to operate on, or any expression that evaluates to an HLL. |
integer The HLL may contain every candidate key listed in list bin candidate_keys (returns 1 when the check is positive).
String exp = "$.visitors.hllMayContain($.candidate_keys) == 1";exp = "$.visitors.hllMayContain($.candidate_keys) == 1"use aerospike::expressions::hll as hll_exp;use aerospike::expressions::{eq, hll_bin, int_val, list_bin};
let exp = eq( hll_exp::may_contain( list_bin("candidate_keys".into()), hll_bin("visitors".into())), int_val(1));Expression exp = Exp.Build( Exp.EQ( HLLExp.MayContain(Exp.ListBin("candidate_keys"), Exp.HLLBin("visitors")), Exp.Val(1)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpEq( as.ExpHLLMayContain(as.ExpListBin("candidate_keys"), as.ExpHLLBin("visitors")), as.ExpIntVal(1),)const exp = Aerospike.exp
const filterExp = exp.eq( exp.hll.mayContain( exp.binHll('visitors'), exp.binList('candidate_keys'), ), exp.int(1),)as_exp_build(predexp, as_exp_cmp_eq( as_exp_hll_may_contain( as_exp_bin_list("candidate_keys"), as_exp_bin_hll("visitors")), as_exp_int(1)));import com.aerospike.client.exp.Exp;import com.aerospike.client.exp.HLLExp;
Expression exp = Exp.build( Exp.eq( HLLExp.mayContain(Exp.listBin("candidate_keys"), Exp.hllBin("visitors")), Exp.val(1)));from aerospike_helpers.expressions import Eq, HLLBin, ListBinfrom aerospike_helpers.expressions.hll import HLLMayContain
exp = Eq(HLLMayContain(ListBin("candidate_keys"), HLLBin("visitors")), 1).compile()