pub async fn make_two_chunk_scenarios(
    partition_key: &str,
    data1: &str,
    data2: &str,
) -> Vec<DbScenario> {
    let db = make_db().await.db;
    write_lp(&db, data1).await;
    write_lp(&db, data2).await;
    let scenario1 = DbScenario {
        scenario_name: "Data in single open chunk of mutable buffer".into(),
        db,
    };

    // spread across 2 mutable buffer chunks
    let db = make_db().await.db;
    let table_names = write_lp(&db, data1).await;
    for table_name in &table_names {
        db.rollover_partition(table_name, partition_key)
            .await
            .unwrap();
    }
    write_lp(&db, data2).await;
    let scenario2 = DbScenario {
        scenario_name: "Data in one open chunk and one closed chunk of mutable buffer".into(),
        db,
    };

    // spread across 1 mutable buffer, 1 read buffer chunks
    let db = make_db().await.db;
    let table_names = write_lp(&db, data1).await;
    for table_name in &table_names {
        db.rollover_partition(table_name, partition_key)
            .await
            .unwrap();
        db.move_chunk_to_read_buffer(table_name, partition_key, 0)
            .await
            .unwrap();
    }
    write_lp(&db, data2).await;
    let scenario3 = DbScenario {
        scenario_name: "Data in open chunk of mutable buffer, and one chunk of read buffer".into(),
        db,
    };

    // in 2 read buffer chunks
    let db = make_db().await.db;
    let table_names = write_lp(&db, data1).await;
    for table_name in &table_names {
        db.rollover_partition(table_name, partition_key)
            .await
            .unwrap();
    }
    let table_names = write_lp(&db, data2).await;
    for table_name in &table_names {
        db.rollover_partition(table_name, partition_key)
            .await
            .unwrap();

        db.move_chunk_to_read_buffer(table_name, partition_key, 0)
            .await
            .unwrap();

        db.move_chunk_to_read_buffer(table_name, partition_key, 1)
            .await
            .unwrap();
    }
    let scenario4 = DbScenario {
        scenario_name: "Data in two read buffer chunks".into(),
        db,
    };

    // in 2 read buffer chunks that also loaded into object store
    let db = make_db().await.db;
    let table_names = write_lp(&db, data1).await;
    for table_name in &table_names {
        db.rollover_partition(table_name, partition_key)
            .await
            .unwrap();
        db.move_chunk_to_read_buffer(table_name, partition_key, 0)
            .await
            .unwrap();
        db.persist_partition(
            table_name,
            partition_key,
            Instant::now() + Duration::from_secs(1),
        )
        .await
        .unwrap();
    }
    let table_names = write_lp(&db, data2).await;
    for table_name in &table_names {
        db.rollover_partition(table_name, partition_key)
            .await
            .unwrap();
        db.move_chunk_to_read_buffer(table_name, partition_key, 2)
            .await
            .unwrap();
        db.persist_partition(
            table_name,
            partition_key,
            Instant::now() + Duration::from_secs(1),
        )
        .await
        .unwrap();
    }
    let scenario5 = DbScenario {
        scenario_name: "Data in two read buffer chunks and two parquet file chunks".into(),
        db,
    };

    // Scenario 6: Two closed chunk in OS only
    let db = make_db().await.db;
    let table_names = write_lp(&db, data1).await;
    for table_name in &table_names {
        db.rollover_partition(table_name, partition_key)
            .await
            .unwrap();
        db.move_chunk_to_read_buffer(table_name, partition_key, 0)
            .await
            .unwrap();
        db.persist_partition(
            table_name,
            partition_key,
            Instant::now() + Duration::from_secs(1),
        )
        .await
        .unwrap();
        db.unload_read_buffer(table_name, partition_key, 1).unwrap();
    }
    let table_names = write_lp(&db, data2).await;
    for table_name in &table_names {
        db.rollover_partition(table_name, partition_key)
            .await
            .unwrap();
        db.move_chunk_to_read_buffer(table_name, partition_key, 2)
            .await
            .unwrap();
        db.persist_partition(
            table_name,
            partition_key,
            Instant::now() + Duration::from_secs(1),
        )
        .await
        .unwrap();
        db.unload_read_buffer(table_name, partition_key, 3).unwrap();
    }
    let scenario6 = DbScenario {
        scenario_name: "Data in 2 parquet chunks in object store only".into(),
        db,
    };

    // Scenario 7: in a single chunk resulting from compacting MUB and RUB
    let db = make_db().await.db;
    let table_names = write_lp(&db, data1).await;
    for table_name in &table_names {
        // put chunk 1 into RUB
        db.rollover_partition(table_name, partition_key)
            .await
            .unwrap();
        db.move_chunk_to_read_buffer(table_name, partition_key, 0)
            .await
            .unwrap();
    }
    let table_names = write_lp(&db, data2).await; // write to MUB
    for table_name in &table_names {
        // compact chunks into a single RUB chunk
        db.compact_partition(table_name, partition_key)
            .await
            .unwrap();
    }
    let scenario7 = DbScenario {
        scenario_name: "Data in one compacted read buffer chunk".into(),
        db,
    };

    vec![
        scenario1, scenario2, scenario3, scenario4, scenario5, scenario6, scenario7,
    ]
}
/// This function loads two chunks of lp data into 4 different scenarios
///
/// Data in single open mutable buffer chunk
/// Data in one open mutable buffer chunk, one closed mutable chunk
/// Data in one open mutable buffer chunk, one read buffer chunk
/// Data in one two read buffer chunks,
This function loads two chunks of lp data into 4 different scenarios
Data in single open mutable buffer chunk
Data in one open mutable buffer chunk, one closed mutable chunk
Data in one open mutable buffer chunk, one read buffer chunk
Data in one two read buffer chunks.
This function loads two chunks of lp data into 4 different scenarios Data in single open mutable buffer chunk Data in one open mutable buffer chunk one closed mutable chunk Data in one open mutable buffer chunk one read buffer chunk Data in one two read buffer chunks .
pub async fn make_two_chunk_scenarios(
    partition_key: &str,
    data1: &str,
    data2: &str,
) -> Vec<DbScenario> {
    let db = make_db().await.db;
    write_lp(&db, data1).await;
    write_lp(&db, data2).await;
    let scenario1 = DbScenario {
        scenario_name: "Data in single open chunk of mutable buffer".into(),
        db,
    };
    // spread across 2 mutable buffer chunks
    let db = make_db().await.db;
    let table_names = write_lp(&db, data1).await;
    for table_name in &table_names {
        db.rollover_partition(table_name, partition_key)
            .await
            .unwrap();
    }
    write_lp(&db, data2).await;
    let scenario2 = DbScenario {
        scenario_name: "Data in one open chunk and one closed chunk of mutable buffer".into(),
        db,
    };
    // spread across 1 mutable buffer, 1 read buffer chunks
    let db = make_db().await.db;
    let table_names = write_lp(&db, data1).await;
    for table_name in &table_names {
        db.rollover_partition(table_name, partition_key)
            .await
            .unwrap();
        db.move_chunk_to_read_buffer(table_name, partition_key, 0)
            .await
            .unwrap();
    }
    write_lp(&db, data2).await;
    let scenario3 = DbScenario {
        scenario_name: "Data in open chunk of mutable buffer, and one chunk of read buffer".into(),
        db,
    };
    // in 2 read buffer chunks
    let db = make_db().await.db;
    let table_names = write_lp(&db, data1).await;
    for table_name in &table_names {
        db.rollover_partition(table_name, partition_key)
            .await
            .unwrap();
    }
    let table_names = write_lp(&db, data2).await;
    for table_name in &table_names {
        db.rollover_partition(table_name, partition_key)
            .await
            .unwrap();
        db.move_chunk_to_read_buffer(table_name, partition_key, 0)
            .await
            .unwrap();
        db.move_chunk_to_read_buffer(table_name, partition_key, 1)
            .await
            .unwrap();
    }
    let scenario4 = DbScenario {
        scenario_name: "Data in two read buffer chunks".into(),
        db,
    };
    // in 2 read buffer chunks that also loaded into object store
    let db = make_db().await.db;
    let table_names = write_lp(&db, data1).await;
    for table_name in &table_names {
        db.rollover_partition(table_name, partition_key)
            .await
            .unwrap();
        db.move_chunk_to_read_buffer(table_name, partition_key, 0)
            .await
            .unwrap();
        db.persist_partition(
            table_name,
            partition_key,
            Instant::now() + Duration::from_secs(1),
        )
        .await
        .unwrap();
    }
    let table_names = write_lp(&db, data2).await;
    for table_name in &table_names {
        db.rollover_partition(table_name, partition_key)
            .await
            .unwrap();
        db.move_chunk_to_read_buffer(table_name, partition_key, 2)
            .await
            .unwrap();
        db.persist_partition(
            table_name,
            partition_key,
            Instant::now() + Duration::from_secs(1),
        )
        .await
        .unwrap();
    }
    let scenario5 = DbScenario {
        scenario_name: "Data in two read buffer chunks and two parquet file chunks".into(),
        db,
    };
    // Scenario 6: Two closed chunk in OS only
    let db = make_db().await.db;
    let table_names = write_lp(&db, data1).await;
    for table_name in &table_names {
        db.rollover_partition(table_name, partition_key)
            .await
            .unwrap();
        db.move_chunk_to_read_buffer(table_name, partition_key, 0)
            .await
            .unwrap();
        db.persist_partition(
            table_name,
            partition_key,
            Instant::now() + Duration::from_secs(1),
        )
        .await
        .unwrap();
        db.unload_read_buffer(table_name, partition_key, 1).unwrap();
    }
    let table_names = write_lp(&db, data2).await;
    for table_name in &table_names {
        db.rollover_partition(table_name, partition_key)
            .await
            .unwrap();
        db.move_chunk_to_read_buffer(table_name, partition_key, 2)
            .await
            .unwrap();
        db.persist_partition(
            table_name,
            partition_key,
            Instant::now() + Duration::from_secs(1),
        )
        .await
        .unwrap();
        db.unload_read_buffer(table_name, partition_key, 3).unwrap();
    }
    let scenario6 = DbScenario {
        scenario_name: "Data in 2 parquet chunks in object store only".into(),
        db,
    };
    // Scenario 7: in a single chunk resulting from compacting MUB and RUB
    let db = make_db().await.db;
    let table_names = write_lp(&db, data1).await;
    for table_name in &table_names {
        // put chunk 1 into RUB
        db.rollover_partition(table_name, partition_key)
            .await
            .unwrap();
        db.move_chunk_to_read_buffer(table_name, partition_key, 0)
            .await
            .unwrap();
    }
    let table_names = write_lp(&db, data2).await; // write to MUB
    for table_name in &table_names {
        // compact chunks into a single RUB chunk
        db.compact_partition(table_name, partition_key)
            .await
            .unwrap();
    }
    let scenario7 = DbScenario {
        scenario_name: "Data in one compacted read buffer chunk".into(),
        db,
    };
    vec![
        scenario1, scenario2, scenario3, scenario4, scenario5, scenario6, scenario7,
    ]
}
pub async fn make_two_chunk_scenarios ( partition_key : & str , data1 : & str , data2 : & str , ) -> Vec < DbScenario > { let db = make_db ( ) . await . db ; write_lp ( & db , data1 ) . await ; write_lp ( & db , data2 ) . await ; let scenario1 = DbScenario { scenario_name : " " . into ( ) , db , } ; // spread across 2 mutable buffer chunks let db = make_db ( ) . await . db ; let table_names = write_lp ( & db , data1 ) . await ; for table_name in & table_names { db . rollover_partition ( table_name , partition_key ) . await . unwrap ( ) ; } write_lp ( & db , data2 ) . await ; let scenario2 = DbScenario { scenario_name : " " . into ( ) , db , } ; // spread across 1 mutable buffer, 1 read buffer chunks let db = make_db ( ) . await . db ; let table_names = write_lp ( & db , data1 ) . await ; for table_name in & table_names { db . rollover_partition ( table_name , partition_key ) . await . unwrap ( ) ; db . move_chunk_to_read_buffer ( table_name , partition_key , 0 ) . await . unwrap ( ) ; } write_lp ( & db , data2 ) . await ; let scenario3 = DbScenario { scenario_name : " " . into ( ) , db , } ; // in 2 read buffer chunks let db = make_db ( ) . await . db ; let table_names = write_lp ( & db , data1 ) . await ; for table_name in & table_names { db . rollover_partition ( table_name , partition_key ) . await . unwrap ( ) ; } let table_names = write_lp ( & db , data2 ) . await ; for table_name in & table_names { db . rollover_partition ( table_name , partition_key ) . await . unwrap ( ) ; db . move_chunk_to_read_buffer ( table_name , partition_key , 0 ) . await . unwrap ( ) ; db . move_chunk_to_read_buffer ( table_name , partition_key , 1 ) . await . unwrap ( ) ; } let scenario4 = DbScenario { scenario_name : " " . into ( ) , db , } ; // in 2 read buffer chunks that also loaded into object store let db = make_db ( ) . await . db ; let table_names = write_lp ( & db , data1 ) . await ; for table_name in & table_names { db . rollover_partition ( table_name , partition_key ) . await . unwrap ( ) ; db . move_chunk_to_read_buffer ( table_name , partition_key , 0 ) . await . unwrap ( ) ; db . persist_partition ( table_name , partition_key , Instant :: now ( ) + Duration :: from_secs ( 1 ) , ) . await . unwrap ( ) ; } let table_names = write_lp ( & db , data2 ) . await ; for table_name in & table_names { db . rollover_partition ( table_name , partition_key ) . await . unwrap ( ) ; db . move_chunk_to_read_buffer ( table_name , partition_key , 2 ) . await . unwrap ( ) ; db . persist_partition ( table_name , partition_key , Instant :: now ( ) + Duration :: from_secs ( 1 ) , ) . await . unwrap ( ) ; } let scenario5 = DbScenario { scenario_name : " " . into ( ) , db , } ; // Scenario 6: Two closed chunk in OS only let db = make_db ( ) . await . db ; let table_names = write_lp ( & db , data1 ) . await ; for table_name in & table_names { db . rollover_partition ( table_name , partition_key ) . await . unwrap ( ) ; db . move_chunk_to_read_buffer ( table_name , partition_key , 0 ) . await . unwrap ( ) ; db . persist_partition ( table_name , partition_key , Instant :: now ( ) + Duration :: from_secs ( 1 ) , ) . await . unwrap ( ) ; db . unload_read_buffer ( table_name , partition_key , 1 ) . unwrap ( ) ; } let table_names = write_lp ( & db , data2 ) . await ; for table_name in & table_names { db . rollover_partition ( table_name , partition_key ) . await . unwrap ( ) ; db . move_chunk_to_read_buffer ( table_name , partition_key , 2 ) . await . unwrap ( ) ; db . persist_partition ( table_name , partition_key , Instant :: now ( ) + Duration :: from_secs ( 1 ) , ) . await . unwrap ( ) ; db . unload_read_buffer ( table_name , partition_key , 3 ) . unwrap ( ) ; } let scenario6 = DbScenario { scenario_name : " " . into ( ) , db , } ; // Scenario 7: in a single chunk resulting from compacting MUB and RUB let db = make_db ( ) . await . db ; let table_names = write_lp ( & db , data1 ) . await ; for table_name in & table_names { // put chunk 1 into RUB db . rollover_partition ( table_name , partition_key ) . await . unwrap ( ) ; db . move_chunk_to_read_buffer ( table_name , partition_key , 0 ) . await . unwrap ( ) ; } let table_names = write_lp ( & db , data2 ) . await ; // write to MUB for table_name in & table_names { // compact chunks into a single RUB chunk db . compact_partition ( table_name , partition_key ) . await . unwrap ( ) ; } let scenario7 = DbScenario { scenario_name : " " . into ( ) , db , } ; vec ! [ scenario1 scenario2 scenario3 scenario4 scenario5 scenario6 scenario7 ] }
This function loads two chunks of lp data into 4 different scenarios
Data in single open mutable buffer chunk
Data in one open mutable buffer chunk, one closed mutable chunk
Data in one open mutable buffer chunk, one read buffer chunk
Data in one two read buffer chunks,
This function loads two chunks of lp data into 4 different scenarios Data in single open mutable buffer chunk Data in one open mutable buffer chunk one closed mutable chunk Data in one open mutable buffer chunk one read buffer chunk Data in one two read buffer chunks
partition_key
&str
data1
&str
data2
&str
partition_key
&str
data1
&str
data2
&str