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 new CompactSketch of the chosen order and direct or on the heap.
|
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 seed)
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(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 seed)
Wrap takes the sketch image in Memory and refers to it directly.
|
compact, getCountLessThanTheta, getCountLessThanThetaLong, getCurrentBytes, getCurrentBytes, getEstimate, getFamily, getLowerBound, getMaxCompactSketchBytes, getMaxUpdateSketchBytes, getRetainedEntries, getRetainedEntries, getSerializationVersion, getTheta, getThetaLong, getUpperBound, hasMemory, isDirect, isEmpty, isEstimationMode, isSameResource, iterator, toByteArray, toString, toString, toString, toString, wrap, wrap
public static UpdateSketch wrap(org.apache.datasketches.memory.WritableMemory srcMem)
Util.DEFAULT_UPDATE_SEED
.
Default Update Seed.srcMem
- an image of a Sketch where the image seed hash matches the default seed hash.
See Memorypublic static UpdateSketch wrap(org.apache.datasketches.memory.WritableMemory srcMem, long seed)
srcMem
- an image of a Sketch where the image seed hash matches the given seed hash.
See Memoryseed
- 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)
Util.DEFAULT_UPDATE_SEED
.srcMem
- See Memorypublic static UpdateSketch heapify(org.apache.datasketches.memory.Memory srcMem, long seed)
srcMem
- See Memoryseed
- See Update Hash Seed.public CompactSketch compact(boolean dstOrdered, org.apache.datasketches.memory.WritableMemory dstMem)
Sketch
If this sketch is already in the proper form, this operation returns this, otherwise, this method returns a new CompactSketch of the proper form.
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.
compact
in class Sketch
dstOrdered
- 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(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–2021 The Apache Software Foundation. All rights reserved.