From: lordi Date: Wed, 19 Jun 2002 12:53:55 +0000 (+0000) Subject: let in scope corrected and new database format support X-Git-Tag: V_0_3_0_debian_8~27 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=b6992cac4c9ffa80337e5e11e5017b0b9b17c65e;p=helm.git let in scope corrected and new database format support --- diff --git a/helm/ocaml/mathql_interpreter/letin.ml b/helm/ocaml/mathql_interpreter/letin.ml index 3cf1fb617..160a7a164 100644 --- a/helm/ocaml/mathql_interpreter/letin.ml +++ b/helm/ocaml/mathql_interpreter/letin.ml @@ -55,7 +55,11 @@ let letref_ex rvar = try List.assoc rvar pool with - Not_found -> let _ = print_endline "nun ce sta" in [] + Not_found -> [] ) ;; +let letdispose () = + let _ = letin_pool = ref None in () +;; + diff --git a/helm/ocaml/mathql_interpreter/letin.mli b/helm/ocaml/mathql_interpreter/letin.mli index b2b6ffda6..d221ddd2e 100644 --- a/helm/ocaml/mathql_interpreter/letin.mli +++ b/helm/ocaml/mathql_interpreter/letin.mli @@ -25,3 +25,4 @@ val letin_ex : MathQL.mqlvar -> Mathql_semantics.result -> Mathql_semantics.result val letref_ex : MathQL.mqlvar -> Mathql_semantics.result +val letdispose : unit -> unit diff --git a/helm/ocaml/mathql_interpreter/mqint.ml b/helm/ocaml/mathql_interpreter/mqint.ml index 34cfc0986..3a0a5fb31 100644 --- a/helm/ocaml/mathql_interpreter/mqint.ml +++ b/helm/ocaml/mathql_interpreter/mqint.ml @@ -39,6 +39,8 @@ open Use;; open Select;; open Letin;; +let prop_pool = ref None;; + let fi_to_string fi = match fi with (None, _) -> @@ -56,10 +58,38 @@ let fi_to_string fi = ")" ;; +let see_prop_pool () = + let _ = print_endline "eccomi" in + List.iter + (fun elem -> print_endline (fst elem ^ ": " ^ snd elem)) + (match !prop_pool with Some l -> l | _ -> print_endline "ciao"; assert false) +;; + (* * inizializzazione della connessione al database *) -let init () = Dbconn.init ();; +let init () = + let _ = Dbconn.init () in + let c = pgc () in + let res = + c#exec "select name,id from property where ns_id in (select id from namespace where url='http://www.cs.unibo.it/helm/schemas/mattone.rdf#')" + in + prop_pool := Some + ( + List.map + (function + a::b::_ -> (a, b) + | _ -> print_endline "no"; assert false + ) + res#get_list + ) +;; + +let get_prop_id prop = + if prop="refObj" then "F" + else if prop="backPointer" then "B" + else List.assoc prop (match !prop_pool with Some l -> l | _ -> assert false) +;; (* execute_ex env q *) (* [env] is the attributed uri environment in which the query [q] *) @@ -71,9 +101,9 @@ let rec execute_ex env = MQSelect (apvar, alist, abool) -> select_ex env apvar (execute_ex env alist) abool | MQUsedBy (alist, asvar) -> - use_ex (execute_ex env alist) asvar "F" (*"refObj"*) + use_ex (execute_ex env alist) asvar (get_prop_id "refObj") (* "F" (*"refObj"*) *) | MQUse (alist, asvar) -> - use_ex (execute_ex env alist) asvar "B" (*"backPointer"*) + use_ex (execute_ex env alist) asvar (get_prop_id "backPointer") (* "B" (*"backPointer"*) *) | MQPattern (apreamble, apattern, afragid) -> pattern_ex (apreamble, apattern, afragid) | MQUnion (l1, l2) -> @@ -93,6 +123,7 @@ let rec execute_ex env = execute_ex env l2 (*CSC: end of the interesting code *) in + letdispose (); print_string ("LETIN = " ^ string_of_int (List.length res) ^ ": ") ; print_endline (string_of_float (Unix.time () -. t) ^ "s") ; flush stdout ; diff --git a/helm/ocaml/mathql_interpreter/use.ml b/helm/ocaml/mathql_interpreter/use.ml index ed8a855ec..93ed9a8a4 100644 --- a/helm/ocaml/mathql_interpreter/use.ml +++ b/helm/ocaml/mathql_interpreter/use.ml @@ -109,7 +109,7 @@ let result = (c#exec ("select id from registry where uri='" ^ uri ^ "'")) in let qq = - "select uri, context from t" ^ tv ^ " where back_for='" ^ usek ^ + "select uri, context from t" ^ tv ^ " where prop_id='" ^ usek ^ "' order by uri asc" in let res = c#exec qq in