projects
/
SXSI
/
xpathcomp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add utility header file.
[SXSI/xpathcomp.git]
/
src
/
main.ml
diff --git
a/src/main.ml
b/src/main.ml
index
fa16737
..
100d0e4
100644
(file)
--- a/
src/main.ml
+++ b/
src/main.ml
@@
-24,7
+24,7
@@
let mk_runtime run auto doc arg count print outfile =
if !Options.do_perf then start_perf ();
let r = time ~count:1 ~msg:"Execution time" (run auto doc) arg in
if !Options.do_perf then stop_perf ();
if !Options.do_perf then start_perf ();
let r = time ~count:1 ~msg:"Execution time" (run auto doc) arg in
if !Options.do_perf then stop_perf ();
-
Printf.eprintf "Number of results: %i\n%!
" (count r);
+
Logger.print Format.err_formatter "Number of results: %i@\n
" (count r);
match outfile with
None -> ()
| Some file ->
match outfile with
None -> ()
| Some file ->
@@
-38,12
+38,11
@@
let main v query_string output =
time ~msg:"Parsing query" XPath.parse query_string
in
if !Options.verbose then begin
time ~msg:"Parsing query" XPath.parse query_string
in
if !Options.verbose then begin
- Printf.eprintf "Parsed query:\n%!";
- XPath.Ast.print Format.err_formatter query;
- Format.fprintf Format.err_formatter "\n%!"
+ Logger.print Format.err_formatter "Parsed query:@\n%a@\n"
+ XPath.Ast.print query;
end;
let auto, bu_info =
end;
let auto, bu_info =
- time ~msg:"Compiling query"
(Compile.compile)
query
+ time ~msg:"Compiling query"
Compile.compile
query
in
if !Options.verbose then Ata.print Format.err_formatter auto;
Gc.full_major();
in
if !Options.verbose then Ata.print Format.err_formatter auto;
Gc.full_major();
@@
-53,12
+52,6
@@
let main v query_string output =
match !Options.bottom_up, bu_info with
| true, Some [ (query, pattern) ] ->
match !Options.bottom_up, bu_info with
| true, Some [ (query, pattern) ] ->
- (* let nodes =
- time
- ~count:1 ~msg:"Computing full text query"
- (Tree.full_text_query query v) pattern
- in
- let nodes = Array.to_list nodes in *)
if !Options.count_only then
let module R = ResJIT.Count in
let module M = Runtime.Make(R) in
if !Options.count_only then
let module R = ResJIT.Count in
let module M = Runtime.Make(R) in
@@
-72,13
+65,14
@@
let main v query_string output =
(* run the query top_down *)
if !Options.bottom_up then
(* run the query top_down *)
if !Options.bottom_up then
- Printf.eprintf "Cannot run the query in bottom-up mode, using top-down evaluator\n%!";
-
+ Logger.print Format.err_formatter "Cannot run the query in bottom-up mode, using top-down evaluator@\n@?";
if !Options.count_only then
let module R = ResJIT.Count in
let module M = Runtime.Make(R) in
if !Options.count_only then
let module R = ResJIT.Count in
let module M = Runtime.Make(R) in
- (* mk_runtime run auto doc arg count print outfile *)
- mk_runtime M.top_down_run auto v Tree.root R.NS.length R.NS.serialize None
+ if !Options.twopass then
+ mk_runtime M.twopass_top_down_run auto v Tree.root R.NS.length R.NS.serialize None
+ else
+ mk_runtime M.top_down_run auto v Tree.root R.NS.length R.NS.serialize None
else
let module R = ResJIT.Mat in
let module M = Runtime.Make(R) in
else
let module R = ResJIT.Mat in
let module M = Runtime.Make(R) in
@@
-108,7
+102,7
@@
let _ =
g
in
begin
g
in
begin
- (* T
odo
Factorise with main *)
+ (* T
ODO
Factorise with main *)
Tag.init (Grammar2.tag_operations g);
let query =
time ~msg:"Parsing query" XPath.parse !Options.query
Tag.init (Grammar2.tag_operations g);
let query =
time ~msg:"Parsing query" XPath.parse !Options.query
@@
-126,10
+120,16
@@
let _ =
Gc.compact();
Gc.set (tuned_gc);
let runtime =
Gc.compact();
Gc.set (tuned_gc);
let runtime =
- let module R = ResJIT.Count in
+ if !Options.count_only then
+ let module R = ResJIT.Make(NodeSet.Partial(NodeSet.Count)) in
let module M = Runtime.Make(R) in
(* mk_runtime run auto doc arg count print outfile *)
mk_runtime M.grammar_run auto (Obj.magic g) () R.NS.length (Obj.magic R.NS.serialize) None
let module M = Runtime.Make(R) in
(* mk_runtime run auto doc arg count print outfile *)
mk_runtime M.grammar_run auto (Obj.magic g) () R.NS.length (Obj.magic R.NS.serialize) None
+ else
+ let module R = ResJIT.Mat in
+ let module M = Runtime.Make(R) in
+ (* mk_runtime run auto doc arg count print outfile *)
+ mk_runtime M.grammar_run auto (Obj.magic g) () R.NS.length (Obj.magic R.NS.serialize) None
in
runtime ();
exit 0
in
runtime ();
exit 0
@@
-140,7
+140,7
@@
let _ =
~msg:"Loading file"
(Tree.load
~sample:!Options.sample_factor
~msg:"Loading file"
(Tree.load
~sample:!Options.sample_factor
- ~load_text:
true
)
+ ~load_text:
(not !Options.disable_text_collection)
)
!Options.input_file
else
let v =
!Options.input_file
else
let v =
@@
-160,21
+160,18
@@
let _ =
v
in
main document !Options.query !Options.output_file;
v
in
main document !Options.query !Options.output_file;
- if !Options.verbose then Printf.eprintf "Maximum resident set size: %s\n" (read_procmem());
+ if !Options.verbose then
+ Logger.print Format.err_formatter "Maximum resident set size: %s @\n" (read_procmem());
Gc.full_major();
Profile.summary Format.err_formatter
with
| Ulexer.Loc.Exc_located ((x,y),e) ->
Gc.full_major();
Profile.summary Format.err_formatter
with
| Ulexer.Loc.Exc_located ((x,y),e) ->
-
Printf.eprintf "character %i-%i %s
\n" x y (Printexc.to_string e);
+
Logger.print Format.err_formatter "character %i-%i %s@
\n" x y (Printexc.to_string e);
exit 1
| e ->
exit 1
| e ->
- output_string stderr "\n";
- flush stderr;
- Printexc.print_backtrace stderr;
- Printf.eprintf "FATAL ERROR: %s\n%!" (Printexc.to_string e);
- output_string stderr "\n";
- flush stderr;
+ Logger.print Format.err_formatter "BACKTRACE: %s@\n@?" (Printexc.get_backtrace());
+ Logger.print Format.err_formatter "FATAL ERROR: %s@\n@?" (Printexc.to_string e);
exit 2
exit 2