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
-
Field Summary
-
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) Deprecated.void
validateOptions
(Map<String, String> config) Subclasses with options should override this method to validate subclass options while also callingsuper.validateOptions(config)
to validate base class options.
-
Field Details
-
REQUIRED_SAMPLER_OPTIONS
-
-
Constructor Details
-
AbstractHashSampler
public AbstractHashSampler()
-
-
Method Details
-
validateOptions
Subclasses with options should override this method to validate subclass options while also callingsuper.validateOptions(config)
to validate base class options.- Specified by:
validateOptions
in interfaceSampler
- Parameters:
config
- Sampler options configuration to validate. Validates option and value.
-
isValidOption
Deprecated.since 2.1.0, replaced byvalidateOptions(Map)
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
-
validateOptions(Map)