the pretty-printing module:
Options depends on Logger to have the list of all logs levels
Logger depends on Options to check whether we are in verbose mode
or not.
Split:
Config options holds the references storing the options
Options only handles the parsing of the command line
Unix.kill !pid Sys.sigint
let time f ?(count=1) ?(msg="") x =
Unix.kill !pid Sys.sigint
let time f ?(count=1) ?(msg="") x =
- if not !Options.verbose then f x
+ if not !Config.verbose then f x
else
let rec loop i =
Gc.compact();
else
let rec loop i =
Gc.compact();
let init () = Memo.clear memo
let compute_jump auto tree tag states dir =
let init () = Memo.clear memo
let compute_jump auto tree tag states dir =
- if !Options.no_jump then
+ if !Config.no_jump then
if dir == DIR_LEFT then FIRST_CHILD states
else NEXT_SIBLING states
else
if dir == DIR_LEFT then FIRST_CHILD states
else NEXT_SIBLING states
else
| BOTH(tr, NOP _, r) -> RIGHT (tr, r)
| _ -> op
in
| BOTH(tr, NOP _, r) -> RIGHT (tr, r)
| _ -> op
in
- if not !Options.no_cache then add cache2 tag states op;
+ if not !Config.no_cache then add cache2 tag states op;
op
let get_transitions = function
op
let get_transitions = function
let mk_runtime run auto doc arg count print outfile =
fun () ->
let mk_runtime run auto doc arg count print outfile =
fun () ->
- if !Options.do_perf then start_perf ();
- let r = time ~count:!Options.repeat ~msg:"Execution time" (run auto doc) arg in
- if !Options.do_perf then stop_perf ();
+ if !Config.do_perf then start_perf ();
+ let r = time ~count:!Config.repeat ~msg:"Execution time" (run auto doc) arg in
+ if !Config.do_perf then stop_perf ();
Logger.verbose Format.err_formatter "Number of results: %i@\n" (count r);
match outfile with
None -> ()
| Some file ->
Logger.verbose Format.err_formatter "Number of results: %i@\n" (count r);
match outfile with
None -> ()
| Some file ->
- time ~count:1 ~msg:"Serialization time" (print file !Options.no_wrap_results doc) r
+ time ~count:1 ~msg:"Serialization time" (print file !Config.no_wrap_results doc) r
;;
let main v query_string output =
Tag.init (Tree.tag_operations v);
;;
let main v query_string output =
Tag.init (Tree.tag_operations v);
- if !Options.docstats then Tree.stats v;
+ if !Config.docstats then Tree.stats v;
let query =
time ~msg:"Parsing query" XPath.parse query_string
in
let query =
time ~msg:"Parsing query" XPath.parse query_string
in
let auto, bu_info =
time ~msg:"Compiling query" Compile.compile query
in
let auto, bu_info =
time ~msg:"Compiling query" Compile.compile query
in
- if !Options.verbose then Ata.print Format.err_formatter auto;
+ if !Config.verbose then Ata.print Format.err_formatter auto;
Gc.full_major();
Gc.compact();
Gc.set (tuned_gc);
let runtime =
Gc.full_major();
Gc.compact();
Gc.set (tuned_gc);
let runtime =
- match !Options.bottom_up, bu_info with
+ match !Config.bottom_up, bu_info with
| true, Some [ (query, pattern) ] ->
| true, Some [ (query, pattern) ] ->
- if !Options.count_only then
+ if !Config.count_only then
let module R = ResJIT.Count in
let module M = Runtime.Make(R) in
let module R = ResJIT.Count in
let module M = Runtime.Make(R) in
- mk_runtime M.bottom_up_run auto v (query, pattern) R.NS.length R.NS.serialize !Options.output_file
+ mk_runtime M.bottom_up_run auto v (query, pattern) R.NS.length R.NS.serialize !Config.output_file
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
- mk_runtime M.bottom_up_run auto v (query, pattern) R.NS.length R.NS.serialize !Options.output_file
+ mk_runtime M.bottom_up_run auto v (query, pattern) R.NS.length R.NS.serialize !Config.output_file
| _ ->
(* run the query top_down *)
| _ ->
(* run the query top_down *)
- if !Options.bottom_up then
+ if !Config.bottom_up then
Logger.verbose Format.err_formatter "Cannot run the query in bottom-up mode, using top-down evaluator@\n@?";
Logger.verbose Format.err_formatter "Cannot run the query in bottom-up mode, using top-down evaluator@\n@?";
- if !Options.count_only then
+ if !Config.count_only then
let module R = ResJIT.Count in
let module M = Runtime.Make(R) in
let module R = ResJIT.Count in
let module M = Runtime.Make(R) in
- if !Options.twopass then
+ if !Config.twopass then
mk_runtime M.twopass_top_down_run auto v Tree.root R.NS.length R.NS.serialize None
else
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 !Options.output_file
+ mk_runtime M.top_down_run auto v Tree.root R.NS.length R.NS.serialize !Config.output_file
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
- mk_runtime M.top_down_run auto v Tree.root R.NS.length R.NS.serialize !Options.output_file
+ mk_runtime M.top_down_run auto v Tree.root R.NS.length R.NS.serialize !Config.output_file
try
Printexc.record_backtrace true;
let document =
try
Printexc.record_backtrace true;
let document =
- if Filename.check_suffix !Options.input_file ".srx"
+ if Filename.check_suffix !Config.input_file ".srx"
then
time
~msg:"Loading file"
(Tree.load
then
time
~msg:"Loading file"
(Tree.load
- ~sample:!Options.sample_factor
- ~load_text:(not !Options.disable_text_collection))
- !Options.input_file
+ ~sample:!Config.sample_factor
+ ~load_text:(not !Config.disable_text_collection))
+ !Config.input_file
else
let v =
time
~msg:"Parsing document"
(Tree.parse_xml_uri)
else
let v =
time
~msg:"Parsing document"
(Tree.parse_xml_uri)
- if !Options.save_file <> ""
+ if !Config.save_file <> ""
then
time
~msg:"Writing file to disk"
(Tree.save v)
then
time
~msg:"Writing file to disk"
(Tree.save v)
- main document !Options.query !Options.output_file;
+ main document !Config.query !Config.output_file;
Logger.verbose Format.err_formatter "Maximum resident set size: %s @\n" (read_procmem());
Gc.full_major();
Profile.summary Format.err_formatter
Logger.verbose Format.err_formatter "Maximum resident set size: %s @\n" (read_procmem());
Gc.full_major();
Profile.summary Format.err_formatter
-
-let index_empty_texts = ref true
-let sample_factor = ref 64
-let disable_text_collection = ref false
-let tc_threshold = ref 60000
-
-let query = ref ""
-let input_file = ref ""
-let output_file = ref None
-let save_file = ref ""
-let count_only = ref false
-let time = ref false
-let bottom_up = ref false
-let no_jump = ref false
-let no_cache = ref false
-let verbose = ref false
-let text_index_type = ref 0
-let do_perf = ref false
-let twopass = ref false
-let repeat = ref 1
-let docstats = ref false
-let no_wrap_results = ref false
let set_index_type = function
| "default" -> text_index_type := 0
let set_index_type = function
| "default" -> text_index_type := 0
val parse_cmdline : unit -> unit
val parse_cmdline : unit -> unit
-val index_empty_texts : bool ref
-val sample_factor : int ref
-val disable_text_collection : bool ref
-val count_only : bool ref
-val query : string ref
-val input_file : string ref
-val output_file : string option ref
-val save_file : string ref
-val time : bool ref
-val tc_threshold : int ref
-val bottom_up : bool ref
-val no_jump : bool ref
-val no_cache : bool ref
-val verbose : bool ref
-val text_index_type : int ref
-val do_perf : bool ref
-val twopass : bool ref
-val repeat : int ref
-val docstats : bool ref
-val no_wrap_results : bool ref
Logger.print err_formatter "@?L3JIT: %i used entries@\n@?" !count
let create () =
let v = Cache.Lvl3.create 1024 dummy in
Logger.print err_formatter "@?L3JIT: %i used entries@\n@?" !count
let create () =
let v = Cache.Lvl3.create 1024 dummy in
- if !Options.verbose then at_exit (fun () -> show_stats v);
+ if !Config.verbose then at_exit (fun () -> show_stats v);
v
let find t tlist s1 s2 =
v
let find t tlist s1 s2 =
let f = gen_code auto tlist s1 s2 in
LOG(__ "top-down-run" 2 "Inserting: %i, %a, %a\n%!"
(Uid.to_int tlist.Translist.Node.id) StateSet.print s1 StateSet.print s2);
let f = gen_code auto tlist s1 s2 in
LOG(__ "top-down-run" 2 "Inserting: %i, %a, %a\n%!"
(Uid.to_int tlist.Translist.Node.id) StateSet.print s1 StateSet.print s2);
- if not !Options.no_cache then add cache tlist s1 s2 f;
+ if not !Config.no_cache then add cache tlist s1 s2 f;
let do_text b t =
if Buffer.length t > 0 then begin
let s = Buffer.contents t in
let do_text b t =
if Buffer.length t > 0 then begin
let s = Buffer.contents t in
- if (!Options.index_empty_texts) || not (is_whitespace s) then
+ if (!Config.index_empty_texts) || not (is_whitespace s) then
begin
open_tag b "<$>";
text b s;
begin
open_tag b "<$>";
text b s;
Expat.set_end_element_handler parser_ (end_element_handler parser_ build buf);
Expat.set_character_data_handler parser_ (character_data_handler parser_ build buf);
LOG ( __ "parsing" 2 "%s\n" "Started parsing");
Expat.set_end_element_handler parser_ (end_element_handler parser_ build buf);
Expat.set_character_data_handler parser_ (character_data_handler parser_ build buf);
LOG ( __ "parsing" 2 "%s\n" "Started parsing");
- open_document build !Options.sample_factor !Options.disable_text_collection !Options.text_index_type;
+ open_document build !Config.sample_factor !Config.disable_text_collection !Config.text_index_type;
open_tag build "";
parser_, finalize
open_tag build "";
parser_, finalize