Skip to content

Commit

Permalink
improving the work done :D
Browse files Browse the repository at this point in the history
  • Loading branch information
angelip2303 committed Jun 27, 2023
1 parent 50143db commit 6ab39bf
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions examples/from_uniprot/main.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
use std::time::Instant;

use pregel_rs::graph_frame::GraphFrame;
use pschema_rs::backends::ntriples::NTriples;
use pschema_rs::backends::parquet::Parquet;
use pschema_rs::backends::Backend;
use pschema_rs::pschema::PSchema;
use pschema_rs::shape::shex::{ShapeAnd, ShapeReference, TripleConstraint};

#[cfg(not(target_env = "msvc"))]
use jemallocator::Jemalloc;

#[cfg(target_env = "msvc")]
use mimalloc::MiMalloc;

#[cfg(not(target_env = "msvc"))]
#[global_allocator]
static GLOBAL: Jemalloc = Jemalloc;

#[cfg(target_env = "msvc")]
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;

fn main() -> Result<(), String> {
// Define validation rules
let start = ShapeAnd::new(
let shape = ShapeAnd::new(
"protein",
vec![
TripleConstraint::new(
Expand Down Expand Up @@ -35,9 +51,14 @@ fn main() -> Result<(), String> {
let edges = NTriples::import("./examples/from_uniprot/uniprotkb_reviewed_viruses_10239.nt")?;

// Perform schema validation
let start = Instant::now();
match GraphFrame::from_edges(edges) {
Ok(graph) => match PSchema::new(start).validate(graph) {
Ok(subset) => Parquet::export("uniprotkb_reviewed_viruses_10239.parquet", subset),
Ok(graph) => match PSchema::new(shape).validate(graph) {
Ok(subset) => {
let duration = start.elapsed();
println!("Time elapsed in validate() is: {:?}", duration);
Parquet::export("uniprotkb_reviewed_viruses_10239.parquet", subset)
}
Err(error) => Err(error.to_string()),
},
Err(error) => Err(format!("Cannot create a GraphFrame: {}", error)),
Expand Down

0 comments on commit 6ab39bf

Please sign in to comment.