Interface HyperLogLogBaseCommands

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.util.concurrent.CompletableFuture<java.lang.Boolean> pfadd​(GlideString key, GlideString[] elements)
      Adds all elements to the HyperLogLog data structure stored at the specified key.
      java.util.concurrent.CompletableFuture<java.lang.Boolean> pfadd​(java.lang.String key, java.lang.String[] elements)
      Adds all elements to the HyperLogLog data structure stored at the specified key.
      java.util.concurrent.CompletableFuture<java.lang.Long> pfcount​(GlideString[] keys)
      Estimates the cardinality of the data stored in a HyperLogLog structure for a single key or calculates the combined cardinality of multiple keys by merging their HyperLogLogs temporarily.
      java.util.concurrent.CompletableFuture<java.lang.Long> pfcount​(java.lang.String[] keys)
      Estimates the cardinality of the data stored in a HyperLogLog structure for a single key or calculates the combined cardinality of multiple keys by merging their HyperLogLogs temporarily.
      java.util.concurrent.CompletableFuture<java.lang.String> pfmerge​(GlideString destination, GlideString[] sourceKeys)
      Merges multiple HyperLogLog values into a unique value.
      If the destination variable exists, it is treated as one of the source HyperLogLog data sets, otherwise a new HyperLogLog is created.
      java.util.concurrent.CompletableFuture<java.lang.String> pfmerge​(java.lang.String destination, java.lang.String[] sourceKeys)
      Merges multiple HyperLogLog values into a unique value.
      If the destination variable exists, it is treated as one of the source HyperLogLog data sets, otherwise a new HyperLogLog is created.
    • Method Detail

      • pfadd

        java.util.concurrent.CompletableFuture<java.lang.Boolean> pfadd​(java.lang.String key,
                                                                        java.lang.String[] elements)
        Adds all elements to the HyperLogLog data structure stored at the specified key.
        Creates a new structure if the key does not exist.

        When no elements are provided, and key exists and is a HyperLogLog, then no operation is performed. If key does not exist, then the HyperLogLog structure is created.

        Parameters:
        key - The key of the HyperLogLog data structure to add elements into.
        elements - An array of members to add to the HyperLogLog stored at key.
        Returns:
        If the HyperLogLog is newly created, or if the HyperLogLog approximated cardinality is altered, then returns 1. Otherwise, returns 0.
        See Also:
        valkey.io for details.
        Example:
        
         Boolean result = client.pfadd("hll_1", new String[] { "a", "b", "c" }).get();
         assert result; // A data structure was created or modified
        
         result = client.pfadd("hll_2", new String[0]).get();
         assert result; // A new empty data structure was created
         
      • pfadd

        java.util.concurrent.CompletableFuture<java.lang.Boolean> pfadd​(GlideString key,
                                                                        GlideString[] elements)
        Adds all elements to the HyperLogLog data structure stored at the specified key.
        Creates a new structure if the key does not exist.

        When no elements are provided, and key exists and is a HyperLogLog, then no operation is performed. If key does not exist, then the HyperLogLog structure is created.

        Parameters:
        key - The key of the HyperLogLog data structure to add elements into.
        elements - An array of members to add to the HyperLogLog stored at key.
        Returns:
        If the HyperLogLog is newly created, or if the HyperLogLog approximated cardinality is altered, then returns true. Otherwise, returns false.
        See Also:
        valkey.io for details.
        Example:
        
         Boolean result = client.pfadd(gs("hll_1"), new GlideString[] { gs("a"), gs("b"), gs("c") }).get();
         assert result; // A data structure was created or modified
        
         result = client.pfadd(gs("hll_2"), new GlideString[0]).get();
         assert result; // A new empty data structure was created
         
      • pfcount

        java.util.concurrent.CompletableFuture<java.lang.Long> pfcount​(java.lang.String[] keys)
        Estimates the cardinality of the data stored in a HyperLogLog structure for a single key or calculates the combined cardinality of multiple keys by merging their HyperLogLogs temporarily.
        Parameters:
        keys - The keys of the HyperLogLog data structures to be analyzed.
        Returns:
        The approximated cardinality of given HyperLogLog data structures.
        The cardinality of a key that does not exist is 0.
        See Also:
        valkey.io for details.
        Example:
        
         Long result = client.pfcount("hll_1", "hll_2").get();
         assert result == 42L; // Count of unique elements in multiple data structures
         
      • pfcount

        java.util.concurrent.CompletableFuture<java.lang.Long> pfcount​(GlideString[] keys)
        Estimates the cardinality of the data stored in a HyperLogLog structure for a single key or calculates the combined cardinality of multiple keys by merging their HyperLogLogs temporarily.
        Parameters:
        keys - The keys of the HyperLogLog data structures to be analyzed.
        Returns:
        The approximated cardinality of given HyperLogLog data structures.
        The cardinality of a key that does not exist is 0.
        See Also:
        valkey.io for details.
        Example:
        
         Long result = client.pfcount(gs("hll_1"), gs("hll_2")).get();
         assert result == 42L; // Count of unique elements in multiple data structures
         
      • pfmerge

        java.util.concurrent.CompletableFuture<java.lang.String> pfmerge​(java.lang.String destination,
                                                                         java.lang.String[] sourceKeys)
        Merges multiple HyperLogLog values into a unique value.
        If the destination variable exists, it is treated as one of the source HyperLogLog data sets, otherwise a new HyperLogLog is created.
        Parameters:
        destination - The key of the destination HyperLogLog where the merged data sets will be stored.
        sourceKeys - The keys of the HyperLogLog structures to be merged.
        Returns:
        OK.
        See Also:
        valkey.io for details.
        Example:
        
         String response = client.pfmerge("new_HLL", "old_HLL_1", "old_HLL_2").get();
         assert response.equals("OK"); // new HyperLogLog data set was created with merged content of old ones
        
         String response = client.pfmerge("old_HLL_1", "old_HLL_2", "old_HLL_3").get();
         assert response.equals("OK"); // content of existing HyperLogLogs was merged into existing variable
         
      • pfmerge

        java.util.concurrent.CompletableFuture<java.lang.String> pfmerge​(GlideString destination,
                                                                         GlideString[] sourceKeys)
        Merges multiple HyperLogLog values into a unique value.
        If the destination variable exists, it is treated as one of the source HyperLogLog data sets, otherwise a new HyperLogLog is created.
        Parameters:
        destination - The key of the destination HyperLogLog where the merged data sets will be stored.
        sourceKeys - The keys of the HyperLogLog structures to be merged.
        Returns:
        OK.
        See Also:
        valkey.io for details.
        Example:
        
         String response = client.pfmerge(gs("new_HLL"), gs("old_HLL_1"), gs("old_HLL_2")).get();
         assert response.equals("OK"); // new HyperLogLog data set was created with merged content of old ones
        
         String response = client.pfmerge(gs("old_HLL_1"), gs("old_HLL_2"), gs("old_HLL_3")).get();
         assert response.equals("OK"); // content of existing HyperLogLogs was merged into existing variable