com.yahoo.sketches.tuple.Sketches Maven / Gradle / Ivy
/*
* Copyright 2015-16, Yahoo! Inc.
* Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
*/
package com.yahoo.sketches.tuple;
import com.yahoo.memory.Memory;
/**
* Convenient static methods to instantiate generic tuple sketches.
*/
public final class Sketches {
/**
* @param Type of Summary
* @return an empty instance of Sketch
*/
public static Sketch createEmptySketch() {
return new CompactSketch(null, null, Long.MAX_VALUE, true);
}
/**
* Instantiate Sketch from a given Memory
* @param Type of Summary
* @param mem Memory object representing a Sketch
* @return Sketch created from its Memory representation
*/
public static Sketch heapifySketch(final Memory mem) {
final SerializerDeserializer.SketchType sketchType = SerializerDeserializer.getSketchType(mem);
if (sketchType == SerializerDeserializer.SketchType.QuickSelectSketch) {
return new QuickSelectSketch(mem);
}
return new CompactSketch(mem);
}
/**
* Instantiate UpdatableSketch from a given Memory
* @param Type of update value
* @param Type of Summary
* @param mem Memory object representing a Sketch
* @return Sketch created from its Memory representation
*/
public static > UpdatableSketch heapifyUpdatableSketch(final Memory mem) {
return new UpdatableSketch(mem);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy