fn generate_row_group(rows: usize, rng: &mut ThreadRng) -> RowGroup {
    let mut timestamp = 1351700038292387000_i64;
    let spans_per_trace = 10;

    let mut column_packers: Vec<Packers> = vec![
        Packers::from(Vec::<Option<String>>::with_capacity(rows)), // env (card 2)
        Packers::from(Vec::<Option<String>>::with_capacity(rows)), // data_centre (card 20)
        Packers::from(Vec::<Option<String>>::with_capacity(rows)), // cluster (card 200)
        Packers::from(Vec::<Option<String>>::with_capacity(rows)), // user_id (card 200,000)
        Packers::from(Vec::<Option<String>>::with_capacity(rows)), // request_id (card 2,000,000)
        Packers::from(Vec::<Option<String>>::with_capacity(rows)), // node_id (card 2,000)
        Packers::from(Vec::<Option<String>>::with_capacity(rows)), // pod_id (card 20,000)
        Packers::from(Vec::<Option<String>>::with_capacity(rows)), // trace_id (card "rows / 10")
        Packers::from(Vec::<Option<String>>::with_capacity(rows)), // span_id (card "rows")
        Packers::from(Vec::<Option<i64>>::with_capacity(rows)),    // duration
        Packers::from(Vec::<Option<i64>>::with_capacity(rows)),    // time
    ];

    let n = rows / spans_per_trace;
    for _ in 0..n {
        column_packers =
            generate_trace_for_row_group(spans_per_trace, timestamp, column_packers, rng);

        // next trace is ~10 seconds in the future
        timestamp += 10_000 * ONE_MS;
    }

    // sort the packers according to lowest to highest cardinality excluding
    // columns that are likely to be unique.
    //
    // - env, data_centre, cluster, node_id, pod_id, user_id, request_id, time
    sorter::sort(&mut column_packers, &[0, 1, 2, 5, 6, 3, 4, 10]).unwrap();

    // create columns
    let columns = vec![
        (
            "env".to_string(),
            ColumnType::Tag(Column::from(column_packers[0].str_packer().values())),
        ),
        (
            "data_centre".to_string(),
            ColumnType::Tag(Column::from(column_packers[1].str_packer().values())),
        ),
        (
            "cluster".to_string(),
            ColumnType::Tag(Column::from(column_packers[2].str_packer().values())),
        ),
        (
            "user_id".to_string(),
            ColumnType::Tag(Column::from(column_packers[3].str_packer().values())),
        ),
        (
            "request_id".to_string(),
            ColumnType::Tag(Column::from(column_packers[4].str_packer().values())),
        ),
        (
            "node_id".to_string(),
            ColumnType::Tag(Column::from(column_packers[5].str_packer().values())),
        ),
        (
            "pod_id".to_string(),
            ColumnType::Tag(Column::from(column_packers[6].str_packer().values())),
        ),
        (
            "trace_id".to_string(),
            ColumnType::Tag(Column::from(column_packers[7].str_packer().values())),
        ),
        (
            "span_id".to_string(),
            ColumnType::Tag(Column::from(column_packers[8].str_packer().values())),
        ),
        (
            "duration".to_string(),
            ColumnType::Field(Column::from(
                column_packers[9].i64_packer().some_values().as_slice(),
            )),
        ),
        (
            "time".to_string(),
            ColumnType::Time(Column::from(
                column_packers[10].i64_packer().some_values().as_slice(),
            )),
        ),
    ];

    RowGroup::new(rows as u32, columns)
}
//
// This generates a `RowGroup` with a known schema, ~known column cardinalities
// and variable number of rows.
//
// The schema and cardinalities are in-line with a tracing data use-case.
This generates a `RowGroup` with a known schema, ~known column cardinalities
and variable number of rows.

The schema and cardinalities are in-line with a tracing data use-case.
This generates a ` RowGroup ` with a known schema ~known column cardinalities and variable number of rows . The schema and cardinalities are in - line with a tracing data use - case .
fn generate_row_group(rows: usize, rng: &mut ThreadRng) -> RowGroup {
    let mut timestamp = 1351700038292387000_i64;
    let spans_per_trace = 10;
    let mut column_packers: Vec<Packers> = vec![
        Packers::from(Vec::<Option<String>>::with_capacity(rows)), // env (card 2)
        Packers::from(Vec::<Option<String>>::with_capacity(rows)), // data_centre (card 20)
        Packers::from(Vec::<Option<String>>::with_capacity(rows)), // cluster (card 200)
        Packers::from(Vec::<Option<String>>::with_capacity(rows)), // user_id (card 200,000)
        Packers::from(Vec::<Option<String>>::with_capacity(rows)), // request_id (card 2,000,000)
        Packers::from(Vec::<Option<String>>::with_capacity(rows)), // node_id (card 2,000)
        Packers::from(Vec::<Option<String>>::with_capacity(rows)), // pod_id (card 20,000)
        Packers::from(Vec::<Option<String>>::with_capacity(rows)), // trace_id (card "rows / 10")
        Packers::from(Vec::<Option<String>>::with_capacity(rows)), // span_id (card "rows")
        Packers::from(Vec::<Option<i64>>::with_capacity(rows)),    // duration
        Packers::from(Vec::<Option<i64>>::with_capacity(rows)),    // time
    ];
    let n = rows / spans_per_trace;
    for _ in 0..n {
        column_packers =
            generate_trace_for_row_group(spans_per_trace, timestamp, column_packers, rng);
        // next trace is ~10 seconds in the future
        timestamp += 10_000 * ONE_MS;
    }
    // sort the packers according to lowest to highest cardinality excluding
    // columns that are likely to be unique.
    //
    // - env, data_centre, cluster, node_id, pod_id, user_id, request_id, time
    sorter::sort(&mut column_packers, &[0, 1, 2, 5, 6, 3, 4, 10]).unwrap();
    // create columns
    let columns = vec![
        (
            "env".to_string(),
            ColumnType::Tag(Column::from(column_packers[0].str_packer().values())),
        ),
        (
            "data_centre".to_string(),
            ColumnType::Tag(Column::from(column_packers[1].str_packer().values())),
        ),
        (
            "cluster".to_string(),
            ColumnType::Tag(Column::from(column_packers[2].str_packer().values())),
        ),
        (
            "user_id".to_string(),
            ColumnType::Tag(Column::from(column_packers[3].str_packer().values())),
        ),
        (
            "request_id".to_string(),
            ColumnType::Tag(Column::from(column_packers[4].str_packer().values())),
        ),
        (
            "node_id".to_string(),
            ColumnType::Tag(Column::from(column_packers[5].str_packer().values())),
        ),
        (
            "pod_id".to_string(),
            ColumnType::Tag(Column::from(column_packers[6].str_packer().values())),
        ),
        (
            "trace_id".to_string(),
            ColumnType::Tag(Column::from(column_packers[7].str_packer().values())),
        ),
        (
            "span_id".to_string(),
            ColumnType::Tag(Column::from(column_packers[8].str_packer().values())),
        ),
        (
            "duration".to_string(),
            ColumnType::Field(Column::from(
                column_packers[9].i64_packer().some_values().as_slice(),
            )),
        ),
        (
            "time".to_string(),
            ColumnType::Time(Column::from(
                column_packers[10].i64_packer().some_values().as_slice(),
            )),
        ),
    ];
    RowGroup::new(rows as u32, columns)
}
fn generate_row_group ( rows : usize , rng : & mut ThreadRng ) -> RowGroup { let mut timestamp = 1351700038292387000_i64 ; let spans_per_trace = 10 ; let mut column_packers : Vec < Packers > = vec ! [ Packers from ( Vec Option String with_capacity ( rows ) ) // env (card 2) Packers from ( Vec Option String with_capacity ( rows ) ) // data_centre (card 20) Packers from ( Vec Option String with_capacity ( rows ) ) // cluster (card 200) Packers from ( Vec Option String with_capacity ( rows ) ) // user_id (card 200,000) Packers from ( Vec Option String with_capacity ( rows ) ) // request_id (card 2,000,000) Packers from ( Vec Option String with_capacity ( rows ) ) // node_id (card 2,000) Packers from ( Vec Option String with_capacity ( rows ) ) // pod_id (card 20,000) Packers from ( Vec Option String with_capacity ( rows ) ) // trace_id (card "rows / 10") Packers from ( Vec Option String with_capacity ( rows ) ) // span_id (card "rows") Packers from ( Vec Option i64 with_capacity ( rows ) ) // duration Packers from ( Vec Option i64 with_capacity ( rows ) ) // time ] ; let n = rows / spans_per_trace ; for _ in 0 .. n { column_packers = generate_trace_for_row_group ( spans_per_trace , timestamp , column_packers , rng ) ; // next trace is ~10 seconds in the future timestamp += 10_000 * ONE_MS ; } // sort the packers according to lowest to highest cardinality excluding // columns that are likely to be unique. // // - env, data_centre, cluster, node_id, pod_id, user_id, request_id, time sorter :: sort ( & mut column_packers , & [ 0 , 1 , 2 , 5 , 6 , 3 , 4 , 10 ] ) . unwrap ( ) ; // create columns let columns = vec ! [ ( " " to_string ( ) ColumnType Tag ( Column from ( column_packers [ 0 ] str_packer ( ) values ( ) ) ) ) ( " " to_string ( ) ColumnType Tag ( Column from ( column_packers [ 1 ] str_packer ( ) values ( ) ) ) ) ( " " to_string ( ) ColumnType Tag ( Column from ( column_packers [ 2 ] str_packer ( ) values ( ) ) ) ) ( " " to_string ( ) ColumnType Tag ( Column from ( column_packers [ 3 ] str_packer ( ) values ( ) ) ) ) ( " " to_string ( ) ColumnType Tag ( Column from ( column_packers [ 4 ] str_packer ( ) values ( ) ) ) ) ( " " to_string ( ) ColumnType Tag ( Column from ( column_packers [ 5 ] str_packer ( ) values ( ) ) ) ) ( " " to_string ( ) ColumnType Tag ( Column from ( column_packers [ 6 ] str_packer ( ) values ( ) ) ) ) ( " " to_string ( ) ColumnType Tag ( Column from ( column_packers [ 7 ] str_packer ( ) values ( ) ) ) ) ( " " to_string ( ) ColumnType Tag ( Column from ( column_packers [ 8 ] str_packer ( ) values ( ) ) ) ) ( " " to_string ( ) ColumnType Field ( Column from ( column_packers [ 9 ] i64_packer ( ) some_values ( ) as_slice ( ) ) ) ) ( " " to_string ( ) ColumnType Time ( Column from ( column_packers [ 10 ] i64_packer ( ) some_values ( ) as_slice ( ) ) ) ) ] ; RowGroup :: new ( rows as u32 , columns ) }
This generates a `RowGroup` with a known schema, ~known column cardinalities
and variable number of rows.
This generates a ` RowGroup ` with a known schema ~known column cardinalities and variable number of rows .
rows
usize
rng
&mut ThreadRng
rows
usize
rng
&mut ThreadRng