-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7350865
commit e7d283b
Showing
10 changed files
with
134 additions
and
15 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
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use log::info; | ||
use neo4rs::Graph; | ||
use anyhow::{Context, Result}; | ||
use crate::schema_account_state::WarehouseAccState; | ||
|
||
|
||
|
||
pub async fn impl_batch_snapshot_insert( | ||
pool: &Graph, | ||
batch_snapshots: &[WarehouseAccState], | ||
) -> Result<()> { | ||
|
||
let list_str = WarehouseAccState::to_cypher_map(batch_snapshots); | ||
let cypher_string = WarehouseAccState::cypher_batch_insert_str(&list_str); | ||
|
||
// Execute the query | ||
let cypher_query = neo4rs::query(&cypher_string); | ||
let mut res = pool | ||
.execute(cypher_query) | ||
.await | ||
.context("execute query error")?; | ||
|
||
let row = res.next().await?.context("no row returned")?; | ||
|
||
let merged_snapshots: u64 = row | ||
.get("merged_snapshots") | ||
.context("no unique_accounts field")?; | ||
|
||
info!("merged snapshots: {}", merged_snapshots); | ||
|
||
Ok(()) | ||
} |
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
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
mod support; | ||
|
||
use libra_forensic_db::{ | ||
extract_snapshot::extract_v5_snapshot, load_account_state::impl_batch_snapshot_insert, neo4j_init::{get_neo4j_localhost_pool, maybe_create_indexes} | ||
}; | ||
use support::{fixtures::v5_state_manifest_fixtures_path, neo4j_testcontainer::start_neo4j_container}; | ||
|
||
#[tokio::test] | ||
async fn test_snapshot_batch() -> anyhow::Result<()> { | ||
libra_forensic_db::log_setup(); | ||
let manifest_file = v5_state_manifest_fixtures_path().join("state.manifest"); | ||
assert!(manifest_file.exists()); | ||
let s = extract_v5_snapshot(&manifest_file).await?; | ||
|
||
|
||
let c = start_neo4j_container(); | ||
let port = c.get_host_port_ipv4(7687); | ||
let graph = get_neo4j_localhost_pool(port) | ||
.await | ||
.expect("could not get neo4j connection pool"); | ||
maybe_create_indexes(&graph) | ||
.await | ||
.expect("could start index"); | ||
|
||
impl_batch_snapshot_insert(&graph, &s).await?; | ||
|
||
|
||
Ok(()) | ||
} |
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