Combine `VolatileCatalog` and `Cluster`
Describe This Problem
Reference to #235:
Clusteris responsible to manageTables andShards whileCatalogis responsible to manageSchemas which is a group of tables in another perspective different fromShard. Their functionalities have a big part that overlaps. It's natural to implement bothClusterandCatalogtraits over one struct, so they can use one memory state and maybe one operation logic.
Proposal
-
[ ] Make a triple to act as
TableRef's full identifier(token)struct TableToken { catalog: CatalogId, schema: SchemaId, table: TableId, }We currently use the three layers separately: first get a
Cataloginstance, and getSchemainstance from it, then getTableinstance. And the storage needs a nested map struct to put all this infos. The entire procedure can be simplified. -
[ ] Remove
CatalogManagerandSchemaManagerto reduce the complexity and simplify interfaces. Now only keep a top-levelManagerand low-levelTableManagerFollows the above description.
CatalogManagerandSchemaManager's interfaces are redundant in some sorts. -
[x] Manage all the
TableRefin one place, here isTableManagerinsidesCluster#260The one who keeps all
TableRefshould be able to serve two requests:- get tables by shard
- get tables by catalog/schema/table
the fields in
TableManagermay look likestruct TableManager { // ... tables: BTreeMap<TableToken, TableRef>, shards: HashMap<ShardId, HashSet<TableToken>>, }
Additional Context
- [ ] (optional) Unify the name and id. Like
SchemaNameandSchemaIdenum CatalogToken{ Id(CatalogId), Name(String) }