Class DelimFrequencySampler

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

public class DelimFrequencySampler
extends java.lang.Object
implements java.util.function.LongFunction<java.lang.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 Summary

    Constructors 
    Constructor Description
    DelimFrequencySampler​(java.lang.String filename, java.lang.String columnName, char delimiter)
    Create a sampler of strings from the given delimited file.
  • Method Summary

    Modifier and Type Method Description
    java.lang.String apply​(long value)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DelimFrequencySampler

      public DelimFrequencySampler​(java.lang.String filename, java.lang.String columnName, char delimiter)
      Create a sampler of strings from the given delimited file. The delimited file must have plain 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
      delimiter - delimmiter
  • Method Details

    • apply

      public java.lang.String apply​(long value)
      Specified by:
      apply in interface java.util.function.LongFunction<java.lang.String>