T
- type of itempublic final class ItemsUnion<T> extends Object
Modifier and Type | Method and Description |
---|---|
int |
getEffectiveK()
Returns the effective k of this Union.
|
static <T> ItemsUnion<T> |
getInstance(Class<T> clazz,
Comparator<? super T> comparator)
Create an instance of ItemsUnion with the default k
|
static <T> ItemsUnion<T> |
getInstance(Class<T> clazz,
int maxK,
Comparator<? super T> comparator)
Create an instance of ItemsUnion
|
static <T> ItemsUnion<T> |
getInstance(Class<T> clazz,
org.apache.datasketches.memory.Memory srcMem,
Comparator<? super T> comparator,
ArrayOfItemsSerDe<T> serDe)
Heapify the given srcMem into a Union object.
|
static <T> ItemsUnion<T> |
getInstance(ItemsSketch<T> sketch)
Create an instance of ItemsUnion based on ItemsSketch
|
int |
getMaxK()
Returns the configured maxK of this Union.
|
ItemsSketch<T> |
getResult()
Gets the result of this Union operation as a copy of the internal state.
|
ItemsSketch<T> |
getResultAndReset()
Gets the result of this Union operation (without a copy) and resets this Union to the
virgin state.
|
boolean |
isDirect()
Returns true if this union is direct
|
boolean |
isEmpty()
Returns true if this union is empty
|
void |
reset()
Resets this Union to a virgin state.
|
byte[] |
toByteArray(ArrayOfItemsSerDe<T> serDe)
Serialize this union to a byte array.
|
String |
toString()
Returns summary information about the backing sketch.
|
String |
toString(boolean sketchSummary,
boolean dataDetail)
Returns summary information about the backing sketch.
|
void |
union(ItemsSketch<T> sketchIn)
Iterative union operation, which means this method can be repeatedly called.
|
void |
union(org.apache.datasketches.memory.Memory srcMem,
ArrayOfItemsSerDe<T> serDe)
Iterative union operation, which means this method can be repeatedly called.
|
void |
update(T dataItem)
Update this union with the given dataItem.
|
public static <T> ItemsUnion<T> getInstance(Class<T> clazz, Comparator<? super T> comparator)
T
- The sketch data typeclazz
- The sketch class typecomparator
- to compare itemspublic static <T> ItemsUnion<T> getInstance(Class<T> clazz, int maxK, Comparator<? super T> comparator)
T
- The sketch data typeclazz
- The sketch class typemaxK
- determines the accuracy and size of the union and is a maximum.
The effective k can be smaller due to unions with smaller k sketches.
It is recommended that maxK be a power of 2 to enable unioning of sketches with a
different k.comparator
- to compare itemspublic static <T> ItemsUnion<T> getInstance(Class<T> clazz, org.apache.datasketches.memory.Memory srcMem, Comparator<? super T> comparator, ArrayOfItemsSerDe<T> serDe)
T
- The sketch data typeclazz
- The sketch class type
A reference to srcMem will not be maintained internally.srcMem
- the given srcMem.comparator
- to compare itemsserDe
- an instance of ArrayOfItemsSerDepublic static <T> ItemsUnion<T> getInstance(ItemsSketch<T> sketch)
T
- The sketch data typesketch
- the basis of the unionpublic void union(ItemsSketch<T> sketchIn)
It is required that the results of the union operation, which can be obtained at any time,
is obtained from getResult()
.
sketchIn
- the sketch to be merged into this one.public void union(org.apache.datasketches.memory.Memory srcMem, ArrayOfItemsSerDe<T> serDe)
It is required that the results of the union operation, which can be obtained at any time,
is obtained from getResult()
.
srcMem
- Memory image of sketch to be mergedserDe
- an instance of ArrayOfItemsSerDepublic void update(T dataItem)
dataItem
- The given datum.public ItemsSketch<T> getResult()
public ItemsSketch<T> getResultAndReset()
public void reset()
public boolean isEmpty()
public boolean isDirect()
public int getMaxK()
public int getEffectiveK()
public String toString()
public String toString(boolean sketchSummary, boolean dataDetail)
sketchSummary
- if true includes sketch summarydataDetail
- if true includes data detailpublic byte[] toByteArray(ArrayOfItemsSerDe<T> serDe)
serDe
- an instance of ArrayOfItemsSerDeCopyright © 2015–2024 The Apache Software Foundation. All rights reserved.