@@ -42,22 +42,21 @@ pub trait EventFormat: Sized {
42
42
43
43
fn to_data (
44
44
self ,
45
- schema : HashMap < String , Arc < Field > > ,
46
- static_schema_flag : Option < String > ,
47
- time_partition : Option < String > ,
45
+ schema : & HashMap < String , Arc < Field > > ,
46
+ static_schema_flag : Option < & String > ,
47
+ time_partition : Option < & String > ,
48
48
) -> Result < ( Self :: Data , EventSchema , bool , Tags , Metadata ) , AnyError > ;
49
+
49
50
fn decode ( data : Self :: Data , schema : Arc < Schema > ) -> Result < RecordBatch , AnyError > ;
51
+
50
52
fn into_recordbatch (
51
53
self ,
52
- storage_schema : HashMap < String , Arc < Field > > ,
53
- static_schema_flag : Option < String > ,
54
- time_partition : Option < String > ,
54
+ storage_schema : & HashMap < String , Arc < Field > > ,
55
+ static_schema_flag : Option < & String > ,
56
+ time_partition : Option < & String > ,
55
57
) -> Result < ( RecordBatch , bool ) , AnyError > {
56
- let ( data, mut schema, is_first, tags, metadata) = self . to_data (
57
- storage_schema. clone ( ) ,
58
- static_schema_flag. clone ( ) ,
59
- time_partition. clone ( ) ,
60
- ) ?;
58
+ let ( data, mut schema, is_first, tags, metadata) =
59
+ self . to_data ( storage_schema, static_schema_flag, time_partition) ?;
61
60
62
61
if get_field ( & schema, DEFAULT_TAGS_KEY ) . is_some ( ) {
63
62
return Err ( anyhow ! ( "field {} is a reserved field" , DEFAULT_TAGS_KEY ) ) ;
@@ -120,8 +119,8 @@ pub trait EventFormat: Sized {
120
119
121
120
fn is_schema_matching (
122
121
new_schema : Arc < Schema > ,
123
- storage_schema : HashMap < String , Arc < Field > > ,
124
- static_schema_flag : Option < String > ,
122
+ storage_schema : & HashMap < String , Arc < Field > > ,
123
+ static_schema_flag : Option < & String > ,
125
124
) -> bool {
126
125
if static_schema_flag. is_none ( ) {
127
126
return true ;
@@ -225,7 +224,7 @@ pub fn override_num_fields_from_schema(schema: Vec<Arc<Field>>) -> Vec<Arc<Field
225
224
pub fn update_field_type_in_schema (
226
225
inferred_schema : Arc < Schema > ,
227
226
existing_schema : Option < & HashMap < String , Arc < Field > > > ,
228
- time_partition : Option < String > ,
227
+ time_partition : Option < & String > ,
229
228
log_records : Option < & Vec < Value > > ,
230
229
) -> Arc < Schema > {
231
230
let mut updated_schema = inferred_schema. clone ( ) ;
@@ -258,12 +257,12 @@ pub fn update_field_type_in_schema(
258
257
if time_partition. is_none ( ) {
259
258
return updated_schema;
260
259
}
261
- let time_partition_field_name = time_partition . unwrap ( ) ;
260
+
262
261
let new_schema: Vec < Field > = updated_schema
263
262
. fields ( )
264
263
. iter ( )
265
264
. map ( |field| {
266
- if * field. name ( ) == time_partition_field_name {
265
+ if field. name ( ) == time_partition . unwrap ( ) {
267
266
if field. data_type ( ) == & DataType :: Utf8 {
268
267
let new_data_type = DataType :: Timestamp ( TimeUnit :: Millisecond , None ) ;
269
268
Field :: new ( field. name ( ) . clone ( ) , new_data_type, true )
0 commit comments