Class AbstractHashSampler
- java.lang.Object
-
- org.apache.accumulo.core.client.sample.AbstractHashSampler
-
- All Implemented Interfaces:
Sampler
- Direct Known Subclasses:
RowColumnSampler,RowSampler
public abstract class AbstractHashSampler extends Object implements Sampler
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 ishasherwhich specifies a hashing algorithm. Valid values for this option aremd5,sha1, andmurmur3_32. If you are not sure, then choosemurmur3_32.The second option is
moduluswhich can have any positive integer as a value.Any data where
hash(data) % modulus == 0will be selected for the sample.- Since:
- 1.8.0
-
-
Constructor Summary
Constructors Constructor Description AbstractHashSampler()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanaccept(Key k)protected abstract voidhash(DataOutput hasher, Key k)Subclass must override this method and hash some portion of the key.voidinit(SamplerConfiguration config)Subclasses with options should override this method and callsuper.init(config).protected booleanisValidOption(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.
-
-
-
Method Detail
-
isValidOption
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.
-
init
public void init(SamplerConfiguration config)
Subclasses with options should override this method and callsuper.init(config).
-
hash
protected abstract void hash(DataOutput hasher, Key k) throws IOException
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
-
-