Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,40 @@ Then you can set the parameter by using `-P`:
latte run <workload> -P row_count=200
```

### Multi-row partitions with different row count

If there is a need to simulate real-life case where we have multi-row partitions
and their sizes differ we can easily cover it with latte.

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:
- `70%` of partitions will be of the `ROWS_PER_PARTITION` size
- `20%` of `2.5*ROWS_PER_PARTITION`
- `10%` of the `3.5*ROWS_PER_PARTITION`.

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.

Number of presets is unlimited. Any rune script may use multiple different presets for different tables.

### Error handling

Errors during execution of a workload script are divided into three classes:
Expand Down
Loading