test_class.file: ml/streaminer/src/test/java/org/streaminer/stream/cardinality/TestLogLog.java
test_class.identifier: TestLogLog
test_case.body: @Test
      public void testMerge() throws CardinalityMergeException
      {
          int numToMerge = 5;
          int bits = 16;
          int cardinality = 1000000;
  
          LogLog[] loglogs = new LogLog[numToMerge];
          LogLog baseline = new LogLog(bits);
          for (int i = 0; i < numToMerge; i++)
          {
              loglogs[i] = new LogLog(bits);
              for (int j = 0; j < cardinality; j++)
              {
                  double val = Math.random();
                  loglogs[i].offer(val);
                  baseline.offer(val);
              }
          }
  
  
          LogLog hll = loglogs[0];
          loglogs = Arrays.asList(loglogs).subList(1, loglogs.length).toArray(new LogLog[0]);
          long mergedEstimate = hll.merge(loglogs).cardinality();
          long baselineEstimate = baseline.cardinality();
  
          System.out.println("Baseline estimate: " + baselineEstimate);
  
          assertEquals(mergedEstimate, baselineEstimate);
      }
test_case.class_method_signature: TestLogLog.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 println assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testMerge()
focal_class.declarator: mAlpha = {
              0,
              0.44567926005415,
              1.2480639342271,
              2.8391255240079,
              6.0165231584811,
              12.369319965552,
              25.073991603109,
              50.482891762521,
              101.30047482549,
              202.93553337953,
              406.20559693552,
              812.74569741657,
              1625.8258887309,
              3251.9862249084,
              6504.3071471860,
              13008.949929672,
              26018.222470181,
              52036.684135280,
              104073.41696276,
              208139.24771523,
              416265.57100022,
              832478.53851627,
              1669443.2499579,
              3356902.8702907,
              6863377.8429508,
              11978069.823687,
              31333767.455026,
              52114301.457757,
              72080129.928986,
              68945006.880409,
              31538957.552704,
              3299942.4347441
      }
focal_class.modifier: protected static final
focal_class.original_string: protected static final double[] mAlpha = {
              0,
              0.44567926005415,
              1.2480639342271,
              2.8391255240079,
              6.0165231584811,
              12.369319965552,
              25.073991603109,
              50.482891762521,
              101.30047482549,
              202.93553337953,
              406.20559693552,
              812.74569741657,
              1625.8258887309,
              3251.9862249084,
              6504.3071471860,
              13008.949929672,
              26018.222470181,
              52036.684135280,
              104073.41696276,
              208139.24771523,
              416265.57100022,
              832478.53851627,
              1669443.2499579,
              3356902.8702907,
              6863377.8429508,
              11978069.823687,
              31333767.455026,
              52114301.457757,
              72080129.928986,
              68945006.880409,
              31538957.552704,
              3299942.4347441
      };
focal_class.type: double[]
focal_class.var_name: mAlpha
focal_class.declarator: k
focal_class.modifier: protected final
focal_class.original_string: protected final int k;
focal_class.type: int
focal_class.var_name: k
focal_class.declarator: m
focal_class.modifier: protected
focal_class.original_string: protected int m;
focal_class.type: int
focal_class.var_name: m
focal_class.declarator: Ca
focal_class.modifier: protected
focal_class.original_string: protected double Ca;
focal_class.type: double
focal_class.var_name: Ca
focal_class.declarator: M
focal_class.modifier: protected
focal_class.original_string: protected byte[] M;
focal_class.type: byte[]
focal_class.var_name: M
focal_class.declarator: Rsum = 0
focal_class.modifier: protected
focal_class.original_string: protected int Rsum = 0;
focal_class.type: int
focal_class.var_name: Rsum
focal_class.file: ml/streaminer/src/main/java/org/streaminer/stream/cardinality/LogLog.java
focal_class.identifier: LogLog
focal_class.interfaces: implements IRichCardinality
focal_class.class_method_signature: LogLog.LogLog(int k)
focal_class.full_signature: public  LogLog(int k)
focal_class.identifier: LogLog
focal_class.modifiers: public
focal_class.parameters: (int k)
focal_class.signature:  LogLog(int k)
focal_class.class_method_signature: LogLog.LogLog(byte[] M)
focal_class.full_signature: public  LogLog(byte[] M)
focal_class.identifier: LogLog
focal_class.modifiers: public
focal_class.parameters: (byte[] M)
focal_class.signature:  LogLog(byte[] M)
focal_class.class_method_signature: LogLog.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: LogLog.sizeof()
focal_class.full_signature: public int sizeof()
focal_class.identifier: sizeof
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int sizeof()
focal_class.class_method_signature: LogLog.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: LogLog.offerHashed(long hashedLong)
focal_class.full_signature: @Override public boolean offerHashed(long hashedLong)
focal_class.identifier: offerHashed
focal_class.modifiers: @Override public
focal_class.parameters: (long hashedLong)
focal_class.return: boolean
focal_class.signature: boolean offerHashed(long hashedLong)
focal_class.class_method_signature: LogLog.offerHashed(int hashedInt)
focal_class.full_signature: @Override public boolean offerHashed(int hashedInt)
focal_class.identifier: offerHashed
focal_class.modifiers: @Override public
focal_class.parameters: (int hashedInt)
focal_class.return: boolean
focal_class.signature: boolean offerHashed(int hashedInt)
focal_class.class_method_signature: LogLog.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: LogLog.rho(int x, int k)
focal_class.full_signature: protected static int rho(int x, int k)
focal_class.identifier: rho
focal_class.modifiers: protected static
focal_class.parameters: (int x, int k)
focal_class.return: int
focal_class.signature: int rho(int x, int k)
focal_class.class_method_signature: LogLog.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_class.class_method_signature: LogLog.mergeEstimators(LogLog... estimators)
focal_class.full_signature: public static LogLog mergeEstimators(LogLog... estimators)
focal_class.identifier: mergeEstimators
focal_class.modifiers: public static
focal_class.parameters: (LogLog... estimators)
focal_class.return: LogLog
focal_class.signature: LogLog mergeEstimators(LogLog... estimators)
focal_method.body: @Override
      public IRichCardinality merge(IRichCardinality... estimators) throws LogLogMergeException
      {
          if (estimators == null)
          {
              return new LogLog(M);
          }
          
          byte[] mergedBytes = Arrays.copyOf(this.M, this.M.length);
          for (IRichCardinality estimator : estimators)
          {
              if (!(this.getClass().isInstance(estimator)))
              {
                  throw new LogLogMergeException("Cannot merge estimators of different class");
              }
              if (estimator.sizeof() != this.sizeof())
              {
                  throw new LogLogMergeException("Cannot merge estimators of different sizes");
              }
              LogLog ll = (LogLog) estimator;
              for (int i = 0; i < mergedBytes.length; ++i)
              {
                  mergedBytes[i] = (byte) Math.max(mergedBytes[i], ll.M[i]);
              }
          }
  
          return new LogLog(mergedBytes);
      }
focal_method.class_method_signature: LogLog.merge(IRichCardinality... estimators)
focal_method.full_signature: @Override public IRichCardinality merge(IRichCardinality... estimators)
focal_method.identifier: merge
focal_method.invocations: copyOf isInstance getClass sizeof sizeof max
focal_method.modifiers: @Override public
focal_method.parameters: (IRichCardinality... estimators)
focal_method.return: IRichCardinality
focal_method.signature: IRichCardinality merge(IRichCardinality... estimators)