public final class ReservoirLongsSketch extends Object
| Modifier and Type | Method and Description |
|---|---|
static ReservoirLongsSketch |
getInstance(int k)
Construct a mergeable reservoir sampling sketch with up to k samples using the default resize
factor (8).
|
static ReservoirLongsSketch |
getInstance(int k,
ResizeFactor rf)
Construct a mergeable reservoir sampling sketch with up to k samples using the default resize
factor (8).
|
static ReservoirLongsSketch |
getInstance(Memory srcMem)
Returns a sketch instance of this class from the given srcMem, which must be a Memory
representation of this sketch class.
|
int |
getK()
Returns the sketch's value of k, the maximum number of samples stored in the reservoir.
|
long |
getN()
Returns the number of items processed from the input stream
|
int |
getNumSamples()
Returns the current number of items in the reservoir, which may be smaller than the reservoir
capacity.
|
long[] |
getSamples()
Returns a copy of the items in the reservoir.
|
byte[] |
toByteArray()
Returns a byte array representation of this sketch
|
String |
toString()
Returns a human-readable summary of the sketch, without data.
|
void |
update(long item)
Randomly decide whether or not to include an item in the sample set.
|
public static ReservoirLongsSketch getInstance(int k)
k - Maximum size of sampling. Allocated size may be smaller until sampling fills. Unlike
many sketches in this package, this value does not need to be a power of 2.public static ReservoirLongsSketch getInstance(int k, ResizeFactor rf)
k - Maximum size of sampling. Allocated size may be smaller until sampling fills. Unlike
many sketches in this package, this value does not need to be a power of 2.rf - See Resize Factorpublic static ReservoirLongsSketch getInstance(Memory srcMem)
srcMem - a Memory representation of a sketch of this class. See Memorypublic int getK()
public long getN()
public int getNumSamples()
public long[] getSamples()
public void update(long item)
item - a unit-weight (equivalently, unweighted) item of the set being sampled frompublic String toString()
public byte[] toByteArray()
Copyright © 2015–2017 Yahoo! Inc.. All rights reserved.