Skip to content

Commit f15a3be

Browse files
authored
Move optimizations from sql to vm (#484)
* Move optimizations from sql to vm * Remove unused method
1 parent e12c26b commit f15a3be

File tree

10 files changed

+423
-332
lines changed

10 files changed

+423
-332
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/core/src/db/datastore/traits.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::execution_context::ExecutionContext;
33
use anyhow::Context;
44
use nonempty::NonEmpty;
55
use spacetimedb_lib::auth::{StAccess, StTableType};
6-
use spacetimedb_lib::relation::{DbTable, FieldName, FieldOnly, Header, TableField};
6+
use spacetimedb_lib::relation::{Column, DbTable, FieldName, FieldOnly, Header, TableField};
77
use spacetimedb_lib::{ColumnIndexAttribute, DataKey, Hash};
88
use spacetimedb_primitives::{ColId, IndexId, SequenceId, TableId};
99
use spacetimedb_sats::product_value::InvalidFieldError;
@@ -249,7 +249,7 @@ impl From<&TableSchema> for ProductType {
249249
impl From<&TableSchema> for SourceExpr {
250250
fn from(value: &TableSchema) -> Self {
251251
SourceExpr::DbTable(DbTable::new(
252-
Header::from_product_type(value.table_name.clone(), value.into()),
252+
value.into(),
253253
value.table_id,
254254
value.table_type,
255255
value.table_access,
@@ -265,7 +265,19 @@ impl From<&TableSchema> for DbTable {
265265

266266
impl From<&TableSchema> for Header {
267267
fn from(value: &TableSchema) -> Self {
268-
Header::from_product_type(value.table_name.clone(), value.into())
268+
Header::new(
269+
value.table_name.clone(),
270+
value
271+
.columns
272+
.iter()
273+
.map(|x| {
274+
let field = FieldName::named(&value.table_name, &x.col_name);
275+
let is_indexed = value.get_index_by_field(&field).is_some();
276+
277+
Column::new(field, x.col_type.clone(), x.col_id, is_indexed)
278+
})
279+
.collect(),
280+
)
269281
}
270282
}
271283

0 commit comments

Comments
 (0)