use of com.yahoo.memory.WritableMemory in project sketches-core by DataSketches.
the class HeapUnionTest method checkUpdateMemorySpecialCases2.
@Test
public void checkUpdateMemorySpecialCases2() {
//4096
int lgK = 12;
int k = 1 << lgK;
int u = 2 * k;
UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
//force prelongs to 3
for (int i = 0; i < u; i++) usk1.update(i);
CompactSketch usk1c = usk1.compact(true, null);
WritableMemory v3mem1 = WritableMemory.wrap(usk1c.toByteArray());
//println(PreambleUtil.toString(v3mem1));
Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
union.update(v3mem1);
}
use of com.yahoo.memory.WritableMemory in project sketches-core by DataSketches.
the class HeapUnionTest method checkMemBadSerVer.
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkMemBadSerVer() {
//4096
int lgK = 12;
int k = 1 << lgK;
UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
CompactSketch usk1c = usk1.compact(true, null);
WritableMemory v3mem1 = WritableMemory.wrap(usk1c.toByteArray());
//corrupt SerVer
v3mem1.putByte(SER_VER_BYTE, (byte) 0);
Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
union.update(v3mem1);
}
use of com.yahoo.memory.WritableMemory in project sketches-core by DataSketches.
the class SetOperationTest method checkIsSameResource.
@Test
public void checkIsSameResource() {
int k = 16;
WritableMemory mem = WritableMemory.wrap(new byte[(k * 16) + 32]);
Memory cmem = Memory.wrap(new byte[8]);
Union union = Sketches.setOperationBuilder().setNominalEntries(k).buildUnion(mem);
assertTrue(union.isSameResource(mem));
assertFalse(union.isSameResource(cmem));
Intersection inter = Sketches.setOperationBuilder().buildIntersection(mem);
assertTrue(inter.isSameResource(mem));
assertFalse(inter.isSameResource(cmem));
}
use of com.yahoo.memory.WritableMemory in project sketches-core by DataSketches.
the class SetOperationTest method checkBuilderAnotB_noMem.
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkBuilderAnotB_noMem() {
WritableMemory mem = WritableMemory.wrap(new byte[64]);
SetOperation.builder().build(Family.A_NOT_B, mem);
}
use of com.yahoo.memory.WritableMemory in project sketches-core by DataSketches.
the class SketchTest method checkHeapifyQSCompactExcep.
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkHeapifyQSCompactExcep() {
int k = 512;
Sketch sketch1 = UpdateSketch.builder().setFamily(QUICKSELECT).setNominalEntries(k).build();
byte[] byteArray = sketch1.toByteArray();
WritableMemory mem = WritableMemory.wrap(byteArray);
//corrupt:
mem.setBits(FLAGS_BYTE, (byte) COMPACT_FLAG_MASK);
Sketch.heapify(mem);
}
Aggregations