T
- type of itempublic final class ItemsUnion<T> extends Object
Modifier and Type | Field and Description |
---|---|
protected Comparator<? super T> |
comparator_ |
protected ItemsSketch<T> |
gadget_ |
protected int |
maxK_ |
Modifier and Type | Method and Description |
---|---|
int |
getEffectiveK()
Returns the effective k of this Union.
|
static <T> ItemsUnion<T> |
getInstance(Comparator<? super T> comparator)
Create an instance of ItemsUnion with the default k
|
static <T> ItemsUnion<T> |
getInstance(int maxK,
Comparator<? super T> comparator)
Create an instance of ItemsUnion
|
static <T> ItemsUnion<T> |
getInstance(ItemsSketch<T> sketch)
Create an instance of ItemsUnion based on ItemsSketch
|
static <T> ItemsUnion<T> |
getInstance(org.apache.datasketches.memory.Memory srcMem,
Comparator<? super T> comparator,
ArrayOfItemsSerDe<T> serDe)
Heapify the given srcMem into a Union object.
|
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 |
update(ItemsSketch<T> sketchIn)
Iterative union operation, which means this method can be repeatedly called.
|
void |
update(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 double (or float) data Item.
|
protected final int maxK_
protected final Comparator<? super T> comparator_
protected ItemsSketch<T> gadget_
public static <T> ItemsUnion<T> getInstance(Comparator<? super T> comparator)
T
- type of itemcomparator
- to compare itemspublic static <T> ItemsUnion<T> getInstance(int maxK, Comparator<? super T> comparator)
T
- type of itemmaxK
- determines the accuracy and size of the union and is a maximum value.
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
different values of k.comparator
- to compare itemspublic static <T> ItemsUnion<T> getInstance(org.apache.datasketches.memory.Memory srcMem, Comparator<? super T> comparator, ArrayOfItemsSerDe<T> serDe)
T
- type of itemsrcMem
- the given srcMem.
A reference to srcMem will not be maintained internally.comparator
- to compare itemsserDe
- an instance of ArrayOfItemsSerDepublic static <T> ItemsUnion<T> getInstance(ItemsSketch<T> sketch)
T
- type of itemsketch
- the basis of the unionpublic void update(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 update(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–2021 The Apache Software Foundation. All rights reserved.