@@ -54,20 +54,20 @@ pub struct TransparentCompressConfig {
5454 /// Examples:
5555 ///
5656 /// * `'a'`
57- /// This will cause a single dictionary to be trained for everything.
57+ /// This will cause a single dictionary to be trained for everything.
5858 ///
5959 /// * `strftime(created, '%Y-%m')`
60- /// This will cause every month of data to be compressed with its own dictionary.
60+ /// This will cause every month of data to be compressed with its own dictionary.
6161 ///
6262 /// * `nullif(strftime(created, '%Y-%m'), strftime('now', '%Y-%m'))`
6363 ///
64- /// The same as above, but if the entry is from the current month it will stay uncompressed.
65- /// This is handy because it means that the dictionary for the month will only be created when the month is over
66- /// and can thus be optimized the most for the given data
64+ /// The same as above, but if the entry is from the current month it will stay uncompressed.
65+ /// This is handy because it means that the dictionary for the month will only be created when the month is over
66+ /// and can thus be optimized the most for the given data
6767 /// * `case when date(timestamp, ''weekday 0'') < date(''now'', ''weekday 0'') then data_type || ''.'' || date(timestamp, ''weekday 0'') else null end`
6868 ///
69- /// This one uses keys like data_type.2020-11-01` where the date is the first day of the week, except for the current week which stays uncompressed.
70- /// This means that every different data_type will be compressed separately and separately for each week.
69+ /// This one uses keys like data_type.2020-11-01` where the date is the first day of the week, except for the current week which stays uncompressed.
70+ /// This means that every different data_type will be compressed separately and separately for each week.
7171 ///
7272 /// You can return the special string `[nodict]` to compress the given data without a dictionary.
7373 /// Note that the compression key is global for all tables. So if you want your dict to only apply to this table return
@@ -97,7 +97,7 @@ pub fn pretty_bytes(bytes: i64) -> String {
9797 } else if bytes >= 1_000 {
9898 format ! ( "{:.2}kB" , bytes as f64 / 1e3 )
9999 } else {
100- format ! ( "{}B" , bytes )
100+ format ! ( "{bytes }B" )
101101 }
102102}
103103
@@ -161,13 +161,13 @@ pub fn zstd_enable_transparent<'a>(ctx: &Context) -> anyhow::Result<ToSqlOutput<
161161
162162 let config_str: String = ctx. get ( arg_config) ?;
163163 let config: TransparentCompressConfig = serde_json:: from_str ( & config_str)
164- . with_context ( || format ! ( "parsing json config '{}'" , config_str ) ) ?;
164+ . with_context ( || format ! ( "parsing json config '{config_str }'" ) ) ?;
165165 let db = & mut unsafe { ctx. get_connection ( ) ? } ;
166166 let db = db
167167 . unchecked_transaction ( )
168168 . context ( "Could not start transaction" ) ?;
169169 let table_name = & config. table ;
170- let new_table_name = format ! ( "_{}_zstd" , table_name ) ;
170+ let new_table_name = format ! ( "_{table_name }_zstd" ) ;
171171
172172 let configs = get_configs ( & db) ?;
173173 let already_compressed_columns = configs
@@ -265,7 +265,7 @@ pub fn zstd_enable_transparent<'a>(ctx: &Context) -> anyhow::Result<ToSqlOutput<
265265 let to_compress_column = columns_info
266266 . iter ( )
267267 . find ( |e| & e. name == column_name)
268- . with_context ( || format ! ( "Column {} does not exist in {}" , column_name , table_name ) ) ?;
268+ . with_context ( || format ! ( "Column {column_name } does not exist in {table_name}" ) ) ?;
269269 if to_compress_column. is_primary_key {
270270 anyhow:: bail!(
271271 "Can't compress column {} since it is part of primary key (this could probably be supported, but currently isn't)" ,
@@ -287,7 +287,7 @@ pub fn zstd_enable_transparent<'a>(ctx: &Context) -> anyhow::Result<ToSqlOutput<
287287 // small sanity check of chooser statement
288288 db. query_row ( & query, params ! [ ] , |row| row. get :: < _ , String > ( 0 ) )
289289 . optional ( )
290- . with_context ( || format ! ( "Tried to execute:\n {}" , query ) )
290+ . with_context ( || format ! ( "Tried to execute:\n {query}" ) )
291291 . context ( r#"Dict chooser expression does not seem to be valid. Make sure you return a string and get your escaping right: If you want an sqlite string inside a json string inside a sqlite string you need to do '{"foo": "''bar''"}'"# ) ?;
292292 }
293293 {
@@ -376,7 +376,7 @@ pub fn zstd_enable_transparent<'a>(ctx: &Context) -> anyhow::Result<ToSqlOutput<
376376}
377377
378378fn get_dict_id ( column_name : & str ) -> String {
379- format ! ( "_{}_dict" , column_name )
379+ format ! ( "_{column_name }_dict" )
380380}
381381
382382fn check_table_exists ( db : & rusqlite:: Connection , table_name : & str ) -> bool {
@@ -496,7 +496,7 @@ fn create_insert_trigger(
496496 internal_table_name : & str ,
497497 _config : & TransparentCompressConfig ,
498498) -> anyhow:: Result < ( ) > {
499- let trigger_name = format ! ( "{}_insert_trigger" , table_name ) ;
499+ let trigger_name = format ! ( "{table_name }_insert_trigger" ) ;
500500
501501 // expressions that map backing table columns to view columns
502502 let mut insert_selection = vec ! [ ] ;
@@ -549,7 +549,7 @@ fn create_delete_trigger(
549549 internal_table_name : & str ,
550550 primary_key_condition : & str ,
551551) -> anyhow:: Result < ( ) > {
552- let trigger_name = format ! ( "{}_delete_trigger" , table_name ) ;
552+ let trigger_name = format ! ( "{table_name }_delete_trigger" ) ;
553553
554554 let deletetrigger_query = format ! (
555555 "
@@ -839,7 +839,7 @@ fn maintenance_for_todo(
839839 ":compact" : COMPACT
840840 } ,
841841 )
842- . with_context ( || format ! ( "while compressing chunk for key {}" , dict_choice ) ) ?;
842+ . with_context ( || format ! ( "while compressing chunk for key {dict_choice}" ) ) ?;
843843
844844 total_updated += updated as i64 ;
845845 log:: debug!( "Compressed {} / {}" , total_updated, todo. count) ;
@@ -985,7 +985,7 @@ mod tests {
985985 }
986986
987987 fn get_whole_table ( db : & Connection , tbl_name : & str ) -> anyhow:: Result < Vec < Vec < Value > > > {
988- let mut stmt = db. prepare ( & format ! ( "select * from {} ORDER BY id" , tbl_name ) ) ?;
988+ let mut stmt = db. prepare ( & format ! ( "select * from {tbl_name } ORDER BY id" ) ) ?;
989989 let q1: Vec < Vec < Value > > = stmt
990990 . query_map ( params ! [ ] , |e| row_to_thong ( e) . map_err ( ah) ) ?
991991 . collect :: < Result < _ , rusqlite:: Error > > ( ) ?;
0 commit comments