Package org.apache.hadoop.hbase.util
Class LoadTestKVGenerator
java.lang.Object
org.apache.hadoop.hbase.util.LoadTestKVGenerator
A generator of random keys and values for load testing. Keys are generated by converting numeric
indexes to strings and prefixing them with an MD5 hash. Values are generated by selecting value
size in the configured range and generating a pseudo-random sequence of bytes seeded by key,
column qualifier, and value size.
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final org.slf4j.Logger
private static int
private final int
private final int
private Random
A random number generator for determining value size -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]
generateRandomSizeValue
(byte[]... seedStrings) Generates a value for the given key index and column qualifier.private static byte[]
getValueForRowColumn
(int dataSize, byte[]... seedStrings) Generates random bytes of the given size for the given row and column qualifier.static String
md5PrefixedKey
(long key) Converts the given key to string, and prefixes it with the MD5 hash of the index's string representation.static boolean
verify
(byte[] value, byte[]... seedStrings) Verifies that the given byte array is the same as what would be generated for the given seed strings (row/cf/column/...).
-
Field Details
-
LOG
-
logLimit
-
randomForValueSize
A random number generator for determining value size -
minValueSize
-
maxValueSize
-
-
Constructor Details
-
LoadTestKVGenerator
-
-
Method Details
-
verify
Verifies that the given byte array is the same as what would be generated for the given seed strings (row/cf/column/...). We are assuming that the value size is correct, and only verify the actual bytes. However, if the min/max value sizes are set sufficiently high, an accidental match should be extremely improbable. -
md5PrefixedKey
Converts the given key to string, and prefixes it with the MD5 hash of the index's string representation. -
generateRandomSizeValue
Generates a value for the given key index and column qualifier. Size is selected randomly in the configured range. The generated value depends only on the combination of the strings passed (key/cf/column/...) and the selected value size. This allows to verify the actual value bytes when reading, as done in {#verify(byte[], byte[]...)} This method is as thread-safe as Random class. It appears that the worst bug ever found with the latter is that multiple threads will get some duplicate values, which we don't care about. -
getValueForRowColumn
Generates random bytes of the given size for the given row and column qualifier. The random seed is fully determined by these parameters.
-