diff --git a/examples/metadata_bench.rs b/examples/metadata_bench.rs new file mode 100644 index 0000000..9eb6645 --- /dev/null +++ b/examples/metadata_bench.rs @@ -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(()) +} diff --git a/src/lib.rs b/src/lib.rs index 1968cf7..ecb6ec0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,3 +4,4 @@ pub mod error; mod io; pub mod storage; mod utils; +pub mod metadata; diff --git a/src/metadata/mod.rs b/src/metadata/mod.rs new file mode 100644 index 0000000..e2b3c00 --- /dev/null +++ b/src/metadata/mod.rs @@ -0,0 +1,82 @@ + + + +use std::default; +use std::path::PathBuf; +use std::str::FromStr; + + +use crate::dictionary::Dictionary; + +use crate::io::Graph; +use crate::io::RdfParser; + +use crate::storage::params::Serialization; +use crate::storage::params::Backend; +use crate::storage::params::ReferenceSystem; +use crate::error::RemoteHDTError; + +use fcsd::Set; +use zarrs::opendal::raw::oio::StreamExt; +use zarrs::opendal::services::Fs; +use zarrs::opendal::services::Http; +use zarrs::opendal::Operator; +use zarrs::storage::store::OpendalStore; +use zarrs::array::Array; + + + +pub type MetadataResult = Result; + +pub struct Metadata { + flatten_graph: Vec<(u32, u32, u32)>, + serialization: Serialization, + dictionary : Dictionary, + array: Option> +} + + +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) + } + + + + + + + +} \ No newline at end of file