} catch (SketchesArgumentException e) {} //OK try { DirectUpdateDoublesSketchR.checkEmptyAndN(true, 1); fail(); } catch (SketchesArgumentException e) {} //OK
/** * Wrap this sketch around the given compact Memory image of a DoublesSketch. * * @param srcMem the given compact Memory image of a DoublesSketch that may have data, * @return a sketch that wraps the given srcMem */ static DirectCompactDoublesSketch wrapInstance(final Memory 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; final long n = empty ? 0 : extractN(srcMem); //VALIDITY CHECKS DirectUpdateDoublesSketchR.checkPreLongs(preLongs); Util.checkFamilyID(familyID); DoublesUtil.checkDoublesSerVer(serVer, MIN_DIRECT_DOUBLES_SER_VER); checkCompact(serVer, flags); Util.checkK(k); checkDirectMemCapacity(k, n, memCap); DirectUpdateDoublesSketchR.checkEmptyAndN(empty, n); final DirectCompactDoublesSketch dds = new DirectCompactDoublesSketch(k); dds.mem_ = (WritableMemory) 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 DirectUpdateDoublesSketchR wrapInstance(final Memory 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 DirectUpdateDoublesSketchR dds = new DirectUpdateDoublesSketchR(k); dds.mem_ = (WritableMemory) srcMem; return dds; }
/** * Wrap this sketch around the given compact Memory image of a DoublesSketch. * * @param srcMem the given compact Memory image of a DoublesSketch that may have data, * @return a sketch that wraps the given srcMem */ static DirectCompactDoublesSketch wrapInstance(final Memory 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; final long n = empty ? 0 : extractN(srcMem); //VALIDITY CHECKS DirectUpdateDoublesSketchR.checkPreLongs(preLongs); Util.checkFamilyID(familyID); DoublesUtil.checkDoublesSerVer(serVer, MIN_DIRECT_DOUBLES_SER_VER); checkCompact(serVer, flags); Util.checkK(k); checkDirectMemCapacity(k, n, memCap); DirectUpdateDoublesSketchR.checkEmptyAndN(empty, n); final DirectCompactDoublesSketch dds = new DirectCompactDoublesSketch(k); dds.mem_ = (WritableMemory) 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 DirectUpdateDoublesSketchR wrapInstance(final Memory 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 DirectUpdateDoublesSketchR dds = new DirectUpdateDoublesSketchR(k); dds.mem_ = (WritableMemory) srcMem; return dds; }