From 6ab19e7e3b9640ee37a796cf8056b2022bf9b305 Mon Sep 17 00:00:00 2001 From: kemalelmizan Date: Wed, 18 Dec 2024 10:23:16 +0700 Subject: [PATCH 1/2] fix mix_direct_read_test for macos build --- test/mix_direct_read_test.cc | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/test/mix_direct_read_test.cc b/test/mix_direct_read_test.cc index 4f02e1b..035cfb1 100644 --- a/test/mix_direct_read_test.cc +++ b/test/mix_direct_read_test.cc @@ -57,27 +57,26 @@ void read_from_oss_and_write_to_disk_rand(const char* read_path, // shuffle the read order in the unit of 100MB std::vector read_order_in_the_unit_of_100MB; std::cout << "total size " << total_size << std::endl; - for (int i = 0; i < (total_size+100*MB-1) / 100 / MB; ++i) { + for (int i = 0; i < (total_size + 100 * MB - 1) / 100 / MB; ++i) { read_order_in_the_unit_of_100MB.push_back(i); } - std::random_shuffle(read_order_in_the_unit_of_100MB.begin(), - read_order_in_the_unit_of_100MB.end()); - size_t sub_total_size = 100*MB; + std::random_shuffle(read_order_in_the_unit_of_100MB.begin(), read_order_in_the_unit_of_100MB.end()); + size_t sub_total_size = 100 * MB; for (int i = 0; i < read_order_in_the_unit_of_100MB.size(); ++i) { int index = read_order_in_the_unit_of_100MB[i]; - sub_total_size = std::min(100 * MB, total_size - index * 100 * MB); + sub_total_size = std::min(100 * MB, total_size - index * 100 * MB); off_t start_offset = index * 100 * MB; - std::cout << "random read, start from " << index*100 << "MB, sub_total_size: " << sub_total_size << std::endl; + std::cout << "random read, start from " << index * 100 << "MB, sub_total_size: " << sub_total_size << std::endl; offset = 0; while (offset < sub_total_size) { - size_t buf_size = std::min(MB, sub_total_size - offset); - bytesread = pread(fd, buf, buf_size, start_offset+offset); - byteswritten = pwrite(wfd, buf, bytesread, start_offset+offset); + size_t buf_size = std::min(MB, sub_total_size - offset); + bytesread = pread(fd, buf, buf_size, start_offset + offset); + byteswritten = pwrite(wfd, buf, bytesread, start_offset + offset); offset += byteswritten; } } - + close(fd); close(wfd); } From 091d990746600dc491f6be8671a44a6a4fcdd2cc Mon Sep 17 00:00:00 2001 From: kemalelmizan Date: Wed, 18 Dec 2024 10:25:27 +0700 Subject: [PATCH 2/2] return formats and whitespaces --- test/mix_direct_read_test.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/test/mix_direct_read_test.cc b/test/mix_direct_read_test.cc index 035cfb1..25472ef 100644 --- a/test/mix_direct_read_test.cc +++ b/test/mix_direct_read_test.cc @@ -57,26 +57,27 @@ void read_from_oss_and_write_to_disk_rand(const char* read_path, // shuffle the read order in the unit of 100MB std::vector read_order_in_the_unit_of_100MB; std::cout << "total size " << total_size << std::endl; - for (int i = 0; i < (total_size + 100 * MB - 1) / 100 / MB; ++i) { + for (int i = 0; i < (total_size+100*MB-1) / 100 / MB; ++i) { read_order_in_the_unit_of_100MB.push_back(i); } - std::random_shuffle(read_order_in_the_unit_of_100MB.begin(), read_order_in_the_unit_of_100MB.end()); - size_t sub_total_size = 100 * MB; + std::random_shuffle(read_order_in_the_unit_of_100MB.begin(), + read_order_in_the_unit_of_100MB.end()); + size_t sub_total_size = 100*MB; for (int i = 0; i < read_order_in_the_unit_of_100MB.size(); ++i) { int index = read_order_in_the_unit_of_100MB[i]; sub_total_size = std::min(100 * MB, total_size - index * 100 * MB); off_t start_offset = index * 100 * MB; - std::cout << "random read, start from " << index * 100 << "MB, sub_total_size: " << sub_total_size << std::endl; + std::cout << "random read, start from " << index*100 << "MB, sub_total_size: " << sub_total_size << std::endl; offset = 0; while (offset < sub_total_size) { size_t buf_size = std::min(MB, sub_total_size - offset); - bytesread = pread(fd, buf, buf_size, start_offset + offset); - byteswritten = pwrite(wfd, buf, bytesread, start_offset + offset); + bytesread = pread(fd, buf, buf_size, start_offset+offset); + byteswritten = pwrite(wfd, buf, bytesread, start_offset+offset); offset += byteswritten; } } - + close(fd); close(wfd); }