Class CSVFrequencySampler

java.lang.Object
io.nosqlbench.virtdata.library.basics.shared.distributions.CSVFrequencySampler
All Implemented Interfaces:
LongFunction<String>

public class CSVFrequencySampler extends Object implements LongFunction<String>
Takes a CSV with sample data and generates random values based on the relative frequencies of the values in the file. The CSV file must have headers which can be used to find the named columns. I.E. take the following imaginary `animals.csv` file: animal,count,country puppy,1,usa puppy,2,colombia puppy,3,senegal kitten,2,colombia `CSVFrequencySampler('animals.csv', animal)` will return `puppy` or `kitten` randomly. `puppy` will be 3x more frequent than `kitten`. `CSVFrequencySampler('animals.csv', country)` will return `usa`, `colombia`, or `senegal` randomly. `colombia` will be 2x more frequent than `usa` or `senegal`. Use this function to infer frequencies of categorical values from CSVs.
  • Constructor Details

    • CSVFrequencySampler

      public CSVFrequencySampler(String filename, String columnName)
      Create a sampler of strings from the given CSV file. The CSV file must have plain CSV headers as its first line.
      Parameters:
      filename - The name of the file to be read into the sampler buffer
      columnName - The name of the column to be sampled
  • Method Details