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 split brain protection SplitBrainProtectionConfig since 3.10 in cluster versions 3.10 and higher.
Asynchronous methods
Asynchronous methods return a CompletionStage that can be used to
chain further computation stages. Alternatively, a CompletableFuture
can be obtained via CompletionStage.toCompletableFuture() to wait
for the operation to complete in a blocking way.
Actions supplied for dependent completions of default non-async methods and async methods
without an explicit Executor argument are performed
by the ForkJoinPool.commonPool() (unless it does not
support a parallelism level of at least 2, in which case a new Thread is
created per task).
| Modifier and Type | Method and Description |
|---|---|
void |
add(Object obj)
Add a new object in the estimation set.
|
CompletionStage<Void> |
addAsync(Object obj)
Add a new object in the estimation set.
|
long |
estimate()
Estimates the cardinality of the aggregation so far.
|
CompletionStage<Long> |
estimateAsync()
Estimates the cardinality of the aggregation so far.
|
destroy, getName, getPartitionKey, getServiceNamevoid add(@Nonnull 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()
CompletionStage<Void> addAsync(@Nonnull 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 a CompletionStage.
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:
CompletionStage<Void> stage = estimator.addAsync();
// do something else, then read the result
Boolean result = stage.toCompletableFuture().get(); // this method will block until the result is available
CompletionStage<Void> stage = estimator.addAsync();
stage.whenCompleteAsync((response, throwable) -> {
if (throwable == null) {
// do something
} else {
// handle failure
}
});
obj - object to add in the estimation set.CompletionStage API consumers can use to chain further computation stagesNullPointerException - if obj is nullCompletionStage<Long> estimateAsync()
This method will dispatch a request and return immediately a CompletionStage.
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:
CompletionStage<Long> stage = estimator.estimateAsync();
// do something else, then read the result
Long result = stage.toCompletableFuture().get(); // this method will block until the result is available
CompletionStage<Long> stage = estimator.estimateAsync();
stage.whenCompleteAsync((response, throwable) -> {
if (throwable == null) {
// do something with the result
} else {
// handle failure
}
});
CompletionStage bearing the response, the estimate.Copyright © 2022 Hazelcast, Inc.. All rights reserved.