/// <summary> /// Merges another instance of <see cref="CountMinSketch{T}"/> with this collection. The results will be an aggregate of both collections after merging. /// </summary> /// <param name="other">The <see cref="CountMinSketchBase{T}"/> that should be merged into the current collection.</param> /// <returns>This <see cref="CountMinSketch{T}"/> with the results from the other collection included.</returns> public override CountMinSketchBase <T> MergeInPlace(CountMinSketchBase <T> other) { if (other == null) { throw new IncompatibleMergeException("Cannot merge null estimator"); } if (other.Depth != Depth) { throw new IncompatibleMergeException("Cannot merge estimators with different depths"); } if (other.Width != Width) { throw new IncompatibleMergeException("Cannot merge estimators with different widths"); } if (other.Seed != Seed) { throw new IncompatibleMergeException("Cannot merge sketches that were initialized with different seeds"); } for (var i = 0; i < _table.GetLength(0); i++) { for (var j = 0; j < _table.GetLength(1); j++) { _table[i, j] = _table[i, j] + other.Table[i, j]; } } _totalCount += other.TotalCount; return(this); }
/// <summary> /// Merges another <see cref="CountMinSketchBase{T}"/> with this one in place. Other must have the same depth, width, and seed to be merged. /// </summary> /// <param name="other"><see cref="CountMinSketchBase{T}"/> to be merged with this <see cref="CountMinSketchBase{T}"/></param> /// <returns></returns> public abstract CountMinSketchBase <T> MergeInPlace(CountMinSketchBase <T> other);