Class HLLExp

java.lang.Object
com.aerospike.client.exp.HLLExp

public final class HLLExp extends Object
HyperLogLog (HLL) expression generator. See Exp.

The bin expression argument in these methods can be a reference to a bin or the result of another expression. Expressions that modify bin values are only used for temporary expression evaluation and are not permanently applied to the bin. HLL modify expressions return the HLL bin's value.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Exp
    add(HLLPolicy policy, Exp list, Exp bin)
    Create expression that adds list values to a HLL set and returns HLL set.
    static Exp
    add(HLLPolicy policy, Exp list, Exp indexBitCount, Exp bin)
    Create expression that adds values to a HLL set and returns HLL set.
    static Exp
    add(HLLPolicy policy, Exp list, Exp indexBitCount, Exp minHashBitCount, Exp bin)
    Create expression that adds values to a HLL set and returns HLL set.
    static Exp
    Create expression that returns indexBitCount and minHashBitCount used to create HLL bin in a list of longs.
    static Exp
    Create expression that returns estimated number of elements in the HLL bin.
    static Exp
    Create expression that returns estimated number of elements that would be contained by the intersection of these HLL objects.
    static Exp
    getSimilarity(Exp list, Exp bin)
    Create expression that returns estimated similarity of these HLL objects as a 64 bit float.
    static Exp
    getUnion(Exp list, Exp bin)
    Create expression that returns a HLL object that is the union of all specified HLL objects in the list with the HLL bin.
    static Exp
    getUnionCount(Exp list, Exp bin)
    Create expression that returns estimated number of elements that would be contained by the union of these HLL objects.
    static Exp
    init(HLLPolicy policy, Exp indexBitCount, Exp bin)
    Create expression that creates a new HLL or resets an existing HLL.
    static Exp
    init(HLLPolicy policy, Exp indexBitCount, Exp minHashBitCount, Exp bin)
    Create expression that creates a new HLL or resets an existing HLL with minhash bits.
    static Exp
    mayContain(Exp list, Exp bin)
    Create expression that returns one if HLL bin may contain all items in the list.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • HLLExp

      public HLLExp()
  • Method Details

    • init

      public static Exp init(HLLPolicy policy, Exp indexBitCount, Exp bin)
      Create expression that creates a new HLL or resets an existing HLL.
      Parameters:
      policy - write policy, use HLLPolicy.Default for default
      indexBitCount - number of index bits. Must be between 4 and 16 inclusive.
      bin - HLL bin or value expression
    • init

      public static Exp init(HLLPolicy policy, Exp indexBitCount, Exp minHashBitCount, Exp bin)
      Create expression that creates a new HLL or resets an existing HLL with minhash bits.
      Parameters:
      policy - write policy, use HLLPolicy.Default for default
      indexBitCount - number of index bits. Must be between 4 and 16 inclusive.
      minHashBitCount - number of min hash bits. Must be between 4 and 51 inclusive. Also, indexBitCount + minHashBitCount must be <= 64.
      bin - HLL bin or value expression
    • add

      public static Exp add(HLLPolicy policy, Exp list, Exp bin)
      Create expression that adds list values to a HLL set and returns HLL set. The function assumes HLL bin already exists.
      
       // Add values to HLL bin "a" and check count > 7
       Exp.gt(
         HLLExp.getCount(
           HLLExp.add(HLLPolicy.Default, Exp.val(list), Exp.hllBin("a"))),
         Exp.val(7))
       
      Parameters:
      policy - write policy, use HLLPolicy.Default for default
      list - list bin or value expression of values to be added
      bin - HLL bin or value expression
    • add

      public static Exp add(HLLPolicy policy, Exp list, Exp indexBitCount, Exp bin)
      Create expression that adds values to a HLL set and returns HLL set. If HLL bin does not exist, use indexBitCount to create HLL bin.
      
       // Add values to HLL bin "a" and check count > 7
       Exp.gt(
         HLLExp.getCount(
           HLLExp.add(HLLPolicy.Default, Exp.val(list), Exp.val(10), Exp.hllBin("a"))),
         Exp.val(7))
       
      Parameters:
      policy - write policy, use HLLPolicy.Default for default
      list - list bin or value expression of values to be added
      indexBitCount - number of index bits expression. Must be between 4 and 16 inclusive.
      bin - HLL bin or value expression
    • add

      public static Exp add(HLLPolicy policy, Exp list, Exp indexBitCount, Exp minHashBitCount, Exp bin)
      Create expression that adds values to a HLL set and returns HLL set. If HLL bin does not exist, use indexBitCount and minHashBitCount to create HLL set.
      
       // Add values to HLL bin "a" and check count > 7
       Exp.gt(
         HLLExp.getCount(
           HLLExp.add(HLLPolicy.Default, Exp.val(list), Exp.val(10), Exp.val(20), Exp.hllBin("a"))),
         Exp.val(7))
       
      Parameters:
      policy - write policy, use HLLPolicy.Default for default
      list - list bin or value expression of values to be added
      indexBitCount - number of index bits expression. Must be between 4 and 16 inclusive.
      minHashBitCount - number of min hash bits expression. Must be between 4 and 51 inclusive. Also, indexBitCount + minHashBitCount must be <= 64.
      bin - HLL bin or value expression
    • getCount

      public static Exp getCount(Exp bin)
      Create expression that returns estimated number of elements in the HLL bin.
      
       // HLL bin "a" count > 7
       Exp.gt(HLLExp.getCount(Exp.hllBin("a")), Exp.val(7))
       
    • getUnion

      public static Exp getUnion(Exp list, Exp bin)
      Create expression that returns a HLL object that is the union of all specified HLL objects in the list with the HLL bin.
      
       // Union of HLL bins "a" and "b"
       HLLExp.getUnion(Exp.hllBin("a"), Exp.hllBin("b"))
      
       // Union of local HLL list with bin "b"
       HLLExp.getUnion(Exp.val(list), Exp.hllBin("b"))
       
    • getUnionCount

      public static Exp getUnionCount(Exp list, Exp bin)
      Create expression that returns estimated number of elements that would be contained by the union of these HLL objects.
      
       // Union count of HLL bins "a" and "b"
       HLLExp.getUnionCount(Exp.hllBin("a"), Exp.hllBin("b"))
      
       // Union count of local HLL list with bin "b"
       HLLExp.getUnionCount(Exp.val(list), Exp.hllBin("b"))
       
    • getIntersectCount

      public static Exp getIntersectCount(Exp list, Exp bin)
      Create expression that returns estimated number of elements that would be contained by the intersection of these HLL objects.
      
       // Intersect count of HLL bins "a" and "b"
       HLLExp.getIntersectCount(Exp.hllBin("a"), Exp.hllBin("b"))
      
       // Intersect count of local HLL list with bin "b"
       HLLExp.getIntersectCount(Exp.val(list), Exp.hllBin("b"))
       
    • getSimilarity

      public static Exp getSimilarity(Exp list, Exp bin)
      Create expression that returns estimated similarity of these HLL objects as a 64 bit float.
      
       // Similarity of HLL bins "a" and "b" >= 0.75
       Exp.ge(HLLExp.getSimilarity(Exp.hllBin("a"), Exp.hllBin("b")), Exp.val(0.75))
       
    • describe

      public static Exp describe(Exp bin)
      Create expression that returns indexBitCount and minHashBitCount used to create HLL bin in a list of longs. list[0] is indexBitCount and list[1] is minHashBitCount.
      
       // Bin "a" indexBitCount < 10
       Exp.lt(
         ListExp.getByIndex(ListReturnType.VALUE, Exp.Type.INT, Exp.val(0),
           HLLExp.describe(Exp.hllBin("a"))),
         Exp.val(10))
       
    • mayContain

      public static Exp mayContain(Exp list, Exp bin)
      Create expression that returns one if HLL bin may contain all items in the list.
      
       // Bin "a" may contain value "x"
       ArrayList<Value> list = new ArrayList<Value>();
       list.add(Value.get("x"));
       Exp.eq(HLLExp.mayContain(Exp.val(list), Exp.hllBin("a")), Exp.val(1));