Class CharBufImage
java.lang.Object
io.nosqlbench.virtdata.library.basics.shared.from_long.to_string.CharBufImage
- All Implemented Interfaces:
java.util.function.LongFunction<java.nio.CharBuffer>
public class CharBufImage
extends java.lang.Object
implements java.util.function.LongFunction<java.nio.CharBuffer>
Builds a shared text image in memory and samples from it
pseudo-randomly with hashing.
The characters provided can be listed like a string (abc123),
or can include range specifiers like a hyphen (a-zA-Z0-9).
These characters are used to build an image of the specified size in
memory that is sampled from according to the size function.
The extracted value is sized according to either a provided function, a
size range, or otherwise the whole image.
The image can be varied between tests if you want by specifying a seed
value. If no seed value is specified, then the image length is used
also as a seed.
-
Constructor Summary
Constructors Constructor Description CharBufImage(int size)Shortcut constructor for building a simple text image from A-Z, a-z, 0-9 and a space, of the specified size.CharBufImage(java.lang.Object charsFunc, int imgsize)This is the same asCharBufImage(java.lang.Object,int,java.lang.Object)except that the extracted sample length is fixed to the buffer size, thus the function will always return the full buffer.CharBufImage(java.lang.Object charsFunc, int imgsize, java.lang.Object sizespec)This is the same asCharBufImage(java.lang.Object,int,java.lang.Object,long)excep that the seed is defaulted to 0LCharBufImage(java.lang.Object charsFunc, int imgsize, java.lang.Object sizespec, long seed)Create a CharBuffer full of the contents of the results of calling a source function until it is full. -
Method Summary
Modifier and Type Method Description java.nio.CharBufferapply(long value)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
CharBufImage
public CharBufImage(int size)Shortcut constructor for building a simple text image from A-Z, a-z, 0-9 and a space, of the specified size. When this function is used, it always returns the full image if constructed in this way.- Parameters:
size- length in characters of the image.
-
CharBufImage
public CharBufImage(java.lang.Object charsFunc, int imgsize)This is the same asCharBufImage(java.lang.Object,int,java.lang.Object)except that the extracted sample length is fixed to the buffer size, thus the function will always return the full buffer.- Parameters:
charsFunc- The function which produces objects, which toString() is used to collect their inputimgsize- The size of the CharBuffer to build at startup
-
CharBufImage
public CharBufImage(java.lang.Object charsFunc, int imgsize, java.lang.Object sizespec)This is the same asCharBufImage(java.lang.Object,int,java.lang.Object,long)excep that the seed is defaulted to 0L- Parameters:
charsFunc- The function which produces objects, which toString() is used to collect their inputimgsize- The size of the CharBuffer to build at startupsizespec- The specifier for how long samples should be. If this is a number, then it is static. If it is a function, then the size is determined for each call.
-
CharBufImage
public CharBufImage(java.lang.Object charsFunc, int imgsize, java.lang.Object sizespec, long seed)Create a CharBuffer full of the contents of the results of calling a source function until it is full. Then allow it to be sampled with random extracts as determined by the sizespec.- Parameters:
charsFunc- The function which produces objects, which toString() is used to collect their inputimgsize- The size of the CharBuffer to build at startupsizespec- The specifier for how long samples should be. If this is a number, then it is static. If it is a function, then the size is determined for each call.seed- A seed that can be used to change up the rendered content.
-
-
Method Details
-
apply
public java.nio.CharBuffer apply(long value)- Specified by:
applyin interfacejava.util.function.LongFunction<java.nio.CharBuffer>
-