@@ -21,7 +21,6 @@ use std::{
21
21
collections:: { HashMap , HashSet } ,
22
22
fs:: { File , OpenOptions } ,
23
23
io:: BufWriter ,
24
- path:: PathBuf ,
25
24
sync:: Arc ,
26
25
} ;
27
26
@@ -40,19 +39,18 @@ use super::StagingError;
40
39
pub struct DiskWriter < const N : usize > {
41
40
inner : FileWriter < BufWriter < File > > ,
42
41
/// Used to ensure un"finish"ed arrow files are renamed on "finish"
43
- path_prefix : PathBuf ,
42
+ path_prefix : String ,
44
43
/// Number of rows written onto disk
45
44
count : usize ,
46
45
/// Denotes distinct files created with similar schema during the same minute by the same ingestor
47
46
file_id : usize ,
48
47
}
49
48
50
49
impl < const N : usize > DiskWriter < N > {
51
- pub fn new ( path_prefix : PathBuf , schema : & Schema ) -> Result < Self , StagingError > {
50
+ pub fn new ( path_prefix : String , schema : & Schema ) -> Result < Self , StagingError > {
52
51
let file_id = 0 ;
53
52
// Live writes happen into partfile
54
- let mut partfile_path = path_prefix. clone ( ) ;
55
- partfile_path. set_extension ( format ! ( "{file_id}.{ARROW_PART_FILE_EXTENSION}" ) ) ;
53
+ let partfile_path = format ! ( "{path_prefix}.{file_id}.{ARROW_PART_FILE_EXTENSION}" ) ;
56
54
let file = OpenOptions :: new ( )
57
55
. create ( true )
58
56
. append ( true )
@@ -93,11 +91,14 @@ impl<const N: usize> DiskWriter<N> {
93
91
pub fn finish ( & mut self ) -> Result < ( ) , StagingError > {
94
92
self . inner . finish ( ) ?;
95
93
96
- let mut partfile_path = self . path_prefix . clone ( ) ;
97
- partfile_path. set_extension ( format ! ( "{}.{ARROW_PART_FILE_EXTENSION}" , self . file_id) ) ;
98
-
99
- let mut arrows_path = self . path_prefix . clone ( ) ;
100
- arrows_path. set_extension ( format ! ( "{}.{ARROW_FILE_EXTENSION}" , self . file_id) ) ;
94
+ let partfile_path = format ! (
95
+ "{}.{}.{ARROW_PART_FILE_EXTENSION}" ,
96
+ self . path_prefix, self . file_id
97
+ ) ;
98
+ let arrows_path = format ! (
99
+ "{}.{}.{ARROW_FILE_EXTENSION}" ,
100
+ self . path_prefix, self . file_id
101
+ ) ;
101
102
102
103
// Rename from part file to finished arrows file
103
104
std:: fs:: rename ( partfile_path, arrows_path) ?;
0 commit comments