Stable state. Includes fixes and tweaking of the caching of automata.
authorkim <kim@3cdefd35-fc62-479d-8e8d-bae585ffb9ca>
Wed, 28 Apr 2010 06:47:14 +0000 (06:47 +0000)
committerkim <kim@3cdefd35-fc62-479d-8e8d-bae585ffb9ca>
Wed, 28 Apr 2010 06:47:14 +0000 (06:47 +0000)
git-svn-id: svn+ssh://idea.nguyen.vg/svn/sxsi/trunk/xpathcomp@812 3cdefd35-fc62-479d-8e8d-bae585ffb9ca

OCamlDriver.cpp
main.ml
tree.ml

index 03f06d5..417ab5b 100644 (file)
@@ -117,7 +117,7 @@ extern "C"  value caml_call_shredder_string(value data,value sf, value iet, valu
   CAMLparam1(data);
   CAMLlocal1(doc);
   XMLDocShredder * shredder;
-  unsigned int ln = string_length(data);
+  unsigned int ln = caml_string_length(data);
   unsigned char *fn = (unsigned char*) String_val(data);
   try {
     shredder = new  XMLDocShredder (fn,ln,Int_val(sf),Bool_val(iet),Bool_val(dtc));  
@@ -696,7 +696,7 @@ NoAlloc extern "C" value caml_result_set_count(value result){
 
 NoAlloc extern "C"  value caml_xml_tree_print(value tree,value node,value fd){
   CAMLparam3(tree,node,fd);
-  XMLTREE(tree)->Print(Int_val(fd),TREENODEVAL(node));
+  XMLTREE(tree)->Print(Int_val(fd),TREENODEVAL(node), false);
   CAMLreturn(Val_unit);
 }
 
diff --git a/main.ml b/main.ml
index 3192810..8bb6b44 100644 (file)
--- a/main.ml
+++ b/main.ml
@@ -201,10 +201,10 @@ let main v query_string output =
                  let _ = Printf.eprintf "Number of nodes in the result set : %i\n%!" r
                  in ()
                else      
-               let module GR = Ata.Test(struct let doc = v end) in
+               let module GR = Ata(*.Test(struct let doc = v end) *) in
                  let result = time ~count:5 (GR.top_down1 auto) v in
                  let _ = Printf.eprintf "Counting results " in
-                 let rcount = time (GR.Results.length) result in
+                 let rcount = time (IdSet.length) result in
                    Printf.eprintf "Number of nodes in the result set : %i\n" rcount;
                    Printf.eprintf "\n%!";
                    begin
@@ -212,28 +212,17 @@ let main v query_string output =
                        | None -> ()
                        | Some f ->                   
                            Printf.eprintf "Serializing results : ";
-                           time( fun () ->
-                                   (*let oc = open_out f in *)
-                                   let oc = Unix.openfile f [ Unix.O_WRONLY;Unix.O_TRUNC;Unix.O_CREAT] 0o644 in
-                                     (*output_string oc "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";*)
-                                   let t1 = ref (Unix.gettimeofday()) in
-                                   let count = ref 1 in
-                                   let old_count = ref 1 in
-                                    GR.Results.iter (fun t -> 
-                                                       incr count;
-                                                       begin
-                                                         if (!count mod 15) == 0
-                                                         then
-                                                         let t2 =  Unix.gettimeofday() in
-                                                         let _ = Printf.eprintf "Printing %i elements in %f ms\n"
-                                                           (!count - !old_count) (1000. *.(t2 -. !t1))
-                                                         in
-                                                         ( old_count := !count; t1 := Unix.gettimeofday())
-                                                       end;
-                                                       Tree.print_xml_fast3 v t oc;
-                                                       (*output_char oc '\n'; *)                               
-                                                    ) result) ();
-                   end;
+                           let oc = 
+                             Unix.openfile f [ Unix.O_WRONLY;Unix.O_TRUNC;Unix.O_CREAT] 0o644 
+                           in
+                           time( 
+                             IdSet.iter (
+                               fun t ->                                  
+                                 
+                                 Tree.print_xml_fast3 v t oc;
+                               
+                             )) result ;
+ end;
          end;
          Printf.eprintf "Total running time : %fms\n%!" (total_time())
 ;;
diff --git a/tree.ml b/tree.ml
index 8e5dbc7..f84c2bd 100644 (file)
--- a/tree.ml
+++ b/tree.ml
@@ -513,7 +513,8 @@ let select_following_sibling t = fun ts ->
     fun n -> tree_select_following_sibling t.doc n v
 
 let next_sibling_below t = (); fun n _ -> tree_next_sibling t.doc n
-let next_element_below t = (); fun n _ ->  tree_next_element t.doc n
+let next_element_below t = (); fun n _ -> tree_next_element t.doc n
+
 let tagged_following_sibling_below t tag = (); fun n  _ -> tree_tagged_following_sibling t.doc n tag
 
 let select_following_sibling_below t = fun ts ->