Class Bindings

java.lang.Object
io.nosqlbench.virtdata.core.bindings.Bindings

public class Bindings extends Object
Maps a template with named bind points and specifiers onto a set of data mapping function instances. Allows for streamlined calling of mapper functions as a set.

There are several ways to get generated data via this class. You must always provide a base input value. Fields can be accessed by parameter position or name. In some cases, you can provide an iterator stride in order to get data in bulk. In other cases, you can have setters called directly on your provided objects. See the detailed method docs for more information.

  • Constructor Details

  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getAll

      public Object[] getAll(long input)
      Get a value from each data mapper in the bindings list
      Parameters:
      input - The long value which the bound data mappers will use as in input
      Returns:
      An array of objects, the values yielded from each data mapper in the bindings list
    • getTemplate

      public BindingsTemplate getTemplate()
      Returns:
      BindingsTemplate associated with this set of bindings
    • getAllMap

      public Map<String,Object> getAllMap(long input)
      Parameters:
      input - The input value for which the values should be generated.
      Returns:
      Map of String to Object
    • getIteratedMaps

      public List<Map<String,Object>> getIteratedMaps(long input, int count)
      Generate a list of maps over a range of inputs.

      For example, calling getIteratedMaps(5,3) with bindings named alpha and gamma might produce something like:

        • alpha -> val1
        • gamma -> val2
        • alpha -> val3
        • gamma -> val4
        • alpha -> val5
        • gamma -> val6
      Parameters:
      input - The base value for which the values should be generated.
      count - The number of iterations, starting at input, to be generated
      Returns:
      List of Map of String to Object
    • getIteratedSuffixMap

      public Map<String,Object> getIteratedSuffixMap(long input, int count)
      Generate a map containing the results from multiple iterations, suffixing the keys in the map with the iterations from 0 to count-1.

      For example, calling getIteratedSuffixMap(5, 3) with generators named alpha and gamma might yield results like

      • alpha0 -> val1
      • gamma0 -> val2
      • alpha1 -> val3
      • gamma1 -> val4
      • alpha2 -> val5
      • gamma2 -> val6
      Parameters:
      input - The base input value for which the values should be generated
      count - The count of maps that should be added to the final map
      Returns:
      Map of String to Object
    • getIteratedSuffixMap

      public Map<String,Object> getIteratedSuffixMap(long input, int count, String... fieldNames)
      This is a version of the setIteratedSuffixMap(Map, long, int, String[]) which creates a new map for each call.
      Parameters:
      input - The base input value for which the values should be generated
      count - The count of maps that should be added to the final map
      fieldNames - The field names which are used to look up the functions in the binding
      Returns:
      A newly created map with the generated names and values.
    • get

      public Object get(int i, long input)
      Get a value for the data mapper in slot i
      Parameters:
      i - the data mapper slot, 0-indexed
      input - the long input value which the bound data mapper will use as input
      Returns:
      a single object, the value yielded from the indexed data mapper in the bindings list
    • get

      public Object get(String name, long input)
      Get a value for the cached mapper name, using the name to mapper index cache.
      Parameters:
      name - The field name in the data mapper
      input - the long input value which the bound data mapper will use as an input
      Returns:
      a single object, the value yielded from the named and indexed data mapper in the bindings list.
    • setMap

      public void setMap(Map<String,Object> donorMap, long cycle)
      Generate all values in the bindings template, and set each of them in the map according to their bind point name.
      Parameters:
      donorMap - - a user-provided Map<String,Object>
      cycle - - the cycle for which to generate the values
    • setSuffixedMap

      public void setSuffixedMap(Map<String,Object> donorMap, long cycle, String suffix)
      Set the values in a provided map, with bound names suffixed with some value. No non-overlapping keys in the map will be affected.
      Parameters:
      donorMap - an existing Map of String to Object
      cycle - the cycle for which values should be generated
      suffix - a string suffix to be appended to any map keys
    • setIteratedSuffixMap

      public void setIteratedSuffixMap(Map<String,Object> donorMap, long input, long count)
      Set the values in a provided map, with the bound names suffixed with an internal iteration value.
      Parameters:
      donorMap - an existing Map of String to Object
      input - the base cycle for which values should be generated
      count - the number of iterations to to generate values and keynames for
    • updateMap

      public void updateMap(Map<String,Object> donorMap, long input)
      Generate only the values which have matching keys in the provided map according to their bind point names, and assign them to the map under that name. It is an error for a key name to be defined in the map for which there is no mapper.
      Parameters:
      donorMap - - a user-provided Map<String,Object>
      input - - the input for which to generate the values
    • setNamedFields

      public void setNamedFields(Bindings.FieldSetter fieldSetter, long input, String... fieldName)
      Generate only the values named in fieldNames, and then call the user-provided field setter for each name and object generated.
      Parameters:
      fieldSetter - user-provided object that implements Bindings.FieldSetter.
      input - the input for which to generate values
      fieldName - A varargs list of field names, or a String[] of names to set
    • setNamedFieldsIterated

      public void setNamedFieldsIterated(Bindings.FieldSetter fieldSetter, long input, int count, String... fieldName)
      Generate all the values named in the bindings for a number of iterations, calling a user-provided field setter for each name and object generated, with the iteration number appended to the fieldName, but only for the named bindings.
      Parameters:
      fieldSetter - user-provided object that implements Bindings.FieldSetter
      input - the base input value for which the objects should be generated
      count - the number of iterations to generate values and names for
      fieldName - the field names for which to generate values and names
    • setAllFields

      public void setAllFields(Bindings.FieldSetter fieldSetter, long input)
      Generate all the values named in the bind point names, then call the user-provided field setter for each name and object generated.
      Parameters:
      fieldSetter - user-provided object that implements Bindings.FieldSetter
      input - the input for which to generate values
    • setAllFieldsIterated

      public void setAllFieldsIterated(Bindings.FieldSetter fieldSetter, long input, int count)
      Generate all the values named in the bindings for a number of iterations, calling a user-provided field setter for each name and object generated, with the iteration number appended to the fieldName.
      Parameters:
      fieldSetter - user-provided object that implements Bindings.FieldSetter
      input - the base input value for which the objects should be generated
      count - the number of iterations to generate values and names for
    • getLazyMap

      public LazyValuesMap getLazyMap(long input)