Open or create a pristine database at the given path This will create all necessary tables if they don't exist.
(path: P)
| 118 | /// |
| 119 | /// This will create all necessary tables if they don't exist. |
| 120 | pub fn open<P: AsRef<Path>>(path: P) -> PristineResult<Self> { |
| 121 | // Use 8 GB cache for machines with plenty of RAM. The default |
| 122 | // redb cache is 1 GB which causes excessive page eviction when |
| 123 | // the GRAPH table grows beyond that during large imports. |
| 124 | let cache_bytes = 8 * 1024 * 1024 * 1024; // 8 GiB |
| 125 | let db = open_database(path.as_ref(), true, cache_bytes)?; |
| 126 | |
| 127 | // Initialize all tables |
| 128 | let write_txn = db.begin_write()?; |
| 129 | { |
| 130 | // ID mapping tables |
| 131 | write_txn.open_table(EXTERNAL)?; |
| 132 | write_txn.open_table(INTERNAL)?; |
| 133 | write_txn.open_table(NODE_TYPES)?; |
| 134 | |
| 135 | // Graph tables |
| 136 | write_txn.open_multimap_table(GRAPH)?; |
| 137 | write_txn.open_multimap_table(INODE_GRAPH)?; |
| 138 | |
| 139 | // View tables |
| 140 | write_txn.open_table(VIEWS)?; |
| 141 | write_txn.open_table(VIEW_CHANGES)?; |
| 142 | write_txn.open_table(REV_VIEW_CHANGES)?; |
| 143 | write_txn.open_table(CONFLICTS)?; |
| 144 | |
| 145 | // Tree tables |
| 146 | write_txn.open_table(TREE)?; |
| 147 | write_txn.open_table(REV_TREE)?; |
| 148 | write_txn.open_table(INODES)?; |
| 149 | write_txn.open_table(REV_INODES)?; |
| 150 | write_txn.open_table(DIRECTORIES)?; |
| 151 | |
| 152 | // File index cache (mtime + size + content hash for fast status detection) |
| 153 | write_txn.open_table(FILE_INDEX)?; |
| 154 | |
| 155 | // Dependency tables |
| 156 | write_txn.open_multimap_table(DEPS)?; |
| 157 | write_txn.open_multimap_table(REV_DEPS)?; |
| 158 | write_txn.open_multimap_table(CHANGE_DEPS)?; |
| 159 | write_txn.open_multimap_table(REV_CHANGE_DEPS)?; |
| 160 | write_txn.open_table(CHANGE_DEPS_INDEXED)?; |
| 161 | |
| 162 | // State tables |
| 163 | write_txn.open_table(STATES)?; |
| 164 | write_txn.open_table(MERKLE_CHAIN)?; |
| 165 | |
| 166 | // Tag record tables |
| 167 | write_txn.open_table(TAG_RECORDS)?; |
| 168 | write_txn.open_table(TAG_NAME_INDEX)?; |
| 169 | |
| 170 | // Git SHA index (git commit SHA → entity_id) |
| 171 | write_txn.open_table(GIT_SHA_INDEX)?; |
| 172 | |
| 173 | // Session tables (provenance-derived session data, any agent) |
| 174 | write_txn.open_table(SESSION_EVENTS)?; |
| 175 | write_txn.open_table(SESSION_TODOS)?; |
| 176 | write_txn.open_table(SESSION_PHASES)?; |
| 177 | write_txn.open_table(SESSION_INTENTS)?; |
no test coverage detected