@Override public CountMinSketch mergeInPlace(CountMinSketch other) throws IncompatibleMergeException { if (other == null) { throw new IncompatibleMergeException("Cannot merge null estimator"); } if (!(other instanceof CountMinSketchImpl)) { throw new IncompatibleMergeException( "Cannot merge estimator of class " + other.getClass().getName() ); } CountMinSketchImpl that = (CountMinSketchImpl) other; if (this.depth != that.depth) { throw new IncompatibleMergeException("Cannot merge estimators of different depth"); } if (this.width != that.width) { throw new IncompatibleMergeException("Cannot merge estimators of different width"); } if (!Arrays.equals(this.hashA, that.hashA)) { throw new IncompatibleMergeException("Cannot merge estimators of different seed"); } for (int i = 0; i < this.table.length; ++i) { for (int j = 0; j < this.table[i].length; ++j) { this.table[i][j] = this.table[i][j] + that.table[i][j]; } } this.totalCount += that.totalCount; return this; }
@Override public CountMinSketch mergeInPlace(CountMinSketch other) throws IncompatibleMergeException { if (other == null) { throw new IncompatibleMergeException("Cannot merge null estimator"); } if (!(other instanceof CountMinSketchImpl)) { throw new IncompatibleMergeException( "Cannot merge estimator of class " + other.getClass().getName() ); } CountMinSketchImpl that = (CountMinSketchImpl) other; if (this.depth != that.depth) { throw new IncompatibleMergeException("Cannot merge estimators of different depth"); } if (this.width != that.width) { throw new IncompatibleMergeException("Cannot merge estimators of different width"); } if (!Arrays.equals(this.hashA, that.hashA)) { throw new IncompatibleMergeException("Cannot merge estimators of different seed"); } for (int i = 0; i < this.table.length; ++i) { for (int j = 0; j < this.table[i].length; ++j) { this.table[i][j] = this.table[i][j] + that.table[i][j]; } } this.totalCount += that.totalCount; return this; }
@Override public CountMinSketch mergeInPlace(CountMinSketch other) throws IncompatibleMergeException { if (other == null) { throw new IncompatibleMergeException("Cannot merge null estimator"); } if (!(other instanceof CountMinSketchImpl)) { throw new IncompatibleMergeException( "Cannot merge estimator of class " + other.getClass().getName() ); } CountMinSketchImpl that = (CountMinSketchImpl) other; if (this.depth != that.depth) { throw new IncompatibleMergeException("Cannot merge estimators of different depth"); } if (this.width != that.width) { throw new IncompatibleMergeException("Cannot merge estimators of different width"); } if (!Arrays.equals(this.hashA, that.hashA)) { throw new IncompatibleMergeException("Cannot merge estimators of different seed"); } for (int i = 0; i < this.table.length; ++i) { for (int j = 0; j < this.table[i].length; ++j) { this.table[i][j] = this.table[i][j] + that.table[i][j]; } } this.totalCount += that.totalCount; return this; }
@Override public CountMinSketch mergeInPlace(CountMinSketch other) throws IncompatibleMergeException { if (other == null) { throw new IncompatibleMergeException("Cannot merge null estimator"); } if (!(other instanceof CountMinSketchImpl)) { throw new IncompatibleMergeException( "Cannot merge estimator of class " + other.getClass().getName() ); } CountMinSketchImpl that = (CountMinSketchImpl) other; if (this.depth != that.depth) { throw new IncompatibleMergeException("Cannot merge estimators of different depth"); } if (this.width != that.width) { throw new IncompatibleMergeException("Cannot merge estimators of different width"); } if (!Arrays.equals(this.hashA, that.hashA)) { throw new IncompatibleMergeException("Cannot merge estimators of different seed"); } for (int i = 0; i < this.table.length; ++i) { for (int j = 0; j < this.table[i].length; ++j) { this.table[i][j] = this.table[i][j] + that.table[i][j]; } } this.totalCount += that.totalCount; return this; }
@Override public BloomFilter mergeInPlace(BloomFilter other) throws IncompatibleMergeException { // Duplicates the logic of `isCompatible` here to provide better error message. if (other == null) { throw new IncompatibleMergeException("Cannot merge null bloom filter"); } if (!(other instanceof BloomFilterImpl)) { throw new IncompatibleMergeException( "Cannot merge bloom filter of class " + other.getClass().getName() ); } BloomFilterImpl that = (BloomFilterImpl) other; if (this.bitSize() != that.bitSize()) { throw new IncompatibleMergeException("Cannot merge bloom filters with different bit size"); } if (this.numHashFunctions != that.numHashFunctions) { throw new IncompatibleMergeException( "Cannot merge bloom filters with different number of hash functions" ); } this.bits.putAll(that.bits); return this; }
@Override public BloomFilter mergeInPlace(BloomFilter other) throws IncompatibleMergeException { // Duplicates the logic of `isCompatible` here to provide better error message. if (other == null) { throw new IncompatibleMergeException("Cannot merge null bloom filter"); } if (!(other instanceof BloomFilterImpl)) { throw new IncompatibleMergeException( "Cannot merge bloom filter of class " + other.getClass().getName() ); } BloomFilterImpl that = (BloomFilterImpl) other; if (this.bitSize() != that.bitSize()) { throw new IncompatibleMergeException("Cannot merge bloom filters with different bit size"); } if (this.numHashFunctions != that.numHashFunctions) { throw new IncompatibleMergeException( "Cannot merge bloom filters with different number of hash functions" ); } this.bits.putAll(that.bits); return this; }
@Override public BloomFilter mergeInPlace(BloomFilter other) throws IncompatibleMergeException { // Duplicates the logic of `isCompatible` here to provide better error message. if (other == null) { throw new IncompatibleMergeException("Cannot merge null bloom filter"); } if (!(other instanceof BloomFilterImpl)) { throw new IncompatibleMergeException( "Cannot merge bloom filter of class " + other.getClass().getName() ); } BloomFilterImpl that = (BloomFilterImpl) other; if (this.bitSize() != that.bitSize()) { throw new IncompatibleMergeException("Cannot merge bloom filters with different bit size"); } if (this.numHashFunctions != that.numHashFunctions) { throw new IncompatibleMergeException( "Cannot merge bloom filters with different number of hash functions" ); } this.bits.putAll(that.bits); return this; }
@Override public BloomFilter mergeInPlace(BloomFilter other) throws IncompatibleMergeException { // Duplicates the logic of `isCompatible` here to provide better error message. if (other == null) { throw new IncompatibleMergeException("Cannot merge null bloom filter"); } if (!(other instanceof BloomFilterImpl)) { throw new IncompatibleMergeException( "Cannot merge bloom filter of class " + other.getClass().getName() ); } BloomFilterImpl that = (BloomFilterImpl) other; if (this.bitSize() != that.bitSize()) { throw new IncompatibleMergeException("Cannot merge bloom filters with different bit size"); } if (this.numHashFunctions != that.numHashFunctions) { throw new IncompatibleMergeException( "Cannot merge bloom filters with different number of hash functions" ); } this.bits.putAll(that.bits); return this; }