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

Conversation

vponomaryov
Copy link
Collaborator

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.

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

src/context.rs Show resolved Hide resolved
Copy link
Collaborator

@fruch fruch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm missing some docs on how init_partition_row_distribution_preset is used and what are the parameters arguments and such.

and an example how it gonna be used within a rune script, it's hard to see it here.

Edit: PR description should go into the code, maybe into README.md or into /docs/

src/context.rs Outdated

#[test]
fn test_partition_row_distribution_preset_10_neg_percentage_is_not_100() {
false_input_for_partition_row_distribution_preset("foo".to_string(), 1000, 10, "90:1,9:2".to_string())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you missing the case the input is above 100%

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is 90+9 = 99%.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see a case like 90+15, as a negative case I've meant

I assume from what I've read, that it would fail, right ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, it will fail.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added one more test.

@vponomaryov
Copy link
Collaborator Author

I'm missing some docs on how init_partition_row_distribution_preset is used and what are the parameters arguments and such.

and an example how it gonna be used within a rune script, it's hard to see it here.

Edit: PR description should go into the code, maybe into README.md or into /docs/

You want me to update the README.md file in scope of this PR?
Even if we have information in the commit message?

@fruch
Copy link
Collaborator

fruch commented Oct 9, 2024

I'm missing some docs on how init_partition_row_distribution_preset is used and what are the parameters arguments and such.
and an example how it gonna be used within a rune script, it's hard to see it here.
Edit: PR description should go into the code, maybe into README.md or into /docs/

You want me to update the README.md file in scope of this PR? Even if we have information in the commit message?

yes, I don't expect user to read a commit message to understand how to use something, do you ?

@vponomaryov
Copy link
Collaborator Author

I'm missing some docs on how init_partition_row_distribution_preset is used and what are the parameters arguments and such.
and an example how it gonna be used within a rune script, it's hard to see it here.
Edit: PR description should go into the code, maybe into README.md or into /docs/

You want me to update the README.md file in scope of this PR? Even if we have information in the commit message?

yes, I don't expect user to read a commit message to understand how to use something, do you ?

Done

Copy link
Collaborator

@fruch fruch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fruch
Copy link
Collaborator

fruch commented Oct 9, 2024

@vladzcloudius @gcarmin FYI,

as part of the work we need for some cases, @vponomaryov implement this new feature for latte
I might correlate with other needs you might have, and you input about it would be appreciated

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 precreate 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' and 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.

This feature is optional to use.
Number of presets is unlimited. Any rune script may use multiple
different presets for different tables.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants