44
55use clap:: { Arg , ArgMatches , Command } ;
66use commonmeta:: file_utils;
7+ use std:: time:: Instant ;
78
89/// Default Parquet row-group size — 10 000 rows per group keeps memory
910/// pressure manageable for large VRAIX daily dumps (millions of rows).
1011const DEFAULT_BATCH_SIZE : usize = 10_000 ;
1112
1213pub fn command ( ) -> Command {
13- Command :: new ( "dump " )
14+ Command :: new ( "package " )
1415 . about ( "Write a VRAIX SQLite dump as a Parquet file" )
1516 . long_about (
1617 "Read a VRAIX transport table from a local SQLite3 file and write \
@@ -26,11 +27,11 @@ pub fn command() -> Command {
2627 .parquet.zip ZIP archive containing the Parquet file\n \
2728 .parquet.tgz tar+gzip archive containing the Parquet file\n \n \
2829 Examples:\n \n \
29- commonmeta dump crossref-2026-06-15.sqlite3\n \
30- commonmeta dump crossref-2026-06-15.sqlite3 --file crossref-2026-06-15.parquet\n \
31- commonmeta dump crossref-2026-06-15.sqlite3 --file crossref-2026-06-15.parquet.zst\n \
32- commonmeta dump crossref-2026-06-15.sqlite3 --file crossref-2026-06-15.parquet.zip\n \
33- commonmeta dump crossref-2026-06-15.sqlite3 --batch-size 50000",
30+ commonmeta package crossref-2026-06-15.sqlite3\n \
31+ commonmeta package crossref-2026-06-15.sqlite3 --file crossref-2026-06-15.parquet\n \
32+ commonmeta package crossref-2026-06-15.sqlite3 --file crossref-2026-06-15.parquet.zst\n \
33+ commonmeta package crossref-2026-06-15.sqlite3 --file crossref-2026-06-15.parquet.zip\n \
34+ commonmeta package crossref-2026-06-15.sqlite3 --batch-size 50000 --timer ",
3435 )
3536 . arg (
3637 Arg :: new ( "input" )
@@ -54,9 +55,17 @@ pub fn command() -> Command {
5455 . help ( "Rows per Parquet row group (default: 10000)" )
5556 . value_parser ( clap:: value_parser!( usize ) ) ,
5657 )
58+ . arg (
59+ Arg :: new ( "timer" )
60+ . long ( "timer" )
61+ . help ( "Print total packaging duration to stderr" )
62+ . action ( clap:: ArgAction :: SetTrue ) ,
63+ )
5764}
5865
5966pub fn execute ( matches : & ArgMatches ) -> Result < ( ) , String > {
67+ let timer = matches. get_flag ( "timer" ) ;
68+ let started = Instant :: now ( ) ;
6069 let input = matches. get_one :: < String > ( "input" ) . expect ( "required" ) ;
6170 let batch_size = matches
6271 . get_one :: < usize > ( "batch_size" )
@@ -74,6 +83,9 @@ pub fn execute(matches: &ArgMatches) -> Result<(), String> {
7483 write_output ( & bytes, & out_path) ?;
7584
7685 eprintln ! ( "wrote {} rows → {}" , parquet_row_count( & bytes) , out_path) ;
86+ if timer {
87+ eprintln ! ( "package timer: {:?}" , started. elapsed( ) ) ;
88+ }
7789
7890 Ok ( ( ) )
7991}
0 commit comments