Class AbstractHashSampler
java.lang.Object
org.apache.accumulo.core.client.sample.AbstractHashSampler
- All Implemented Interfaces:
Sampler
- Direct Known Subclasses:
RowColumnSampler
,RowSampler
A base class that can be used to create Samplers based on hashing. This class offers consistent
options for configuring the hash function. The subclass decides which parts of the key to hash.
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.
- Since:
- 1.8.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
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 callsuper.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 ifsuper.isValidOption(opt)
returns true.
-
Constructor Details
-
AbstractHashSampler
public AbstractHashSampler()
-
-
Method Details
-
isValidOption
Subclasses with options should override this method and return true if the option is valid for the subclass or ifsuper.isValidOption(opt)
returns true. -
init
Subclasses with options should override this method and callsuper.init(config)
. -
hash
Subclass must override this method and hash some portion of the key.- Parameters:
hasher
- Data written to this will be used to compute the hash for the key.- Throws:
IOException
-
accept
-