github.com/square/finch@v0.0.0-20240412205204-6530c03e2b96/docs/content/data/generators.md (about) 1 --- 2 weight: 3 3 --- 4 5 {{< toc >}} 6 7 ## Integer 8 9 All integers are `int64` unless otherwise noted. 10 11 ### int 12 13 Random integer between `[min, max]` with uniform or normal distribution 14 {.tagline} 15 16 |Param|Default|Valid Values (v)| 17 |-----|-------|----| 18 |`min`|1|v ≥ 0| 19 |`max`|100,000|v < 2<sup>64</sup>| 20 |`dist`|`uniform`|`uniform` or `normal`| 21 |`mean`|(max-min+1)/2|| 22 |`stddev`|max-min/8.0|| 23 {.compact .params} 24 25 If `dist = normal`, you can shift/scale the distribution by tweaking `mean` and `stddev`. 26 27 ### int-gaps 28 29 `p` percentage of integers between `[min, max]` with uniform random access 30 {.tagline} 31 32 |Param|Default|Valid Values (n)| 33 |-----|-------|----| 34 |`min`|1|0 ≥ n < `max`| 35 |`max`|100,000|`min`< n < 2<sup>64</sup>| 36 |`p`|20|1–100 (percentage)| 37 {.compact .params} 38 39 Used to access a fraction of data with intentional gaps between accessed records. 40 41 ### int-range 42 43 Random ordered pairs `{n, n+size-1}` where `n` between `[min, max]` with uniform distribution 44 {.tagline} 45 46 |Param|Default|Valid Values (n)| 47 |-----|-------|----| 48 |`min`|1|int| 49 |`max`|100,000|int| 50 |`size`|100|≥ 1| 51 {.compact .params} 52 53 Used for `BETWEEN @d AND @PREV`. 54 55 ### int-range-seq 56 57 Sequential ordered pairs `{n, n+size-1}` from `begin` to `end` 58 {.tagline} 59 60 |Param|Default|Valid Values (n)| 61 |-----|-------|----| 62 |`begin`|1|int| 63 |`end`|100,000|int| 64 |`size`|100|≥ 1| 65 {.compact .params} 66 67 Used to scan a table or index in order by a range of values: [1, 10], [11, 20]. 68 When `end` is reached, restarts from `begin`. 69 70 ### auto-inc 71 72 Monotonically increasing uint64 counter from `start` by `step` increments 73 {.tagline} 74 75 |Param|Default|Valid Value (n)| 76 |-----|-------|----| 77 |`start`|0|0 ≤ n < 2<sup>64</sup>| 78 |`step`|1|n ≥1| 79 {.compact .params} 80 81 Every call adds `step` then returns the value. 82 By default starting at zero, returns 1, 2, 3, etc. 83 If `start = 10`, returns 11, 12, 13, etc. 84 If `start = 100` and `step = 5`, returns 105, 110, 115, etc. 85 86 ## String 87 88 ### str-fill-az 89 90 Fixed-length string filled with random characters a-z and A-Z 91 {.tagline} 92 93 |Param|Default|Valid Value (n)| 94 |-----|-------|----| 95 |`len`|100|n ≥ 1| 96 {.compact .params} 97 98 String length `len` is _characters_, not bytes. 99 100 ## ID 101 102 ### xid 103 104 Returns [rs/xid](https://github.com/rs/xid) values as strings. 105 106 ## Column 107 108 The `column` generator is used for SQL modifiers [`save-insert-id`]({{< relref "syntax/trx-file#save-insert-id" >}}) and [`save-result`]({{< relref "syntax/trx-file#save-result" >}}) 109 {.tagline} 110 111 112 |Param|Default|Valid Value| 113 |-----|-------|----| 114 |`quote-value`|yes|[string-bool]({{< relref "syntax/values#string-bool" >}}) 115 {.compact .params} 116 117 The `quote-value` param determines if the value is quoted or not when used as output to a SQL statement: 118 119 * yes → `WHERE id = "%v"` 120 * no → `WHERE id = %v` 121 122 The underlying MySQL column type does not matter because the value is not cast to a data type; it's inputted and outputted as raw bytes. 123 124 The default [data scope]({{< relref "data/scope" >}}) for column data is _trx_, not statement. 125 This can be changed with an explicit scope configuration. 126 Iter data scope might be useful, but statement (or value) scope will probably not work since the purpose is to resue the value in another statment.