Skip to content

Commit 3411c5b

Browse files
freemandealerzzzxl1993
authored andcommitted
[fix](filecache) add OFFSET column for table file_cache_info (apache#59645)
1 parent d01fc8f commit 3411c5b

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

be/src/exec/schema_scanner/schema_file_cache_info_scanner.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ namespace doris {
3030
std::vector<SchemaScanner::ColumnDesc> SchemaFileCacheInfoScanner::_s_tbls_columns = {
3131
// name, type, size, is_null
3232
{"HASH", TYPE_STRING, sizeof(StringRef), true},
33+
{"OFFSET", TYPE_BIGINT, sizeof(int64_t), true},
3334
{"TABLET_ID", TYPE_BIGINT, sizeof(int64_t), true},
3435
{"SIZE", TYPE_BIGINT, sizeof(int64_t), true},
3536
{"TYPE", TYPE_STRING, sizeof(StringRef), true},
@@ -68,7 +69,7 @@ Status SchemaFileCacheInfoScanner::_fill_block_impl(vectorized::Block* block) {
6869
}
6970

7071
// Collect all cache entries from all file cache instances
71-
std::vector<std::tuple<std::string, int64_t, int64_t, int, std::string>> cache_entries;
72+
std::vector<std::tuple<std::string, int64_t, int64_t, int64_t, int, std::string>> cache_entries;
7273

7374
// Get all cache instances using the public getter
7475
const auto& caches = file_cache_factory->get_caches();
@@ -116,7 +117,8 @@ Status SchemaFileCacheInfoScanner::_fill_block_impl(vectorized::Block* block) {
116117
std::string hash_str = key.hash.to_string();
117118

118119
// Add to cache entries
119-
cache_entries.emplace_back(hash_str, key.tablet_id, value.size, value.type, cache_path);
120+
cache_entries.emplace_back(hash_str, static_cast<int64_t>(key.offset), key.tablet_id,
121+
static_cast<int64_t>(value.size), value.type, cache_path);
120122

121123
iterator->next();
122124
}
@@ -137,21 +139,21 @@ Status SchemaFileCacheInfoScanner::_fill_block_impl(vectorized::Block* block) {
137139

138140
for (size_t row_idx = 0; row_idx < row_num; ++row_idx) {
139141
const auto& entry = cache_entries[row_idx];
140-
const auto& [hash, tablet_id, size, type, cache_path] = entry;
142+
const auto& [hash, offset, tablet_id, size, type, cache_path] = entry;
141143

142144
if (col_desc.type == TYPE_STRING) {
143145
switch (col_idx) {
144146
case 0: // HASH
145147
column_values[row_idx] = hash;
146148
break;
147-
case 3: // TYPE
149+
case 4: // TYPE
148150
column_values[row_idx] = doris::io::cache_type_to_string(
149151
static_cast<doris::io::FileCacheType>(type));
150152
break;
151-
case 4: // REMOTE_PATH
153+
case 5: // REMOTE_PATH
152154
column_values[row_idx] = ""; // TODO: Implement remote path retrieval
153155
break;
154-
case 5: // CACHE_PATH
156+
case 6: // CACHE_PATH
155157
column_values[row_idx] = cache_path;
156158
break;
157159
default:
@@ -163,13 +165,16 @@ Status SchemaFileCacheInfoScanner::_fill_block_impl(vectorized::Block* block) {
163165
datas[row_idx] = &str_refs[row_idx];
164166
} else if (col_desc.type == TYPE_BIGINT) {
165167
switch (col_idx) {
166-
case 1: // TABLET_ID
168+
case 1: // OFFSET
169+
int64_vals[row_idx] = offset;
170+
break;
171+
case 2: // TABLET_ID
167172
int64_vals[row_idx] = tablet_id;
168173
break;
169-
case 2: // SIZE
174+
case 3: // SIZE
170175
int64_vals[row_idx] = size;
171176
break;
172-
case 6: // BE_ID
177+
case 7: // BE_ID
173178
int64_vals[row_idx] = ExecEnv::GetInstance()->cluster_info()->backend_id;
174179
break;
175180
default:

fe/fe-core/src/main/java/org/apache/doris/catalog/SchemaTable.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,7 @@ public class SchemaTable extends Table {
714714
.put("file_cache_info",
715715
new SchemaTable(SystemIdGenerator.getNextId(), "file_cache_info", TableType.SCHEMA,
716716
builder().column("HASH", ScalarType.createStringType())
717+
.column("OFFSET", ScalarType.createType(PrimitiveType.BIGINT))
717718
.column("TABLET_ID", ScalarType.createType(PrimitiveType.BIGINT))
718719
.column("SIZE", ScalarType.createType(PrimitiveType.BIGINT))
719720
.column("TYPE", ScalarType.createStringType())

regression-test/suites/cloud_p0/cache/test_file_cache_info.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ suite("test_file_cache_info") {
8383
def tablet_id = get_tablet_id("customer")
8484
println "Tablet ID: ${tablet_id}"
8585

86+
def desc_cache_info = sql "desc information_schema.file_cache_info"
87+
assertTrue(desc_cache_info.size() > 0, "desc information_schema.file_cache_info should not be empty")
88+
assertEquals(desc_cache_info[0][0].toString().toUpperCase(), "HASH")
89+
assertEquals(desc_cache_info[1][0].toString().toUpperCase(), "OFFSET")
90+
8691
def cache_info = sql "select * from information_schema.file_cache_info"
8792

8893
assertTrue(cache_info.size() > 0, "file_cache_info should not be empty for tablet_id ${tablet_id}")

0 commit comments

Comments
 (0)