@@ -69,11 +69,11 @@ static void sqlfn_genomicsqlite_version(sqlite3_context *ctx, int argc,
6969std::string GenomicSQLiteDefaultConfigJSON () {
7070 return R"( {
7171 "unsafe_load": false,
72- "page_cache_size ": -1048576 ,
72+ "page_cache_MiB ": 1024 ,
7373 "threads": -1,
7474 "zstd_level": 6,
75- "inner_page_size ": 16384 ,
76- "outer_page_size ": 32768
75+ "inner_page_KiB ": 16 ,
76+ "outer_page_KiB ": 32
7777})" ;
7878}
7979
@@ -118,11 +118,11 @@ string GenomicSQLiteURI(const string &dbfile, const string &config_json = "") {
118118 int threads = extract->getColumn (0 ).getInt ();
119119 extract->reset ();
120120
121- extract->bind (2 , " $.outer_page_size " );
121+ extract->bind (2 , " $.outer_page_KiB " );
122122 if (!extract->executeStep () || extract->getColumnCount () != 1 ||
123123 !extract->getColumn (0 ).isInteger ())
124- throw std::runtime_error (" error processing config JSON $.outer_page_size " );
125- int outer_page_size = extract->getColumn (0 ).getInt ();
124+ throw std::runtime_error (" error processing config JSON $.outer_page_KiB " );
125+ int outer_page_KiB = extract->getColumn (0 ).getInt ();
126126 extract->reset ();
127127
128128 extract->bind (2 , " $.zstd_level" );
@@ -135,7 +135,7 @@ string GenomicSQLiteURI(const string &dbfile, const string &config_json = "") {
135135 ostringstream uri;
136136 uri << " file:" << dbfile << " ?vfs=zstd" ;
137137 uri << " &threads=" << to_string (threads);
138- uri << " &outer_page_size=" << to_string (outer_page_size );
138+ uri << " &outer_page_size=" << to_string (outer_page_KiB * 1024 );
139139 uri << " &level=" << to_string (zstd_level);
140140 if (unsafe_load) {
141141 uri << " &outer_unsafe" ;
@@ -210,11 +210,11 @@ string GenomicSQLiteTuningSQL(const string &config_json, const string &schema =
210210 bool unsafe_load = extract->getColumn (0 ).getInt () != 0 ;
211211 extract->reset ();
212212
213- extract->bind (2 , " $.page_cache_size " );
213+ extract->bind (2 , " $.page_cache_MiB " );
214214 if (!extract->executeStep () || extract->getColumnCount () != 1 ||
215215 !extract->getColumn (0 ).isInteger ())
216- throw std::runtime_error (" error processing config JSON $.page_cache_size " );
217- int page_cache_size = extract->getColumn (0 ).getInt ();
216+ throw std::runtime_error (" error processing config JSON $.page_cache_MiB " );
217+ auto page_cache_MiB = extract->getColumn (0 ).getInt64 ();
218218 extract->reset ();
219219
220220 extract->bind (2 , " $.threads" );
@@ -224,19 +224,19 @@ string GenomicSQLiteTuningSQL(const string &config_json, const string &schema =
224224 int threads = extract->getColumn (0 ).getInt ();
225225 extract->reset ();
226226
227- extract->bind (2 , " $.inner_page_size " );
227+ extract->bind (2 , " $.inner_page_KiB " );
228228 if (!extract->executeStep () || extract->getColumnCount () != 1 ||
229229 !extract->getColumn (0 ).isInteger ())
230- throw std::runtime_error (" error processing config JSON $.inner_page_size " );
231- int inner_page_size = extract->getColumn (0 ).getInt ();
230+ throw std::runtime_error (" error processing config JSON $.inner_page_KiB " );
231+ int inner_page_KiB = extract->getColumn (0 ).getInt ();
232232 extract->reset ();
233233
234234 string schema_prefix;
235235 if (!schema.empty ()) {
236236 schema_prefix = schema + " ." ;
237237 }
238238 map<string, string> pragmas;
239- pragmas[schema_prefix + " cache_size" ] = to_string (page_cache_size );
239+ pragmas[schema_prefix + " cache_size" ] = to_string (- 1024 * page_cache_MiB );
240240 pragmas[" threads" ] = to_string (threads >= 0 ? threads : thread::hardware_concurrency ());
241241 if (unsafe_load) {
242242 pragmas[schema_prefix + " journal_mode" ] = " OFF" ;
@@ -247,7 +247,7 @@ string GenomicSQLiteTuningSQL(const string &config_json, const string &schema =
247247 }
248248 ostringstream out;
249249 // must go first:
250- out << " PRAGMA " << schema_prefix << " page_size=" << to_string (inner_page_size );
250+ out << " PRAGMA " << schema_prefix << " page_size=" << to_string (inner_page_KiB * 1024 );
251251 for (const auto &p : pragmas) {
252252 out << " ; PRAGMA " << p.first << " =" << p.second ;
253253 }
@@ -379,16 +379,16 @@ static string sqlquote(const std::string &v) {
379379string GenomicSQLiteVacuumIntoSQL (const string &destfile, const string &config_json) {
380380 SQLite::Database tmpdb (" :memory:" , SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE);
381381 auto extract = ConfigExtractor (tmpdb, config_json);
382- extract->bind (2 , " $.inner_page_size " );
382+ extract->bind (2 , " $.inner_page_KiB " );
383383 if (!extract->executeStep () || extract->getColumnCount () != 1 ||
384384 !extract->getColumn (0 ).isInteger ())
385- throw std::runtime_error (" error processing config JSON $.inner_page_size " );
386- int inner_page_size = extract->getColumn (0 ).getInt ();
385+ throw std::runtime_error (" error processing config JSON $.inner_page_KiB " );
386+ int inner_page_KiB = extract->getColumn (0 ).getInt ();
387387
388388 string desturi = GenomicSQLiteURI (destfile, config_json) + " &outer_unsafe=true" ;
389389
390390 ostringstream ans;
391- ans << " PRAGMA page_size = " << inner_page_size << " ;\n PRAGMA auto_vacuum = FULL"
391+ ans << " PRAGMA page_size = " << (inner_page_KiB * 1024 ) << " ;\n PRAGMA auto_vacuum = FULL"
392392 << " ;\n VACUUM INTO " << sqlquote (desturi);
393393 return ans.str ();
394394}
0 commit comments