From 7c839256470690b6b1a415a784bd924236c426a4 Mon Sep 17 00:00:00 2001 From: Gang Wu Date: Fri, 3 Nov 2023 13:41:23 +0800 Subject: [PATCH] ORC-1480: [C++] Fix build break w/ BUILD_CPP_ENABLE_METRICS=ON ### What changes were proposed in this pull request? Pass IOCount to SCOPED_STOPWATCH when counting I/Os. ### Why are the changes needed? SCOPED_STOPWATCH macro was not correctly called when counting I/Os. This breaks build when BUILD_CPP_ENABLE_METRICS is set to ON and fails the unit test as well. ### How was this patch tested? Failed test cases are fixed and all cases pass. Closes #1646 from wgtmac/ORC-1480. Authored-by: Gang Wu Signed-off-by: Gang Wu --- c++/src/io/OutputStream.cc | 2 +- c++/test/TestBufferedOutputStream.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/c++/src/io/OutputStream.cc b/c++/src/io/OutputStream.cc index 118a664716..ac5339c644 100644 --- a/c++/src/io/OutputStream.cc +++ b/c++/src/io/OutputStream.cc @@ -87,7 +87,7 @@ namespace orc { uint64_t dataSize = dataBuffer->size(); // flush data buffer into outputStream if (dataSize > 0) { - SCOPED_STOPWATCH(metrics, IOBlockingLatencyUs, nullptr); + SCOPED_STOPWATCH(metrics, IOBlockingLatencyUs, IOCount); dataBuffer->writeTo(outputStream, metrics); } dataBuffer->resize(0); diff --git a/c++/test/TestBufferedOutputStream.cc b/c++/test/TestBufferedOutputStream.cc index 4cb70007b4..6735ac43d3 100644 --- a/c++/test/TestBufferedOutputStream.cc +++ b/c++/test/TestBufferedOutputStream.cc @@ -46,7 +46,7 @@ namespace orc { EXPECT_EQ(memStream.getData()[i], 'a' + i % 10); } #if ENABLE_METRICS - EXPECT_EQ(metrics.IOCount.load(), 1); + EXPECT_EQ(metrics.IOCount.load(), 2); #endif } @@ -95,7 +95,7 @@ namespace orc { EXPECT_EQ(memStream.getData()[i + 7], 'a' + i); } #if ENABLE_METRICS - EXPECT_EQ(metrics.IOCount.load(), 2); + EXPECT_EQ(metrics.IOCount.load(), 4); #endif }