Skip to content

Commit bf2366e

Browse files
author
Devdutt Shenoi
committed
refactor: simplify logsource write to store
1 parent 70a926f commit bf2366e

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

src/event/format/mod.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use arrow_array::RecordBatch;
2828
use arrow_schema::{DataType, Field, Schema, TimeUnit};
2929
use chrono::{DateTime, Utc};
3030
use serde::{Deserialize, Serialize};
31-
use serde_json::{json, Value};
31+
use serde_json::Value;
3232

3333
use crate::{
3434
metadata::SchemaVersion,
@@ -107,15 +107,6 @@ impl LogSourceEntry {
107107
fields,
108108
}
109109
}
110-
111-
pub fn add_log_source(&mut self, log_source_format: LogSource, fields: HashSet<String>) {
112-
self.log_source_format = log_source_format;
113-
self.fields = fields;
114-
}
115-
116-
pub fn to_value(&self) -> Value {
117-
json!(self)
118-
}
119110
}
120111

121112
// Global Trait for event format

src/migration/stream_metadata_migration.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,13 @@ pub fn v5_v6(mut stream_metadata: Value) -> Value {
191191
"version".to_owned(),
192192
Value::String(storage::CURRENT_SCHEMA_VERSION.into()),
193193
);
194-
let log_source = stream_metadata_map.get("log_source");
195194
let mut log_source_entry = LogSourceEntry::default();
196-
if log_source.is_some() {
197-
if let Ok(log_source) = serde_json::from_value::<LogSource>(log_source.unwrap().clone()) {
198-
log_source_entry.add_log_source(log_source, HashSet::new());
195+
if let Some(log_source) = stream_metadata_map.get("log_source") {
196+
if let Ok(log_source) = serde_json::from_value::<LogSource>(log_source.clone()) {
197+
log_source_entry = LogSourceEntry::new(log_source, HashSet::new());
199198
}
200199
}
201-
stream_metadata_map.insert("log_source".to_owned(), log_source_entry.to_value());
200+
stream_metadata_map.insert("log_source".to_owned(), json!(log_source_entry));
202201
stream_metadata
203202
}
204203

0 commit comments

Comments
 (0)