public final class ReservoirLongsUnion extends Object
For efficiency reasons, the unioning process picks one of the two sketches to use as the base. As a result, we provide only a stateful union. Using the same approach for a merge would result in unpredictable side effects on the underlying sketches.
A union object is created with a maximum value of k, represented using the ReservoirSize class. The unioning process may cause the actual number of samples to fall below that maximum value, but never to exceed it. The result of a union will be a reservoir where each item from the global input has a uniform probability of selection, but there are no claims about higher order statistics. For instance, in general all possible permutations of the global input are not equally likely.
Modifier and Type | Method and Description |
---|---|
int |
getMaxK()
Returns the maximum allowed reservoir capacity in this union.
|
ReservoirLongsSketch |
getResult()
Returns a sketch representing the current state of the union.
|
static ReservoirLongsUnion |
heapify(org.apache.datasketches.memory.Memory srcMem)
Instantiates a Union from Memory
|
static ReservoirLongsUnion |
newInstance(int maxK)
Creates an empty Union with a maximum reservoir capacity of size k.
|
byte[] |
toByteArray()
Returns a byte array representation of this union
|
String |
toString()
Returns a human-readable summary of the sketch, without items.
|
void |
update(long datum)
Present this union with a long.
|
void |
update(org.apache.datasketches.memory.Memory mem)
Union the given Memory image of the sketch.
|
void |
update(ReservoirLongsSketch sketchIn)
Union the given sketch.
|
public static ReservoirLongsUnion newInstance(int maxK)
maxK
- The maximum allowed reservoir capacity for any sketches in the unionpublic static ReservoirLongsUnion heapify(org.apache.datasketches.memory.Memory srcMem)
srcMem
- Memory object containing a serialized unionpublic int getMaxK()
public void update(ReservoirLongsSketch sketchIn)
This method can be repeatedly called. If the given sketch is null it is interpreted as an empty sketch.
sketchIn
- The incoming sketch.public void update(org.apache.datasketches.memory.Memory mem)
This method can be repeatedly called. If the given sketch is null it is interpreted as an empty sketch.
mem
- Memory image of sketch to be mergedpublic void update(long datum)
datum
- The given long datum.public ReservoirLongsSketch getResult()
public String toString()
public byte[] toByteArray()
Copyright © 2015–2021 The Apache Software Foundation. All rights reserved.