Skip to content

Commit

Permalink
Add new command: show index segment info (#1273)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

We need to show the detailed information of each index segment.

### Type of change

- [x] New Feature (non-breaking change which adds functionality)

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
  • Loading branch information
JinHai-CN authored Jun 2, 2024
1 parent 72f491a commit a755221
Show file tree
Hide file tree
Showing 15 changed files with 1,643 additions and 1,468 deletions.
30 changes: 24 additions & 6 deletions src/executor/explain_physical_plan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1159,9 +1159,9 @@ void ExplainPhysicalPlan::Explain(const PhysicalShow *show_node, SharedPtr<Vecto
String show_str;
if (intent_size != 0) {
show_str = String(intent_size - 2, ' ');
show_str += "-> SHOW TABLES ";
show_str += "-> SHOW TABLE ";
} else {
show_str = "SHOW TABLES ";
show_str = "SHOW TABLE ";
}
show_str += "(";
show_str += std::to_string(show_node->node_id());
Expand All @@ -1177,9 +1177,27 @@ void ExplainPhysicalPlan::Explain(const PhysicalShow *show_node, SharedPtr<Vecto
String show_str;
if (intent_size != 0) {
show_str = String(intent_size - 2, ' ');
show_str += "-> SHOW TABLES ";
show_str += "-> SHOW INDEX ";
} else {
show_str = "SHOW TABLES ";
show_str = "SHOW INDEX ";
}
show_str += "(";
show_str += std::to_string(show_node->node_id());
show_str += ")";
result->emplace_back(MakeShared<String>(show_str));

String output_columns_str = String(intent_size, ' ');
output_columns_str += " - output columns: [name, value]";
result->emplace_back(MakeShared<String>(output_columns_str));
break;
}
case ShowType::kShowIndexSegment: {
String show_str;
if (intent_size != 0) {
show_str = String(intent_size - 2, ' ');
show_str += "-> SHOW INDEX SEGMENT";
} else {
show_str = "SHOW INDEX SEGMENT";
}
show_str += "(";
show_str += std::to_string(show_node->node_id());
Expand Down Expand Up @@ -1223,9 +1241,9 @@ void ExplainPhysicalPlan::Explain(const PhysicalShow *show_node, SharedPtr<Vecto
case ShowType::kShowColumn: {
String show_str;
if (intent_size != 0) {
show_str = String(intent_size - 2, ' ') + "-> DESCRIBE TABLE/COLLECTION ";
show_str = String(intent_size - 2, ' ') + "-> SHOW COLUMN ";
} else {
show_str = "DESCRIBE TABLE/COLLECTION ";
show_str = "SHOW COLUMN ";
}
show_str += "(" + std::to_string(show_node->node_id()) + ")";
result->emplace_back(MakeShared<String>(show_str));
Expand Down
328 changes: 158 additions & 170 deletions src/executor/operator/physical_show.cpp

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/executor/operator/physical_show.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ private:

void ExecuteShowIndex(QueryContext *query_context, ShowOperatorState *operator_state);

void ExecuteShowIndexSegment(QueryContext *query_context, ShowOperatorState *operator_state);

void ExecuteShowDatabases(QueryContext *query_context, ShowOperatorState *operator_state);

void ExecuteShowTables(QueryContext *query_context, ShowOperatorState *operator_state);
Expand Down
17 changes: 17 additions & 0 deletions src/main/infinity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,23 @@ QueryResult Infinity::ShowIndex(const String &db_name, const String &table_name,
return result;
}

QueryResult Infinity::ShowIndexSegment(const String &db_name, const String &table_name, const String &index_name, SegmentID segment_id) {
UniquePtr<QueryContext> query_context_ptr = MakeUnique<QueryContext>(session_.get());
query_context_ptr->Init(InfinityContext::instance().config(),
InfinityContext::instance().task_scheduler(),
InfinityContext::instance().storage(),
InfinityContext::instance().resource_manager(),
InfinityContext::instance().session_manager());
UniquePtr<ShowStatement> show_statement = MakeUnique<ShowStatement>();
show_statement->schema_name_ = db_name;
show_statement->table_name_ = table_name;
show_statement->index_name_ = index_name;
show_statement->segment_id_ = segment_id;
show_statement->show_type_ = ShowStmtType::kIndexSegment;
QueryResult result = query_context_ptr->QueryStatement(show_statement.get());
return result;
}

QueryResult Infinity::ShowSegment(const String &db_name, const String &table_name, const SegmentID &segment_id) {
UniquePtr<QueryContext> query_context_ptr = MakeUnique<QueryContext>(session_.get());
query_context_ptr->Init(InfinityContext::instance().config(),
Expand Down
2 changes: 2 additions & 0 deletions src/main/infinity.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ public:

QueryResult ShowIndex(const String &db_name, const String &table_name, const String &index_name);

QueryResult ShowIndexSegment(const String &db_name, const String &table_name, const String &index_name, SegmentID segment_id);

QueryResult ShowSegment(const String &db_name, const String &table_name, const SegmentID &segment_id);

QueryResult ShowSegments(const String &db_name, const String &table_name);
Expand Down
Loading

0 comments on commit a755221

Please sign in to comment.