1 -- We maintain a local index of data blocks that have been previously stored
2 -- for constructing incremental snapshots.
4 -- The index is stored in an SQLite3 database. This is its schema.
6 -- List of snapshots which have been created.
7 create table snapshots (
8 snapshotid integer primary key,
14 -- List of segments which have been created.
15 create table segments (
16 segmentid integer primary key,
17 segment text unique not null,
24 -- Index of all blocks which have been stored, by checksum.
25 create table block_index (
26 blockid integer primary key,
27 segmentid integer not null,
34 create index block_content_index on block_index(checksum);
35 create unique index block_name_index on block_index(segmentid, object);
37 -- Summary of segment utilization for each snapshots.
38 create table segments_used (
39 snapshotid integer not null,
40 segmentid integer not null,
44 -- Overall estimate of segment utilization, for all snapshots combined.
45 create view segment_info as
46 select segmentid, mtime, size, cast(size * utilization as integer) as used,
49 (select segmentid, max(utilization) as utilization
50 from segments_used group by segmentid)