-
Notifications
You must be signed in to change notification settings - Fork 109
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
Refactoring IDs for system objects #439
Conversation
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.
Some more ideas on how to further split this PR.
c8e3f98
to
504a1ef
Compare
22a4523
to
0021da4
Compare
crates/core/src/db/datastore/locking_tx_datastore/btree_index.rs
Outdated
Show resolved
Hide resolved
0021da4
to
7dba4dc
Compare
7dba4dc
to
b0d8b18
Compare
b0d8b18
to
1cee02c
Compare
ef2f883
to
2813cef
Compare
4b04100
to
aa3bdc3
Compare
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'm worried about the number of seemingly stray kind-constraint find and replace changes.
@@ -12,7 +12,7 @@ use std::{ | |||
hint::black_box, | |||
sync::{Arc, RwLock}, | |||
}; | |||
use tempfile::TempDir; | |||
use tempdir::TempDir; |
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.
Don't change it at this point, but why did this change in this PR?
crates/core/src/db/commit_log.rs
Outdated
@@ -248,7 +245,7 @@ impl CommitLogView { | |||
/// the transactions in a [`Commit`]. | |||
/// | |||
/// The iterator attempts to read each large object in turn, yielding an | |||
/// [`io::Error`] with kind [`io::ErrorKind::NotFound`] if the object was | |||
/// [`io::Error`] with constraints [`io::ErrorKind::NotFound`] if the object was |
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.
Was this a stray find-and-replace change? It reads oddly now.
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.
You are right. I make a wrong refactor.
@@ -223,7 +223,7 @@ pub trait MutTxDatastore: TxDatastore + MutTx { | |||
|
|||
/// Describes a programmable [`TxDatastore`]. | |||
/// | |||
/// A programmable datastore is one which has a program of some kind associated | |||
/// A programmable datastore is one which has a program of some constraints associated |
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.
Ditto on the find-and-replace in a comment.
crates/core/src/db/relational_db.rs
Outdated
@@ -477,7 +467,7 @@ impl RelationalDB { | |||
/// | |||
/// NOTE: It loads the data from the table into it before returning | |||
#[tracing::instrument(skip(self, tx, index), fields(index=index.name))] | |||
pub fn create_index(&self, tx: &mut MutTxId, index: IndexDef) -> Result<IndexId, DBError> { | |||
pub fn create_index(&self, tx: &mut MutTxId, table_id: TableId, index: IndexDef) -> Result<IndexId, DBError> { |
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.
Why is table_id
plumbed through but not used? Does it get used in #267 ?
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.
Correct. I will remove this change because if is not used is pointless here.
"table_id", TableId = 3, | ||
"columns", Columns = 4, | ||
}); | ||
// WARNING: For a stable schema, don't change the field names and discriminants. | ||
st_fields_enum!(enum StModuleFields { | ||
"program_hash", ProgramHash = 0, | ||
"kind", Kind = 1, | ||
"constraints", Kind = 1, |
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.
It's a bit odd that this one did not change both, but the equivalent in StConstraintsFields
did. But maybe that's an artifact of the split from #267?
@@ -945,7 +941,7 @@ pub struct ModuleKind(u8); | |||
|
|||
/// The [`ModuleKind`] of WASM-based modules. | |||
/// | |||
/// This is currently the only known kind. | |||
/// This is currently the only known constraints. |
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.
Another constraint-kind doc comment change?
x.table_id, | ||
ArrayValue::from(cols) | ||
] | ||
} | ||
} | ||
|
||
/// Indicates the kind of module the `program_hash` of a [`StModuleRow`] | ||
/// Indicates the constraints of module the `program_hash` of a [`StModuleRow`] |
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.
Ditto. I'm a bit concerned about these.
@@ -503,7 +505,7 @@ impl Inner { | |||
is_unique: false, | |||
index_type: IndexType::BTree, | |||
}, | |||
x => panic!("Adding constraint of kind `{x:?}` is not supported yet."), | |||
x => panic!("Adding constraint of constraints `{x:?}` is not supported yet."), |
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.
Yet another.
crates/bindings/src/lib.rs
Outdated
@@ -13,22 +13,22 @@ mod timestamp; | |||
use crate::sats::db::def::IndexType; | |||
use spacetimedb_lib::buffer::{BufReader, BufWriter, Cursor, DecodeError}; | |||
use spacetimedb_lib::sats::{impl_deserialize, impl_serialize, impl_st}; | |||
pub use spacetimedb_lib::ser::Serialize; |
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.
This looks out of place. It should at least be with the other pub use
entries.
@@ -343,24 +332,118 @@ impl From<&ColumnSchema> for ProductTypeElement { | |||
#[derive(Clone)] | |||
pub struct ColumnDefMeta { | |||
pub column: ProductTypeElement, | |||
pub attr: ColumnIndexAttribute, | |||
pub attr: Constraints, |
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.
Nit: should this field be named constraints
now?
#[derive(Debug, Clone, Eq, PartialEq, PartialOrd, Ord)] | ||
pub struct ProductTypeMeta { | ||
pub columns: ProductType, | ||
pub attr: Vec<Constraints>, |
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.
Nit: should this field be named constraints
now?
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.
This will be gone it the last PR, and for now attr
is more correct because is for the column, not the table.
Also, my approval is assuming the chat discussion about autoinc sematics etc is agreed to be good |
d678943
to
9cd06cd
Compare
9cd06cd
to
b11669d
Compare
Description of Changes
Note: This is a multi-step set of PRs to bring constraints + multi-column indexes
Step:
This PR is to simplify the review of #267. It only have the movement of schema objects and the use of
newtypes
for system objects.API and ABI
If the API is breaking, please state below what will break