Skip to content

Object spec

ClaytonKnittel edited this page Feb 10, 2021 · 2 revisions

The enhanced object-spec allows for flexible nested structures with fine control over data types and structure, which can be used to closely emulate real-world data structure.

Object-spec structure

Object specs are a comma-separated list of bin specs, with each bin consisting of one of six types of data. The first four types of data are scalar and are as follows:

I<bytes>: an integer bin/value in a specific byte range (with I == I4)
  I1 for 0 - 255
  I2 for 256 - 65535
  I3 for 65536 - 2**24-1
  I4 for 2**24 - 2**32-1
  I5 for 2**32 - 2**40-1
  I6 for 2**40 - 2**48-1
  I7 for 2**48 - 2**56-1
  I8 for 2**56 - 2**64-1

B<n_bytes>: 'n_bytes' of random binary data.
  B12 - generates a bytearray of 12 random bytes

S<n_characters>: a string of random alphanumeric characters of length exactly 'n_characters'.
  S16 - a string of length 16 (i.e. "uirb4cm2kdxpo860")

D: an 8-byte double floating point bin/value

The remaining two types are collection bins/values, and consist of one or multiple values (which may also themselves be collection values). They are defined as follows:

[] - a list of values, with a multiplier in front indicating how many times to repeat that
     value in the list
  [3*I2] - ex: [312, 1651, 756]
  [I2, S4, I2] - ex: [892, "sfb7", 8712]
  [2*S12, 3*I1] - ex: ["b1alkr2s5pcs", "nd3iaq7brcf0", 18, 109, 212]
  [3*[I1, I1]] - ex: [[1,11],[123,240],[78,241]]

{} - a map from a scalar to any value, with a multiplier in front of the key indicating how
     many elements to generate in the map
  {5*S1:I1} - ex {"a":1, "b":2, "d":4, "z":26, "5":5}
  {2*S1:[3*I1]} - ex {"a": [1,2,3], "b": [6,7,8]}

At the top level, each value in the comma-separated list of values is its own bin in a record, so for the example I2,S12,[3*I1], with bin names (in order) bin_1, bin_2, and bin_3, a possible record would look like:

bin_1: 478
bin_2: "dfoiuaweopbg"
bin_3: [12, 45, 209]

Notes:

  • With --compression, only binary data (i.e. B<n_bytes>) are made to be compressible at the supplied compression ratio

Clone this wiki locally