Skip to content

Commit

Permalink
count: if --verbose option is present, output a message every 1mm rows (
Browse files Browse the repository at this point in the history
#252)

* count: if --verbose option is present, output a message every 1mm rows
  • Loading branch information
liquidaty authored Oct 31, 2024
1 parent 255b981 commit ff1329b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/count.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ struct data {
size_t rows;
};

static void row_verbose(void *ctx) {
((struct data *)ctx)->rows++;
if ((((struct data *)ctx)->rows - 1) % 1000000 == 0)
fprintf(stderr, "Processed %zumm data rows\n", (((struct data *)ctx)->rows - 1) / 1000000);
}

static void row(void *ctx) {
((struct data *)ctx)->rows++;
}
Expand Down Expand Up @@ -71,7 +77,7 @@ int ZSV_MAIN_FUNC(ZSV_COMMAND)(int argc, const char *argv[], struct zsv_opts *op
#endif

if (!err) {
opts->row_handler = row;
opts->row_handler = opts->verbose ? row_verbose : row;
opts->ctx = &data;
if (zsv_new_with_properties(opts, custom_prop_handler, input_path, opts_used, &data.parser) != zsv_status_ok) {
fprintf(stderr, "Unable to initialize parser\n");
Expand Down

0 comments on commit ff1329b

Please sign in to comment.