public abstract class UpdateSketch extends Sketch
Modifier and Type | Method and Description |
---|---|
static UpdateSketchBuilder |
builder()
Returns a new builder
|
CompactSketch |
compact(boolean dstOrdered,
org.apache.datasketches.memory.WritableMemory dstMem)
Convert this sketch to a CompactSketch.
|
int |
getCompactBytes()
Returns the number of storage bytes required for this Sketch if its current state were
compacted.
|
abstract int |
getLgNomLongs()
Gets the Log base 2 of the configured nominal entries
|
abstract ResizeFactor |
getResizeFactor()
Returns the configured ResizeFactor
|
static UpdateSketch |
heapify(org.apache.datasketches.memory.Memory srcMem)
Instantiates an on-heap UpdateSketch from Memory.
|
static UpdateSketch |
heapify(org.apache.datasketches.memory.Memory srcMem,
long expectedSeed)
Instantiates an on-heap UpdateSketch from Memory.
|
boolean |
isCompact()
Returns true if this sketch is in compact form.
|
boolean |
isOrdered()
Returns true if internal cache is ordered
|
abstract UpdateSketch |
rebuild()
Rebuilds the hash table to remove dirty values or to reduce the size
to nominal entries.
|
abstract void |
reset()
Resets this sketch back to a virgin empty state.
|
UpdateReturnState |
update(byte[] data)
Present this sketch with the given byte array.
|
UpdateReturnState |
update(ByteBuffer buffer)
Present this sketch with the given ByteBuffer
If the ByteBuffer is null or empty, no update attempt is made and the method returns.
|
UpdateReturnState |
update(char[] data)
Present this sketch with the given char array.
|
UpdateReturnState |
update(double datum)
Present this sketch with the given double (or float) datum.
|
UpdateReturnState |
update(int[] data)
Present this sketch with the given integer array.
|
UpdateReturnState |
update(long datum)
Present this sketch with a long.
|
UpdateReturnState |
update(long[] data)
Present this sketch with the given long array.
|
UpdateReturnState |
update(String datum)
Present this sketch with the given String.
|
static UpdateSketch |
wrap(org.apache.datasketches.memory.WritableMemory srcMem)
Wrap takes the sketch image in Memory and refers to it directly.
|
static UpdateSketch |
wrap(org.apache.datasketches.memory.WritableMemory srcMem,
long expectedSeed)
Wrap takes the sketch image in Memory and refers to it directly.
|
compact, getCompactSketchMaxBytes, getCountLessThanThetaLong, getCurrentBytes, getEstimate, getFamily, getLowerBound, getMaxCompactSketchBytes, getMaxUpdateSketchBytes, getRetainedEntries, getRetainedEntries, getSerializationVersion, getTheta, getThetaLong, getUpperBound, isEmpty, isEstimationMode, iterator, toByteArray, toString, toString, toString, toString, wrap, wrap
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
hasMemory, isDirect, isSameResource
public static UpdateSketch wrap(org.apache.datasketches.memory.WritableMemory srcMem)
ThetaUtil.DEFAULT_UPDATE_SEED
.
Default Update Seed.srcMem
- an image of a Sketch where the image seed hash matches the default seed hash.
It must have a size of at least 24 bytes.
See Memorypublic static UpdateSketch wrap(org.apache.datasketches.memory.WritableMemory srcMem, long expectedSeed)
srcMem
- an image of a Sketch where the image seed hash matches the given seed hash.
It must have a size of at least 24 bytes.
See MemoryexpectedSeed
- the seed used to validate the given Memory image.
See Update Hash Seed.
Compact sketches store a 16-bit hash of the seed, but not the seed itself.public static UpdateSketch heapify(org.apache.datasketches.memory.Memory srcMem)
ThetaUtil.DEFAULT_UPDATE_SEED
.srcMem
- See Memory
It must have a size of at least 24 bytes.public static UpdateSketch heapify(org.apache.datasketches.memory.Memory srcMem, long expectedSeed)
srcMem
- See Memory
It must have a size of at least 24 bytes.expectedSeed
- the seed used to validate the given Memory image.
See Update Hash Seed.public CompactSketch compact(boolean dstOrdered, org.apache.datasketches.memory.WritableMemory dstMem)
Sketch
If this sketch is a type of UpdateSketch, the compacting process converts the hash table of the UpdateSketch to a simple list of the valid hash values. Any hash values of zero or equal-to or greater than theta will be discarded. The number of valid values remaining in the CompactSketch depends on a number of factors, but may be larger or smaller than Nominal Entries (or k). It will never exceed 2k. If it is critical to always limit the size to no more than k, then rebuild() should be called on the UpdateSketch prior to calling this method.
A CompactSketch is always immutable.
A new CompactSketch object is created:
Otherwise, this operation returns this.
compact
in class Sketch
dstOrdered
- assumed true if this sketch is empty or has only one value
See Destination OrdereddstMem
- See Destination Memory.public int getCompactBytes()
Sketch
Sketch.getCurrentBytes()
.getCompactBytes
in class Sketch
public boolean isCompact()
Sketch
public boolean isOrdered()
Sketch
public static final UpdateSketchBuilder builder()
public abstract ResizeFactor getResizeFactor()
public abstract void reset()
public abstract UpdateSketch rebuild()
public UpdateReturnState update(long datum)
datum
- The given long datum.public UpdateReturnState update(double datum)
datum
- The given double datum.public UpdateReturnState update(String datum)
Note: this will not produce the same output hash values as the update(char[])
method and will generally be a little slower depending on the complexity of the UTF8 encoding.
datum
- The given String.public UpdateReturnState update(byte[] data)
data
- The given byte array.public UpdateReturnState update(ByteBuffer buffer)
buffer
- the input ByteBufferpublic UpdateReturnState update(char[] data)
Note: this will not produce the same output hash values as the update(String)
method but will be a little faster as it avoids the complexity of the UTF8 encoding.
data
- The given char array.public UpdateReturnState update(int[] data)
data
- The given int array.public UpdateReturnState update(long[] data)
data
- The given long array.public abstract int getLgNomLongs()
Copyright © 2015–2024 The Apache Software Foundation. All rights reserved.