File: spanner.sdl

package info (click to toggle)
trillian 1.7.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,600 kB
  • sloc: sh: 1,181; javascript: 474; sql: 330; makefile: 39
file content (67 lines) | stat: -rw-r--r-- 2,575 bytes parent folder | download | duplicates (2)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
-- CloudSpanner has a strong recommendation to restrict all data between
-- top-level table rows to less than a few GiB:
--  | As a rule of thumb, the size of every set of related rows in a hierarchy
--  | of parent-child tables should be less than a few GiB. A set of related
--  | rows in a hierarchy of parent-child tables is defined as: (a single row
--  | of a table at the root of a database hierarchy) + (all rows of that table's
--  | descendent tables that share the row's primary key) + (all rows of
--  | interleaved indexes that share the row's primary key).
--  | (https://cloud.google.com/spanner/docs/schema-and-data-model)
-- so we don't interleave our tables.

CREATE TABLE TreeRoots(
  TreeID                INT64 NOT NULL,
  TreeState             INT64 NOT NULL,
  TreeType              INT64 NOT NULL,
  TreeInfo              BYTES(2097152) NOT NULL,
  Deleted               BOOL NOT NULL,
  DeleteTimeMillis      INT64,
) PRIMARY KEY(TreeID);

CREATE INDEX TreeRootsByDeleted
  ON TreeRoots (Deleted);

CREATE TABLE TreeHeads(
  TreeID                  INT64 NOT NULL,
  TimestampNanos          INT64 NOT NULL,
  TreeSize                INT64 NOT NULL,
  RootHash                BYTES(256) NOT NULL,
  RootSignature           BYTES(1024) NOT NULL,
  TreeRevision            INT64 NOT NULL,
  TreeMetadata            BYTES(2097152),
) PRIMARY KEY(TreeID, TreeRevision DESC);

CREATE TABLE SubtreeData(
  TreeID      INT64 NOT NULL,
  SubtreeID   BYTES(256) NOT NULL,
  Revision    INT64 NOT NULL,
  Subtree     BYTES(MAX) NOT NULL
) PRIMARY KEY(TreeID, SubtreeID, Revision DESC);

CREATE TABLE LeafData(
  TreeID              INT64 NOT NULL,
  LeafIdentityHash    BYTES(256) NOT NULL,
  LeafValue           BYTES(MAX) NOT NULL,
  ExtraData           BYTES(MAX),
  QueueTimestampNanos INT64 NOT NULL,
) PRIMARY KEY(TreeID, LeafIdentityHash);

CREATE TABLE SequencedLeafData(
  TreeID                  INT64 NOT NULL,
  SequenceNumber          INT64 NOT NULL,
  LeafIdentityHash        BYTES(256) NOT NULL,
  MerkleLeafHash          BYTES(256) NOT NULL,
  IntegrateTimestampNanos INT64 NOT NULL,
) PRIMARY KEY(TreeID, SequenceNumber);

CREATE INDEX SequenceByMerkleHash
  ON SequencedLeafData(TreeID, MerkleLeafHash)
  STORING(LeafIdentityHash);

CREATE TABLE Unsequenced(
  TreeID                 INT64 NOT NULL,
  Bucket                 INT64 NOT NULL,
  QueueTimestampNanos    INT64 NOT NULL,
  MerkleLeafHash         BYTES(256) NOT NULL,
  LeafIdentityHash       BYTES(256) NOT NULL,
) PRIMARY KEY (TreeID, Bucket, QueueTimestampNanos, MerkleLeafHash);