43f665fed103fc02da693d371237e6265a8e13dc
[SXSI/xpathcomp.git] / options.ml
1 let index_empty_texts = ref false
2 let sample_factor = ref 64
3 let disable_text_collection = ref false
4 let tc_threshold = ref 60000
5
6 let query = ref ""
7 let input_file = ref ""
8 let output_file = ref None
9 let save_file = ref ""
10 let count_only = ref false
11 let time = ref false
12
13 let usage_msg = Printf.sprintf "%s <input.{xml|srx}> 'query' [output]" Sys.argv.(0)
14
15
16 let pos = ref 0
17 let anon_fun = 
18   fun s -> match !pos with
19     | 0 -> input_file:= s;incr pos
20     | 1 -> query := s; incr pos
21     | 2 -> output_file := Some s; incr pos
22     | _ -> raise (Arg.Bad(s))
23
24 let spec = [ "-c", Arg.Set(count_only), "counting only (don't materialize the result set)";
25              "-t", Arg.Set(time), "print timing statistics";
26              "-max-tc", Arg.Set_int(tc_threshold), "set maximum count for which the TextCollection is used";
27              "-f", Arg.Set_int(sample_factor), "sample factor [default=64]";
28              "-i", Arg.Set(index_empty_texts), "index empty texts [default=false]";
29              "-d", Arg.Set(disable_text_collection), "disable text collection[default=false]"; 
30              "-s", Arg.Set_string(save_file), "save the intermediate representation into file.srx"; 
31            ]
32
33 let parse_cmdline() = 
34   let _ = Arg.parse spec anon_fun usage_msg
35   in
36     if (!pos > 3 || !pos < 2)
37     then begin Arg.usage spec usage_msg; exit 1 end
38
39       
40              
41