public interface CardinalityEstimator extends DistributedObject
CardinalityEstimator is internally based on a HyperLogLog++ data-structure, and uses P^2 byte registers for storage and computation. (Default P = 14)
Supports Quorum QuorumConfig
since 3.10 in cluster versions 3.10 and higher.
Modifier and Type | Method and Description |
---|---|
void |
add(Object obj)
Add a new object in the estimation set.
|
ICompletableFuture<Void> |
addAsync(Object obj)
Add a new object in the estimation set.
|
long |
estimate()
Estimates the cardinality of the aggregation so far.
|
ICompletableFuture<Long> |
estimateAsync()
Estimates the cardinality of the aggregation so far.
|
destroy, getName, getPartitionKey, getServiceName
void add(Object obj)
Objects are considered identical if they are serialized into the same binary blob. In other words: It does not use Java equality.
obj
- object to add in the estimation set.NullPointerException
- if obj is nulllong estimate()
ICompletableFuture<Void> addAsync(Object obj)
Objects are considered identical if they are serialized into the same binary blob. In other words: It does not use Java equality.
This method will dispatch a request and return immediately an ICompletableFuture
.
The operations result can be obtained in a blocking way, or a
callback can be provided for execution upon completion, as demonstrated in the following examples:
ICompletableFuture<Void> future = estimator.addAsync(); // do something else, then read the result Boolean result = future.get(); // this method will block until the result is available
ICompletableFuture<Void> future = estimator.addAsync(); future.andThen(new ExecutionCallback<Void>() { void onResponse(Void response) { // do something } void onFailure(Throwable t) { // handle failure } });
obj
- object to add in the estimation set.ICompletableFuture
API consumers can use to track execution of this request.NullPointerException
- if obj is nullICompletableFuture<Long> estimateAsync()
This method will dispatch a request and return immediately an ICompletableFuture
.
The operations result can be obtained in a blocking way, or a
callback can be provided for execution upon completion, as demonstrated in the following examples:
ICompletableFuture<Long> future = estimator.estimateAsync(); // do something else, then read the result Long result = future.get(); // this method will block until the result is available
ICompletableFuture<Long> future = estimator.estimateAsync(); future.andThen(new ExecutionCallback<Long>() { void onResponse(Long response) { // do something with the result } void onFailure(Throwable t) { // handle failure } });
ICompletableFuture
bearing the response, the estimate.Copyright © 2022 Hazelcast, Inc.. All Rights Reserved.