Class QuantilesDoublesUnion
java.lang.Object
org.apache.datasketches.quantiles.QuantilesDoublesUnion
- All Implemented Interfaces:
MemorySegmentStatus
The API for Union operations for QuantilesDoublesSketches
- Author:
- Lee Rhodes
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic QuantilesDoublesUnionBuilderbuilder()Returns a new UnionBuilderabstract intReturns the effective k of this Union.abstract intgetMaxK()Returns the configured maxK of this Union.abstract UpdatableQuantilesDoublesSketchGets the result of this Union as an UpdatableQuantilesDoublesSketch, which enables further update operations on the resulting sketch.abstract UpdatableQuantilesDoublesSketchgetResult(MemorySegment dstSeg, MemorySegmentRequest mSegReq) Places the result of this Union into the provided MemorySegment as an UpdatableQuantilesDoublesSketch, which enables further update operations on the resulting sketch.abstract UpdatableQuantilesDoublesSketchGets the result of this Union as an UpdatableQuantilesDoublesSketch, which enables further update operations on the resulting sketch.abstract booleanReturns true if this object's internal data is backed by a MemorySegment, which may be on-heap or off-heap.static QuantilesDoublesUnionheapify(MemorySegment srcSeg) Returns a Heap Union object that has been initialized with the data from the given MemorySegment that contains an image of a sketch.static QuantilesDoublesUnionheapify(QuantilesDoublesSketch sketch) Returns a Heap Union object that has been initialized with the data from the given sketch.abstract booleanisEmpty()Returns true if this union is emptyabstract booleanReturns true if this object's internal data is backed by an off-heap (direct or native)) MemorySegment.abstract booleanisSameResource(MemorySegment that) Returns true if an internally referenced MemorySegment has the same backing resource as that, or equivalently, if their two memory regions overlap.abstract voidreset()Resets this Union to a virgin state.abstract byte[]Serialize this union to a byte array.abstract StringtoString()Returns summary information about the backing sketch.abstract StringtoString(boolean sketchSummary, boolean dataDetail) Returns summary information about the backing sketch.abstract voidunion(MemorySegment seg) Iterative union operation, which means this method can be repeatedly called.abstract voidunion(QuantilesDoublesSketch sketchIn) Iterative union operation, which means this method can be repeatedly called.abstract voidupdate(double dataItem) Update this union with the given double (or float) data Item.static QuantilesDoublesUnionwrap(MemorySegment srcSeg) Returns an updatable Union object that wraps the given MemorySegment that contains an image of a QuantilesDoublesSketch.static QuantilesDoublesUnionwrap(MemorySegment srcSeg, MemorySegmentRequest mSegReq) Returns an updatable Union object that wraps the given MemorySegment that contains an image of a QuantilesDoublesSketch.
-
Constructor Details
-
QuantilesDoublesUnion
public QuantilesDoublesUnion()No argument constructor.
-
-
Method Details
-
builder
Returns a new UnionBuilder- Returns:
- a new UnionBuilder
-
heapify
Returns a Heap Union object that has been initialized with the data from the given sketch.- Parameters:
sketch- A QuantilesDoublesSketch to be used as a source of data only and will not be modified.- Returns:
- a QuantilesDoublesUnion object
-
heapify
Returns a Heap Union object that has been initialized with the data from the given MemorySegment that contains an image of a sketch.- Parameters:
srcSeg- A MemorySegment image of a QuantilesDoublesSketch to be used as a source of data and will not be modified.- Returns:
- a Union object
-
wrap
Returns an updatable Union object that wraps the given MemorySegment that contains an image of a QuantilesDoublesSketch.- Parameters:
srcSeg- A MemorySegment image of an updatable QuantilesDoublesSketch to be used as the data structure for the union and will be modified.- Returns:
- a Union object
-
wrap
Returns an updatable Union object that wraps the given MemorySegment that contains an image of a QuantilesDoublesSketch.- Parameters:
srcSeg- A MemorySegment sketch to be used as the data structure for the union and will be modified.mSegReq- the MemorySegmentRequest used if the given MemorySegment needs to expand. Otherwise, it can be null and the default MemorySegmentRequest will be used.- Returns:
- a Union object
-
hasMemorySegment
public abstract boolean hasMemorySegment()Description copied from interface:MemorySegmentStatusReturns true if this object's internal data is backed by a MemorySegment, which may be on-heap or off-heap.- Specified by:
hasMemorySegmentin interfaceMemorySegmentStatus- Returns:
- true if this object's internal data is backed by a MemorySegment.
-
isOffHeap
public abstract boolean isOffHeap()Description copied from interface:MemorySegmentStatusReturns true if this object's internal data is backed by an off-heap (direct or native)) MemorySegment.- Specified by:
isOffHeapin interfaceMemorySegmentStatus- Returns:
- true if this object's internal data is backed by an off-heap (direct or native)) MemorySegment.
-
isSameResource
Description copied from interface:MemorySegmentStatusReturns true if an internally referenced MemorySegment has the same backing resource as that, or equivalently, if their two memory regions overlap. This applies to both on-heap and off-heap MemorySegments.Note: If both segments are on-heap and not read-only, it can be determined if they were derived from the same backing memory (array). However, this is not always possible off-heap. Because of this asymmetry, this definition of "isSameResource" is confined to the existence of an overlap.
- Specified by:
isSameResourcein interfaceMemorySegmentStatus- Parameters:
that- The given MemorySegment.- Returns:
- true if an internally referenced MemorySegment has the same backing resource as that.
-
isEmpty
public abstract boolean isEmpty()Returns true if this union is empty- Returns:
- true if this union is empty
-
getMaxK
public abstract int getMaxK()Returns the configured maxK of this Union.- Returns:
- the configured maxK of this Union.
-
getEffectiveK
public abstract int getEffectiveK()Returns the effective k of this Union.- Returns:
- the effective k of this Union.
-
union
Iterative union operation, which means this method can be repeatedly called. Merges the given sketch into this union object. The given sketch is not modified. It is required that the ratio of the two K's be a power of 2. This is easily satisfied if each of the K's are already a power of 2. If the given sketch is null or empty it is ignored.It is required that the results of the union operation, which can be obtained at any time, is obtained from
getResult().- Parameters:
sketchIn- the sketch to be merged into this one.
-
union
Iterative union operation, which means this method can be repeatedly called. Merges the given MemorySegment image of a QuantilesDoublesSketch into this union object. The given MemorySegment object is not modified and a link to it is not retained. It is required that the ratio of the two K's be a power of 2. This is easily satisfied if each of the K's are already a power of 2. If the given sketch is null or empty it is ignored.It is required that the results of the union operation, which can be obtained at any time, is obtained from
getResult().- Parameters:
seg- MemorySegment image of sketch to be merged
-
update
public abstract void update(double dataItem) Update this union with the given double (or float) data Item.- Parameters:
dataItem- The given double datum.
-
getResult
Gets the result of this Union as an UpdatableQuantilesDoublesSketch, which enables further update operations on the resulting sketch. The Union state has not been changed, which allows further union operations.- Returns:
- the result of this Union operation
-
getResult
public abstract UpdatableQuantilesDoublesSketch getResult(MemorySegment dstSeg, MemorySegmentRequest mSegReq) Places the result of this Union into the provided MemorySegment as an UpdatableQuantilesDoublesSketch, which enables further update operations on the resulting sketch. The Union state has not been changed, which allows further union operations.- Parameters:
dstSeg- the destination MemorySegment for the resultmSegReq- the MemorySegmentRequest used if the given MemorySegment needs to expand. Otherwise, it can be null and the default MemorySegmentRequest will be used.- Returns:
- the result of this Union operation
-
getResultAndReset
Gets the result of this Union as an UpdatableQuantilesDoublesSketch, which enables further update operations on the resulting sketch. The Union is reset to the virgin state.- Returns:
- the result of this Union operation and reset.
-
reset
public abstract void reset()Resets this Union to a virgin state. -
toByteArray
public abstract byte[] toByteArray()Serialize this union to a byte array. Result is an UpdatableQuantilesDoublesSketch, serialized in an unordered, non-compact form. The resulting byte[] can be heapified or wrapped as either a sketch or a union.- Returns:
- byte array of this union
-
toString
-
toString
Returns summary information about the backing sketch. Used for debugging.- Parameters:
sketchSummary- if true includes sketch summarydataDetail- if true includes data detail- Returns:
- summary information about the sketch.
-