From 48f12de3277a9765c9c0ee07994ba9e97666e358 Mon Sep 17 00:00:00 2001 From: st1page <1245835950@qq.com> Date: Thu, 10 Mar 2022 20:46:05 +0800 Subject: [PATCH 1/7] rename cell based table instead of row table --- rust/storage/src/lib.rs | 7 ------- .../{row_table.rs => cell_based_table.rs} | 20 +++++++++---------- rust/storage/src/table/mod.rs | 2 +- 3 files changed, 11 insertions(+), 18 deletions(-) rename rust/storage/src/table/{row_table.rs => cell_based_table.rs} (60%) diff --git a/rust/storage/src/lib.rs b/rust/storage/src/lib.rs index 255e57f65bdd..07550b4ced66 100644 --- a/rust/storage/src/lib.rs +++ b/rust/storage/src/lib.rs @@ -48,13 +48,6 @@ use risingwave_common::catalog::ColumnId; pub use store::{StateStore, StateStoreIter}; pub use store_impl::StateStoreImpl; -#[derive(Clone, Debug)] -pub struct IndexDesc { - pub column_id: ColumnId, - pub data_type: DataType, - pub order: OrderType, -} - pub enum TableScanOptions { SequentialScan, SparseIndexScan, diff --git a/rust/storage/src/table/row_table.rs b/rust/storage/src/table/cell_based_table.rs similarity index 60% rename from rust/storage/src/table/row_table.rs rename to rust/storage/src/table/cell_based_table.rs index 0f6fccf74842..fd161c28d051 100644 --- a/rust/storage/src/table/row_table.rs +++ b/rust/storage/src/table/cell_based_table.rs @@ -1,33 +1,33 @@ #![allow(dead_code)] #![allow(unused)] use risingwave_common::array::Row; -use risingwave_common::catalog::{ColumnDesc, ColumnId}; +use risingwave_common::catalog::{ColumnDesc, ColumnId, OrderedColumnDesc}; use risingwave_common::error::Result; use risingwave_common::types::Datum; use risingwave_common::util::ordered::*; use super::TableIter; -use crate::{IndexDesc, Keyspace, StateStore}; +use crate::{Keyspace, StateStore}; -/// `RowTable` is the interface accessing relational data in KV(`StateStore`) with encoding format: -/// [keyspace | pk | `column_id` (4B)] -> value. +/// `CellBasedTable` is the interface accessing relational data in KV(`StateStore`) with encoding +/// format: [keyspace | pk | `column_id` (4B)] -> value. /// if the key of the column id does not exist, it will be Null in the relation -pub struct RowTable { +pub struct CellBasedTable { keyspace: Keyspace, - pk: Vec, + pk: Vec, pk_serializer: OrderedRowSerializer, } -impl RowTable { - pub fn new(keyspace: Keyspace, pk: Vec) -> Self { +impl CellBasedTable { + pub fn new(keyspace: Keyspace, pk: Vec) -> Self { todo!() } - pub async fn get(&self, pk: Row, column: ColumnDesc, epoch: u64) -> Result> { + pub async fn get(&self, pk: Row, column: &ColumnDesc, epoch: u64) -> Result> { todo!() } - pub async fn get_row(&self, pk: Row, columns: Vec, epoch: u64) -> Result { + pub async fn get_row(&self, pk: Row, columns: &[ColumnDesc], epoch: u64) -> Result { todo!() } } diff --git a/rust/storage/src/table/mod.rs b/rust/storage/src/table/mod.rs index 6ea442190ce4..dd154e8927b9 100644 --- a/rust/storage/src/table/mod.rs +++ b/rust/storage/src/table/mod.rs @@ -1,5 +1,5 @@ +pub mod cell_based_table; pub mod mview; -pub mod row_table; use risingwave_common::array::Row; use risingwave_common::error::Result; From 91d94e43bf40b7246d8420c3c7b92ac500c7e36c Mon Sep 17 00:00:00 2001 From: st1page <1245835950@qq.com> Date: Fri, 11 Mar 2022 10:48:50 +0800 Subject: [PATCH 2/7] RowSeqScanExecutorBuilder for new --- rust/batch/src/executor/row_seq_scan.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rust/batch/src/executor/row_seq_scan.rs b/rust/batch/src/executor/row_seq_scan.rs index 03f5bfc29fc5..a363071c9c9c 100644 --- a/rust/batch/src/executor/row_seq_scan.rs +++ b/rust/batch/src/executor/row_seq_scan.rs @@ -66,7 +66,9 @@ impl BoxedExecutorBuilder for RowSeqScanExecutorBuilder { NodeBody::RowSeqScan )?; - let table_id = TableId::from(&seq_scan_node.table_ref_id); + let table_id = TableId { + table_id: seq_scan_node.table_desc.as_ref().unwrap().table_id, + }; let column_descs = seq_scan_node .column_descs .iter() From 75915fb1a8585c275d52e66c60a3ba3f7f497a41 Mon Sep 17 00:00:00 2001 From: st1page <1245835950@qq.com> Date: Fri, 11 Mar 2022 10:49:11 +0800 Subject: [PATCH 3/7] RowSeqScanExecutorBuilder for new --- proto/plan.proto | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proto/plan.proto b/proto/plan.proto index 638aaca857f9..ed30293cb86f 100644 --- a/proto/plan.proto +++ b/proto/plan.proto @@ -48,7 +48,7 @@ message ColumnCatalog { } message CellBasedTableDesc { - int32 table_id = 1; + uint32 table_id = 1; repeated OrderedColumnDesc pk = 2; } @@ -70,7 +70,7 @@ message MaterializedViewInfo { } message RowSeqScanNode { - TableRefId table_ref_id = 1; + CellBasedTableDesc table_desc = 1; repeated ColumnDesc column_descs = 2; } From e85999d388e741c1877ecdd514a636bb44efc643 Mon Sep 17 00:00:00 2001 From: st1page <1245835950@qq.com> Date: Fri, 11 Mar 2022 10:51:19 +0800 Subject: [PATCH 4/7] clippy --- rust/storage/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rust/storage/src/lib.rs b/rust/storage/src/lib.rs index 07550b4ced66..dd81947a7ae6 100644 --- a/rust/storage/src/lib.rs +++ b/rust/storage/src/lib.rs @@ -16,8 +16,8 @@ #![feature(map_first_last)] #![feature(let_chains)] -use risingwave_common::types::DataType; -use risingwave_common::util::sort_util::OrderType; + + pub mod cell_based_row_deserializer; pub mod hummock; @@ -44,7 +44,7 @@ pub mod tikv; pub mod tikv; pub use keyspace::{Keyspace, Segment}; -use risingwave_common::catalog::ColumnId; + pub use store::{StateStore, StateStoreIter}; pub use store_impl::StateStoreImpl; From 5ac5596a75ac9d6e2c7b099ed667eb7abbaaee9e Mon Sep 17 00:00:00 2001 From: st1page <1245835950@qq.com> Date: Fri, 11 Mar 2022 11:02:13 +0800 Subject: [PATCH 5/7] add frontend support in --- .../com/risingwave/planner/rel/physical/RwBatchScan.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/java/planner/src/main/java/com/risingwave/planner/rel/physical/RwBatchScan.java b/java/planner/src/main/java/com/risingwave/planner/rel/physical/RwBatchScan.java index 23dcd53cc375..5b46036e04bf 100644 --- a/java/planner/src/main/java/com/risingwave/planner/rel/physical/RwBatchScan.java +++ b/java/planner/src/main/java/com/risingwave/planner/rel/physical/RwBatchScan.java @@ -5,10 +5,10 @@ import com.risingwave.catalog.TableCatalog; import com.risingwave.planner.rel.common.RwScan; import com.risingwave.planner.rel.common.dist.RwDistributions; +import com.risingwave.proto.plan.CellBasedTableDesc; import com.risingwave.proto.plan.ColumnDesc; import com.risingwave.proto.plan.PlanNode; import com.risingwave.proto.plan.RowSeqScanNode; -import com.risingwave.rpc.Messages; import java.util.Collections; import java.util.List; import org.apache.calcite.plan.RelOptCluster; @@ -56,8 +56,11 @@ public RelNode convertToDistributed() { @Override public PlanNode serialize() { var table = getTable().unwrapOrThrow(TableCatalog.class); - var tableRefId = Messages.getTableRefId(tableId); - var builder = RowSeqScanNode.newBuilder().setTableRefId(tableRefId); + + // FIXME: here should add pk's desc in the table desc. + var builder = + RowSeqScanNode.newBuilder() + .setTableDesc(CellBasedTableDesc.newBuilder().setTableId(tableId.getValue()).build()); columnIds.forEach( c -> { From 441216ffee2f21d6e38bd7f4cd16e5bc199605a8 Mon Sep 17 00:00:00 2001 From: st1page <1245835950@qq.com> Date: Fri, 11 Mar 2022 11:25:57 +0800 Subject: [PATCH 6/7] fix planner test --- .../planner/json/batch/basic/hash_inner_join.json | 12 ++---------- .../risingwave/planner/json/batch/basic/limit.json | 6 +----- .../planner/json/batch/basic/nested_loop_join.json | 12 ++---------- .../planner/json/batch/basic/round_digit.json | 6 +----- .../json/batch/basic/select_less_with_sort_by.json | 6 +----- .../planner/json/batch/basic/select_with_filter.json | 6 +----- .../json/batch/basic/select_with_order_by.json | 6 +----- .../json/batch/basic/select_with_order_by_limit.json | 6 +----- 8 files changed, 10 insertions(+), 50 deletions(-) diff --git a/java/planner/src/test/resources/com/risingwave/planner/json/batch/basic/hash_inner_join.json b/java/planner/src/test/resources/com/risingwave/planner/json/batch/basic/hash_inner_join.json index 89d397f32ef2..fe26d69079c8 100644 --- a/java/planner/src/test/resources/com/risingwave/planner/json/batch/basic/hash_inner_join.json +++ b/java/planner/src/test/resources/com/risingwave/planner/json/batch/basic/hash_inner_join.json @@ -1,11 +1,7 @@ { "children": [{ "rowSeqScan": { - "tableRefId": { - "schemaRefId": { - "databaseRefId": { - } - }, + "tableDesc": { "tableId": 1 }, "columnDescs": [{ @@ -30,11 +26,7 @@ "identity": "RwBatchScan(table\u003d[[test_schema, t]], columns\u003d[v1,v2,v3])" }, { "rowSeqScan": { - "tableRefId": { - "schemaRefId": { - "databaseRefId": { - } - }, + "tableDesc": { "tableId": 5 }, "columnDescs": [{ diff --git a/java/planner/src/test/resources/com/risingwave/planner/json/batch/basic/limit.json b/java/planner/src/test/resources/com/risingwave/planner/json/batch/basic/limit.json index 0d7d14dab7c7..ff28e0de9d70 100644 --- a/java/planner/src/test/resources/com/risingwave/planner/json/batch/basic/limit.json +++ b/java/planner/src/test/resources/com/risingwave/planner/json/batch/basic/limit.json @@ -1,11 +1,7 @@ { "children": [{ "rowSeqScan": { - "tableRefId": { - "schemaRefId": { - "databaseRefId": { - } - }, + "tableDesc": { "tableId": 9 }, "columnDescs": [{ diff --git a/java/planner/src/test/resources/com/risingwave/planner/json/batch/basic/nested_loop_join.json b/java/planner/src/test/resources/com/risingwave/planner/json/batch/basic/nested_loop_join.json index 7663be728672..ee9d8f80a83f 100644 --- a/java/planner/src/test/resources/com/risingwave/planner/json/batch/basic/nested_loop_join.json +++ b/java/planner/src/test/resources/com/risingwave/planner/json/batch/basic/nested_loop_join.json @@ -1,11 +1,7 @@ { "children": [{ "rowSeqScan": { - "tableRefId": { - "schemaRefId": { - "databaseRefId": { - } - }, + "tableDesc": { "tableId": 1 }, "columnDescs": [{ @@ -30,11 +26,7 @@ "identity": "RwBatchScan(table\u003d[[test_schema, t]], columns\u003d[v1,v2,v3])" }, { "rowSeqScan": { - "tableRefId": { - "schemaRefId": { - "databaseRefId": { - } - }, + "tableDesc": { "tableId": 5 }, "columnDescs": [{ diff --git a/java/planner/src/test/resources/com/risingwave/planner/json/batch/basic/round_digit.json b/java/planner/src/test/resources/com/risingwave/planner/json/batch/basic/round_digit.json index a9e152b46441..21044c38f7de 100644 --- a/java/planner/src/test/resources/com/risingwave/planner/json/batch/basic/round_digit.json +++ b/java/planner/src/test/resources/com/risingwave/planner/json/batch/basic/round_digit.json @@ -1,11 +1,7 @@ { "children": [{ "rowSeqScan": { - "tableRefId": { - "schemaRefId": { - "databaseRefId": { - } - }, + "tableDesc": { "tableId": 9 }, "columnDescs": [{ diff --git a/java/planner/src/test/resources/com/risingwave/planner/json/batch/basic/select_less_with_sort_by.json b/java/planner/src/test/resources/com/risingwave/planner/json/batch/basic/select_less_with_sort_by.json index 70b2682203c2..0eca8314bfae 100644 --- a/java/planner/src/test/resources/com/risingwave/planner/json/batch/basic/select_less_with_sort_by.json +++ b/java/planner/src/test/resources/com/risingwave/planner/json/batch/basic/select_less_with_sort_by.json @@ -2,11 +2,7 @@ "children": [{ "children": [{ "rowSeqScan": { - "tableRefId": { - "schemaRefId": { - "databaseRefId": { - } - }, + "tableDesc": { "tableId": 1 }, "columnDescs": [{ diff --git a/java/planner/src/test/resources/com/risingwave/planner/json/batch/basic/select_with_filter.json b/java/planner/src/test/resources/com/risingwave/planner/json/batch/basic/select_with_filter.json index eb6a499e9865..51615dda8996 100644 --- a/java/planner/src/test/resources/com/risingwave/planner/json/batch/basic/select_with_filter.json +++ b/java/planner/src/test/resources/com/risingwave/planner/json/batch/basic/select_with_filter.json @@ -1,11 +1,7 @@ { "children": [{ "rowSeqScan": { - "tableRefId": { - "schemaRefId": { - "databaseRefId": { - } - }, + "tableDesc": { "tableId": 1 }, "columnDescs": [{ diff --git a/java/planner/src/test/resources/com/risingwave/planner/json/batch/basic/select_with_order_by.json b/java/planner/src/test/resources/com/risingwave/planner/json/batch/basic/select_with_order_by.json index 651ccb8e5405..e71d9a8d165e 100644 --- a/java/planner/src/test/resources/com/risingwave/planner/json/batch/basic/select_with_order_by.json +++ b/java/planner/src/test/resources/com/risingwave/planner/json/batch/basic/select_with_order_by.json @@ -1,11 +1,7 @@ { "children": [{ "rowSeqScan": { - "tableRefId": { - "schemaRefId": { - "databaseRefId": { - } - }, + "tableDesc": { "tableId": 1 }, "columnDescs": [{ diff --git a/java/planner/src/test/resources/com/risingwave/planner/json/batch/basic/select_with_order_by_limit.json b/java/planner/src/test/resources/com/risingwave/planner/json/batch/basic/select_with_order_by_limit.json index e91653ce1122..11659eb692be 100644 --- a/java/planner/src/test/resources/com/risingwave/planner/json/batch/basic/select_with_order_by_limit.json +++ b/java/planner/src/test/resources/com/risingwave/planner/json/batch/basic/select_with_order_by_limit.json @@ -1,11 +1,7 @@ { "children": [{ "rowSeqScan": { - "tableRefId": { - "schemaRefId": { - "databaseRefId": { - } - }, + "tableDesc": { "tableId": 1 }, "columnDescs": [{ From 06fd29386ff0a70a802215c1a8c8c68d4fd3d534 Mon Sep 17 00:00:00 2001 From: st1page <1245835950@qq.com> Date: Fri, 11 Mar 2022 11:55:19 +0800 Subject: [PATCH 7/7] fmt --- rust/storage/src/lib.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/rust/storage/src/lib.rs b/rust/storage/src/lib.rs index dd81947a7ae6..ded66e387b2f 100644 --- a/rust/storage/src/lib.rs +++ b/rust/storage/src/lib.rs @@ -16,9 +16,6 @@ #![feature(map_first_last)] #![feature(let_chains)] - - - pub mod cell_based_row_deserializer; pub mod hummock; pub mod keyspace; @@ -44,7 +41,6 @@ pub mod tikv; pub mod tikv; pub use keyspace::{Keyspace, Segment}; - pub use store::{StateStore, StateStoreIter}; pub use store_impl::StateStoreImpl;