HolyLow commented on code in PR #3137: URL: https://github.com/apache/celeborn/pull/3137#discussion_r1986658937
########## cpp/celeborn/client/reader/WorkerPartitionReader.h: ########## @@ -0,0 +1,95 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "celeborn/network/TransportClient.h" +#include "celeborn/protocol/PartitionLocation.h" + +namespace celeborn { +namespace client { +class PartitionReader { + public: + virtual ~PartitionReader() = default; + + virtual bool hasNext() = 0; + + virtual std::unique_ptr<memory::ReadOnlyByteBuffer> next() = 0; +}; + +class WorkerPartitionReader + : public PartitionReader, + public std::enable_shared_from_this<WorkerPartitionReader> { + public: + // Only allow using create method to get the shared_ptr holder. This is + // required by the std::enable_shared_from_this functionality. + static std::shared_ptr<WorkerPartitionReader> create( + const std::shared_ptr<const conf::CelebornConf>& conf, + const std::string& shuffleKey, + const protocol::PartitionLocation& location, + int32_t startMapIndex, + int32_t endMapIndex, + network::TransportClientFactory* clientFactory); + + ~WorkerPartitionReader() override; + + bool hasNext() override; + + std::unique_ptr<memory::ReadOnlyByteBuffer> next() override; + + void fetchChunks(); + + private: + // Disable creating the object directly to make sure that + // std::enable_shared_from_this works properly. + WorkerPartitionReader( + const std::shared_ptr<const conf::CelebornConf>& conf, + const std::string& shuffleKey, + const protocol::PartitionLocation& location, + int32_t startMapIndex, + int32_t endMapIndex, + network::TransportClientFactory* clientFactory); + + // This function cannot be called within constructor! + void initAndCheck(); + + std::string shuffleKey_; + protocol::PartitionLocation location_; Review Comment: If this is used, we could add the getter method later, but for now this is not used yet. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
