test_class.file: ml/streaminer/src/test/java/org/streaminer/stream/cardinality/TestHyperLogLog.java
test_class.identifier: TestHyperLogLog
test_case.body: @Test
      public void testMerge() throws CardinalityMergeException
      {
          int numToMerge = 5;
          int bits = 16;
          int cardinality = 1000000;
  
          HyperLogLog[] hyperLogLogs = new HyperLogLog[numToMerge];
          HyperLogLog baseline = new HyperLogLog(bits);
          for (int i = 0; i < numToMerge; i++)
          {
              hyperLogLogs[i] = new HyperLogLog(bits);
              for (int j = 0; j < cardinality; j++)
              {
                  double val = Math.random();
                  hyperLogLogs[i].offer(val);
                  baseline.offer(val);
              }
          }
  
  
          long expectedCardinality = numToMerge * cardinality;
          HyperLogLog hll = hyperLogLogs[0];
          hyperLogLogs = Arrays.asList(hyperLogLogs).subList(1, hyperLogLogs.length).toArray(new HyperLogLog[0]);
          long mergedEstimate = hll.merge(hyperLogLogs).cardinality();
          long baselineEstimate = baseline.cardinality();
          double se = expectedCardinality * (1.04 / Math.sqrt(Math.pow(2, bits)));
  
          System.out.println("Baseline estimate: " + baselineEstimate);
          System.out.println("Expect estimate: " + mergedEstimate + " is between " + (expectedCardinality - (3 * se)) + " and " + (expectedCardinality + (3 * se)));
  
          assertTrue(mergedEstimate >= expectedCardinality - (3 * se));
          assertTrue(mergedEstimate <= expectedCardinality + (3 * se));
          assertEquals(mergedEstimate, baselineEstimate);
      }
test_case.class_method_signature: TestHyperLogLog.testMerge()
test_case.full_signature: @Test public void testMerge()
test_case.identifier: testMerge
test_case.invocations: random offer offer toArray subList asList cardinality merge cardinality sqrt pow println println assertTrue assertTrue assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testMerge()
focal_class.declarator: registerSet
focal_class.modifier: private final
focal_class.original_string: private final RegisterSet registerSet;
focal_class.type: RegisterSet
focal_class.var_name: registerSet
focal_class.declarator: log2m
focal_class.modifier: private final
focal_class.original_string: private final int log2m;
focal_class.type: int
focal_class.var_name: log2m
focal_class.declarator: alphaMM
focal_class.modifier: private final
focal_class.original_string: private final double alphaMM;
focal_class.type: double
focal_class.var_name: alphaMM
focal_class.file: ml/streaminer/src/main/java/org/streaminer/stream/cardinality/HyperLogLog.java
focal_class.identifier: HyperLogLog
focal_class.interfaces: implements IRichCardinality
focal_class.class_method_signature: HyperLogLog.HyperLogLog(double rsd)
focal_class.full_signature: public  HyperLogLog(double rsd)
focal_class.identifier: HyperLogLog
focal_class.modifiers: public
focal_class.parameters: (double rsd)
focal_class.signature:  HyperLogLog(double rsd)
focal_class.class_method_signature: HyperLogLog.log2m(double rsd)
focal_class.full_signature: private static int log2m(double rsd)
focal_class.identifier: log2m
focal_class.modifiers: private static
focal_class.parameters: (double rsd)
focal_class.return: int
focal_class.signature: int log2m(double rsd)
focal_class.class_method_signature: HyperLogLog.HyperLogLog(int log2m)
focal_class.full_signature: public  HyperLogLog(int log2m)
focal_class.identifier: HyperLogLog
focal_class.modifiers: public
focal_class.parameters: (int log2m)
focal_class.signature:  HyperLogLog(int log2m)
focal_class.class_method_signature: HyperLogLog.HyperLogLog(int log2m, RegisterSet registerSet)
focal_class.full_signature: public  HyperLogLog(int log2m, RegisterSet registerSet)
focal_class.identifier: HyperLogLog
focal_class.modifiers: public
focal_class.parameters: (int log2m, RegisterSet registerSet)
focal_class.signature:  HyperLogLog(int log2m, RegisterSet registerSet)
focal_class.class_method_signature: HyperLogLog.offerHashed(long hashedValue)
focal_class.full_signature: @Override public boolean offerHashed(long hashedValue)
focal_class.identifier: offerHashed
focal_class.modifiers: @Override public
focal_class.parameters: (long hashedValue)
focal_class.return: boolean
focal_class.signature: boolean offerHashed(long hashedValue)
focal_class.class_method_signature: HyperLogLog.offerHashed(int hashedValue)
focal_class.full_signature: @Override public boolean offerHashed(int hashedValue)
focal_class.identifier: offerHashed
focal_class.modifiers: @Override public
focal_class.parameters: (int hashedValue)
focal_class.return: boolean
focal_class.signature: boolean offerHashed(int hashedValue)
focal_class.class_method_signature: HyperLogLog.offer(Object o)
focal_class.full_signature: @Override public boolean offer(Object o)
focal_class.identifier: offer
focal_class.modifiers: @Override public
focal_class.parameters: (Object o)
focal_class.return: boolean
focal_class.signature: boolean offer(Object o)
focal_class.class_method_signature: HyperLogLog.cardinality()
focal_class.full_signature: @Override public long cardinality()
focal_class.identifier: cardinality
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: long
focal_class.signature: long cardinality()
focal_class.class_method_signature: HyperLogLog.sizeof()
focal_class.full_signature: @Override public int sizeof()
focal_class.identifier: sizeof
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int sizeof()
focal_class.class_method_signature: HyperLogLog.getBytes()
focal_class.full_signature: @Override public byte[] getBytes()
focal_class.identifier: getBytes
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: byte[]
focal_class.signature: byte[] getBytes()
focal_class.class_method_signature: HyperLogLog.addAll(HyperLogLog other)
focal_class.full_signature: public void addAll(HyperLogLog other)
focal_class.identifier: addAll
focal_class.modifiers: public
focal_class.parameters: (HyperLogLog other)
focal_class.return: void
focal_class.signature: void addAll(HyperLogLog other)
focal_class.class_method_signature: HyperLogLog.merge(IRichCardinality... estimators)
focal_class.full_signature: @Override public IRichCardinality merge(IRichCardinality... estimators)
focal_class.identifier: merge
focal_class.modifiers: @Override public
focal_class.parameters: (IRichCardinality... estimators)
focal_class.return: IRichCardinality
focal_class.signature: IRichCardinality merge(IRichCardinality... estimators)
focal_method.body: @Override
      public IRichCardinality merge(IRichCardinality... estimators) throws CardinalityMergeException {
          HyperLogLog merged = new HyperLogLog(log2m);
          merged.addAll(this);
  
          if (estimators == null) {
              return merged;
          }
  
          for (IRichCardinality estimator : estimators) {
              if (!(estimator instanceof HyperLogLog)) {
                  throw new HyperLogLogMergeException("Cannot merge estimators of different class");
              }
              HyperLogLog hll = (HyperLogLog) estimator;
              merged.addAll(hll);
          }
  
          return merged;
      }
focal_method.class_method_signature: HyperLogLog.merge(IRichCardinality... estimators)
focal_method.full_signature: @Override public IRichCardinality merge(IRichCardinality... estimators)
focal_method.identifier: merge
focal_method.invocations: addAll addAll
focal_method.modifiers: @Override public
focal_method.parameters: (IRichCardinality... estimators)
focal_method.return: IRichCardinality
focal_method.signature: IRichCardinality merge(IRichCardinality... estimators)