pkolaczk / latte

Latency Tester for Apache Cassandra
Apache License 2.0
176 stars 19 forks source link

Add functions to generate multi-row partitions with flexible size #108

Closed vponomaryov closed 1 week ago

vponomaryov commented 1 week ago

First step is to define following function in the prepare section of a rune script:

  pub async fn prepare(db) {
    ...
    db.init_partition_row_distribution_preset(
      "foo", ROW_COUNT, ROWS_PER_PARTITION, "70:1,20:2.5,10:3.5").await?;
    ...
  }

With this function we pre-create a preset with the foo name and instruct it to calculate number of partitions and their rows-sizes like following:

Then, in the target functions we can reuse it like following:

  pub async fn insert(db, i) {
    let idx = i % ROW_COUNT + OFFSET;
    let partition_idx = db.get_partition_idx("foo", idx).await? + OFFSET;
    ...
  }

As a result we will be able to get multi-row partitions in a requested size proportions.

This feature is optional to use. Number of presets is unlimited. Any rune script may use multiple different presets for different tables.