| 28 | } // namespace |
| 29 | |
| 30 | Status SetupTensorboardSqliteDb(Sqlite* db) { |
| 31 | // Note: GCC raw strings macros are broken. |
| 32 | // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55971 |
| 33 | TF_RETURN_IF_ERROR( |
| 34 | db->PrepareOrDie(strings::StrCat("PRAGMA application_id=", |
| 35 | kTensorboardSqliteApplicationId)) |
| 36 | .StepAndReset()); |
| 37 | db->PrepareOrDie("PRAGMA user_version=0").StepAndResetOrDie(); |
| 38 | Status s; |
| 39 | |
| 40 | // Ids identify resources. |
| 41 | // |
| 42 | // This table can be used to efficiently generate Permanent IDs in |
| 43 | // conjunction with a random number generator. Unlike rowids these |
| 44 | // IDs safe to use in URLs and unique across tables. |
| 45 | // |
| 46 | // Within any given system, there can't be any foo_id == bar_id for |
| 47 | // all rows of any two (Foos, Bars) tables. A row should only be |
| 48 | // deleted from this table if there's a very high level of confidence |
| 49 | // it exists nowhere else in the system. |
| 50 | // |
| 51 | // Fields: |
| 52 | // id: The system-wide ID. This must be in the range [1,2**47). 0 |
| 53 | // is assigned the same meaning as NULL and shouldn't be stored |
| 54 | // and all other int64 values are reserved for future use. Please |
| 55 | // note that id is also the rowid. |
| 56 | s.Update(Run(db, R"sql( |
| 57 | CREATE TABLE IF NOT EXISTS Ids ( |
| 58 | id INTEGER PRIMARY KEY |
| 59 | ) |
| 60 | )sql")); |
| 61 | |
| 62 | // Descriptions are Markdown text that can be associated with any |
| 63 | // resource that has a Permanent ID. |
| 64 | // |
| 65 | // Fields: |
| 66 | // id: The foo_id of the associated row in Foos. |
| 67 | // description: Arbitrary NUL-terminated Markdown text. |
| 68 | s.Update(Run(db, R"sql( |
| 69 | CREATE TABLE IF NOT EXISTS Descriptions ( |
| 70 | id INTEGER PRIMARY KEY, |
| 71 | description TEXT |
| 72 | ) |
| 73 | )sql")); |
| 74 | |
| 75 | // Tensors are 0..n-dimensional numbers or strings. |
| 76 | // |
| 77 | // Fields: |
| 78 | // rowid: Ephemeral b-tree ID. |
| 79 | // series: The Permanent ID of a different resource, e.g. tag_id. A |
| 80 | // tensor will be vacuumed if no series == foo_id exists for all |
| 81 | // rows of all Foos. When series is NULL this tensor may serve |
| 82 | // undefined purposes. This field should be set on placeholders. |
| 83 | // step: Arbitrary number to uniquely order tensors within series. |
| 84 | // The meaning of step is undefined when series is NULL. This may |
| 85 | // be set on placeholders to prepopulate index pages. |
| 86 | // computed_time: Float UNIX timestamp with microsecond precision. |
| 87 | // In the old summaries system that uses FileWriter, this is the |