-
Notifications
You must be signed in to change notification settings - Fork 109
Expand file tree
/
Copy pathcreate_db.sh
More file actions
executable file
·27 lines (23 loc) · 797 Bytes
/
create_db.sh
File metadata and controls
executable file
·27 lines (23 loc) · 797 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
set -eu
indb="$1"
outdir="$2"
# for chunked mode, we need to know the database size in bytes beforehand
bytes="$(stat --printf="%s" "$indb")"
# set chunk size to 10MiB (needs to be a multiple of the `pragma page_size`!)
serverChunkSize=$((10 * 1024 * 1024))
suffixLength=3
rm -f "$outdir/db.sqlite3"*
split "$indb" --bytes=$serverChunkSize "$outdir/db.sqlite3." --suffix-length=$suffixLength --numeric-suffixes
# set request chunk size to match page size
requestChunkSize="$(sqlite3 "$indb" 'pragma page_size')"
# write a json config
echo '
{
"serverMode": "chunked",
"requestChunkSize": '$requestChunkSize',
"databaseLengthBytes": '$bytes',
"serverChunkSize": '$serverChunkSize',
"urlPrefix": "db.sqlite3.",
"suffixLength": '$suffixLength'
}
' > "$outdir/config.json"