Creates a new table instance and registers it in the AnchorContext's table_instances HashMap. Also generates new IDs and names for columns as needed.
(
&mut self,
table_ref: TableRef,
cid_redirects: HashMap<CId, CId>,
)
| 148 | /// table_instances HashMap. Also generates new IDs and names for columns |
| 149 | /// as needed. |
| 150 | pub fn create_relation_instance( |
| 151 | &mut self, |
| 152 | table_ref: TableRef, |
| 153 | cid_redirects: HashMap<CId, CId>, |
| 154 | ) -> RIId { |
| 155 | let riid = self.riid.gen(); |
| 156 | |
| 157 | for (col, cid) in &table_ref.columns { |
| 158 | let def = ColumnDecl::RelationColumn(riid, *cid, col.clone()); |
| 159 | self.column_decls.insert(*cid, def); |
| 160 | } |
| 161 | |
| 162 | let original_cids = table_ref.columns.iter().map(|(_, c)| *c).collect(); |
| 163 | let relation_instance = RelationInstance { |
| 164 | table_ref, |
| 165 | cid_redirects, |
| 166 | original_cids, |
| 167 | }; |
| 168 | |
| 169 | self.relation_instances.insert(riid, relation_instance); |
| 170 | riid |
| 171 | } |
| 172 | |
| 173 | /// Returns the name of a column if it has been given a name already, or generates |
| 174 | /// a new name for it and registers it in the AnchorContext's column_names HashMap. |