public Sketch<?> merge(Sketch<?> left, Sketch<?> right) {
        if (left instanceof NormalSketch && right instanceof NormalSketch) {
            return mergeNormalWithNormal(asNormal(left), asNormal(right));
        } else if (left instanceof NormalSketch && right instanceof SparseSketch) {
            return mergeNormalWithSparse(asNormal(left), asSparse(right));
        } else if (left instanceof SparseSketch && right instanceof NormalSketch) {
            return mergeNormalWithSparse(asNormal(right), asSparse(left));
        } else if (left instanceof SparseSketch && right instanceof SparseSketch) {
            return mergeSparseWithSparse(asSparse(left), asSparse(right));
        } else {
            throw new IllegalArgumentException(
                    String.format("Invalid sketch types: left=%s, right=%s", right.getClass(), left.getClass()));
        }
    }
Merges one of the two sketches into the other. The merge operation is performed in-place is possible.

@param left Either a {@link NormalSketch} or {@link SparseSketch}.
@param right Either a {@link NormalSketch} or {@link SparseSketch}.
@return The merged sketch. Is either first parameter, the other parameter or a new instance.
searchlib/src/main/java/com/yahoo/searchlib/aggregation/hll/SketchMerger.java