@Test(expectedExceptions = SketchesArgumentException.class) public void checkSerVer() { DoublesUtil.checkDoublesSerVer(0, HeapUpdateDoublesSketch.MIN_HEAP_DOUBLES_SER_VER); }
@Override public UpdateDoublesSketch getResult() { if (gadget_ == null) { return HeapUpdateDoublesSketch.newInstance(maxK_); } return DoublesUtil.copyToHeap(gadget_); //can't have any externally owned handles. }
static String toString(final boolean sketchSummary, final boolean dataDetail, final DoublesSketch sketch) { final StringBuilder sb = new StringBuilder(); if (dataDetail) { sb.append(getDataDetail(sketch)); } if (sketchSummary) { sb.append(getSummary(sketch)); } return sb.toString(); }
@Test public void checkPrintMemData2() { final int k = PreambleUtil.DEFAULT_K; final int n = 0; final DoublesSketch qs = buildAndLoadQS(k,n); final byte[] byteArr = qs.toByteArray(); final Memory mem = Memory.wrap(byteArr); println(DoublesUtil.memToString(true, true, mem)); }
/** * Returns summary information about this sketch. Used for debugging. * @param sketchSummary if true includes sketch summary * @param dataDetail if true includes data detail * @return summary information about the sketch. */ public String toString(final boolean sketchSummary, final boolean dataDetail) { return DoublesUtil.toString(sketchSummary, dataDetail, this); }
@Test public void checkPrintMemData() { final int k = 16; final int n = 1000; final DoublesSketch qs = buildAndLoadQS(k,n); byte[] byteArr = qs.toByteArray(false); Memory mem = Memory.wrap(byteArr); println(DoublesUtil.memToString(true, true, mem)); byteArr = qs.toByteArray(true); mem = Memory.wrap(byteArr); println(DoublesUtil.memToString(true, true, mem)); }
/** * Returns summary information about this sketch. Used for debugging. * @param sketchSummary if true includes sketch summary * @param dataDetail if true includes data detail * @return summary information about the sketch. */ public String toString(final boolean sketchSummary, final boolean dataDetail) { return DoublesUtil.toString(sketchSummary, dataDetail, this); }
/** * 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; }
/** * Returns a Heap DoublesUnion object that has been initialized with the data from the given * sketch. * * @param sketch A DoublesSketch to be used as a source of data only and will not be modified. * @return a DoublesUnion object */ static DoublesUnionImpl heapifyInstance(final DoublesSketch sketch) { final int k = sketch.getK(); final DoublesUnionImpl union = new DoublesUnionImpl(k); union.maxK_ = k; union.gadget_ = copyToHeap(sketch); return union; }
static String toString(final boolean sketchSummary, final boolean dataDetail, final DoublesSketch sketch) { final StringBuilder sb = new StringBuilder(); if (dataDetail) { sb.append(getDataDetail(sketch)); } if (sketchSummary) { sb.append(getSummary(sketch)); } return sb.toString(); }
/** * 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; }
private static String getDataDetail(final DoublesSketch sketchIn) { final DoublesSketch sketch = sketchIn.isCompact() ? copyToHeap(sketchIn) : sketchIn; final StringBuilder sb = new StringBuilder(); final String skName = sketch.getClass().getSimpleName();
/** * 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; }
@Test public void checkCopyToHeap() { final int k = 128; final int n = 400; // HeapUpdateDoublesSketch final HeapUpdateDoublesSketch huds = (HeapUpdateDoublesSketch) buildAndLoadQS(k, n); final HeapUpdateDoublesSketch target1 = DoublesUtil.copyToHeap(huds); DoublesSketchTest.testSketchEquality(huds, target1); // DirectUpdateDoublesSketch final WritableMemory mem1 = WritableMemory.wrap(huds.toByteArray()); final DirectUpdateDoublesSketch duds = (DirectUpdateDoublesSketch) UpdateDoublesSketch.wrap(mem1); final HeapUpdateDoublesSketch target2 = DoublesUtil.copyToHeap(duds); DoublesSketchTest.testSketchEquality(huds, duds); DoublesSketchTest.testSketchEquality(duds, target2); // HeapCompactDoublesSketch final CompactDoublesSketch hcds = huds.compact(); final HeapUpdateDoublesSketch target3 = DoublesUtil.copyToHeap(hcds); DoublesSketchTest.testSketchEquality(huds, hcds); DoublesSketchTest.testSketchEquality(hcds, target3); // DirectCompactDoublesSketch final Memory mem2 = Memory.wrap(hcds.toByteArray()); final DirectCompactDoublesSketch dcds = (DirectCompactDoublesSketch) DoublesSketch.wrap(mem2); final HeapUpdateDoublesSketch target4 = DoublesUtil.copyToHeap(dcds); DoublesSketchTest.testSketchEquality(huds, dcds); DoublesSketchTest.testSketchEquality(dcds, target4); }
DoublesUtil.checkDoublesSerVer(serVer, MIN_HEAP_DOUBLES_SER_VER); Util.checkHeapFlags(flags); checkPreLongsFlagsSerVer(flags, serVer, preLongs);
@Override public UpdateDoublesSketch getResult() { if (gadget_ == null) { return HeapUpdateDoublesSketch.newInstance(maxK_); } return DoublesUtil.copyToHeap(gadget_); //can't have any externally owned handles. }
DoublesUtil.checkDoublesSerVer(serVer, MIN_HEAP_DOUBLES_SER_VER); Util.checkHeapFlags(flags); HeapUpdateDoublesSketch.checkPreLongsFlagsSerVer(flags, serVer, preLongs);
/** * Returns a Heap DoublesUnion object that has been initialized with the data from the given * sketch. * * @param sketch A DoublesSketch to be used as a source of data only and will not be modified. * @return a DoublesUnion object */ static DoublesUnionImpl heapifyInstance(final DoublesSketch sketch) { final int k = sketch.getK(); final DoublesUnionImpl union = new DoublesUnionImpl(k); union.maxK_ = k; union.gadget_ = copyToHeap(sketch); return union; }
/** * 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; }
private static String getDataDetail(final DoublesSketch sketchIn) { final DoublesSketch sketch = sketchIn.isCompact() ? copyToHeap(sketchIn) : sketchIn; final StringBuilder sb = new StringBuilder(); final String skName = sketch.getClass().getSimpleName();