makedb: properly add cache
This commit is contained in:
parent
6173675677
commit
33171d2bd2
19
makedb.ml
19
makedb.ml
|
@ -65,17 +65,14 @@ let makedb db json = let open Sqlite3
|
|||
(if x = "" then Data.NULL else Data.TEXT x)
|
||||
|
||||
(* Cache fuzzy matching automaton. *)
|
||||
in let do_model name vals =
|
||||
let stmt = "INSERT INTO cache VALUES (:name, :cache);"
|
||||
|> prepare db
|
||||
in let open Batch_jaro_winkler
|
||||
in let do_model stmt name vals =
|
||||
let open Batch_jaro_winkler
|
||||
in let model = build_exportable_model
|
||||
~encoding:Encoding.UTF8 vals
|
||||
in
|
||||
binds stmt "name" (Data.TEXT name);
|
||||
binds stmt "cache" (Data.TEXT model);
|
||||
allstep stmt;
|
||||
finalize stmt |> Rc.check
|
||||
binds stmt "cache" (Data.BLOB model);
|
||||
allstep stmt
|
||||
|
||||
in let open Yojson.Basic.Util
|
||||
in let access_data x = x |> member "Cell" |> to_list
|
||||
|
@ -84,5 +81,9 @@ let makedb db json = let open Sqlite3
|
|||
in json |> member "Table" |> member "Row" |> to_list
|
||||
|> List.iter access_data;
|
||||
finalize stmt |> Rc.check;
|
||||
do_model "symbs" !symbs;
|
||||
do_model "names" !names
|
||||
let stmt = "INSERT INTO cache VALUES (:name, :cache);"
|
||||
|> prepare db
|
||||
in
|
||||
do_model stmt "symbs" !symbs;
|
||||
do_model stmt "names" !names;
|
||||
finalize stmt |> Rc.check
|
||||
|
|
Loading…
Reference in New Issue