Closed vponomaryov closed 1 week ago
First step is to define following function in the prepare section of a rune script:
prepare
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:
foo
70%
ROWS_PER_PARTITION
20%
2.5*ROWS_PER_PARTITION
10%
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.
This feature is optional to use. Number of presets is unlimited. Any rune script may use multiple different presets for different tables.
First step is to define following function in the
prepare
section of a rune script: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 theROWS_PER_PARTITION
size20%
of2.5*ROWS_PER_PARTITION
10%
of the3.5*ROWS_PER_PARTITION
.Then, in the target functions we can reuse it like following:
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.