docs: @SuppressWarnings({ "unchecked", "null" })
    public void update(final Sketch<S> sketchIn) {
      final boolean isFirstCall = isFirstCall_;
      isFirstCall_ = false;
      if (sketchIn == null) {
        isEmpty_ = true;
        sketch_ = null;
        return;
      }
      theta_ = min(theta_, sketchIn.getThetaLong());
      isEmpty_ |= sketchIn.isEmpty();
      if (isEmpty_ || (sketchIn.getRetainedEntries() == 0)) {
        sketch_ = null;
        return;
      }
      // assumes that constructor of QuickSelectSketch bumps the requested size up to the nearest power of 2
      if (isFirstCall) {
        sketch_ = new QuickSelectSketch<>(sketchIn.getRetainedEntries(), ResizeFactor.X1.lg(), null);
        final SketchIterator<S> it = sketchIn.iterator();
        while (it.next()) {
          final S summary = (S)it.getSummary().copy();
          sketch_.insert(it.getKey(), summary);
        }
      } else {
        if (sketch_ == null) {
          return;
        }
        final int matchSize = min(sketch_.getRetainedEntries(), sketchIn.getRetainedEntries());
        final long[] matchKeys = new long[matchSize];
        S[] matchSummaries = null;
        int matchCount = 0;
        final SketchIterator<S> it = sketchIn.iterator();
        while (it.next()) {
          final S summary = sketch_.find(it.getKey());
          if (summary != null) {
            matchKeys[matchCount] = it.getKey();
            if (matchSummaries == null) {
              matchSummaries = (S[]) Array.newInstance(summary.getClass(), matchSize);
            }
            matchSummaries[matchCount] =
                summarySetOps_.intersection(summary, it.getSummary());
            matchCount++;
          }
        }
        sketch_ = null;
        if (matchCount > 0) {
          sketch_ = new QuickSelectSketch<>(matchCount, ResizeFactor.X1.lg(), null);
          for (int i = 0; i < matchCount; i++) {
            sketch_.insert(matchKeys[i], matchSummaries[i]);
          }
        }
      }
      if (sketch_ != null) {
        sketch_.setThetaLong(theta_);
        sketch_.setNotEmpty();
      }
    }