Skip to content
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

chore: remove useless cluster_version #804

Merged
merged 1 commit into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions analytic_engine/src/instance/open.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 CeresDB Project Authors. Licensed under Apache-2.0.
// Copyright 2022-2023 CeresDB Project Authors. Licensed under Apache-2.0.

//! Open logic of instance

Expand Down Expand Up @@ -291,7 +291,6 @@ impl Instance {
&self.file_purger,
space.mem_usage_collector.clone(),
request.shard_id,
request.cluster_version,
)
.context(RecoverTableData {
space_id: table_meta.space_id,
Expand Down
13 changes: 2 additions & 11 deletions analytic_engine/src/manifest/details.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 CeresDB Project Authors. Licensed under Apache-2.0.
// Copyright 2022-2023 CeresDB Project Authors. Licensed under Apache-2.0.

//! Implementation of Manifest

Expand Down Expand Up @@ -691,11 +691,7 @@ mod tests {

use bytes::Bytes;
use common_types::{
column_schema,
datum::DatumKind,
schema,
schema::Schema,
table::{DEFAULT_CLUSTER_VERSION, DEFAULT_SHARD_ID},
column_schema, datum::DatumKind, schema, schema::Schema, table::DEFAULT_SHARD_ID,
};
use common_util::{runtime, runtime::Runtime, tests::init_log_for_test};
use futures::future::BoxFuture;
Expand Down Expand Up @@ -908,7 +904,6 @@ mod tests {
) {
let shard_info = TableShardInfo {
shard_id: DEFAULT_SHARD_ID,
cluster_version: DEFAULT_CLUSTER_VERSION,
};

let add_table =
Expand All @@ -932,7 +927,6 @@ mod tests {
) {
let shard_info = TableShardInfo {
shard_id: DEFAULT_SHARD_ID,
cluster_version: DEFAULT_CLUSTER_VERSION,
};

let drop_table = self.meta_update_drop_table(table_id);
Expand All @@ -955,7 +949,6 @@ mod tests {
) {
let shard_info = TableShardInfo {
shard_id: DEFAULT_SHARD_ID,
cluster_version: DEFAULT_CLUSTER_VERSION,
};

let version_edit = self.meta_update_version_edit(table_id, flushed_seq);
Expand Down Expand Up @@ -1009,7 +1002,6 @@ mod tests {

let shard_info = TableShardInfo {
shard_id: DEFAULT_SHARD_ID,
cluster_version: DEFAULT_CLUSTER_VERSION,
};

let alter_options = self.meta_update_alter_table_options(table_id);
Expand All @@ -1032,7 +1024,6 @@ mod tests {

let shard_info = TableShardInfo {
shard_id: DEFAULT_SHARD_ID,
cluster_version: DEFAULT_CLUSTER_VERSION,
};

let alter_schema = self.meta_update_alter_table_schema(table_id);
Expand Down
37 changes: 8 additions & 29 deletions analytic_engine/src/table/data.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 CeresDB Project Authors. Licensed under Apache-2.0.
// Copyright 2022-2023 CeresDB Project Authors. Licensed under Apache-2.0.

//! Table data

Expand All @@ -19,7 +19,7 @@ use arena::CollectorRef;
use common_types::{
self,
schema::{Schema, Version},
table::{ClusterVersion, ShardId},
table::ShardId,
time::{TimeRange, Timestamp},
SequenceNumber,
};
Expand Down Expand Up @@ -78,15 +78,11 @@ pub type MemTableId = u64;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct TableShardInfo {
pub shard_id: ShardId,
pub cluster_version: ClusterVersion,
}

impl TableShardInfo {
pub fn new(shard_id: ShardId, cluster_version: ClusterVersion) -> Self {
Self {
shard_id,
cluster_version,
}
pub fn new(shard_id: ShardId) -> Self {
Self { shard_id }
}
}

Expand Down Expand Up @@ -222,7 +218,7 @@ impl TableData {
last_flush_time_ms: AtomicU64::new(0),
dropped: AtomicBool::new(false),
metrics,
shard_info: TableShardInfo::new(request.shard_id, request.cluster_version),
shard_info: TableShardInfo::new(request.shard_id),
partition_info: request.partition_info,
})
}
Expand All @@ -236,7 +232,6 @@ impl TableData {
purger: &FilePurger,
mem_usage_collector: CollectorRef,
shard_id: ShardId,
cluster_version: ClusterVersion,
) -> Result<Self> {
let memtable_factory = Arc::new(SkiplistMemTableFactory);
let purge_queue = purger.create_purge_queue(add_meta.space_id, add_meta.table_id);
Expand All @@ -260,7 +255,7 @@ impl TableData {
last_flush_time_ms: AtomicU64::new(0),
dropped: AtomicBool::new(false),
metrics,
shard_info: TableShardInfo::new(shard_id, cluster_version),
shard_info: TableShardInfo::new(shard_id),
partition_info: add_meta.partition_info,
})
}
Expand Down Expand Up @@ -598,10 +593,7 @@ pub mod tests {
use std::sync::Arc;

use arena::NoopCollector;
use common_types::{
datum::DatumKind,
table::{DEFAULT_CLUSTER_VERSION, DEFAULT_SHARD_ID},
};
use common_types::{datum::DatumKind, table::DEFAULT_SHARD_ID};
use common_util::config::ReadableDuration;
use table_engine::{engine::TableState, table::SchemaId};

Expand Down Expand Up @@ -647,7 +639,6 @@ pub mod tests {
table_id: TableId,
table_name: String,
shard_id: ShardId,
cluster_version: ClusterVersion,
write_handle: Option<WriteHandle>,
}

Expand All @@ -667,11 +658,6 @@ pub mod tests {
self
}

pub fn cluster_version(mut self, cluster_version: ClusterVersion) -> Self {
self.cluster_version = cluster_version;
self
}

pub fn write_handle(mut self, write_handle: WriteHandle) -> Self {
self.write_handle = Some(write_handle);
self
Expand All @@ -691,7 +677,6 @@ pub mod tests {
options: HashMap::new(),
state: TableState::Stable,
shard_id: self.shard_id,
cluster_version: self.cluster_version,
partition_info: None,
};

Expand Down Expand Up @@ -721,7 +706,6 @@ pub mod tests {
table_id: table::new_table_id(2, 1),
table_name: "mocked_table".to_string(),
shard_id: DEFAULT_SHARD_ID,
cluster_version: DEFAULT_CLUSTER_VERSION,
write_handle: None,
}
}
Expand All @@ -732,20 +716,15 @@ pub mod tests {
let table_id = table::new_table_id(100, 30);
let table_name = "new_table".to_string();
let shard_id = 42;
let cluster_version = 1;
let table_data = TableDataMocker::default()
.table_id(table_id)
.table_name(table_name.clone())
.shard_id(shard_id)
.cluster_version(cluster_version)
.build();

assert_eq!(table_id, table_data.id);
assert_eq!(table_name, table_data.name);
assert_eq!(
TableShardInfo::new(shard_id, cluster_version),
table_data.shard_info
);
assert_eq!(TableShardInfo::new(shard_id), table_data.shard_info);
assert_eq!(0, table_data.last_sequence());
assert!(!table_data.is_dropped());
assert_eq!(0, table_data.last_file_id());
Expand Down
5 changes: 2 additions & 3 deletions analytic_engine/src/tests/table.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 CeresDB Project Authors. Licensed under Apache-2.0.
// Copyright 2022-2023 CeresDB Project Authors. Licensed under Apache-2.0.

//! Utils to create table.

Expand All @@ -12,7 +12,7 @@ use common_types::{
request_id::RequestId,
row::{Row, RowGroup, RowGroupBuilder},
schema::{self, Schema},
table::{DEFAULT_CLUSTER_VERSION, DEFAULT_SHARD_ID},
table::DEFAULT_SHARD_ID,
time::Timestamp,
};
use common_util::config::ReadableDuration;
Expand Down Expand Up @@ -312,7 +312,6 @@ impl Default for Builder {
options: HashMap::new(),
state: TableState::Stable,
shard_id: DEFAULT_SHARD_ID,
cluster_version: DEFAULT_CLUSTER_VERSION,
},
}
}
Expand Down
6 changes: 2 additions & 4 deletions analytic_engine/src/tests/util.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 CeresDB Project Authors. Licensed under Apache-2.0.
// Copyright 2022-2023 CeresDB Project Authors. Licensed under Apache-2.0.

//! Test utils.

Expand All @@ -8,7 +8,7 @@ use common_types::{
datum::Datum,
record_batch::RecordBatch,
row::{Row, RowGroup},
table::{DEFAULT_CLUSTER_VERSION, DEFAULT_SHARD_ID},
table::DEFAULT_SHARD_ID,
time::Timestamp,
};
use common_util::{
Expand Down Expand Up @@ -186,7 +186,6 @@ impl<T: WalsOpener> TestContext<T> {
table_id,
engine: table_engine::ANALYTIC_ENGINE_TYPE.to_string(),
shard_id: DEFAULT_SHARD_ID,
cluster_version: DEFAULT_CLUSTER_VERSION,
})
.await
.unwrap()
Expand All @@ -210,7 +209,6 @@ impl<T: WalsOpener> TestContext<T> {
table_id,
engine: table_engine::ANALYTIC_ENGINE_TYPE.to_string(),
shard_id: DEFAULT_SHARD_ID,
cluster_version: DEFAULT_CLUSTER_VERSION,
})
.await?;

Expand Down
10 changes: 2 additions & 8 deletions catalog/src/schema.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
// Copyright 2022 CeresDB Project Authors. Licensed under Apache-2.0.
// Copyright 2022-2023 CeresDB Project Authors. Licensed under Apache-2.0.

//! Schema contains one or more tables

use std::{collections::HashMap, sync::Arc};

use async_trait::async_trait;
use common_types::{
column_schema::ColumnSchema,
table::{ClusterVersion, ShardId},
};
use common_types::{column_schema::ColumnSchema, table::ShardId};
use common_util::error::GenericError;
use snafu::{Backtrace, Snafu};
use table_engine::{
Expand Down Expand Up @@ -206,8 +203,6 @@ pub struct CreateTableRequest {
pub state: TableState,
/// Shard id of the table
pub shard_id: ShardId,
/// Cluster version of shard
pub cluster_version: ClusterVersion,
/// Partition info if this is a partitioned table
pub partition_info: Option<PartitionInfo>,
}
Expand All @@ -225,7 +220,6 @@ impl CreateTableRequest {
options: self.options,
state: self.state,
shard_id: self.shard_id,
cluster_version: self.cluster_version,
partition_info: self.partition_info,
}
}
Expand Down
5 changes: 2 additions & 3 deletions catalog_impls/src/table_based.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 CeresDB Project Authors. Licensed under Apache-2.0.
// Copyright 2022-2023 CeresDB Project Authors. Licensed under Apache-2.0.

//! Table based catalog implementation

Expand Down Expand Up @@ -911,7 +911,7 @@ mod tests {
manager::Manager,
schema::{CreateOptions, CreateTableRequest, DropOptions, DropTableRequest, SchemaRef},
};
use common_types::table::{DEFAULT_CLUSTER_VERSION, DEFAULT_SHARD_ID};
use common_types::table::DEFAULT_SHARD_ID;
use table_engine::{
engine::{TableEngineRef, TableState},
memory::MemoryTableEngine,
Expand Down Expand Up @@ -955,7 +955,6 @@ mod tests {
options: HashMap::new(),
state: TableState::Stable,
shard_id: DEFAULT_SHARD_ID,
cluster_version: DEFAULT_CLUSTER_VERSION,
partition_info: None,
}
}
Expand Down
4 changes: 1 addition & 3 deletions common_types/src/table.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// Copyright 2022 CeresDB Project Authors. Licensed under Apache-2.0.
// Copyright 2022-2023 CeresDB Project Authors. Licensed under Apache-2.0.

pub type TableId = u64;
pub type TableName = String;
pub type ShardId = u32;
pub type ShardVersion = u64;
pub type ClusterVersion = u64;
pub const DEFAULT_SHARD_ID: u32 = 0;
pub const DEFAULT_SHARD_VERSION: u64 = 0;
pub const DEFAULT_CLUSTER_VERSION: u64 = 0;
5 changes: 2 additions & 3 deletions interpreters/src/table_manipulator/catalog_based.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright 2022 CeresDB Project Authors. Licensed under Apache-2.0.
// Copyright 2022-2023 CeresDB Project Authors. Licensed under Apache-2.0.

use async_trait::async_trait;
use catalog::{
manager::ManagerRef,
schema::{CreateOptions, CreateTableRequest, DropOptions, DropTableRequest},
};
use common_types::table::{DEFAULT_CLUSTER_VERSION, DEFAULT_SHARD_ID};
use common_types::table::DEFAULT_SHARD_ID;
use log::warn;
use snafu::{ensure, OptionExt, ResultExt};
use sql::plan::{CreateTablePlan, DropTablePlan};
Expand Down Expand Up @@ -82,7 +82,6 @@ impl TableManipulator for TableManipulatorImpl {
options,
state: TableState::Stable,
shard_id: DEFAULT_SHARD_ID,
cluster_version: DEFAULT_CLUSTER_VERSION,
partition_info: None,
};

Expand Down
Loading