@@ -27,7 +27,7 @@ int main(int argc, char* argv[]) {
27
27
28
28
std::string bucket = " gavin-test-hk-1308700295" ;
29
29
// prefix, in key
30
- std::string key = " / dx_micro_bench/test25/aaaaaa" ;
30
+ std::string key = " dx_micro_bench/test25/aaaaaa" ;
31
31
size_t data_size = std::stoull (argv[3 ]); // 数据大小(字节)
32
32
33
33
// 生成随机数据
@@ -65,6 +65,7 @@ int main(int argc, char* argv[]) {
65
65
// 写入数据到 S3
66
66
{
67
67
doris::io::FileWriterOptions options;
68
+ options.write_file_cache = true ;
68
69
auto writer = std::make_unique<doris::io::S3FileWriter>(client, bucket, key, &options);
69
70
70
71
doris::Slice slice (data.data (), data.size ());
@@ -84,17 +85,20 @@ int main(int argc, char* argv[]) {
84
85
std::cout << " Data written to S3 successfully." << std::endl;
85
86
}
86
87
88
+ std::this_thread::sleep_for (std::chrono::seconds (1 ));
89
+
87
90
// 使用 CachedRemoteFileReader 读取数据进行验证
88
91
{
89
92
// 创建读取选项
90
93
doris::io::FileReaderOptions reader_opts;
91
94
reader_opts.cache_type = doris::io::FileCachePolicy::FILE_BLOCK_CACHE;
92
- reader_opts.is_doris_table = false ; // 非 Doris 表数据
93
- reader_opts.cache_base_path = " /mnt/disk2/dengxin/file_cache" ;
95
+ reader_opts.is_doris_table = true ; // 非 Doris 表数据
96
+ // reader_opts.cache_base_path = "/mnt/disk2/dengxin/file_cache";
94
97
95
98
// 创建基础的 S3FileReader
96
99
doris::io::FileDescription fd;
97
- fd.path = doris::io::Path (" s3://" + bucket + key);
100
+ std::cout << " read = s3://" + bucket + " /" + key << std::endl;
101
+ fd.path = doris::io::Path (" s3://" + bucket + " /" + key);
98
102
doris::io::FileSystemProperties fs_props;
99
103
fs_props.system_type = doris::TFileType::FILE_S3;
100
104
@@ -126,9 +130,6 @@ int main(int argc, char* argv[]) {
126
130
return 1 ;
127
131
}
128
132
129
- // 创建 CachedRemoteFileReader
130
- auto cached_reader = std::make_shared<doris::io::CachedRemoteFileReader>(s3_reader, reader_opts);
131
-
132
133
// 准备读取缓冲区
133
134
std::string read_buffer;
134
135
read_buffer.resize (data.size ());
@@ -141,7 +142,7 @@ int main(int argc, char* argv[]) {
141
142
142
143
// 读取数据
143
144
size_t bytes_read = 0 ;
144
- doris::Status read_status = cached_reader ->read_at (0 , read_slice, &bytes_read, &io_ctx);
145
+ doris::Status read_status = s3_reader ->read_at (0 , read_slice, &bytes_read, &io_ctx);
145
146
146
147
if (!read_status.ok ()) {
147
148
std::cerr << " Error reading from S3: " << read_status.to_string () << std::endl;
0 commit comments