Skip to content

Commit

Permalink
misc: Add toString() to OutputBuffer stats
Browse files Browse the repository at this point in the history
  • Loading branch information
yingsu00 committed Nov 17, 2024
1 parent 427ac31 commit 5a4513c
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion velox/exec/OutputBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<SerializedPage> data);
Expand Down Expand Up @@ -254,7 +266,28 @@ class OutputBuffer {
/// Stats of the OutputBuffer's destinations.
std::vector<DestinationBuffer::Stats> 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(
Expand Down

0 comments on commit 5a4513c

Please sign in to comment.