docs: static void downSamplingMergeInto(final DoublesSketch src, final UpdateDoublesSketch tgt) {
      final int srcK = src.getK();
      final int tgtK = tgt.getK();
      final long tgtN = tgt.getN();
  
      if ((srcK % tgtK) != 0) {
        throw new SketchesArgumentException(
            "source.getK() must equal target.getK() * 2^(nonnegative integer).");
      }
  
      final int downFactor = srcK / tgtK;
      checkIfPowerOf2(downFactor, "source.getK()/target.getK() ratio");
      final int lgDownFactor = Integer.numberOfTrailingZeros(downFactor);
  
      if (src.isEmpty()) { return; }
  
      final DoublesSketchAccessor srcSketchBuf = DoublesSketchAccessor.wrap(src);
      final long nFinal = tgtN + src.getN();
  
      for (int i = 0; i < srcSketchBuf.numItems(); i++) { // update only the base buffer
        tgt.update(srcSketchBuf.get(i));
      }
  
      final int spaceNeeded = DoublesUpdateImpl.getRequiredItemCapacity(tgtK, nFinal);
      final int curCombBufCap = tgt.getCombinedBufferItemCapacity();
      if (spaceNeeded > curCombBufCap) { //copies base buffer plus current levels
        tgt.growCombinedBuffer(curCombBufCap, spaceNeeded);
      }
  
      //working scratch buffers
      final DoublesArrayAccessor scratch2KAcc = DoublesArrayAccessor.initialize(2 * tgtK);
      final DoublesArrayAccessor downScratchKAcc = DoublesArrayAccessor.initialize(tgtK);
  
      final DoublesSketchAccessor tgtSketchBuf = DoublesSketchAccessor.wrap(tgt, true);
  
      long srcBitPattern = src.getBitPattern();
      long newTgtBitPattern = tgt.getBitPattern();
      for (int srcLvl = 0; srcBitPattern != 0L; srcLvl++, srcBitPattern >>>= 1) {
        if ((srcBitPattern & 1L) > 0L) {
          justZipWithStride(
                  srcSketchBuf.setLevel(srcLvl),
                  downScratchKAcc,
                  tgtK,
                  downFactor
          );
          newTgtBitPattern = DoublesUpdateImpl.inPlacePropagateCarry(
                  srcLvl + lgDownFactor,    //starting level
                  downScratchKAcc,       //optSrcKBuf,
                  scratch2KAcc,          //size2KBuf,
                  false,                    //do mergeInto version
                  tgtK,
                  tgtSketchBuf,
                  newTgtBitPattern
          );
  
          tgt.putBitPattern(newTgtBitPattern); //off-heap is a no-op
        }
      }
      if (tgt.isDirect() && (nFinal > 0)) {
        final WritableMemory mem = tgt.getMemory();
        mem.clearBits(FLAGS_BYTE, (byte) EMPTY_FLAG_MASK);
      }
      tgt.putN(nFinal);
  
      assert (tgt.getN() / (2L * tgtK)) == newTgtBitPattern; // internal consistency check
  
      double srcMax = src.getMaxValue();
      srcMax = Double.isNaN(srcMax) ? Double.NEGATIVE_INFINITY : srcMax;
      double srcMin = src.getMinValue();
      srcMin = Double.isNaN(srcMin) ? Double.POSITIVE_INFINITY : srcMin;
  
      double tgtMax = tgt.getMaxValue();
      tgtMax = Double.isNaN(tgtMax) ? Double.NEGATIVE_INFINITY : tgtMax;
      double tgtMin = tgt.getMinValue();
      tgtMin = Double.isNaN(tgtMin) ? Double.POSITIVE_INFINITY : tgtMin;
  
      if (srcMax > tgtMax) { tgt.putMaxValue(srcMax); }
      if (srcMin < tgtMin) { tgt.putMinValue(srcMin); }
    }