Module: Ucode::DbBuilder
- Defined in:
- lib/ucode/db_builder.rb
Overview
Builds the SQLite cache for one UCD version.
Single entry point: ‘DbBuilder.build(version)`. Streams the Coordinator output through an IndexBuilder, then persists the coalesced block + script ranges into a SQLite DB at `Cache.sqlite_path(version)`.
Streaming: the Coordinator yields one CodePoint at a time; the IndexBuilder folds it into per-property accumulators. Peak memory is the in-progress accumulators (~10 MB for the full UCD) plus one CodePoint — never all 160k CodePoints at once.
Class Method Summary collapse
-
.build(version) ⇒ Pathname
Path to the built SQLite file.
Class Method Details
.build(version) ⇒ Pathname
Returns path to the built SQLite file.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/ucode/db_builder.rb', line 56 def build(version) Ucode::VersionResolver.validate!(version) ucd_dir = Cache.ucd_dir(version) unihan_dir = Cache.unihan_dir(version) db_path = Cache.sqlite_path(version) Cache.ensure_version_dir!(version) builder = IndexBuilder.new Coordinator.new.each_codepoint(ucd_dir: ucd_dir, unihan_dir: unihan_dir) do |cp| builder.add(cp) end write_db(db_path, version, builder.blocks_index, builder.scripts_index) db_path end |