diff options
| author | 2021-08-08 23:37:12 -0400 | |
|---|---|---|
| committer | 2021-08-08 23:37:12 -0400 | |
| commit | 33171d2bd218c48b1126e4927e514431cbe6d064 (patch) | |
| tree | 715a9d6413a21ee5be239e393cb3c8c859f3dfc0 | |
| parent | makedb: make cached automaton (diff) | |
makedb: properly add cache
Diffstat (limited to '')
| -rw-r--r-- | makedb.ml | 19 |
1 files changed, 10 insertions, 9 deletions
@@ -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 |
