Search in sources :

Example 1 with ArrayOfDoublesSerDe

use of com.yahoo.sketches.ArrayOfDoublesSerDe in project sketches-core by DataSketches.

the class ReservoirItemsUnionTest method checkBadFamily.

@Test(expectedExceptions = SketchesArgumentException.class)
public void checkBadFamily() {
    final ReservoirItemsUnion<Double> rlu = ReservoirItemsUnion.newInstance(1024);
    final WritableMemory mem = WritableMemory.wrap(rlu.toByteArray(new ArrayOfDoublesSerDe()));
    // corrupt the family ID
    mem.putByte(FAMILY_BYTE, (byte) 0);
    ReservoirItemsUnion.heapify(mem, new ArrayOfDoublesSerDe());
    fail();
}
Also used : ArrayOfDoublesSerDe(com.yahoo.sketches.ArrayOfDoublesSerDe) WritableMemory(com.yahoo.memory.WritableMemory) Test(org.testng.annotations.Test)

Example 2 with ArrayOfDoublesSerDe

use of com.yahoo.sketches.ArrayOfDoublesSerDe in project sketches-core by DataSketches.

the class ItemsSketchTest method compactNotSupported.

@Test(expectedExceptions = SketchesArgumentException.class)
public void compactNotSupported() {
    ArrayOfDoublesSerDe serDe = new ArrayOfDoublesSerDe();
    ItemsSketch<Double> sketch = ItemsSketch.getInstance(Comparator.naturalOrder());
    byte[] byteArr = sketch.toByteArray(serDe);
    WritableMemory mem = WritableMemory.wrap(byteArr);
    mem.clearBits(PreambleUtil.FLAGS_BYTE, (byte) PreambleUtil.COMPACT_FLAG_MASK);
    println(PreambleUtil.toString(mem, false));
    ItemsSketch.getInstance(mem, Comparator.naturalOrder(), serDe);
}
Also used : ArrayOfDoublesSerDe(com.yahoo.sketches.ArrayOfDoublesSerDe) WritableMemory(com.yahoo.memory.WritableMemory) Test(org.testng.annotations.Test)

Aggregations

WritableMemory (com.yahoo.memory.WritableMemory)2 ArrayOfDoublesSerDe (com.yahoo.sketches.ArrayOfDoublesSerDe)2 Test (org.testng.annotations.Test)2