From 33171d2bd218c48b1126e4927e514431cbe6d064 Mon Sep 17 00:00:00 2001 From: Peter McGoron Date: Sun, 8 Aug 2021 23:37:12 -0400 Subject: [PATCH] makedb: properly add cache --- makedb.ml | 19 ++++++++++--------- 1 file 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