1414#include " presto_cpp/main/operators/ShuffleRead.h"
1515#include " presto_cpp/main/operators/ShuffleExchangeSource.h"
1616#include " velox/common/Casts.h"
17- #include " velox/exec/Exchange.h"
1817#include " velox/row/CompactRow.h"
1918
2019using namespace facebook ::velox::exec;
@@ -25,61 +24,30 @@ velox::core::PlanNodeId deserializePlanNodeId(const folly::dynamic& obj) {
2524 return obj[" id" ].asString ();
2625}
2726
28- namespace {
29- class ShuffleRead : public Exchange {
30- public:
31- ShuffleRead (
32- int32_t operatorId,
33- DriverCtx* ctx,
34- const std::shared_ptr<const ShuffleReadNode>& shuffleReadNode,
35- std::shared_ptr<ExchangeClient> exchangeClient)
36- : Exchange(
37- operatorId,
38- ctx,
39- std::make_shared<core::ExchangeNode>(
40- shuffleReadNode->id (),
41- shuffleReadNode->outputType(),
42- VectorSerde::Kind::kCompactRow),
43- exchangeClient,
44- "ShuffleRead") {
45- initStats ();
46- }
47-
48- RowVectorPtr getOutput () override ;
49-
50- void close () override ;
51-
52- protected:
53- VectorSerde* getSerde () override {
54- VELOX_UNSUPPORTED (" ShuffleReadOperator doesn't use serde" );
55- }
56-
57- private:
58- static inline const std::string kShuffleDecodeTime {" shuffleDecodeWallNanos" };
59- static inline const std::string kShuffleNumBatchesPerRead {
60- " shuffleNumBatchesPerRead" };
61- static inline const std::string kShuffleNumBatches {" shuffleNumBatches" };
62-
63- void initStats ();
64-
65- void resetOutputState ();
66-
67- int64_t numBatches_{0 };
68- std::unordered_map<std::string, velox::RuntimeMetric> runtimeStats_;
69-
70- size_t nextRow_{0 };
71- size_t nextPage_{0 };
72- // Reusable buffers.
73- std::vector<std::string_view> rows_;
74- std::vector<size_t > pageRows_;
75- };
27+ ShuffleRead::ShuffleRead (
28+ int32_t operatorId,
29+ DriverCtx* ctx,
30+ const std::shared_ptr<const ShuffleReadNode>& shuffleReadNode,
31+ std::shared_ptr<ExchangeClient> exchangeClient)
32+ : Exchange(
33+ operatorId,
34+ ctx,
35+ std::make_shared<core::ExchangeNode>(
36+ shuffleReadNode->id (),
37+ shuffleReadNode->outputType(),
38+ VectorSerde::Kind::kCompactRow),
39+ exchangeClient,
40+ "ShuffleRead") {
41+ initStats ();
42+ }
7643
7744void ShuffleRead::initStats () {
7845 VELOX_CHECK (runtimeStats_.empty ());
7946 runtimeStats_.insert (
8047 std::pair{kShuffleDecodeTime , velox::RuntimeCounter::Unit::kNanos });
8148 runtimeStats_.insert (
82- std::pair{kShuffleNumBatchesPerRead , velox::RuntimeCounter::Unit::kNone });
49+ std::pair{
50+ kShufflePagesPerInputBatch , velox::RuntimeCounter::Unit::kNone });
8351}
8452
8553void ShuffleRead::resetOutputState () {
@@ -122,8 +90,8 @@ RowVectorPtr ShuffleRead::getOutput() {
12290 }
12391 }
12492 if (!currentPages_.empty ()) {
125- runtimeStats_[kShuffleNumBatchesPerRead ].addValue (currentPages_.size ());
126- numBatches_ += currentPages_. size () ;
93+ runtimeStats_[kShufflePagesPerInputBatch ].addValue (currentPages_.size ());
94+ ++numInputBatches_ ;
12795 }
12896 }
12997 VELOX_CHECK_LE (nextRow_, rows_.size ());
@@ -177,12 +145,11 @@ void ShuffleRead::close() {
177145 }
178146 lockedStats->runtimeStats [name] = metric;
179147 }
180- if (numBatches_ != 0 ) {
148+ if (numInputBatches_ != 0 ) {
181149 lockedStats->addRuntimeStat (
182- kShuffleNumBatches , RuntimeCounter (numBatches_ ));
150+ kShuffleInputBatches , RuntimeCounter (numInputBatches_ ));
183151 }
184152}
185- } // namespace
186153
187154folly::dynamic ShuffleReadNode::serialize () const {
188155 auto obj = PlanNode::serialize ();
0 commit comments