com.hazelcast.client.proxy

## Class ClientCardinalityEstimatorProxy

- java.lang.Object
- - com.hazelcast.client.spi.ClientProxy
  - - com.hazelcast.client.proxy.ClientCardinalityEstimatorProxy

- All Implemented Interfaces:
    CardinalityEstimator, DistributedObject

      public class ClientCardinalityEstimatorProxy
      extends ClientProxy
      implements CardinalityEstimator

  Proxy implementation of `CardinalityEstimator`.

- - ### Field Summary

    - ### Fields inherited from class com.hazelcast.client.spi.ClientProxy

      `name`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ClientCardinalityEstimatorProxy(String serviceName, String objectId, ClientContext context)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(Object obj)` Add a new object in the estimation set.
    `InternalCompletableFuture<Void>` | `addAsync(Object obj)` Add a new object in the estimation set.
    `long` | `estimate()` Estimates the cardinality of the aggregation so far.
    `InternalCompletableFuture<Long>` | `estimateAsync()` Estimates the cardinality of the aggregation so far.
    `protected com.hazelcast.client.impl.protocol.ClientMessage` | `invokeOnPartition(com.hazelcast.client.impl.protocol.ClientMessage req)`
    `protected <T> T` | `invokeOnPartition(com.hazelcast.client.impl.protocol.ClientMessage clientMessage, long invocationTimeoutSeconds)`
    `protected <T> ClientDelegatingFuture<T>` | `invokeOnPartitionAsync(com.hazelcast.client.impl.protocol.ClientMessage clientMessage, com.hazelcast.client.impl.clientside.ClientMessageDecoder clientMessageDecoder)`
    `protected <T> T` | `invokeOnPartitionInterruptibly(com.hazelcast.client.impl.protocol.ClientMessage clientMessage)`
    `protected <T> T` | `invokeOnPartitionInterruptibly(com.hazelcast.client.impl.protocol.ClientMessage clientMessage, long invocationTimeoutSeconds)`
    `protected void` | `onInitialize()` Called when proxy is created.
    `String` | `toString()`

    - ### Methods inherited from class com.hazelcast.client.spi.ClientProxy

      `deregisterListener, destroy, destroyLocally, destroyRemotely, equals, getClient, getConnectedServerVersion, getContext, getDistributedObjectName, getId, getName, getPartitionKey, getSerializationService, getServiceName, hashCode, invoke, invoke, invokeOnAddress, invokeOnPartition, invokeOnPartitionInterruptibly, onDestroy, onShutdown, postDestroy, preDestroy, registerListener, setContext, toData, toObject`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface com.hazelcast.core.DistributedObject

      `destroy, getName, getPartitionKey, getServiceName`

- - ### Constructor Detail

    - #### ClientCardinalityEstimatorProxy

          public ClientCardinalityEstimatorProxy(String serviceName,
                                                 String objectId,
                                                 ClientContext context)

  - ### Method Detail

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### add

          public void add(Object obj)

      Description copied from interface: `CardinalityEstimator`
      Add a new object in the estimation set. This is the method you want to use to feed objects into the estimator.

      Objects are considered identical if they are serialized into the same binary blob. In other words: It does not use Java equality.

      Specified by:
        `add` in interface `CardinalityEstimator`
      Parameters:
        `obj` - object to add in the estimation set.

    - #### estimate

          public long estimate()

      Description copied from interface: `CardinalityEstimator`
      Estimates the cardinality of the aggregation so far. If it was previously estimated and never invalidated, then a cached version is used.
      Specified by:
        `estimate` in interface `CardinalityEstimator`
      Returns:
        a cached estimation or a newly computed one.

    - #### addAsync

          public InternalCompletableFuture<Void> addAsync(Object obj)

      Description copied from interface: `CardinalityEstimator`
      Add a new object in the estimation set. This is the method you want to use to feed objects into the estimator.

      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
                    }
               });

      Specified by:
        `addAsync` in interface `CardinalityEstimator`
      Parameters:
        `obj` - object to add in the estimation set.
      Returns:
        an `ICompletableFuture` API consumers can use to track execution of this request.

    - #### estimateAsync

          public InternalCompletableFuture<Long> estimateAsync()

      Description copied from interface: `CardinalityEstimator`
      Estimates the cardinality of the aggregation so far. If it was previously estimated and never invalidated, then a cached version is used.

      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
                    }
               });

      Specified by:
        `estimateAsync` in interface `CardinalityEstimator`
      Returns:
        `ICompletableFuture` bearing the response, the estimate.

    - #### onInitialize

          protected void onInitialize()

      Description copied from class: `ClientProxy`
      Called when proxy is created. Overriding implementations can add initialization specific logic into this method like registering a listener, creating a cleanup task etc.
      Overrides:
        `onInitialize` in class `ClientProxy`

    - #### invokeOnPartition

          protected com.hazelcast.client.impl.protocol.ClientMessage invokeOnPartition(com.hazelcast.client.impl.protocol.ClientMessage req)

    - #### invokeOnPartitionInterruptibly

          protected <T> T invokeOnPartitionInterruptibly(com.hazelcast.client.impl.protocol.ClientMessage clientMessage)
                                                  throws InterruptedException

      Throws:
        `InterruptedException`

    - #### invokeOnPartitionAsync

          protected <T> ClientDelegatingFuture<T> invokeOnPartitionAsync(com.hazelcast.client.impl.protocol.ClientMessage clientMessage,
                                                                         com.hazelcast.client.impl.clientside.ClientMessageDecoder clientMessageDecoder)

    - #### invokeOnPartition

          protected <T> T invokeOnPartition(com.hazelcast.client.impl.protocol.ClientMessage clientMessage,
                                            long invocationTimeoutSeconds)

    - #### invokeOnPartitionInterruptibly

          protected <T> T invokeOnPartitionInterruptibly(com.hazelcast.client.impl.protocol.ClientMessage clientMessage,
                                                         long invocationTimeoutSeconds)
                                                  throws InterruptedException

      Throws:
        `InterruptedException`

Copyright © 2019. All rights reserved.