@@ -39,6 +39,7 @@ use rayon::prelude::*;
3939
4040use std:: fs;
4141use std:: fs:: File ;
42+ use std:: ops:: Deref ;
4243use std:: path:: PathBuf ;
4344use std:: str:: from_utf8_unchecked;
4445use std:: sync:: Arc ;
@@ -48,7 +49,7 @@ use super::{
4849 Stats ,
4950} ;
5051use crate :: chunked;
51- use crate :: chunked:: threaded_file_output:: { ipc_file_out, parquet_file_out} ;
52+ use crate :: chunked:: threaded_file_output:: { ipc_file_out, output_factory , parquet_file_out} ;
5253use crate :: datatype:: DataType ;
5354use crate :: schema;
5455use arrow:: datatypes:: { Field , Schema , SchemaRef } ;
@@ -65,6 +66,7 @@ use std::thread;
6566use std:: thread:: JoinHandle ;
6667use std:: time:: { Duration , Instant } ;
6768use thread:: spawn;
69+ use crate :: cli:: Targets ;
6870//use ordered_channel::Sender;
6971//use crossbeam::channel::{Receiver, Sender};
7072
@@ -76,7 +78,7 @@ pub(crate) struct Slice2Arrow<'a> {
7678 pub ( crate ) fn_line_break_len : FnLineBreakLen ,
7779 pub ( crate ) masterbuilders : MasterBuilders ,
7880 pub ( crate ) consistent_counter : ConsistentCounter ,
79- pub ( crate ) threaded_write : ( Sender < RecordBatch > , JoinHandle < Result < Stats > > ) ,
81+ pub ( crate ) target : Targets
8082}
8183
8284pub ( crate ) struct MasterBuilders {
@@ -233,17 +235,11 @@ impl<'a> Converter<'a> for Slice2Arrow<'a> {
233235 ( bytes_in, bytes_out, parse_duration, builder_write_duration)
234236 }
235237
236- fn setup ( & mut self ) -> JoinHandle < Result < Stats > > {
237- let schema = self . masterbuilders . schema_factory ( ) ;
238- let _outfile = self . masterbuilders . outfile . clone ( ) ;
239-
240- let mut pfo: Box < dyn arrow_file_output > = Box :: new ( ipc_file_out { sender : None } ) ;
241- let ( sender, joinhandler) = pfo. setup ( schema, _outfile) ;
242-
243- self . masterbuilders . sender = Some ( sender) ;
244- joinhandler
238+ fn setup ( & mut self ) -> ( Sender < RecordBatch > , JoinHandle < Result < Stats > > ) {
239+ output_factory ( self . target . clone ( ) , self . masterbuilders . schema_factory ( ) , self . masterbuilders . outfile . clone ( ) )
245240 }
246241
242+
247243 fn shutdown ( & mut self ) {
248244 // converter.shutdown();
249245 let schema = Schema :: new ( vec ! [ Field :: new(
@@ -255,6 +251,7 @@ impl<'a> Converter<'a> for Slice2Arrow<'a> {
255251 let emptyrb = arrow:: record_batch:: RecordBatch :: new_empty ( Arc :: new ( schema) ) ;
256252 let c = self . consistent_counter . get ( ) ;
257253 let _ = & self . masterbuilders . sender . clone ( ) . unwrap ( ) . send ( c, emptyrb) ;
254+
258255 }
259256}
260257
0 commit comments