Skip to content

Commit 54baee7

Browse files
committed
[Enhancement] Add medium type of data dir in be_tablets
Signed-off-by: Dejun Xia <[email protected]>
1 parent 86c9791 commit 54baee7

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

be/src/exec/schema_scanner/schema_be_tablets_scanner.cpp

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616

1717
#include "agent/master_info.h"
1818
#include "exec/schema_scanner/schema_helper.h"
19+
#include "gen_cpp/Types_types.h" // for TStorageMedium::type
1920
#include "gutil/strings/substitute.h"
2021
#include "runtime/string_value.h"
2122
#include "storage/storage_engine.h"
2223
#include "storage/tablet.h"
2324
#include "storage/tablet_manager.h"
24-
#include "types/logical_type.h"
2525

2626
namespace starrocks {
2727

@@ -34,7 +34,7 @@ SchemaScanner::ColumnDesc SchemaBeTabletsScanner::_s_columns[] = {
3434
{"INDEX_MEM", TYPE_BIGINT, sizeof(int64_t), false}, {"CREATE_TIME", TYPE_BIGINT, sizeof(int64_t), false},
3535
{"STATE", TYPE_VARCHAR, sizeof(StringValue), false}, {"TYPE", TYPE_VARCHAR, sizeof(StringValue), false},
3636
{"DATA_DIR", TYPE_VARCHAR, sizeof(StringValue), false}, {"SHARD_ID", TYPE_BIGINT, sizeof(int64_t), false},
37-
{"SCHEMA_HASH", TYPE_BIGINT, sizeof(int64_t), false},
37+
{"SCHEMA_HASH", TYPE_BIGINT, sizeof(int64_t), false}, {"MEDIUM_TYPE", TYPE_VARCHAR, sizeof(StringValue), false},
3838
};
3939

4040
SchemaBeTabletsScanner::SchemaBeTabletsScanner()
@@ -86,13 +86,24 @@ static const char* keys_type_to_string(KeysType type) {
8686
}
8787
}
8888

89+
static const char* medium_type_to_string(TStorageMedium::type type) {
90+
switch (type) {
91+
case TStorageMedium::SSD:
92+
return "SSD";
93+
case TStorageMedium::HDD:
94+
return "HDD";
95+
default:
96+
return "UNKNOWN";
97+
}
98+
}
99+
89100
Status SchemaBeTabletsScanner::fill_chunk(ChunkPtr* chunk) {
90101
const auto& slot_id_to_index_map = (*chunk)->get_slot_id_to_index_map();
91102
auto end = _cur_idx + 1;
92103
for (; _cur_idx < end; _cur_idx++) {
93104
auto& info = _infos[_cur_idx];
94105
for (const auto& [slot_id, index] : slot_id_to_index_map) {
95-
if (slot_id < 1 || slot_id > 17) {
106+
if (slot_id < 1 || slot_id > 18) {
96107
return Status::InternalError(strings::Substitute("invalid slot id:$0", slot_id));
97108
}
98109
ColumnPtr column = (*chunk)->get_column_by_slot_id(slot_id);
@@ -138,7 +149,7 @@ Status SchemaBeTabletsScanner::fill_chunk(ChunkPtr* chunk) {
138149
break;
139150
}
140151
case 9: {
141-
// num rowt
152+
// num rows
142153
fill_column_with_slot<TYPE_BIGINT>(column.get(), (void*)&info.num_row);
143154
break;
144155
}
@@ -170,8 +181,8 @@ Status SchemaBeTabletsScanner::fill_chunk(ChunkPtr* chunk) {
170181
break;
171182
}
172183
case 15: {
173-
Slice type = Slice(info.data_dir);
174-
fill_column_with_slot<TYPE_VARCHAR>(column.get(), (void*)&type);
184+
Slice data_dir = Slice(info.data_dir);
185+
fill_column_with_slot<TYPE_VARCHAR>(column.get(), (void*)&data_dir);
175186
break;
176187
}
177188
case 16: {
@@ -182,6 +193,12 @@ Status SchemaBeTabletsScanner::fill_chunk(ChunkPtr* chunk) {
182193
fill_column_with_slot<TYPE_BIGINT>(column.get(), (void*)&info.schema_hash);
183194
break;
184195
}
196+
case 18: {
197+
// medium type
198+
Slice medium_type = Slice(medium_type_to_string(info.medium_type));
199+
fill_column_with_slot<TYPE_VARCHAR>(column.get(), (void*)&medium_type);
200+
break;
201+
}
185202
default:
186203
break;
187204
}

be/src/exec/schema_scanner/schema_be_tablets_scanner.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include "exec/schema_scanner.h"
2020
#include "gen_cpp/FrontendService_types.h"
21+
#include "gen_cpp/Types_types.h" // for TStorageMedium::type
2122

2223
namespace starrocks {
2324

@@ -38,6 +39,7 @@ struct TabletBasicInfo {
3839
std::string data_dir;
3940
int64_t shard_id{0};
4041
int64_t schema_hash{0};
42+
TStorageMedium::type medium_type;
4143
};
4244

4345
class SchemaBeTabletsScanner : public SchemaScanner {

be/src/storage/tablet.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,6 +1637,7 @@ void Tablet::get_basic_info(TabletBasicInfo& info) {
16371637
info.data_dir = data_dir()->path();
16381638
info.shard_id = shard_id();
16391639
info.schema_hash = schema_hash();
1640+
info.medium_type = data_dir()->storage_medium();
16401641
if (_updates != nullptr) {
16411642
_updates->get_basic_info_extra(info);
16421643
} else {

fe/fe-core/src/main/java/com/starrocks/catalog/system/information/BeTabletsSystemTable.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public static SystemTable create() {
4646
.column("DATA_DIR", ScalarType.createVarchar(NAME_CHAR_LEN))
4747
.column("SHARD_ID", ScalarType.createType(PrimitiveType.BIGINT))
4848
.column("SCHEMA_HASH", ScalarType.createType(PrimitiveType.BIGINT))
49+
.column("MEDIUM_TYPE", ScalarType.createVarchar(NAME_CHAR_LEN))
4950
.build(), TSchemaTableType.SCH_BE_TABLETS);
5051
}
5152
}

0 commit comments

Comments
 (0)