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

count: if --verbose option is present, output a message every 1mm rows #252

Merged
merged 4 commits into from
Oct 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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