docs: public static <T> ItemsSketch<T> getInstance(final Memory srcMem,
                                                 final Comparator<? super T> comparator,
                                                 final ArrayOfItemsSerDe<T> serDe) {
      final long memCapBytes = srcMem.getCapacity();
      if (memCapBytes < 8) {
        throw new SketchesArgumentException("Memory too small: " + memCapBytes);
      }
  
      final int preambleLongs = extractPreLongs(srcMem);
      final int serVer = extractSerVer(srcMem);
      final int familyID = extractFamilyID(srcMem);
      final int flags = extractFlags(srcMem);
      final int k = extractK(srcMem);
  
      ItemsUtil.checkItemsSerVer(serVer);
  
      if ((serVer == 3) && ((flags & COMPACT_FLAG_MASK) == 0)) {
        throw new SketchesArgumentException("Non-compact Memory images are not supported.");
      }
  
      final boolean empty = Util.checkPreLongsFlagsCap(preambleLongs, flags, memCapBytes);
      Util.checkFamilyID(familyID);
  
      final ItemsSketch<T> qs = getInstance(k, comparator); //checks k
      if (empty) { return qs; }
  
      //Not empty, must have valid preamble + min, max
      final long n = extractN(srcMem);
  
      //can't check memory capacity here, not enough information
      final int extra = 2; //for min, max
      final int numMemItems = Util.computeRetainedItems(k, n) + extra;
  
      //set class members
      qs.n_ = n;
      qs.combinedBufferItemCapacity_ = Util.computeCombinedBufferItemCapacity(k, n);
      qs.baseBufferCount_ = computeBaseBufferItems(k, n);
      qs.bitPattern_ = computeBitPattern(k, n);
      qs.combinedBuffer_ = new Object[qs.combinedBufferItemCapacity_];
  
      final int srcMemItemsOffsetBytes = preambleLongs * Long.BYTES;
      final Memory mReg = srcMem.region(srcMemItemsOffsetBytes,
          srcMem.getCapacity() - srcMemItemsOffsetBytes);
      final T[] itemsArray = serDe.deserializeFromMemory(mReg, numMemItems);
      qs.itemsArrayToCombinedBuffer(itemsArray);
      return qs;
    }