/** * Wrap this sketch around the given non-compact Memory image of a DoublesSketch. * * @param srcMem the given non-compact Memory image of a DoublesSketch that may have data * @return a sketch that wraps the given srcMem */ static DirectUpdateDoublesSketch wrapInstance(final WritableMemory srcMem) { final long memCap = srcMem.getCapacity(); final int preLongs = extractPreLongs(srcMem); final int serVer = extractSerVer(srcMem); final int familyID = extractFamilyID(srcMem); final int flags = extractFlags(srcMem); final int k = extractK(srcMem); final boolean empty = (flags & EMPTY_FLAG_MASK) > 0; //Preamble flags empty state final long n = empty ? 0 : extractN(srcMem); //VALIDITY CHECKS checkPreLongs(preLongs); Util.checkFamilyID(familyID); DoublesUtil.checkDoublesSerVer(serVer, MIN_DIRECT_DOUBLES_SER_VER); checkDirectFlags(flags); //Cannot be compact Util.checkK(k); checkCompact(serVer, flags); checkDirectMemCapacity(k, n, memCap); checkEmptyAndN(empty, n); final DirectUpdateDoublesSketch dds = new DirectUpdateDoublesSketch(k); dds.mem_ = srcMem; return dds; }
/** * Wrap this sketch around the given non-compact Memory image of a DoublesSketch. * * @param srcMem the given non-compact Memory image of a DoublesSketch that may have data * @return a sketch that wraps the given srcMem */ static DirectUpdateDoublesSketch wrapInstance(final WritableMemory srcMem) { final long memCap = srcMem.getCapacity(); final int preLongs = extractPreLongs(srcMem); final int serVer = extractSerVer(srcMem); final int familyID = extractFamilyID(srcMem); final int flags = extractFlags(srcMem); final int k = extractK(srcMem); final boolean empty = (flags & EMPTY_FLAG_MASK) > 0; //Preamble flags empty state final long n = empty ? 0 : extractN(srcMem); //VALIDITY CHECKS checkPreLongs(preLongs); Util.checkFamilyID(familyID); DoublesUtil.checkDoublesSerVer(serVer, MIN_DIRECT_DOUBLES_SER_VER); checkDirectFlags(flags); //Cannot be compact Util.checkK(k); checkCompact(serVer, flags); checkDirectMemCapacity(k, n, memCap); checkEmptyAndN(empty, n); final DirectUpdateDoublesSketch dds = new DirectUpdateDoublesSketch(k); dds.mem_ = srcMem; return dds; }