Crate rsbatch_maestro

Source
Expand description

§Batch Maestro

A Rust crate for flexible batch splitting and management with various strategies.

This crate provides a comprehensive set of functions to divide a total number into batches, offering different splitting strategies to suit various scenarios such as task distribution, load balancing, and resource allocation.

§Features

  • Even and uneven splitting of totals into batches
  • Splitting by count, with remainder, or based on weights
  • Range-based splitting and optimization
  • Minimum batch size enforcement
  • Batch merging and rebalancing

§Usage

use batch_maestro::even_split;

fn main() {
    match even_split(128, 8) {
        Ok((num_batches, batch_sizes)) => {
            println!("Number of batches: {}", num_batches);
            println!("Batch sizes: {:?}", batch_sizes);
        },
        Err(e) => println!("Error: {}", e),
    }
}

For more information and examples, please visit the GitHub repository.

Functions§

even_split
Splits a total number into even batches.
optimize_split
Finds the most even split possible within a given range of batch counts.
split_by_count
Splits a total number into a specified number of batches.
split_range
Generates a range of possible split configurations based on a min and max batch size.
split_weighted
Splits the total based on provided weights for each batch.
split_with_min_batch
Splits a total number into even batches, ensuring each batch meets a minimum size requirement.
split_with_remainder
Splits a total number into even batches, returning the remainder separately.