pub(crate) async fn make_one_chunk_scenarios(partition_key: &str, data: &str) -> Vec<DbScenario> {
    // Scenario 1: One open chunk in MUB
    let db = make_db().await.db;
    write_lp(&db, data).await;
    let scenario1 = DbScenario {
        scenario_name: "Data in open chunk of mutable buffer".into(),
        db,
    };

    // Scenario 2: One closed chunk in MUB
    let db = make_db().await.db;
    let table_names = write_lp(&db, data).await;
    for table_name in &table_names {
        db.rollover_partition(table_name, partition_key)
            .await
            .unwrap();
    }
    let scenario2 = DbScenario {
        scenario_name: "Data in closed chunk of mutable buffer".into(),
        db,
    };

    // Scenario 3: One closed chunk in RUB
    let db = make_db().await.db;
    let table_names = write_lp(&db, data).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();
    }
    let scenario3 = DbScenario {
        scenario_name: "Data in read buffer".into(),
        db,
    };

    // Scenario 4: One closed chunk in both RUb and OS
    let db = make_db().await.db;
    let table_names = write_lp(&db, data).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 scenario4 = DbScenario {
        scenario_name: "Data in both read buffer and object store".into(),
        db,
    };

    // Scenario 5: One closed chunk in OS only
    let db = make_db().await.db;
    let table_names = write_lp(&db, data).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 scenario5 = DbScenario {
        scenario_name: "Data in object store only".into(),
        db,
    };

    vec![scenario1, scenario2, scenario3, scenario4, scenario5]
}
/// This function loads one chunk of lp data into different scenarios that simulates
/// the data life cycle.
///
This function loads one chunk of lp data into different scenarios that simulates
the data life cycle.
This function loads one chunk of lp data into different scenarios that simulates the data life cycle .
pub(crate) async fn make_one_chunk_scenarios(partition_key: &str, data: &str) -> Vec<DbScenario> {
    // Scenario 1: One open chunk in MUB
    let db = make_db().await.db;
    write_lp(&db, data).await;
    let scenario1 = DbScenario {
        scenario_name: "Data in open chunk of mutable buffer".into(),
        db,
    };
    // Scenario 2: One closed chunk in MUB
    let db = make_db().await.db;
    let table_names = write_lp(&db, data).await;
    for table_name in &table_names {
        db.rollover_partition(table_name, partition_key)
            .await
            .unwrap();
    }
    let scenario2 = DbScenario {
        scenario_name: "Data in closed chunk of mutable buffer".into(),
        db,
    };
    // Scenario 3: One closed chunk in RUB
    let db = make_db().await.db;
    let table_names = write_lp(&db, data).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();
    }
    let scenario3 = DbScenario {
        scenario_name: "Data in read buffer".into(),
        db,
    };
    // Scenario 4: One closed chunk in both RUb and OS
    let db = make_db().await.db;
    let table_names = write_lp(&db, data).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 scenario4 = DbScenario {
        scenario_name: "Data in both read buffer and object store".into(),
        db,
    };
    // Scenario 5: One closed chunk in OS only
    let db = make_db().await.db;
    let table_names = write_lp(&db, data).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 scenario5 = DbScenario {
        scenario_name: "Data in object store only".into(),
        db,
    };
    vec![scenario1, scenario2, scenario3, scenario4, scenario5]
}
pub ( crate ) async fn make_one_chunk_scenarios ( partition_key : & str , data : & str ) -> Vec < DbScenario > { // Scenario 1: One open chunk in MUB let db = make_db ( ) . await . db ; write_lp ( & db , data ) . await ; let scenario1 = DbScenario { scenario_name : " " . into ( ) , db , } ; // Scenario 2: One closed chunk in MUB let db = make_db ( ) . await . db ; let table_names = write_lp ( & db , data ) . await ; for table_name in & table_names { db . rollover_partition ( table_name , partition_key ) . await . unwrap ( ) ; } let scenario2 = DbScenario { scenario_name : " " . into ( ) , db , } ; // Scenario 3: One closed chunk in RUB let db = make_db ( ) . await . db ; let table_names = write_lp ( & db , data ) . 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 ( ) ; } let scenario3 = DbScenario { scenario_name : " " . into ( ) , db , } ; // Scenario 4: One closed chunk in both RUb and OS let db = make_db ( ) . await . db ; let table_names = write_lp ( & db , data ) . 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 scenario4 = DbScenario { scenario_name : " " . into ( ) , db , } ; // Scenario 5: One closed chunk in OS only let db = make_db ( ) . await . db ; let table_names = write_lp ( & db , data ) . 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 scenario5 = DbScenario { scenario_name : " " . into ( ) , db , } ; vec ! [ scenario1 scenario2 scenario3 scenario4 scenario5 ] }
This function loads one chunk of lp data into different scenarios that simulates
the data life cycle.
This function loads one chunk of lp data into different scenarios that simulates the data life cycle .
partition_key
&str
data
&str
partition_key
&str
data
&str