@@ -52,39 +52,23 @@ impl AsRef<ObjPath> for CatalogFilePath {
52
52
pub struct ParquetFilePath ( ObjPath ) ;
53
53
54
54
impl ParquetFilePath {
55
+ /// Generate a parquet file path using the given arguments. This will convert the provided
56
+ /// `chunk_time` into a date time string with format `'YYYY-MM-DD/HH-MM'`
55
57
pub fn new (
56
58
host_prefix : & str ,
57
- db_name : & str ,
58
- db_id : u32 ,
59
- table_name : & str ,
60
- table_id : u32 ,
61
- date : DateTime < Utc > ,
62
- wal_file_sequence_number : WalFileSequenceNumber ,
63
- ) -> Self {
64
- let path = ObjPath :: from ( format ! (
65
- "{host_prefix}/dbs/{db_name}-{db_id}/{table_name}-{table_id}/{}/{}.{}" ,
66
- date. format( "%Y-%m-%d/%H-%M" ) ,
67
- wal_file_sequence_number. as_u64( ) ,
68
- PARQUET_FILE_EXTENSION
69
- ) ) ;
70
- Self ( path)
71
- }
72
-
73
- pub fn new_with_chunk_time (
74
59
db_name : & str ,
75
60
db_id : u32 ,
76
61
table_name : & str ,
77
62
table_id : u32 ,
78
63
chunk_time : i64 ,
79
64
wal_file_sequence_number : WalFileSequenceNumber ,
80
65
) -> Self {
81
- // Convert the chunk time into a date time string for YYYY-MM-DDTHH-MM
82
66
let date_time = DateTime :: < Utc > :: from_timestamp_nanos ( chunk_time) ;
83
67
let path = ObjPath :: from ( format ! (
84
- "dbs/{db_name}-{db_id}/{table_name}-{table_id}/{}/{:010}.{}" ,
85
- date_time. format( "%Y-%m-%d/%H-%M" ) ,
86
- wal_file_sequence_number. as_u64( ) ,
87
- PARQUET_FILE_EXTENSION
68
+ "{host_prefix}/ dbs/{db_name}-{db_id}/{table_name}-{table_id}/{date_string }/{wal_seq :010}.{ext }" ,
69
+ date_string = date_time. format( "%Y-%m-%d/%H-%M" ) ,
70
+ wal_seq = wal_file_sequence_number. as_u64( ) ,
71
+ ext = PARQUET_FILE_EXTENSION
88
72
) ) ;
89
73
Self ( path)
90
74
}
@@ -153,10 +137,13 @@ fn parquet_file_path_new() {
153
137
0 ,
154
138
"my_table" ,
155
139
0 ,
156
- Utc . with_ymd_and_hms( 2038 , 1 , 19 , 3 , 14 , 7 ) . unwrap( ) ,
157
- WalFileSequenceNumber :: new( 0 ) ,
140
+ Utc . with_ymd_and_hms( 2038 , 1 , 19 , 3 , 14 , 7 )
141
+ . unwrap( )
142
+ . timestamp_nanos_opt( )
143
+ . unwrap( ) ,
144
+ WalFileSequenceNumber :: new( 1337 ) ,
158
145
) ,
159
- ObjPath :: from( "my_host/dbs/my_db-0/my_table-0/2038-01-19/03-14/0 .parquet" )
146
+ ObjPath :: from( "my_host/dbs/my_db-0/my_table-0/2038-01-19/03-14/0000001337 .parquet" )
160
147
) ;
161
148
}
162
149
@@ -169,12 +156,15 @@ fn parquet_file_percent_encoded() {
169
156
0 ,
170
157
".." ,
171
158
0 ,
172
- Utc . with_ymd_and_hms( 2038 , 1 , 19 , 3 , 14 , 7 ) . unwrap( ) ,
173
- WalFileSequenceNumber :: new( 0 ) ,
159
+ Utc . with_ymd_and_hms( 2038 , 1 , 19 , 3 , 14 , 7 )
160
+ . unwrap( )
161
+ . timestamp_nanos_opt( )
162
+ . unwrap( ) ,
163
+ WalFileSequenceNumber :: new( 100 ) ,
174
164
)
175
165
. as_ref( )
176
166
. as_ref( ) ,
177
- "%2E%2E/dbs/..-0/..-0/2038-01-19/03-14/0 .parquet"
167
+ "%2E%2E/dbs/..-0/..-0/2038-01-19/03-14/0000000100 .parquet"
178
168
) ;
179
169
}
180
170
0 commit comments