test_class.declarator: fraction = 0.01
test_class.modifier: static final
test_class.original_string: static final double fraction = 0.01;
test_class.type: double
test_class.var_name: fraction
test_class.declarator: error = 0.005
test_class.modifier: static final
test_class.original_string: static final double error = 0.005;
test_class.type: double
test_class.var_name: error
test_class.declarator: confidence = 0.99
test_class.modifier: static final
test_class.original_string: static final double confidence = 0.99;
test_class.type: double
test_class.var_name: confidence
test_class.declarator: seed = 7362181
test_class.modifier: static final
test_class.original_string: static final int seed = 7362181;
test_class.type: int
test_class.var_name: seed
test_class.declarator: r = new Random()
test_class.modifier: static final
test_class.original_string: static final Random r = new Random();
test_class.type: Random
test_class.var_name: r
test_class.declarator: cardinality = 1000000
test_class.modifier: static final
test_class.original_string: static final int cardinality = 1000000;
test_class.type: int
test_class.var_name: cardinality
test_class.declarator: maxScale = 100000
test_class.modifier: static final
test_class.original_string: static final int maxScale = 100000;
test_class.type: int
test_class.var_name: maxScale
test_class.file: flink-contrib/flink-operator-stats/src/test/java/org/apache/flink/contrib/operatorstatistics/heavyhitters/CountMinHeavyHitterTest.java
test_class.identifier: CountMinHeavyHitterTest
test_case.body: @Test
  	public void merge() throws CountMinHeavyHitter.CMHeavyHitterMergeException {
  
  		int numToMerge = 5;
  
  		long[] actualFreq = new long[maxScale];
  		CountMinHeavyHitter merged = new CountMinHeavyHitter(fraction,error,confidence,seed);
  		long totalCardinality = 0;
  
  		CountMinHeavyHitter[] sketches = new CountMinHeavyHitter[numToMerge];
  		for (int i = 0; i < numToMerge; i++) {
  			CountMinSketch cms = new CountMinSketch(error, confidence, seed);
  			sketches[i] = new CountMinHeavyHitter(cms, fraction);
  			for (int j = 0; j < cardinality; j++) {
  				int val;
  				if (r.nextDouble()<0.1){
  					val = r.nextInt(10);
  				}else{
  					val = r.nextInt(maxScale);
  				}
  				sketches[i].addObject(val);
  				actualFreq[val]++;
  				totalCardinality++;
  			}
  			merged.merge(sketches[i]);
  		}
  
  		Map<Object,Long> mergedHeavyHitters = merged.getHeavyHitters();
  		long frequency = (long)(totalCardinality*fraction);
  
  		for (int i = 0; i < actualFreq.length; ++i) {
  			if (actualFreq[i] >= frequency) {
  				assertTrue("All items with freq. > s.n will be found. Item " + i + ". Real freq. " + actualFreq[i] + " Expected freq." + frequency, mergedHeavyHitters.containsKey(i));
  			}
  		}
  	}
test_case.class_method_signature: CountMinHeavyHitterTest.merge()
test_case.full_signature: @Test public void merge()
test_case.identifier: merge
test_case.invocations: nextDouble nextInt nextInt addObject merge getHeavyHitters assertTrue containsKey
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void merge()
focal_class.declarator: countMinSketch
focal_class.modifier: private transient
focal_class.original_string: private transient CountMinSketch countMinSketch;
focal_class.type: CountMinSketch
focal_class.var_name: countMinSketch
focal_class.declarator: heavyHitters
focal_class.modifier: private
focal_class.original_string: private HashMap<Object,Long> heavyHitters;
focal_class.type: HashMap<Object,Long>
focal_class.var_name: heavyHitters
focal_class.declarator: fraction
focal_class.modifier: private
focal_class.original_string: private double fraction;
focal_class.type: double
focal_class.var_name: fraction
focal_class.declarator: error
focal_class.modifier: private
focal_class.original_string: private double error;
focal_class.type: double
focal_class.var_name: error
focal_class.declarator: cardinality
focal_class.modifier: private
focal_class.original_string: private long cardinality;
focal_class.type: long
focal_class.var_name: cardinality
focal_class.file: flink-contrib/flink-operator-stats/src/main/java/org/apache/flink/contrib/operatorstatistics/heavyhitters/CountMinHeavyHitter.java
focal_class.identifier: CountMinHeavyHitter
focal_class.interfaces: implements HeavyHitter, Serializable
focal_class.class_method_signature: CountMinHeavyHitter.CountMinHeavyHitter(double fraction, double error, double confidence, int seed)
focal_class.full_signature: public  CountMinHeavyHitter(double fraction, double error, double confidence, int seed)
focal_class.identifier: CountMinHeavyHitter
focal_class.modifiers: public
focal_class.parameters: (double fraction, double error, double confidence, int seed)
focal_class.signature:  CountMinHeavyHitter(double fraction, double error, double confidence, int seed)
focal_class.class_method_signature: CountMinHeavyHitter.CountMinHeavyHitter(CountMinSketch countMinSketch, double fraction)
focal_class.full_signature: public  CountMinHeavyHitter(CountMinSketch countMinSketch, double fraction)
focal_class.identifier: CountMinHeavyHitter
focal_class.modifiers: public
focal_class.parameters: (CountMinSketch countMinSketch, double fraction)
focal_class.signature:  CountMinHeavyHitter(CountMinSketch countMinSketch, double fraction)
focal_class.class_method_signature: CountMinHeavyHitter.addObject(Object o)
focal_class.full_signature: @Override public void addObject(Object o)
focal_class.identifier: addObject
focal_class.modifiers: @Override public
focal_class.parameters: (Object o)
focal_class.return: void
focal_class.signature: void addObject(Object o)
focal_class.class_method_signature: CountMinHeavyHitter.updateHeavyHitters(Object item)
focal_class.full_signature: private void updateHeavyHitters(Object item)
focal_class.identifier: updateHeavyHitters
focal_class.modifiers: private
focal_class.parameters: (Object item)
focal_class.return: void
focal_class.signature: void updateHeavyHitters(Object item)
focal_class.class_method_signature: CountMinHeavyHitter.removeNonFrequent(long minFrequency)
focal_class.full_signature: private void removeNonFrequent(long minFrequency)
focal_class.identifier: removeNonFrequent
focal_class.modifiers: private
focal_class.parameters: (long minFrequency)
focal_class.return: void
focal_class.signature: void removeNonFrequent(long minFrequency)
focal_class.class_method_signature: CountMinHeavyHitter.estimateCount(Object item)
focal_class.full_signature: public long estimateCount(Object item)
focal_class.identifier: estimateCount
focal_class.modifiers: public
focal_class.parameters: (Object item)
focal_class.return: long
focal_class.signature: long estimateCount(Object item)
focal_class.class_method_signature: CountMinHeavyHitter.merge(HeavyHitter toMerge)
focal_class.full_signature: public void merge(HeavyHitter toMerge)
focal_class.identifier: merge
focal_class.modifiers: public
focal_class.parameters: (HeavyHitter toMerge)
focal_class.return: void
focal_class.signature: void merge(HeavyHitter toMerge)
focal_class.class_method_signature: CountMinHeavyHitter.getHeavyHitters()
focal_class.full_signature: @Override public HashMap<Object,Long> getHeavyHitters()
focal_class.identifier: getHeavyHitters
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: HashMap<Object,Long>
focal_class.signature: HashMap<Object,Long> getHeavyHitters()
focal_class.class_method_signature: CountMinHeavyHitter.toString()
focal_class.full_signature: @Override public String toString()
focal_class.identifier: toString
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String toString()
focal_class.class_method_signature: CountMinHeavyHitter.writeObject(ObjectOutputStream oos)
focal_class.full_signature: private void writeObject(ObjectOutputStream oos)
focal_class.identifier: writeObject
focal_class.modifiers: private
focal_class.parameters: (ObjectOutputStream oos)
focal_class.return: void
focal_class.signature: void writeObject(ObjectOutputStream oos)
focal_class.class_method_signature: CountMinHeavyHitter.readObject(ObjectInputStream in)
focal_class.full_signature: private void readObject(ObjectInputStream in)
focal_class.identifier: readObject
focal_class.modifiers: private
focal_class.parameters: (ObjectInputStream in)
focal_class.return: void
focal_class.signature: void readObject(ObjectInputStream in)
focal_method.body: public void merge(HeavyHitter toMerge) throws CMHeavyHitterMergeException {
  
  		try {
  			CountMinHeavyHitter cmToMerge = (CountMinHeavyHitter)toMerge;
  			if (this.fraction != cmToMerge.fraction) {
  				throw new CMHeavyHitterMergeException("The fraction for both heavy hitters must be the same");
  			}
  
  			this.countMinSketch = CountMinSketch.merge(this.countMinSketch, cmToMerge.countMinSketch);
  
  			HashMap<Object,Long> mergedHeavyHitters = new HashMap<Object, Long>();
  
  			for (Map.Entry<Object, Long> entry : this.heavyHitters.entrySet()) {
  				mergedHeavyHitters.put(entry.getKey(), estimateCount(entry.getKey()));
  			}
  
  			for (Map.Entry<Object, Long> entry : cmToMerge.heavyHitters.entrySet()) {
  				if (!mergedHeavyHitters.containsKey(entry.getKey())) {
  					mergedHeavyHitters.put(entry.getKey(), estimateCount(entry.getKey()));
  				}
  			}
  			this.heavyHitters = mergedHeavyHitters;
  			cardinality+=cmToMerge.cardinality;
  
  		}catch (ClassCastException ex){
  			throw new CMHeavyHitterMergeException("Both heavy hitter objects must belong to the same class");
  		}catch (Exception ex){
  			throw new CMHeavyHitterMergeException("Cannot merge count min sketches: "+ex.getMessage());
  		}
  	}
focal_method.class_method_signature: CountMinHeavyHitter.merge(HeavyHitter toMerge)
focal_method.full_signature: public void merge(HeavyHitter toMerge)
focal_method.identifier: merge
focal_method.invocations: merge entrySet put getKey estimateCount getKey entrySet containsKey getKey put getKey estimateCount getKey getMessage
focal_method.modifiers: public
focal_method.parameters: (HeavyHitter toMerge)
focal_method.return: void
focal_method.signature: void merge(HeavyHitter toMerge)