code: static DirectUpdateDoublesSketch newInstance(final int k, final WritableMemory dstMem) {
      // must be able to hold at least an empty sketch
      final long memCap = dstMem.getCapacity();
      checkDirectMemCapacity(k, 0, memCap);
  
      //initialize dstMem
      dstMem.putLong(0, 0L); //clear pre0
      insertPreLongs(dstMem, 2);
      insertSerVer(dstMem, DoublesSketch.DOUBLES_SER_VER);
      insertFamilyID(dstMem, Family.QUANTILES.getID());
      insertFlags(dstMem, EMPTY_FLAG_MASK);
      insertK(dstMem, k);
  
      if (memCap >= COMBINED_BUFFER) {
        insertN(dstMem, 0L);
        insertMinDouble(dstMem, Double.NaN);
        insertMaxDouble(dstMem, Double.NaN);
      }
  
      final DirectUpdateDoublesSketch dds = new DirectUpdateDoublesSketch(k);
      dds.mem_ = dstMem;
      return dds;
    }
docs: Obtains a new Direct instance of a DoublesSketch, which may be off-heap.
  
  @param k Parameter that controls space usage of sketch and accuracy of estimates.
  Must be greater than 1 and less than 65536 and a power of 2.
  @param dstMem the destination Memory that will be initialized to hold the data for this sketch.
  It must initially be at least (16 * MIN_K + 32) bytes, where MIN_K defaults to 2. As it grows
  it will request more memory using the MemoryRequest callback.
  @return a DirectUpdateDoublesSketch