Skip to content

Commit ed090a0

Browse files
authored
Merge pull request #7558 from lichuang/add_table_stage_file_meta
feat: save table stage file info into meta, remove these data when truncate table
2 parents 8d1d931 + d1cf75c commit ed090a0

File tree

19 files changed

+947
-91
lines changed

19 files changed

+947
-91
lines changed

src/meta/api/src/kv_api_key.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ pub enum KVApiKeyError {
3030
#[error("Expect {expect} segments, but: '{got}'")]
3131
WrongNumberOfSegments { expect: usize, got: String },
3232

33+
#[error("Expect at least {expect} segments, but {actual} segments found")]
34+
AtleastSegments { expect: usize, actual: usize },
35+
3336
#[error("Invalid id string: '{s}': {reason}")]
3437
InvalidId { s: String, reason: String },
3538
}

src/meta/api/src/kv_api_test_suite.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ impl KVApiTestSuite {
483483
key: txn_key.clone(),
484484
value: b"new_v1".to_vec(),
485485
prev_value: true,
486+
expire_at: None,
486487
})),
487488
}];
488489

@@ -640,6 +641,7 @@ impl KVApiTestSuite {
640641
key: txn_key.clone(),
641642
value: b"new_v1".to_vec(),
642643
prev_value: true,
644+
expire_at: None,
643645
})),
644646
}];
645647

@@ -691,6 +693,7 @@ impl KVApiTestSuite {
691693
key: txn_key1.clone(),
692694
value: b"new_v1".to_vec(),
693695
prev_value: true,
696+
expire_at: None,
694697
})),
695698
}];
696699

@@ -745,6 +748,7 @@ impl KVApiTestSuite {
745748
key: txn_key1.clone(),
746749
value: val1_new.to_vec(),
747750
prev_value: true,
751+
expire_at: None,
748752
})),
749753
},
750754
// change k2
@@ -753,6 +757,7 @@ impl KVApiTestSuite {
753757
key: txn_key2.clone(),
754758
value: b"new_v2".to_vec(),
755759
prev_value: true,
760+
expire_at: None,
756761
})),
757762
},
758763
// get k1
@@ -852,6 +857,7 @@ impl KVApiTestSuite {
852857
key: txn_key1.clone(),
853858
value: val1_new.to_vec(),
854859
prev_value: true,
860+
expire_at: None,
855861
})),
856862
},
857863
// get k1

src/meta/api/src/kv_api_utils.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,18 @@ pub fn txn_op_put(key: &impl KVApiKey, value: Vec<u8>) -> TxnOp {
226226
key: key.to_key(),
227227
value,
228228
prev_value: true,
229+
expire_at: None,
230+
})),
231+
}
232+
}
233+
234+
pub fn txn_op_put_with_expire(key: &impl KVApiKey, value: Vec<u8>, expire_at: u64) -> TxnOp {
235+
TxnOp {
236+
request: Some(Request::Put(TxnPutRequest {
237+
key: key.to_key(),
238+
value,
239+
prev_value: true,
240+
expire_at: Some(expire_at),
229241
})),
230242
}
231243
}

src/meta/api/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ pub use kv_api_utils::table_has_to_exist;
6464
pub use kv_api_utils::txn_cond_seq;
6565
pub use kv_api_utils::txn_op_del;
6666
pub use kv_api_utils::txn_op_put;
67+
pub use kv_api_utils::txn_op_put_with_expire;
6768
pub use kv_api_utils::TXN_MAX_RETRY_TIMES;
6869
pub use schema_api::SchemaApi;
6970
pub(crate) use schema_api_impl::get_db_or_err;

src/meta/api/src/schema_api.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ use common_meta_app::schema::DropDatabaseReq;
2626
use common_meta_app::schema::DropTableReply;
2727
use common_meta_app::schema::DropTableReq;
2828
use common_meta_app::schema::GetDatabaseReq;
29+
use common_meta_app::schema::GetTableCopiedFileReply;
30+
use common_meta_app::schema::GetTableCopiedFileReq;
2931
use common_meta_app::schema::GetTableReq;
3032
use common_meta_app::schema::ListDatabaseReq;
3133
use common_meta_app::schema::ListTableReq;
@@ -36,12 +38,16 @@ use common_meta_app::schema::RenameTableReq;
3638
use common_meta_app::schema::TableIdent;
3739
use common_meta_app::schema::TableInfo;
3840
use common_meta_app::schema::TableMeta;
41+
use common_meta_app::schema::TruncateTableReply;
42+
use common_meta_app::schema::TruncateTableReq;
3943
use common_meta_app::schema::UndropDatabaseReply;
4044
use common_meta_app::schema::UndropDatabaseReq;
4145
use common_meta_app::schema::UndropTableReply;
4246
use common_meta_app::schema::UndropTableReq;
4347
use common_meta_app::schema::UpdateTableMetaReply;
4448
use common_meta_app::schema::UpdateTableMetaReq;
49+
use common_meta_app::schema::UpsertTableCopiedFileReply;
50+
use common_meta_app::schema::UpsertTableCopiedFileReq;
4551
use common_meta_app::schema::UpsertTableOptionReply;
4652
use common_meta_app::schema::UpsertTableOptionReq;
4753
use common_meta_types::GCDroppedDataReply;
@@ -104,6 +110,18 @@ pub trait SchemaApi: Send + Sync {
104110
table_id: MetaId,
105111
) -> Result<(TableIdent, Arc<TableMeta>), MetaError>;
106112

113+
async fn get_table_copied_file_info(
114+
&self,
115+
req: GetTableCopiedFileReq,
116+
) -> Result<GetTableCopiedFileReply, MetaError>;
117+
118+
async fn upsert_table_copied_file_info(
119+
&self,
120+
req: UpsertTableCopiedFileReq,
121+
) -> Result<UpsertTableCopiedFileReply, MetaError>;
122+
123+
async fn truncate_table(&self, req: TruncateTableReq) -> Result<TruncateTableReply, MetaError>;
124+
107125
async fn upsert_table_option(
108126
&self,
109127
req: UpsertTableOptionReq,

0 commit comments

Comments
 (0)