diff --git a/paddle/fluid/operators/reader/ctr_reader.cc b/paddle/fluid/operators/reader/ctr_reader.cc index 6c24a1ce77a39760a8321ee0b166faa78c33e782..da109733da812f61f11abb8939d05fcc5c8e16bd 100644 --- a/paddle/fluid/operators/reader/ctr_reader.cc +++ b/paddle/fluid/operators/reader/ctr_reader.cc @@ -72,29 +72,29 @@ static inline void parse_line( } } -// class Reader { -// public: -// virtual ~Reader() {} -// virtual bool HasNext() = 0; -// virtual void NextLine(std::string& line) = 0; -//}; - -class GzipReader { +class Reader { + public: + virtual ~Reader() {} + virtual bool HasNext() = 0; + virtual void NextLine(std::string* line) = 0; +}; + +class GzipReader : public Reader { public: explicit GzipReader(const std::string& file_name) : gzstream_(file_name.c_str()) {} ~GzipReader() {} - bool HasNext() { return gzstream_.peek() != EOF; } + bool HasNext() override { return gzstream_.peek() != EOF; } - void NextLine(std::string* line) { std::getline(gzstream_, *line); } + void NextLine(std::string* line) override { std::getline(gzstream_, *line); } private: igzstream gzstream_; }; -class MultiGzipReader { +class MultiGzipReader : public Reader { public: explicit MultiGzipReader(const std::vector& file_list) { for (auto& file : file_list) { @@ -102,7 +102,7 @@ class MultiGzipReader { } } - bool HasNext() { + bool HasNext() override { if (current_reader_index_ >= readers_.size()) { return false; } @@ -113,7 +113,7 @@ class MultiGzipReader { return true; } - void NextLine(std::string* line) { + void NextLine(std::string* line) override { readers_[current_reader_index_]->NextLine(line); } @@ -151,6 +151,7 @@ void CTRReader::ReadThread(const std::vector& file_list, for (auto& slots_to_data : batch_data) { std::vector lod_data{0}; std::vector batch_feasign; + std::vector batch_label; auto& feasign = slots_to_data[slot];