@@ -19,12 +19,19 @@ use vortex::file::VortexWriteOptions;
19
19
use vortex:: stream:: { ArrayStream , ArrayStreamArrayExt } ;
20
20
use vortex:: { Array , ArrayRef } ;
21
21
22
+ #[ derive( Default ) ]
23
+ pub struct Flags {
24
+ pub quiet : bool ,
25
+ }
26
+
22
27
/// Convert Parquet files to Vortex.
23
- pub async fn exec_convert ( input_path : impl AsRef < Path > ) -> VortexResult < ( ) > {
24
- println ! (
25
- "Converting input Parquet file: {}" ,
26
- input_path. as_ref( ) . display( )
27
- ) ;
28
+ pub async fn exec_convert ( input_path : impl AsRef < Path > , flags : Flags ) -> VortexResult < ( ) > {
29
+ if !flags. quiet {
30
+ println ! (
31
+ "Converting input Parquet file: {}" ,
32
+ input_path. as_ref( ) . display( )
33
+ ) ;
34
+ }
28
35
29
36
let wall_start = Instant :: now ( ) ;
30
37
@@ -42,34 +49,46 @@ pub async fn exec_convert(input_path: impl AsRef<Path>) -> VortexResult<()> {
42
49
}
43
50
44
51
let read_complete = Instant :: now ( ) ;
45
- println ! (
46
- "Read Parquet file in {:?}" ,
47
- read_complete. duration_since( wall_start)
48
- ) ;
52
+
53
+ if !flags. quiet {
54
+ println ! (
55
+ "Read Parquet file in {:?}" ,
56
+ read_complete. duration_since( wall_start)
57
+ ) ;
58
+
59
+ println ! (
60
+ "Writing {} chunks to new Vortex file {}" ,
61
+ chunks. len( ) ,
62
+ output_path. display( )
63
+ ) ;
64
+ }
49
65
50
66
let dtype = chunks. first ( ) . vortex_expect ( "empty chunks" ) . dtype ( ) . clone ( ) ;
51
67
let chunked_array = ChunkedArray :: try_new ( chunks, dtype) ?;
52
68
53
69
let writer = VortexWriteOptions :: default ( ) ;
54
70
55
- let pb = ProgressBar :: new ( chunked_array. nchunks ( ) as u64 ) ;
56
- let stream = ProgressArrayStream {
57
- inner : chunked_array. to_array_stream ( ) ,
58
- progress : pb,
59
- } ;
60
-
61
- println ! (
62
- "Writing {} chunks to new Vortex file {}" ,
63
- chunked_array. nchunks( ) ,
64
- output_path. display( )
65
- ) ;
66
71
let output_file = File :: create ( output_path) . await ?;
67
- writer. write ( output_file, stream) . await ?;
68
72
69
- println ! (
70
- "Wrote Vortex in {:?}" ,
71
- Instant :: now( ) . duration_since( read_complete)
72
- ) ;
73
+ if !flags. quiet {
74
+ let pb = ProgressBar :: new ( chunked_array. nchunks ( ) as u64 ) ;
75
+ let stream = ProgressArrayStream {
76
+ inner : chunked_array. to_array_stream ( ) ,
77
+ progress : pb,
78
+ } ;
79
+ writer. write ( output_file, stream) . await ?;
80
+ } else {
81
+ writer
82
+ . write ( output_file, chunked_array. to_array_stream ( ) )
83
+ . await ?;
84
+ }
85
+
86
+ if !flags. quiet {
87
+ println ! (
88
+ "Wrote Vortex in {:?}" ,
89
+ Instant :: now( ) . duration_since( read_complete)
90
+ ) ;
91
+ }
73
92
74
93
Ok ( ( ) )
75
94
}
0 commit comments