From 5a4513cb61b1af8f717d845791973463c9e13646 Mon Sep 17 00:00:00 2001 From: yingsu00 Date: Sat, 16 Nov 2024 20:37:48 -0800 Subject: [PATCH] misc: Add toString() to OutputBuffer stats --- velox/exec/OutputBuffer.h | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/velox/exec/OutputBuffer.h b/velox/exec/OutputBuffer.h index 2620693e6900d..5188ef7791963 100644 --- a/velox/exec/OutputBuffer.h +++ b/velox/exec/OutputBuffer.h @@ -115,6 +115,18 @@ class DestinationBuffer { int64_t bytesSent{0}; int64_t rowsSent{0}; int64_t pagesSent{0}; + + std::string toString() { + return fmt::format( + "[{}, {}, {}, {}, {}, {}, {}]", + finished, + bytesBuffered, + rowsBuffered, + pagesBuffered, + bytesSent, + rowsSent, + pagesSent); + } }; void enqueue(std::shared_ptr data); @@ -254,7 +266,28 @@ class OutputBuffer { /// Stats of the OutputBuffer's destinations. std::vector buffersStats; - std::string toString() const; + std::string toString() { + std::string destinationBufferStats; + if (!buffersStats.empty()) { + for (auto& destinationBufferStat : buffersStats) { + destinationBufferStats += destinationBufferStat.toString(); + destinationBufferStats += ", "; + } + } + + return fmt::format( + "[ bufferedBytes: {}, bufferedPages: {}, " + "totalBytesSent: {}, totalRowsSent: {}, totalPagesSent: {}, " + "averageBufferTimeMs: {}, numTopBuffers: {}, {}]", + bufferedBytes, + bufferedPages, + totalBytesSent, + totalRowsSent, + totalPagesSent, + averageBufferTimeMs, + numTopBuffers, + destinationBufferStats); + } }; OutputBuffer(