Class VarOptItemsUnion<T>
java.lang.Object
org.apache.datasketches.sampling.VarOptItemsUnion<T>
- Type Parameters:
T- Type of items
Provides a unioning operation over varopt sketches. This union allows the sample size k to float,
possibly increasing or decreasing as warranted by the available data.
- Author:
- Jon Malkin, Kevin Lang
-
Method Summary
Modifier and TypeMethodDescriptionGets the varopt sketch resulting from the union of any input sketches.static <T> VarOptItemsUnion<T> heapify(MemorySegment srcSeg, ArrayOfItemsSerDe<T> serDe) Instantiates a Union from MemorySegmentstatic <T> VarOptItemsUnion<T> newInstance(int maxK) Creates an empty Union with a maximum capacity of size k.voidreset()Resets this sketch to the empty state, but retains the original value of max k.byte[]toByteArray(ArrayOfItemsSerDe<T> serDe) Returns a byte array representation of this unionbyte[]toByteArray(ArrayOfItemsSerDe<T> serDe, Class<?> clazz) Returns a byte array representation of this union.toString()Returns a human-readable summary of the sketch, without items.voidupdate(MemorySegment seg, ArrayOfItemsSerDe<T> serDe) Union the given MemorySegment image of the sketch.voidupdate(ReservoirItemsSketch<T> reservoirIn) Union a reservoir sketch.voidupdate(VarOptItemsSketch<T> sketchIn) Union the given sketch.
-
Method Details
-
newInstance
Creates an empty Union with a maximum capacity of size k.- Type Parameters:
T- The type of item this union contains- Parameters:
maxK- The maximum allowed capacity of the unioned result- Returns:
- A new VarOptItemsUnion
-
heapify
Instantiates a Union from MemorySegment- Type Parameters:
T- The type of item this sketch contains- Parameters:
srcSeg- MemorySegment object containing a serialized unionserDe- An instance of ArrayOfItemsSerDe- Returns:
- A VarOptItemsUnion created from the provided MemorySegment
-
update
Union the given sketch.This method can be repeatedly called.
- Parameters:
sketchIn- The sketch to be merged
-
update
Union the given MemorySegment image of the sketch.This method can be repeatedly called.
- Parameters:
seg- MemorySegment image of sketch to be mergedserDe- An instance of ArrayOfItemsSerDe
-
update
Union a reservoir sketch. The reservoir sample is treated as if all items were added with a weight of 1.0.- Parameters:
reservoirIn- The reservoir sketch to be merged
-
getResult
Gets the varopt sketch resulting from the union of any input sketches.- Returns:
- A varopt sketch
-
reset
public void reset()Resets this sketch to the empty state, but retains the original value of max k. -
toString
-
toByteArray
Returns a byte array representation of this union- Parameters:
serDe- An instance of ArrayOfItemsSerDe- Returns:
- a byte array representation of this union
-
toByteArray
Returns a byte array representation of this union. This method should be used when the array elements are subclasses of a common base class.- Parameters:
serDe- An instance of ArrayOfItemsSerDeclazz- A class to which the items are cast before serialization- Returns:
- a byte array representation of this union
-