MCPcopy Create free account
hub / github.com/dfinity/orbit / rebuild

Method rebuild

libs/orbit-essentials/src/repository.rs:52–69  ·  view source on GitHub ↗

This method goes over all the entries and rebuilds the indexes. WARNING: Please only use during upgrades to ensure enough intructions are available.

(&self)

Source from the content-addressed store, hash-verified

50 ///
51 /// WARNING: Please only use during upgrades to ensure enough intructions are available.
52 fn rebuild(&self) {
53 let mut entries = Vec::with_capacity(self.len());
54 Self::with_db(|db| db.iter().for_each(|(_, v)| entries.push(v)));
55
56 // First remove all the indexes.
57 self.clear_indexes();
58
59 // Then clear the repository because the key might have changed for the entries and
60 // we don't want to have dangling entries.
61 Self::with_db(|db| db.clear_new());
62
63 for value in entries {
64 // Then add the updated indexes.
65 self.add_entry_indexes(&value);
66 // Finally, update the entry in the database.
67 Self::with_db(|db| db.insert(value.key(), value));
68 }
69 }
70}
71
72/// A repository is a generic interface for storing and retrieving data.

Callers

nothing calls this directly

Calls 6

iterMethod · 0.80
lenMethod · 0.45
clear_indexesMethod · 0.45
add_entry_indexesMethod · 0.45
insertMethod · 0.45
keyMethod · 0.45

Tested by

no test coverage detected