public abstract class AbstractHashSampler extends Object implements Sampler
This class support two options passed into init(SamplerConfiguration). One option is
hasher which specifies a hashing algorithm. Valid values for this option are md5,
sha1, and murmur3_32. If you are not sure, then choose murmur3_32.
The second option is modulus which can have any positive integer as a value.
Any data where hash(data) % modulus == 0 will be selected for the sample.
| Constructor and Description |
|---|
AbstractHashSampler() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
accept(Key k) |
protected abstract void |
hash(DataOutput hasher,
Key k)
Subclass must override this method and hash some portion of the key.
|
void |
init(SamplerConfiguration config)
Subclasses with options should override this method and call
super.init(config). |
protected boolean |
isValidOption(String option)
Subclasses with options should override this method and return true if the option is valid for
the subclass or if
super.isValidOption(opt) returns true. |
protected boolean isValidOption(String option)
super.isValidOption(opt) returns true.public void init(SamplerConfiguration config)
super.init(config).protected abstract void hash(DataOutput hasher, Key k) throws IOException
hasher - Data written to this will be used to compute the hash for the key.IOExceptionCopyright © 2011–2019 The Apache Software Foundation. All rights reserved.