| | 1 | == sqlite tile storage == #sqlite |
| | 2 | ''available since '''V0.16-1''''' |
| | 3 | |
| | 4 | '''What is this good for ?'''[[br]] |
| | 5 | As mentioned earlier in the modRana thread on talk.maemo.org and also in a related Mappero thread, tiles take up more space than expected because each tile, even if only 500B in size, takes a whole 64kB cluster. |
| | 6 | When using sqlite for tile storage, there are basically just 2 files per layer, not the usual tens of thousands of files and folders. |
| | 7 | |
| | 8 | '''How to enable sqlite tile storage ?'''[[br]] |
| | 9 | Go to '''options'''->'''map''' and switch '''tile storage''' from '''files''' to '''sqlite'''. |
| | 10 | |
| | 11 | '''Is it stable ?'''[[br]] |
| | 12 | It seems to work OK for both normal automatic tile download (including overlay) and batch download. But some errors can still can show up, so please report any unusual behavior, thanks ! :) |
| | 13 | |
| | 14 | '''What about the 4GB maximum file size limit on FAT32 ?'''[[br]] |
| | 15 | When a size of the storage database reaches 3.7 GB, a new one is added. The is no limit on the number of storage databases. |
| | 16 | |
| | 17 | '''How does it work ?'''[[br]] |
| | 18 | The tiles are stored in a sqlite database as blobs. There are two types of database files, ''lookup.sqlite'' and ''store.sqlite''. The lookup file stores a database that indicates in which store the requested tile is. The store file has the actual data. Multiple stores should be numbered in ascending order, starting from 0: |
| | 19 | {{{ |
| | 20 | store.sqlite.0 |
| | 21 | store.sqlite.1 |
| | 22 | store.sqlite.2 |
| | 23 | etc. |
| | 24 | }}} |
| | 25 | |
| | 26 | The storage database looks like this:[[br]][[br]] |
| | 27 | {{{table tiles (z integer, x integer, y integer, store_filename string, extension varchar(10), unix_epoch_timestamp integer, primary key (z, x, y, extension))}}}[[br]][[br]][[br]] |
| | 28 | The store databases look like this:[[br]][[br]] |
| | 29 | {{{table tiles (z integer, x integer, y integer, tile blob, extension varchar(10), unix_epoch_timestamp integer, primary key (z, x, y, extension))}}}[[br]][[br]] |
| | 30 | The only difference in the structure is that the lookup databases only stores the name of the store for given coordinates and the store database stores the actual blob. |
| | 31 | Both also have a table called version which has an integer column called v. There is a single 1 inserted, which indicates the current version of the table. |
| | 32 | |
| | 33 | Database files are stored in the corresponding layer folders. |
| | 34 | |
| | 35 | When looking for a tile in the database, modRana first asks the lookup database and when it gets an answer, it asks the store described in the store_filename for the given tile coordinates. |
| | 36 | |
| | 37 | '''Could this be used by other navigation apps ?'''[[br]] |
| | 38 | Why do you think I just described how it works ? :D |