aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Peter McGoron 2021-08-08 23:37:12 -0400
committerGravatar Peter McGoron 2021-08-08 23:37:12 -0400
commit33171d2bd218c48b1126e4927e514431cbe6d064 (patch)
tree715a9d6413a21ee5be239e393cb3c8c859f3dfc0
parentmakedb: make cached automaton (diff)
makedb: properly add cache
Diffstat (limited to '')
-rw-r--r--makedb.ml19
1 files changed, 10 insertions, 9 deletions
diff --git a/makedb.ml b/makedb.ml
index ef338af..3f28e12 100644
--- a/makedb.ml
+++ b/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