public class LinearCounting extends Object implements ICardinality
Modifier and Type | Class and Description |
---|---|
static class |
LinearCounting.Builder |
protected static class |
LinearCounting.LinearCountingMergeException |
Modifier and Type | Field and Description |
---|---|
protected int |
count
Number of bits left unset in the map
|
protected int |
length
Size of the map in bits
|
protected byte[] |
map
Bitmap
Hashed stream elements are mapped to bits in this array
|
Constructor and Description |
---|
LinearCounting(byte[] map) |
LinearCounting(int size) |
Modifier and Type | Method and Description |
---|---|
long |
cardinality() |
protected int |
computeCount() |
byte[] |
getBytes() |
int |
getCount() |
double |
getUtilization() |
boolean |
isSaturated() |
protected String |
mapAsBitString()
For debug purposes
|
ICardinality |
merge(ICardinality... estimators)
Merges estimators to produce a new estimator for the combined streams
of this estimator and those passed as arguments.
|
static LinearCounting |
mergeEstimators(LinearCounting... estimators)
Merges estimators to produce an estimator for their combined streams
|
boolean |
offer(Object o) |
boolean |
offerHashed(int hashedInt)
Offer the value as a hashed long value
|
boolean |
offerHashed(long hashedLong)
Offer the value as a hashed long value
|
int |
sizeof() |
protected byte[] map
protected final int length
protected int count
public LinearCounting(int size)
size
- of bit array in bytespublic LinearCounting(byte[] map)
public long cardinality()
cardinality
in interface ICardinality
public byte[] getBytes()
getBytes
in interface ICardinality
public boolean offerHashed(long hashedLong)
ICardinality
offerHashed
in interface ICardinality
hashedLong
- - the hash of the item to offer to the estimatorpublic boolean offerHashed(int hashedInt)
ICardinality
offerHashed
in interface ICardinality
hashedInt
- - the hash of the item to offer to the estimatorpublic boolean offer(Object o)
offer
in interface ICardinality
o
- stream elementpublic int sizeof()
sizeof
in interface ICardinality
protected int computeCount()
public double getUtilization()
public int getCount()
public boolean isSaturated()
protected String mapAsBitString()
public ICardinality merge(ICardinality... estimators) throws LinearCounting.LinearCountingMergeException
ICardinality
merge
in interface ICardinality
estimators
- Zero or more compatible estimatorsLinearCounting.LinearCountingMergeException
- if estimators are not mergeable (all estimators must be instances of LinearCounting of the same size)public static LinearCounting mergeEstimators(LinearCounting... estimators) throws LinearCounting.LinearCountingMergeException
estimators
- LinearCounting.LinearCountingMergeException
- if estimators are not mergeable (all estimators must be the same size)Copyright © 2019. All rights reserved.