@@ -5,8 +5,7 @@ use crate::specification::{DataSpec, FieldKind, MeasurementSpec};
55use chrono:: { DateTime , Local } ;
66use influxdb3_client:: { Client , Precision } ;
77use rand:: distributions:: Alphanumeric ;
8- use rand:: rngs:: SmallRng ;
9- use rand:: { Rng , RngCore , SeedableRng } ;
8+ use rand:: { Rng , RngCore } ;
109use std:: collections:: HashMap ;
1110use std:: io:: Write ;
1211use std:: ops:: Add ;
@@ -133,9 +132,15 @@ fn create_measurement<'a>(
133132 key : Arc :: clone ( & key) ,
134133 copy_id,
135134 null_probability,
136- field_value : FieldValue :: Boolean ( BooleanValue :: Random (
137- SmallRng :: from_entropy ( ) ,
138- ) ) ,
135+ field_value : FieldValue :: Boolean ( BooleanValue :: Random ) ,
136+ } ) ;
137+ }
138+ FieldKind :: BoolToggle => {
139+ fields. push ( Field {
140+ key : Arc :: clone ( & key) ,
141+ copy_id,
142+ null_probability,
143+ field_value : FieldValue :: Boolean ( BooleanValue :: Toggle ( false ) ) ,
139144 } ) ;
140145 }
141146 FieldKind :: String ( s) => {
@@ -215,6 +220,17 @@ fn create_measurement<'a>(
215220 } ) ) ,
216221 } ) ;
217222 }
223+ FieldKind :: FloatSeqWithInc ( inc) => {
224+ fields. push ( Field {
225+ key : Arc :: clone ( & key) ,
226+ copy_id,
227+ null_probability,
228+ field_value : FieldValue :: Float ( FloatValue :: SequentialWithInc {
229+ next : 0f64 ,
230+ inc : * inc,
231+ } ) ,
232+ } ) ;
233+ }
218234 }
219235 }
220236 }
@@ -458,6 +474,10 @@ impl Field {
458474 let v: f64 = rng. gen_range ( range. clone ( ) ) ;
459475 write ! ( w, "{:.3}" , v) ?;
460476 }
477+ FloatValue :: SequentialWithInc { next, inc } => {
478+ write ! ( w, "{:.10}" , next) ?;
479+ * next += * inc;
480+ }
461481 } ,
462482 FieldValue :: String ( s) => match s {
463483 StringValue :: Fixed ( v) => write ! ( w, "\" {}\" " , v) ?,
@@ -476,10 +496,14 @@ impl Field {
476496 }
477497 } ,
478498 FieldValue :: Boolean ( f) => match f {
479- BooleanValue :: Random ( rng ) => {
499+ BooleanValue :: Random => {
480500 let v: bool = rng. r#gen ( ) ;
481501 write ! ( w, "{}" , v) ?;
482502 }
503+ BooleanValue :: Toggle ( current) => {
504+ write ! ( w, "{current}" ) ?;
505+ * current = !* current;
506+ }
483507 } ,
484508 }
485509
@@ -498,6 +522,7 @@ pub enum IntegerValue {
498522pub enum FloatValue {
499523 Fixed ( f64 ) ,
500524 Random ( Range < f64 > ) ,
525+ SequentialWithInc { next : f64 , inc : f64 } ,
501526}
502527
503528#[ derive( Clone , Debug ) ]
@@ -507,9 +532,10 @@ pub enum StringValue {
507532 Sequential ( Arc < str > , u64 ) ,
508533}
509534
510- #[ derive( Clone , Debug ) ]
535+ #[ derive( Clone , Copy , Debug ) ]
511536pub enum BooleanValue {
512- Random ( SmallRng ) ,
537+ Random ,
538+ Toggle ( bool ) ,
513539}
514540
515541struct ByteCounter < W > {
@@ -722,6 +748,7 @@ pub struct Output {
722748#[ cfg( test) ]
723749mod tests {
724750 use chrono:: TimeZone ;
751+ use rand:: { SeedableRng , rngs:: SmallRng } ;
725752
726753 use super :: * ;
727754 use crate :: specification:: { FieldSpec , TagSpec } ;
0 commit comments