-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate Parquet Events Processor to SDK (#618)
- Loading branch information
1 parent
3c62913
commit b823242
Showing
19 changed files
with
505 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod raw_events; |
58 changes: 58 additions & 0 deletions
58
rust/processor/src/db/common/models/event_models/raw_events.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use crate::utils::util::{standardize_address, truncate_str}; | ||
use aptos_protos::transaction::v1::{Event as EventPB, EventSizeInfo}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// P99 currently is 303 so using 300 as a safe max length | ||
pub const EVENT_TYPE_MAX_LENGTH: usize = 300; | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
pub struct RawEvent { | ||
pub sequence_number: i64, | ||
pub creation_number: i64, | ||
pub account_address: String, | ||
pub transaction_version: i64, | ||
pub transaction_block_height: i64, | ||
pub type_: String, | ||
pub data: String, | ||
pub event_index: i64, | ||
pub indexed_type: String, | ||
pub block_timestamp: Option<chrono::NaiveDateTime>, | ||
pub type_tag_bytes: Option<i64>, | ||
pub total_bytes: Option<i64>, | ||
} | ||
|
||
pub trait EventConvertible { | ||
fn from_raw(raw_item: &RawEvent) -> Self; | ||
} | ||
|
||
impl RawEvent { | ||
pub fn from_raw_event( | ||
event: &EventPB, | ||
txn_version: i64, | ||
txn_block_height: i64, | ||
event_index: i64, | ||
size_info: Option<&EventSizeInfo>, | ||
block_timestamp: Option<chrono::NaiveDateTime>, | ||
) -> RawEvent { | ||
let type_tag_bytes = size_info.map_or(0, |info| info.type_tag_bytes as i64); | ||
let total_bytes = size_info.map_or(0, |info| info.total_bytes as i64); | ||
let event_type = event.type_str.to_string(); | ||
|
||
RawEvent { | ||
sequence_number: event.sequence_number as i64, | ||
creation_number: event.key.as_ref().unwrap().creation_number as i64, | ||
account_address: standardize_address( | ||
event.key.as_ref().unwrap().account_address.as_str(), | ||
), | ||
transaction_version: txn_version, | ||
transaction_block_height: txn_block_height, | ||
type_: event_type.clone(), | ||
data: event.data.clone(), | ||
event_index, | ||
indexed_type: truncate_str(&event_type, EVENT_TYPE_MAX_LENGTH), | ||
block_timestamp, | ||
type_tag_bytes: Some(type_tag_bytes), | ||
total_bytes: Some(total_bytes), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pub mod default_models; | ||
pub mod event_models; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod parquet_events; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pub mod default_models; | ||
pub mod event_models; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,3 @@ | |
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
pub mod events; | ||
|
||
// parquet model | ||
pub mod parquet_events; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.