X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=src%2Ftable_driver.ml;h=e961abbfccc3a109a091b2fbb664deef82a29851;hb=c5480c3711c7431e70f78871c738f2d86ecb96ac;hp=371dbdf5eba5fc53ad28d02878079e97f6369119;hpb=8fbdb25170c3376272f7eec7ef2be8fc008d11f7;p=tatoo.git diff --git a/src/table_driver.ml b/src/table_driver.ml index 371dbdf..e961abb 100644 --- a/src/table_driver.ml +++ b/src/table_driver.ml @@ -5,6 +5,8 @@ open Query_tree let parse_xpath p = Xpath.Parser.parse (Ulexing.from_utf8_string p) +let display = ref false + let main () = let () = Table_options.parse () in let doc = @@ -18,37 +20,37 @@ let main () = close_fd(); doc in - (*Hashtbl.clear Query_tree.table_query_tree; il faut vider le hashtbl?????????????????*) let queries = List.map ( fun q -> parse_xpath q) !Table_options.queries in + let t1 = Unix.gettimeofday () in let query_tree_list = List.map (fun query -> compile_xpath query) queries in - List.iter ( fun q -> - let res = eval_query_tree doc [ (Naive_tree.root doc) ] q in + let mini_qtree_list = + List.map (fun qtree -> Query_tree.minimize_qtree qtree) query_tree_list + in + let root = Bitvector.create (Naive_tree.size doc) in + Bitvector.set root 0 true; + List.iter ( fun q -> + let v = eval_qtree doc root q in + if !display then begin + let res = decode_bit doc v in + print_string "\n"; print_node_list doc res; - print_string "\n" - ) query_tree_list ; + print_string "\n"; + end; + () + ) mini_qtree_list ; + let t2 = Unix.gettimeofday () in + let t = (t2 -. t1) *. 1000. in let _ = if !Table_options.count then - Format.fprintf Format.std_formatter "there are %i nodes\n" !Query_tree.compteur; + Format.fprintf Format.std_formatter "there are %i nodes\nit takes %fms\n" !Query_tree.compteur t; in - - (* let output = - match !Options.output_file with - | None | Some "-" | Some "/dev/stdout" -> stdout - | Some f -> open_out f - in - List.iter (fun query -> - Logger.msg `STATS "Query: %a " Xpath.Ast.print_path query) queries; - List.iter (fun query_tree -> - Logger.msg `STATS "@[Query_tree: @\n%a@]" print_query_tree Format.std_formatter query_tree) query_tree_list; - - *) exit 0 @@ -60,76 +62,4 @@ let () = main () -(* let query = Xpath.Parser.parse - (Ulexing.from_utf8_string Sys.argv.(2)) - in - Format.printf "La requete est: %a\n%!" - Xpath.Ast.print_path query; *) - - (* print_endline "Test 1 root.firstchild"; - let c1 = eval_move doc [ (Naive_tree.root doc) ] Firstchild in - print_node_list doc c1; - print_endline "Test 2 root.firstchild.firstchild"; - let c2 = eval_move doc c1 Firstchild in - print_node_list doc c2; - print_endline "Test 3 root.firstchild.firstchild.nextsibling"; - let c3 = eval_move doc c2 Nextsibling in - print_node_list doc c3; - print_endline "Test 4 root.firstchild.firstchild.nextsibling.firstchild"; - let c4 = eval_move doc c3 Firstchild in - print_node_list doc c4; - print_endline "Test 5 root.firstchild.firstchild.nextsibling.firstchild.ancestor false"; - let c5 = eval_axis doc c4 (Ancestor false) in - print_node_list doc c5; - print_endline "Test 6"; - let c6 = eval_move doc c5 Prevsibling in - print_node_list doc c6; - print_endline "Test 7"; - let c7 = eval_move doc c6 Revfirstchild in - print_node_list doc c7; - print_endline "Test 8 Child [root]"; - let c8 = eval_axis doc [Naive_tree.root doc] Child in - print_node_list doc c8; - print_endline "Test 9 Descendant [b]"; - let c9 = eval_axis doc c2 (Descendant false) in - print_node_list doc c9; - print_endline "Test 10 Descendant or self [b]"; - let c10 = eval_axis doc c2 (Descendant true) in - print_node_list doc c10; - print_endline "Test 11 FollowingSibling [b]"; - let c11 = eval_axis doc c2 FollowingSibling in - print_node_list doc c11; - print_endline "Test 12 Parent [b]"; - let c12 = eval_axis doc c2 Parent in - print_node_list doc c12; - print_endline "Test 13 Ancestor or self [b]"; - let c13 = eval_axis doc c2 (Ancestor true) in - print_node_list doc c13; - print_endline "Test 14 PrecdingSibling [b]"; - let c14 = eval_axis doc c2 PrecedingSibling in - print_node_list doc c14; - print_endline "Test 15 preceding [b]"; - let c15 = eval_axis doc c2 Preceding in - print_node_list doc c15; - print_endline "Test 16 Following [b]"; - let c16 = eval_axis doc c2 Following in - print_node_list doc c16; - print_endline "Test 17 tag [b]"; - let c17 = element_by_tag doc (QName.make "b") in - print_node_list doc c17; - print_endline "Test 18 all nodes"; - let c18 = all_nodes doc in - print_node_list doc c18; - print_endline "Test 19 compile_xpath"; *) - - - (*Format.printf "Le document contient: %i noeuds\n%!" (Naive_tree.size doc); - let c19 = compile_xpath (parse_xpath "/child::a[child::b or not(following::]") in - Format.printf ">> %a\n%!" print_query_tree c19; - print_endline "Test 20 eval_query_tree"; - let res = eval_query_tree doc [ (Naive_tree.root doc) ] c19 in - print_node_list doc res; - print_endline "Fin";*) - -