Skip to content

Commit

Permalink
apply: add --batch zero support
Browse files Browse the repository at this point in the history
  • Loading branch information
jqnatividad committed Jun 30, 2024
1 parent 9fdf066 commit bfe2355
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/cmd/apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ apply options:
-j, --jobs <arg> The number of jobs to run in parallel.
When not set, the number of jobs is set to the number of CPUs detected.
-b, --batch <size> The number of rows per batch to load into memory, before running in parallel.
Set to 0 to load all rows at once.
[default: 50000]
Common options:
Expand Down Expand Up @@ -390,7 +391,7 @@ struct Args {
flag_comparand: String,
flag_replacement: String,
flag_formatstr: String,
flag_batch: u32,
flag_batch: usize,
flag_jobs: Option<usize>,
flag_new_column: Option<String>,
flag_output: Option<String>,
Expand Down Expand Up @@ -558,7 +559,11 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
let mut batch_record = csv::StringRecord::new();

// reuse batch buffers
let batchsize: usize = args.flag_batch as usize;
let batchsize: usize = if args.flag_batch == 0 {
util::count_rows(&rconfig)? as usize
} else {
args.flag_batch
};
let mut batch = Vec::with_capacity(batchsize);
let mut batch_results = Vec::with_capacity(batchsize);

Expand Down

0 comments on commit bfe2355

Please sign in to comment.