@@ -40,6 +40,7 @@ use chrontext::engine::{Engine, EngineConfig};
4040use flight:: client:: ChrontextFlightClient ;
4141use flight:: server:: ChrontextFlightServer ;
4242use log:: { debug, info} ;
43+ use oxrdfio:: RdfFormat ;
4344use postgres:: catalog:: { Catalog , DataProduct } ;
4445use postgres:: server:: { start_server, Config } ;
4546use pydf_io:: to_python:: { df_to_py_df, fix_cats_and_multicolumns} ;
@@ -149,7 +150,7 @@ impl PyEngine {
149150 #[ cfg( not( feature = "opcua" ) ) ]
150151 #[ new]
151152 #[ pyo3( signature = ( resources, virtualized_python_database=None , virtualized_bigquery_database=None , sparql_endpoint=None , sparql_embedded_oxigraph=None ) ) ]
152- pub fn new (
153+ pub fn new < ' py > (
153154 resources : HashMap < String , PyTemplate > ,
154155 virtualized_python_database : Option < VirtualizedPythonDatabase > ,
155156 virtualized_bigquery_database : Option < PyVirtualizedBigQueryDatabase > ,
@@ -187,14 +188,19 @@ impl PyEngine {
187188 #[ cfg( not( feature = "opcua" ) ) ]
188189 panic ! ( "Should never happen" ) ;
189190 } ;
190- let sparql_endpoint = self . sparql_endpoint . clone ( ) ;
191+ let sparql_endpoint = if let Some ( endpoint) = & self . sparql_endpoint {
192+ Some ( endpoint. clone ( ) )
193+ } else {
194+ None
195+ } ;
191196
192- let sparql_oxigraph_config =
193- self . sparql_embedded_oxigraph
194- . as_ref ( )
195- . map ( |store| EmbeddedOxigraph {
196- store : store. clone ( ) ,
197- } ) ;
197+ let sparql_oxigraph_config = if let Some ( store) = & self . sparql_embedded_oxigraph {
198+ Some ( EmbeddedOxigraph {
199+ store : store. clone ( ) ,
200+ } )
201+ } else {
202+ None
203+ } ;
198204
199205 let mut virtualization_map = HashMap :: new ( ) ;
200206 for ( k, v) in & self . resources {
@@ -212,7 +218,7 @@ impl PyEngine {
212218 } ;
213219
214220 self . engine =
215- Some ( Engine :: from_config ( config) . map_err ( PyChrontextError :: ChrontextError ) ?) ;
221+ Some ( Engine :: from_config ( config) . map_err ( |x| PyChrontextError :: ChrontextError ( x ) ) ?) ;
216222 }
217223 Ok ( ( ) )
218224 }
@@ -236,7 +242,7 @@ impl PyEngine {
236242 . build ( )
237243 . unwrap ( )
238244 . block_on ( self . engine . as_mut ( ) . unwrap ( ) . query ( sparql) )
239- . map_err ( PyChrontextError :: ChrontextError )
245+ . map_err ( |err| PyChrontextError :: ChrontextError ( err ) )
240246 } ) ?;
241247
242248 ( df, datatypes) =
@@ -283,7 +289,7 @@ impl PyEngine {
283289 . build ( )
284290 . unwrap ( )
285291 . block_on ( flight_server. serve ( address) )
286- . map_err ( PyChrontextError :: FlightServerError ) ?;
292+ . map_err ( |x| PyChrontextError :: FlightServerError ( x ) ) ?;
287293 Ok ( ( ) )
288294 } )
289295 }
@@ -333,7 +339,7 @@ impl PyFlightClient {
333339 . build ( )
334340 . unwrap ( )
335341 . block_on ( client. query ( & sparql, & self . metadata ) )
336- . map_err ( PyChrontextError :: FlightClientError ) ?;
342+ . map_err ( |x| PyChrontextError :: FlightClientError ( x ) ) ?;
337343 Ok ( sm)
338344 } ) ;
339345 match res {
@@ -361,6 +367,15 @@ impl PyFlightClient {
361367 }
362368}
363369
370+ fn resolve_format ( format : & str ) -> RdfFormat {
371+ match format. to_lowercase ( ) . as_str ( ) {
372+ "ntriples" => RdfFormat :: NTriples ,
373+ "turtle" => RdfFormat :: Turtle ,
374+ "rdf/xml" | "xml" | "rdfxml" => RdfFormat :: RdfXml ,
375+ _ => unimplemented ! ( "Unknown format {}" , format) ,
376+ }
377+ }
378+
364379#[ pyclass( name = "VirtualizedBigQueryDatabase" ) ]
365380#[ derive( Clone ) ]
366381pub struct PyVirtualizedBigQueryDatabase {
@@ -455,7 +470,7 @@ impl PyDataProduct {
455470 rdf_node_types,
456471 } ;
457472 rdp. init ( )
458- . map_err ( PyChrontextError :: DataProductQueryParseError ) ?;
473+ . map_err ( |x| PyChrontextError :: DataProductQueryParseError ( x ) ) ?;
459474 Ok ( rdp)
460475 }
461476}
0 commit comments