csvzall 0.4.0
CSV command-line tool and emerging C++ library
Loading...
Searching...
No Matches
pipeline_types.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <cstdint>
5#include <functional>
6#include <optional>
7#include <string>
8
9namespace csvzall::pipeline {
10
12 Auto,
13 Paged,
14};
15
16struct RunOptions {
17 bool single_threaded = false;
18 bool input_is_stdin = false;
20 // Field delimiter for the input (and output for streaming commands).
21 // nullopt = auto-detect from {',', '|', '\t', ';', '^'}.
22 // A value forces the exact delimiter (e.g. '\t' for TSV).
23 std::optional<char> delimiter = std::nullopt;
24 // SQLite memory strategy: load into :memory: if file is at or below this
25 // threshold; otherwise write a temporary on-disk database that is deleted on
26 // exit. Overridable via --sqlite-threshold-mb <n>.
27 std::size_t sqlite_threshold_mb = 256;
28 // Explicit SQLite database path. When non-empty, the database is opened at
29 // this path and is NOT deleted on exit (the caller owns it). Overrides the
30 // threshold check. Mostly useful for stdin input where file size is unknown.
31 std::string sqlite_db_path;
32 // Absolute path of the input file currently being processed. Empty or "-"
33 // means stdin. Used by the SQLite layer to decide in-memory vs temp-file.
34 std::string input_path;
35 // ZIP member to read when input_path points to a .zip archive. Empty means
36 // auto-select only when the archive contains exactly one file entry.
37 std::string zip_entry;
38 // Bulk-load safety/perf tradeoff for CSV->SQLite inserts.
39 // false (default): disable SQLite journaling during load for speed.
40 // true: keep default SQLite journal mode (safer for crash recovery).
42 // PostgreSQL COPY producer chunk size. Larger values can reduce queue churn
43 // but increase peak memory; 10k was a good default on large local loads.
44 std::size_t postgres_copy_batch_rows = 10000;
45 // Number of PostgreSQL COPY workers. Values above 1 do not preserve physical
46 // insertion order and use one PostgreSQL connection per worker.
48 // Viewer loading strategy. The viewer uses row-offset paging for all files;
49 // Auto remains as a compatibility spelling for the default paged behavior.
52 // Enable csvzall view's explicit editable mode. Editing uses a paged source
53 // file plus an in-memory overlay until save rewrites the CSV deterministically.
54 bool view_edit = false;
55 // Optional development override for first-party viewer assets. When set,
56 // view serves index.html, viewer.css, viewer.js, and viewer modules from this
57 // directory on each request instead of using embedded copies.
58 std::string view_asset_dir;
59};
60
61struct RunStats {
62 std::uint64_t rows_processed = 0;
63 std::uint64_t bytes_processed = 0;
64};
65
67 std::function<void(const std::string&)> error;
68 std::function<void(const std::string&)> verbose;
69 std::function<void(const std::string&)> info;
70 std::function<void(const std::string&, std::uint64_t)> progress_start;
71 std::function<void(std::uint64_t)> progress_update;
72 std::function<void()> progress_finish;
73};
74
75} // namespace csvzall::pipeline
std::vector< JsonValue > array
Definition json_extract.cpp:33
Definition chart_spec.hpp:100
ViewModeSelection
Definition pipeline_types.hpp:11
Definition pipeline_types.hpp:66
std::function< void(std::uint64_t)> progress_update
Definition pipeline_types.hpp:71
std::function< void()> progress_finish
Definition pipeline_types.hpp:72
std::function< void(const std::string &)> error
Definition pipeline_types.hpp:67
std::function< void(const std::string &)> info
Definition pipeline_types.hpp:69
std::function< void(const std::string &)> verbose
Definition pipeline_types.hpp:68
std::function< void(const std::string &, std::uint64_t)> progress_start
Definition pipeline_types.hpp:70
Definition pipeline_types.hpp:16
bool exact_column_matching
Definition pipeline_types.hpp:19
bool single_threaded
Definition pipeline_types.hpp:17
std::size_t postgres_parallel_copy_workers
Definition pipeline_types.hpp:47
std::optional< char > delimiter
Definition pipeline_types.hpp:23
std::string view_asset_dir
Definition pipeline_types.hpp:58
std::string input_path
Definition pipeline_types.hpp:34
ViewModeSelection view_mode
Definition pipeline_types.hpp:50
std::string sqlite_db_path
Definition pipeline_types.hpp:31
std::size_t view_materialize_threshold_mb
Definition pipeline_types.hpp:51
std::string zip_entry
Definition pipeline_types.hpp:37
bool view_edit
Definition pipeline_types.hpp:54
std::size_t sqlite_threshold_mb
Definition pipeline_types.hpp:27
bool input_is_stdin
Definition pipeline_types.hpp:18
std::size_t postgres_copy_batch_rows
Definition pipeline_types.hpp:44
bool sqlite_journal_enabled
Definition pipeline_types.hpp:41
Definition pipeline_types.hpp:61
std::uint64_t bytes_processed
Definition pipeline_types.hpp:63
std::uint64_t rows_processed
Definition pipeline_types.hpp:62