Skip to content

Commit

Permalink
Move optimizations from sql to vm (#484)
Browse files Browse the repository at this point in the history
* Move optimizations from sql to vm

* Remove unused method
  • Loading branch information
mamcx authored Oct 30, 2023
1 parent e12c26b commit f15a3be
Show file tree
Hide file tree
Showing 10 changed files with 423 additions and 332 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 15 additions & 3 deletions crates/core/src/db/datastore/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::execution_context::ExecutionContext;
use anyhow::Context;
use nonempty::NonEmpty;
use spacetimedb_lib::auth::{StAccess, StTableType};
use spacetimedb_lib::relation::{DbTable, FieldName, FieldOnly, Header, TableField};
use spacetimedb_lib::relation::{Column, DbTable, FieldName, FieldOnly, Header, TableField};
use spacetimedb_lib::{ColumnIndexAttribute, DataKey, Hash};
use spacetimedb_primitives::{ColId, IndexId, SequenceId, TableId};
use spacetimedb_sats::product_value::InvalidFieldError;
Expand Down Expand Up @@ -249,7 +249,7 @@ impl From<&TableSchema> for ProductType {
impl From<&TableSchema> for SourceExpr {
fn from(value: &TableSchema) -> Self {
SourceExpr::DbTable(DbTable::new(
Header::from_product_type(value.table_name.clone(), value.into()),
value.into(),
value.table_id,
value.table_type,
value.table_access,
Expand All @@ -265,7 +265,19 @@ impl From<&TableSchema> for DbTable {

impl From<&TableSchema> for Header {
fn from(value: &TableSchema) -> Self {
Header::from_product_type(value.table_name.clone(), value.into())
Header::new(
value.table_name.clone(),
value
.columns
.iter()
.map(|x| {
let field = FieldName::named(&value.table_name, &x.col_name);
let is_indexed = value.get_index_by_field(&field).is_some();

Column::new(field, x.col_type.clone(), x.col_id, is_indexed)
})
.collect(),
)
}
}

Expand Down
Loading

1 comment on commit f15a3be

@github-actions
Copy link

@github-actions github-actions bot commented on f15a3be Oct 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmarking failed. Please check the workflow run for details.

Please sign in to comment.