-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use remote_hdt::error::RemoteHDTError; | ||
use remote_hdt::metadata::Metadata; | ||
use remote_hdt::storage::params::Serialization; | ||
use remote_hdt::storage::params::Backend; | ||
use remote_hdt::storage::params::ReferenceSystem; | ||
|
||
fn main() -> Result<(), RemoteHDTError> { | ||
|
||
let rdf_path = ""; | ||
let metadata_path = ""; | ||
let fields = vec!["X_pos", "Y_pos"]; | ||
let mut metadata: Metadata = Metadata::new(Serialization::Zarr); | ||
metadata.serialize(rdf_path, ReferenceSystem::SPO,metadata_path,fields).unwrap(); | ||
|
||
Ok(()) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ pub mod error; | |
mod io; | ||
pub mod storage; | ||
mod utils; | ||
pub mod metadata; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
|
||
|
||
|
||
use std::default; | ||
Check warning on line 4 in src/metadata/mod.rs GitHub Actions / Check (stable)
Check failure on line 4 in src/metadata/mod.rs GitHub Actions / Clippy (stable)
|
||
use std::path::PathBuf; | ||
Check warning on line 5 in src/metadata/mod.rs GitHub Actions / Check (stable)
Check failure on line 5 in src/metadata/mod.rs GitHub Actions / Clippy (stable)
|
||
use std::str::FromStr; | ||
Check warning on line 6 in src/metadata/mod.rs GitHub Actions / Check (stable)
Check failure on line 6 in src/metadata/mod.rs GitHub Actions / Clippy (stable)
|
||
|
||
|
||
use crate::dictionary::Dictionary; | ||
|
||
use crate::io::Graph; | ||
use crate::io::RdfParser; | ||
|
||
use crate::storage::params::Serialization; | ||
use crate::storage::params::Backend; | ||
Check warning on line 15 in src/metadata/mod.rs GitHub Actions / Check (stable)
Check failure on line 15 in src/metadata/mod.rs GitHub Actions / Clippy (stable)
|
||
use crate::storage::params::ReferenceSystem; | ||
use crate::error::RemoteHDTError; | ||
|
||
use fcsd::Set; | ||
Check warning on line 19 in src/metadata/mod.rs GitHub Actions / Check (stable)
Check failure on line 19 in src/metadata/mod.rs GitHub Actions / Clippy (stable)
|
||
use zarrs::opendal::raw::oio::StreamExt; | ||
Check warning on line 20 in src/metadata/mod.rs GitHub Actions / Check (stable)
Check failure on line 20 in src/metadata/mod.rs GitHub Actions / Clippy (stable)
|
||
use zarrs::opendal::services::Fs; | ||
Check warning on line 21 in src/metadata/mod.rs GitHub Actions / Check (stable)
Check failure on line 21 in src/metadata/mod.rs GitHub Actions / Clippy (stable)
|
||
use zarrs::opendal::services::Http; | ||
Check warning on line 22 in src/metadata/mod.rs GitHub Actions / Check (stable)
Check failure on line 22 in src/metadata/mod.rs GitHub Actions / Clippy (stable)
|
||
use zarrs::opendal::Operator; | ||
Check warning on line 23 in src/metadata/mod.rs GitHub Actions / Check (stable)
Check failure on line 23 in src/metadata/mod.rs GitHub Actions / Clippy (stable)
|
||
use zarrs::storage::store::OpendalStore; | ||
use zarrs::array::Array; | ||
|
||
|
||
|
||
pub type MetadataResult<T> = Result<T, RemoteHDTError>; | ||
|
||
pub struct Metadata { | ||
flatten_graph: Vec<(u32, u32, u32)>, | ||
serialization: Serialization, | ||
dictionary : Dictionary, | ||
array: Option<Array<OpendalStore>> | ||
} | ||
|
||
|
||
impl Metadata{ | ||
pub fn new( serialization: Serialization) -> Self { | ||
Metadata { | ||
flatten_graph: Vec::<(u32, u32, u32)>::default(), | ||
serialization: serialization, | ||
dictionary: Dictionary::default(), | ||
array: None, | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
pub fn serialize(&mut self, rdf_path: &str, reference_system: ReferenceSystem, metadata_path: &str, fields: Vec<&str>) -> MetadataResult<&mut Self>{ | ||
|
||
let graph_vector: Graph; | ||
|
||
match RdfParser::parse(rdf_path, &reference_system) { | ||
Ok((graph, dictionary)) => { | ||
graph_vector = graph; | ||
self.dictionary = dictionary; | ||
} | ||
Err(_) => return Err(RemoteHDTError::RdfParse), | ||
}; | ||
|
||
let mut count = 0; | ||
for i in graph_vector.iter() { | ||
for j in i.iter(){ | ||
self.flatten_graph.push((count, j.0, j.1)) | ||
} | ||
count +=1; | ||
} | ||
|
||
|
||
Ok(self) | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
} |