[][src]Function atm::utils::gen_partition_size

pub fn gen_partition_size(
    num_notes: f32,
    length: i32,
    max_file_count: f32,
    partition_depth: i32
) -> u32

Calculate number of MIDI notes per partition.

Arguments

Preconditions

Examples

let partition_size = atm::utils::gen_partition_size(8.0, 12, 4096.0, 2);

// With these parameters, the calculation would be:
// https://www.wolframalpha.com/input/?i=ceil%28log64%28max%288%5E12%2F4096%2C+1%29%29%29
assert_eq!(4, partition_size)

Notes:

Most modern filesystems do not perform well with more than 4K files per folder, and XFS is no exception. In order to prevent overloading a single folder, we decided to partition sequences by their hash, which is just the integer representation of the MIDI notes in the sequence (see: libatm::MIDIFile::gen_hash), such that no folder would contain more than max_file_count number of files. The formula works as follows:

let N = num_noteslength (number of files to be generated)
let D = max(N / max_file_count, 1) (maximum number of directories to generate)
let B = num_notespartition_depth (logarithm base)
partition_size = ceil(logB(D))

NOTE: If num_notes is 1 or num_noteslength is less than or equal to max_file_count then the function will simply return length (see Preconditions above).