@@ -313,12 +313,10 @@ void TableEntry::Import(SharedPtr<SegmentEntry> segment_entry, Txn *txn) {
313
313
{
314
314
std::unique_lock lock (this ->rw_locker_ );
315
315
SegmentID segment_id = segment_entry->segment_id ();
316
- SizeT row_count = segment_entry->row_count ();
317
316
auto [_, insert_ok] = this ->segment_map_ .emplace (segment_id, segment_entry);
318
317
if (!insert_ok) {
319
318
UnrecoverableError (fmt::format (" Insert segment {} failed." , segment_id));
320
319
}
321
- this ->row_count_ += row_count;
322
320
}
323
321
// Populate index entirely for the segment
324
322
TxnTableStore *txn_table_store = txn->GetTxnTableStore (this );
@@ -369,6 +367,12 @@ void TableEntry::AppendData(TransactionID txn_id, void *txn_store, TxnTimeStamp
369
367
AppendState *append_state_ptr = txn_store_ptr->append_state_ .get ();
370
368
Txn *txn = txn_store_ptr->txn_ ;
371
369
if (append_state_ptr->Finished ()) {
370
+ // Import update row count
371
+ if (append_state_ptr->blocks_ .empty ()) {
372
+ for (auto &segment : txn_store_ptr->flushed_segments ()) {
373
+ this ->row_count_ += segment->row_count ();
374
+ }
375
+ }
372
376
LOG_TRACE (" No append is done." );
373
377
return ;
374
378
}
@@ -904,11 +908,11 @@ nlohmann::json TableEntry::Serialize(TxnTimeStamp max_commit_ts) {
904
908
Vector<SegmentEntry *> segment_candidates;
905
909
Vector<TableIndexMeta *> table_index_meta_candidates;
906
910
Vector<String> table_index_name_candidates;
911
+ SizeT checkpoint_row_count = 0 ;
907
912
{
908
913
std::shared_lock<std::shared_mutex> lck (this ->rw_locker_ );
909
914
json_res[" table_name" ] = *this ->GetTableName ();
910
915
json_res[" table_entry_type" ] = this ->table_entry_type_ ;
911
- json_res[" row_count" ] = this ->row_count_ .load ();
912
916
json_res[" begin_ts" ] = this ->begin_ts_ ;
913
917
json_res[" commit_ts" ] = this ->commit_ts_ .load ();
914
918
json_res[" txn_id" ] = this ->txn_id_ .load ();
@@ -952,7 +956,9 @@ nlohmann::json TableEntry::Serialize(TxnTimeStamp max_commit_ts) {
952
956
// Serialize segments
953
957
for (const auto &segment_entry : segment_candidates) {
954
958
json_res[" segments" ].emplace_back (segment_entry->Serialize (max_commit_ts));
959
+ checkpoint_row_count += segment_entry->checkpoint_row_count ();
955
960
}
961
+ json_res[" row_count" ] = checkpoint_row_count;
956
962
json_res[" unsealed_id" ] = unsealed_id_;
957
963
958
964
// Serialize indexes
0 commit comments