Search in sources :

Example 41 with SketchesArgumentException

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

the class SetOperation method heapify.

/**
   * Heapify takes the SetOperation image in Memory and instantiates an on-heap
   * SetOperation using the given seed.
   * The resulting SetOperation will not retain any link to the source Memory.
   * @param srcMem an image of a SetOperation where the hash of the given seed matches the image seed hash.
   * <a href="{@docRoot}/resources/dictionary.html#mem">See Memory</a>
   * @param seed <a href="{@docRoot}/resources/dictionary.html#seed">See Update Hash Seed</a>.
   * @return a Heap-based SetOperation from the given Memory
   */
public static SetOperation heapify(final Memory srcMem, final long seed) {
    final byte famID = srcMem.getByte(FAMILY_BYTE);
    final Family family = idToFamily(famID);
    switch(family) {
        case UNION:
            {
                return UnionImpl.heapifyInstance(srcMem, seed);
            }
        case INTERSECTION:
            {
                return IntersectionImpl.heapifyInstance(srcMem, seed);
            }
        default:
            {
                throw new SketchesArgumentException("SetOperation cannot heapify family: " + family.toString());
            }
    }
}
Also used : SketchesArgumentException(com.yahoo.sketches.SketchesArgumentException) Family(com.yahoo.sketches.Family) Family.idToFamily(com.yahoo.sketches.Family.idToFamily)

Aggregations

SketchesArgumentException (com.yahoo.sketches.SketchesArgumentException)41 WritableMemory (com.yahoo.memory.WritableMemory)22 Test (org.testng.annotations.Test)12 Family (com.yahoo.sketches.Family)11 Memory (com.yahoo.memory.Memory)10 ResizeFactor (com.yahoo.sketches.ResizeFactor)6 Family.idToFamily (com.yahoo.sketches.Family.idToFamily)5 ArrayOfLongsSerDe (com.yahoo.sketches.ArrayOfLongsSerDe)4 PreambleUtil.extractResizeFactor (com.yahoo.sketches.sampling.PreambleUtil.extractResizeFactor)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ArrayList (java.util.ArrayList)2 ArrayOfBooleansSerDe (com.yahoo.sketches.ArrayOfBooleansSerDe)1 ArrayOfNumbersSerDe (com.yahoo.sketches.ArrayOfNumbersSerDe)1 ArrayOfStringsSerDe (com.yahoo.sketches.ArrayOfStringsSerDe)1 Util.checkIsCompactMemory (com.yahoo.sketches.quantiles.Util.checkIsCompactMemory)1 Method (java.lang.reflect.Method)1 BigDecimal (java.math.BigDecimal)1