Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into index_name_sql
Browse files Browse the repository at this point in the history
  • Loading branch information
Ami11111 committed Aug 14, 2024
2 parents 8afbce4 + 8e91613 commit f83fde6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
9 changes: 9 additions & 0 deletions src/executor/operator/physical_compact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import logger;
import infinity_exception;
import third_party;
import status;
import wal_entry;

namespace infinity {

Expand Down Expand Up @@ -154,8 +155,10 @@ bool PhysicalCompact::Execute(QueryContext *query_context, OperatorState *operat
BlockEntry::NewBlockEntry(new_segment.get(), new_segment->GetNextBlockID(), 0 /*checkpoint_ts*/, column_count, txn);
const SizeT block_capacity = new_block->row_capacity();

Vector<SegmentID> old_segment_ids;
for (SegmentEntry *segment : compactible_segments) {
SegmentID segment_id = segment->segment_id();
old_segment_ids.push_back(segment_id);
const auto &segment_info = block_index->segment_block_index_.at(segment_id);
for (const auto *block_entry : segment_info.block_map_) {
BlockID block_id = block_entry->block_id();
Expand Down Expand Up @@ -210,6 +213,12 @@ bool PhysicalCompact::Execute(QueryContext *query_context, OperatorState *operat
}
compact_operator_state->SetComplete();

String db_name = *table_entry->GetDBName();
String table_name = *table_entry->GetTableName();
Vector<WalSegmentInfo> new_segment_infos;
new_segment_infos.emplace_back(new_segment.get());
txn->AddWalCmd(MakeShared<WalCmdCompact>(std::move(db_name), std::move(table_name), std::move(new_segment_infos), std::move(old_segment_ids)));

return true;
}

Expand Down
7 changes: 0 additions & 7 deletions src/executor/operator/physical_compact_finish.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,30 +49,23 @@ void PhysicalCompactFinish::SaveSegmentData(QueryContext *query_context, const C
auto *txn = query_context->GetTxn();
auto *table_entry = base_table_ref_->table_entry_ptr_;

Vector<WalSegmentInfo> segment_infos;
Vector<SegmentID> old_segment_ids;
Vector<Pair<SharedPtr<SegmentEntry>, Vector<SegmentEntry *>>> segment_data;

std::stringstream ss;
for (const auto &compact_segment_data : compact_state_data->segment_data_list_) {
auto *new_segment = compact_segment_data.new_segment_.get();
ss << "Compact ";
new_segment->FlushNewData();
segment_infos.emplace_back(new_segment);

for (const auto *old_segment : compact_segment_data.old_segments_) {
ss << "old segment " << old_segment->segment_id() << ", ";
old_segment_ids.push_back(old_segment->segment_id());
}
ss << "to new segment " << new_segment->segment_id();
segment_data.emplace_back(compact_segment_data.new_segment_, compact_segment_data.old_segments_);
}
LOG_DEBUG(ss.str());

txn->Compact(table_entry, std::move(segment_data), compact_type_);
String db_name = *table_entry->GetDBName();
String table_name = *table_entry->GetTableName();
txn->AddWalCmd(MakeShared<WalCmdCompact>(std::move(db_name), std::move(table_name), std::move(segment_infos), std::move(old_segment_ids)));
}

bool PhysicalCompactFinish::ApplyDeletes(QueryContext *query_context, const CompactStateData *compact_state_data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ using namespace infinity;
class SealingTaskTest : public BaseTestParamStr {
void SetUp() override {
tree_cmd = "tree ";
tree_cmd += GetHomeDir();
tree_cmd += GetFullDataDir();
#ifdef INFINITY_DEBUG
infinity::GlobalResourceUsage::Init();
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/unit_test/storage/wal/wal_replay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class WalReplayTest : public BaseTestParamStr {
system(("mkdir -p " + String(GetFullDataDir())).c_str());
system(("mkdir -p " + String(GetFullTmpDir())).c_str());
tree_cmd = "tree ";
tree_cmd += GetHomeDir();
tree_cmd += GetFullDataDir();
}

void TearDown() override {
Expand Down

0 comments on commit f83fde6

Please sign in to comment.