-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Misc datastore cleanups & less cloning #1263
Conversation
pub(crate) const ST_TABLES_IDX: usize = 0; | ||
pub(crate) const ST_COLUMNS_IDX: usize = 1; | ||
pub(crate) const ST_INDEXES_IDX: usize = 2; | ||
pub(crate) const ST_CONSTRAINTS_IDX: usize = 3; | ||
pub(crate) const ST_MODULE_IDX: usize = 4; | ||
pub(crate) const ST_SEQUENCES_IDX: usize = 5; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should correspond to the indices in the array in system_tables()
above.
fn table_exists(&self, table_id: &TableId) -> Option<&str> { | ||
self.committed_state_shared_lock.table_exists(table_id) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now a provided function defined via get_schema
.
fn table_name(&self, table_id: TableId) -> Option<&str> { | ||
self.get_schema(table_id).map(|s| &*s.table_name) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Said provided definition.
fn table_exists(&self, table_id: &TableId) -> Option<&str> { | ||
// TODO(bikeshedding, docs): should this also check if the schema is in the system tables, | ||
// but the table hasn't been constructed yet? | ||
// If not, document why. | ||
self.tx_state | ||
.insert_tables | ||
.get(table_id) | ||
.or_else(|| self.committed_state_write_lock.tables.get(table_id)) | ||
.map(|table| &*table.schema.table_name) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the provided definition.
fn table_exists(&self, table_id: &TableId) -> Option<&str> { | ||
self.tables.get(table_id).map(|t| &*t.schema.table_name) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
provided def.
let schemas = system_tables().map(Arc::new); | ||
let ref_schemas = schemas.each_ref().map(|s| &**s); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We immediately Arc
all the system tables and then get out &TableSchema
for use as needed. We refer to all system tables by index rather than recreating them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I extensively checked for system_table and related schema changes, Looks fine to me.
5e1aa59
to
df8b241
Compare
2. Only call system_tables() once in bootstrap_system_tables. 3. Take `TableId` by value more 4. Rename `table_exists` -> `table_name` 5. Dedup `table_name` by using `get_schema()`. 6. Other misc deduping.
df8b241
to
8a6241a
Compare
Description of Changes
st_*_schema
functions, only used in system_tables() now.system_tables()
once inbootstrap_system_tables
. EagerlyArc
those and then clone as little as possible.TableId
by value moretable_exists
->table_name
table_name
by usingget_schema()
.API and ABI breaking changes
None
Expected complexity level and risk
2, touches some system table code but in a fairly small way.
Still, be sure to double check
ST_TABLES_IDX
and thebootstrap_system_tables
changes.