data_reader.cc 20.8 KB
Newer Older
R
rensilin 已提交
1 2 3
#include "paddle/fluid/train/custom_trainer/feed/dataset/data_reader.h"

#include <cstdio>
R
openmp  
rensilin 已提交
4
#include <atomic>
R
rensilin 已提交
5 6

#include <glog/logging.h>
R
rensilin 已提交
7
#include <omp.h>
R
rensilin 已提交
8

R
rensilin 已提交
9
#include "paddle/fluid/train/custom_trainer/feed/io/file_system.h"
R
rensilin 已提交
10 11 12 13 14

namespace paddle {
namespace custom_trainer {
namespace feed {

X
xiexionghang 已提交
15 16 17 18
int LineDataParser::parse(const char* str, size_t len, DataItem& data) const {
    size_t pos = 0;
    while (pos < len && str[pos] != ' ') {
        ++pos;
R
rensilin 已提交
19
    }
X
xiexionghang 已提交
20 21 22
    if (pos >= len) {
        VLOG(2) << "fail to parse line: " << std::string(str, len) << ", strlen: " << len;
        return -1;
R
rensilin 已提交
23
    }
X
xiexionghang 已提交
24 25 26 27 28 29
    VLOG(5) << "getline: " << str << " , pos: " << pos << ", len: " << len;
    data.id.assign(str, pos);
    data.data.assign(str + pos + 1, len - pos - 1);
    return 0;
}
REGIST_CLASS(DataParser, LineDataParser);
R
rensilin 已提交
30

W
wangyihong01 已提交
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
/********************************
 * feasign压缩格式
 * 情形1:slot:hot
 * |4b|4b|4b|4b|4b| 28b |
 * |slot       |0 |sign |
 * 情形2:slot:hot*n
 * |4b|4b|4b|4b|4b|4b|4b|4b|32b*n|
 * |slot       |1 |0 |len  |sign |
 * 情形3:slot:cold
 * |4b|4b|4b|4b|4b|4b| 64b |
 * |slot       |2 |0 |sign |
 * 情形4:slot:cold*n
 * |4b|4b|4b|4b|4b|4b|4b|4b|64b*n|
 * |slot       |3 |0 |len  |sign |
 ********************************/
class ArchiveDataParse : public DataParser {
public:
    static const uint8_t HOT_SIGN_SIZE = 4;
    static const uint8_t COLD_SIGN_SIZE = 8;

R
rensilin 已提交
51
public:
W
wangyihong01 已提交
52 53 54 55 56 57 58 59
    ArchiveDataParse() {}
    virtual ~ArchiveDataParse() {}

    struct Record {
        int show, clk;
        std::string tags;
        std::map<std::string, std::vector<float>> vec_feas;
        int sample_type;
W
wangyihong01 已提交
60
        std::map<std::string, std::vector<std::string>> auc_category_info_map; //为细维度计算auc准备的数据
W
wangyihong01 已提交
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
        std::vector<FeatureItem> hot_feas, cold_feas; //冷(int32_t)热(uint64_t)feasign

        void clear() {
            show = 0;
            clk = 0;
            tags.clear();
            vec_feas.clear();
            sample_type = 0;
            auc_category_info_map.clear();
            hot_feas.clear();
            cold_feas.clear();
        }

        uint32_t calc_compress_feas_lens() const {
            uint32_t hot_len = hot_feas.size();
            uint32_t cold_len = cold_feas.size();
            uint32_t cursor = 0;
            int32_t pre_slot = -1;
            uint32_t k = 0;
            //热编码
            if (hot_len > 0) {
                pre_slot = hot_feas[0].slot();
R
rensilin 已提交
83

W
wangyihong01 已提交
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
                for (uint32_t i = 0; i < hot_len + 1; ++i) {
                    if (i == hot_len || pre_slot != hot_feas[i].slot()) {
                        cursor += 2;
                        //情形2
                        if (i - k > 1) {
                            cursor += 2;
                        }
                        //情形1/2
                        cursor += (HOT_SIGN_SIZE * (i - k));
                        k = i;
                    }
                    pre_slot = hot_feas[i].slot();
                }
            }
            //冷编码
            if (cold_len > 0) {
                pre_slot = cold_feas[0].slot();
                k = 0;

                for (uint32_t i = 0; i < cold_len + 1; ++i) {
                    if (i == cold_len || pre_slot != cold_feas[i].slot()) {
                        cursor += 2;
                        //情形4
                        if (i - k > 1) {
                            cursor += 2;
                        } else { //情形3
                            cursor++;
                        }
                        //情形3/4
                        cursor += (COLD_SIGN_SIZE * (i - k));
                        k = i;
                    }
                    pre_slot = cold_feas[i].slot();
                }
            }
            return cursor;
        }

W
wangyihong01 已提交
122
        void serialize_to_compress_feas(char* buffer) const {
W
wangyihong01 已提交
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
            if (buffer == nullptr) {
                return ;
            }
            uint32_t cursor = 0;
            uint32_t hot_len = hot_feas.size();
            uint32_t cold_len = cold_feas.size();
            int32_t pre_slot = -1;
            int32_t hot_sign;
            uint16_t slot;
            uint8_t flag = 0, len = 0;
            uint32_t k = 0;
            //热编码
            if (hot_len > 0) {
                pre_slot = hot_feas[0].slot();

                for (uint32_t i = 0; i < hot_len + 1; ++i) {
                    if (i == hot_len || pre_slot != hot_feas[i].slot()) {
                        memcpy(buffer + cursor, &pre_slot, 2);
                        cursor += 2;
                        //情形2
                        if (i - k > 1) {
                            flag = 0x10;
                            memcpy(buffer + cursor, &flag, 1);
                            cursor++;
                            len = i - k;
                            memcpy(buffer + cursor, &len, 1);
                            cursor++;
                        }
                        //情形1/2
                        for (uint32_t j = k; j < i; ++j) {
                            hot_sign = (int32_t) hot_feas[j].sign();
                            for (uint8_t b = 0; b < HOT_SIGN_SIZE; ++b) {
                                flag = (hot_sign >> ((HOT_SIGN_SIZE - b - 1) * 8)) & 0xFF;
                                memcpy(buffer + cursor, &flag, 1);
                                cursor++;
                            }
                        }
                        k = i;
                    }
                    pre_slot = hot_feas[i].slot();
                }
            }
            //冷编码
            if (cold_len > 0) {
                pre_slot = cold_feas[0].slot();
                k = 0;

                for (uint32_t i = 0; i < cold_len + 1; ++i) {
                    if (i == cold_len || pre_slot != cold_feas[i].slot()) {
                        memcpy(buffer + cursor, &pre_slot, 2);
                        cursor += 2;
                        //情形4
                        if (i - k > 1) {
                            flag = 0x30;
                            memcpy(buffer + cursor, &flag, 1);
                            cursor++;
                            len = i - k;
                            memcpy(buffer + cursor, &len, 1);
                            cursor++;
                        }
                        //情形3/4
                        for (uint32_t j = k; j < i; ++j) {
                            if (i - k == 1) {
                                flag = 0x20;
                                memcpy(buffer + cursor, &flag, 1);
                                cursor++;
                            }
                            memcpy(buffer + cursor, &cold_feas[j].sign(), COLD_SIGN_SIZE);
                            cursor += COLD_SIGN_SIZE;
                        }
                        k = i;
                    }
                    pre_slot = cold_feas[i].slot();
                }
            }
        }
    };
R
rensilin 已提交
200 201

    virtual int initialize(const YAML::Node& config, std::shared_ptr<TrainerContext> context) {
W
wangyihong01 已提交
202 203
        _index = context->cache_dict;

R
rensilin 已提交
204 205 206 207
        return 0;
    }

    virtual int parse(const char* str, size_t len, DataItem& data) const {
W
wangyihong01 已提交
208
        size_t pos = paddle::string::count_nonspaces(str);
R
rensilin 已提交
209
        if (pos >= len) {
R
rensilin 已提交
210
            VLOG(2) << "fail to parse line: " << std::string(str, len) << ", strlen: " << len;
R
rensilin 已提交
211 212
            return -1;
        }
R
rensilin 已提交
213
        VLOG(5) << "getline: " << str << " , pos: " << pos << ", len: " << len;
R
rensilin 已提交
214
        data.id.assign(str, pos);
W
wangyihong01 已提交
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265
        str += pos;

        static thread_local std::vector<float> vec_feas;
        static thread_local Record rec;
        rec.clear();

        const char* line_end = str + len;
        char* cursor = NULL;
        CHECK((rec.show = (int)strtol(str, &cursor, 10), cursor != str));
        str = cursor;
        CHECK((rec.clk = (int)strtol(str, &cursor, 10), cursor != str));
        str = cursor;
        CHECK(rec.show >= 1 && rec.clk >= 0 && rec.clk <= rec.show);

        while (*(str += paddle::string::count_nonspaces(str)) != 0) {
            if (*str == '*') {
                str++;
                size_t len = paddle::string::count_nonspaces(str);
                std::string tag(str, str + len);
                rec.tags = tag;
                str += len;
            } else if (*str == '$') {
                str++;
                CHECK((rec.sample_type = (int)strtol(str, &cursor, 10), cursor != str))<<" sample type parse err:" << str;
                str = cursor;
            } else if (*str == '#') {
                str++;
                size_t len = std::find_if_not(str, line_end,
                                              [](char c) { return std::isalnum(c) != 0 || c == '_';}) - str;
                CHECK(len > 0 && *(str + len) == ':');
                std::string name(str, len);
                str += len;
                vec_feas.clear();
                while (*str == ':') {
                    float val = 0;
                    CHECK((val = strtof(str + 1, &cursor), cursor > str));
                    vec_feas.push_back(val);
                    str = cursor;
                }
                CHECK(rec.vec_feas.insert({name, vec_feas}).second);
            } else if (*str == '@') {
                str++;
                size_t len = paddle::string::count_nonspaces(str);
                std::string all_str(str, str + len);
                str += len;
                //category_name1=value1,value2,value3|category_name2=value1,value2|....
                std::vector<std::string> all_category_vec = paddle::string::split_string(all_str, "|");
                for (size_t i = 0; i < all_category_vec.size(); ++i) {
                    std::string& single_category_str = all_category_vec[i];
                    std::vector<std::string> str_vec = paddle::string::split_string(single_category_str, "=");
                    CHECK(str_vec.size() == 2);
W
wangyihong01 已提交
266 267
                    std::string category_name = str_vec[0];
                    std::vector<std::string> category_info_vec = paddle::string::split_string<std::string>(str_vec[1], ",");
W
wangyihong01 已提交
268 269
                    CHECK(category_info_vec.size() > 0);

W
wangyihong01 已提交
270
                    CHECK(rec.auc_category_info_map.insert({category_name, category_info_vec}).second);
W
wangyihong01 已提交
271 272 273 274
                }
            } else {
                uint64_t sign = 0;
                int slot = -1;
W
wangyihong01 已提交
275 276 277 278 279 280
                sign = (uint64_t)strtoull(str, &cursor, 10);
                if (cursor == str) { //FIXME abacus没有这种情况
                    str++;
                    continue;
                }
                //CHECK((sign = (uint64_t)strtoull(str, &cursor, 10), cursor != str));
W
wangyihong01 已提交
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297
                str = cursor;
                CHECK(*str++ == ':');
                CHECK(!isspace(*str));
                CHECK((slot = (int) strtol(str, &cursor, 10), cursor != str)) << " format error: " << str;
                CHECK((uint16_t) slot == slot);
                str = cursor;

                int32_t compress_sign = _index->sign2index(sign);
                if (compress_sign < 0) {
                    rec.cold_feas.emplace_back(sign, (uint16_t)slot);
                } else {
                    rec.hot_feas.emplace_back(compress_sign, (uint16_t)slot);
                }
            }
        }

        paddle::framework::BinaryArchive bar;
W
wangyihong01 已提交
298 299
        bar << rec.show << rec.clk << rec.tags << rec.vec_feas << rec.sample_type << rec.auc_category_info_map;
        uint32_t feas_len = rec.calc_compress_feas_lens(); //事先计算好压缩后feasign的空间
W
wangyihong01 已提交
300 301
        bar << feas_len;
        bar.Resize(bar.Length() + feas_len);
W
wangyihong01 已提交
302 303
        rec.serialize_to_compress_feas(bar.Finish() - feas_len); //直接在archive内部buffer进行压缩,避免不必要的拷贝
        data.data.assign(bar.Buffer(), bar.Length()); //TODO 这一步拷贝是否也能避免
W
wangyihong01 已提交
304

R
rensilin 已提交
305 306 307
        return 0;
    }

W
wangyihong01 已提交
308 309 310
    virtual int parse_to_sample(const DataItem& data, SampleInstance& instance) const {
        instance.id = data.id;
        if (data.data.empty()) {
R
rensilin 已提交
311 312
            return -1;
        }
W
wangyihong01 已提交
313

W
wangyihong01 已提交
314 315
        //FIXME temp
        int show = 0, clk = 0;
W
wangyihong01 已提交
316 317
        std::string tags;
        std::map<std::string, std::vector<float>> vec_feas;
W
wangyihong01 已提交
318
        int sample_type = 0;
W
wangyihong01 已提交
319 320 321 322 323 324 325 326 327 328 329 330
        std::map<std::string, std::vector<int>> auc_category_info_map;
        uint32_t feas_len = 0;

        paddle::framework::BinaryArchive bar;
        bar.SetReadBuffer(const_cast<char*>(&data.data[0]), data.data.size(), nullptr);
        bar >> show;
        bar >> clk;
        bar >> tags;
        bar >> vec_feas;
        bar >> sample_type;
        bar >> auc_category_info_map;
        bar >> feas_len;
W
wangyihong01 已提交
331 332
        CHECK((bar.Finish() - bar.Cursor()) == feas_len);
        deserialize_feas_to_ins(bar.Cursor(), feas_len, instance.features);
W
wangyihong01 已提交
333

R
rensilin 已提交
334 335 336
        return 0;
    }

W
wangyihong01 已提交
337
private:
W
wangyihong01 已提交
338
    void deserialize_feas_to_ins(char* buffer, uint32_t len, std::vector<FeatureItem>& ins) const {
W
wangyihong01 已提交
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390
        if (buffer == nullptr) {
            return ;
        }

        uint32_t cursor = 0;
        uint16_t slot;
        uint8_t flag;
        while (cursor < len) {
            memcpy(&slot, buffer + cursor, 2);
            cursor += 2;

            memcpy(&flag, buffer + cursor, 1);
            flag &= 0xF0;

            CHECK(flag == 0x00 || flag == 0x10|| flag == 0x20 || flag == 0x30);

            if (flag == 0x00 || flag == 0x10) {
                uint8_t len = 1;
                if (flag == 0x10) {
                    cursor++;
                    memcpy(&len, buffer + cursor, 1);
                    cursor++;
                }
                for (uint8_t i = 0; i < len; ++i) {
                    int32_t sign;
                    for (uint8_t j = 0; j < HOT_SIGN_SIZE; ++j) {
                        memcpy((char*)&sign + HOT_SIGN_SIZE-j-1, buffer + cursor, 1);
                        cursor++;
                    }

                    uint64_t sign64 = sign & 0x0FFFFFFF;
                    sign64 = _index->index2sign((int32_t)sign64);
                    ins.emplace_back(sign64, slot);
                }
            }

            if (flag == 0x20 || flag == 0x30) {
                uint8_t len = 1;
                cursor++;
                if (flag == 0x30) {
                    memcpy(&len, buffer + cursor, 1);
                    cursor++;
                }

                for (uint8_t i = 0; i < len; ++i) {
                    uint64_t sign64;
                    memcpy(&sign64, buffer + cursor, COLD_SIGN_SIZE);
                    cursor += COLD_SIGN_SIZE;
                    ins.emplace_back(sign64, slot);
                }
            }
        }
R
rensilin 已提交
391
    }
W
wangyihong01 已提交
392 393 394 395

private:
    std::shared_ptr<SignCacheDict> _index;

R
rensilin 已提交
396
};
X
xiexionghang 已提交
397
REGIST_CLASS(DataParser, ArchiveDataParse);
R
rensilin 已提交
398 399

int DataReader::initialize(const YAML::Node& config, std::shared_ptr<TrainerContext> context) {
X
xiexionghang 已提交
400
    _parser.reset(CREATE_INSTANCE(DataParser, config["parser"]["class"].as<std::string>()));
R
rensilin 已提交
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421
    if (_parser == nullptr) {
        VLOG(2) << "fail to get parser: " << config["parser"]["class"].as<std::string>();
        return -1;
    }
    if (_parser->initialize(config["parser"], context) != 0) {
        VLOG(2) << "fail to initialize parser" << config["parser"]["class"].as<std::string>();
        return -1;
    }
    _pipeline_cmd = config["pipeline_cmd"].as<std::string>();
    return 0;
}

class LineDataReader : public DataReader {
public:
    LineDataReader() {}
    virtual ~LineDataReader() {}
    virtual int initialize(const YAML::Node& config, std::shared_ptr<TrainerContext> context) {
        if (DataReader::initialize(config, context) != 0) {
            return -1;
        }
        _done_file_name = config["done_file"].as<std::string>();
R
rensilin 已提交
422
        _filename_prefix = config["filename_prefix"].as<std::string>("");
R
rensilin 已提交
423 424 425

        if (config["file_system"] && config["file_system"]["class"]) {
            _file_system.reset(
X
xiexionghang 已提交
426
                    CREATE_INSTANCE(FileSystem, config["file_system"]["class"].as<std::string>()));
R
rensilin 已提交
427 428 429 430 431 432
            if (_file_system == nullptr ||
                _file_system->initialize(config["file_system"], context) != 0) {
                VLOG(2) << "fail to create class: "
                        << config["file_system"]["class"].as<std::string>();
                return -1;
            }
X
xiexionghang 已提交
433 434
        } else if (context->file_system != nullptr) { 
            _file_system = context->file_system;
R
rensilin 已提交
435
        } else {
X
xiexionghang 已提交
436
            _file_system.reset(CREATE_INSTANCE(FileSystem, "LocalFileSystem"));
R
rensilin 已提交
437 438 439 440 441
            if (_file_system == nullptr || _file_system->initialize(YAML::Load(""), context) != 0) {
                VLOG(2) << "fail to init file system";
                return -1;
            }
        }
R
rensilin 已提交
442 443 444 445 446
        return 0;
    }

    //判断样本数据是否已就绪,就绪表明可以开始download
    virtual bool is_data_ready(const std::string& data_dir) {
R
rensilin 已提交
447 448
        auto done_file_path = _file_system->path_join(data_dir, _done_file_name);
        if (_file_system->exists(done_file_path)) {
R
rensilin 已提交
449 450 451 452 453
            return true;
        }
        return false;
    }

R
rensilin 已提交
454 455
    virtual std::vector<std::string> data_file_list(const std::string& data_dir) {
        std::vector<std::string> data_files;
R
rensilin 已提交
456 457
        for (auto& filepath : _file_system->list(data_dir)) {
            auto filename = _file_system->path_split(filepath).second;
R
rensilin 已提交
458 459
            if (filename != _done_file_name &&
                string::begin_with(filename, _filename_prefix)) {
R
rensilin 已提交
460 461 462 463 464 465
                data_files.push_back(std::move(filepath));
            }
        }
        return data_files;
    }

R
rensilin 已提交
466
    //读取数据样本流中
R
rensilin 已提交
467
    virtual int read_all(const std::string& data_dir, framework::Channel<DataItem> data_channel) {
X
xiexionghang 已提交
468 469 470 471
        auto file_list = data_file_list(data_dir);
        return read_all(file_list, data_channel);
    }
    virtual int read_all(const std::vector<std::string>& file_list, ::paddle::framework::Channel<DataItem> data_channel) {
R
fs_bug  
rensilin 已提交
472
        const int file_list_size = file_list.size();
R
openmp  
rensilin 已提交
473
        std::atomic<bool> is_failed(false);
R
rensilin 已提交
474

R
fs_bug  
rensilin 已提交
475 476 477 478 479 480 481
        const int max_threads = omp_get_max_threads();
        std::vector<framework::ChannelWriter<DataItem>> writers; // writer is not thread safe
        writers.reserve(max_threads);
        for (int i = 0; i < max_threads; ++i) {
            writers.emplace_back(data_channel.get());
        }
        VLOG(5) << "file_list: " << string::join_strings(file_list, ' ');
R
rensilin 已提交
482 483
        #pragma omp parallel for
        for (int i = 0; i < file_list_size; ++i) {
R
fs_bug  
rensilin 已提交
484 485 486 487 488 489 490 491
            if (is_failed) {
                continue;
            }
            const int thread_num = omp_get_thread_num();
            framework::ChannelWriter<DataItem> *writer = nullptr;
            if (thread_num < max_threads) {
                writer = &writers[thread_num];
            }
R
rensilin 已提交
492
            const auto& filepath = file_list[i];
R
fs_bug  
rensilin 已提交
493 494 495 496 497 498 499 500 501 502
            std::shared_ptr<FILE> fin = _file_system->open_read(filepath, _pipeline_cmd);
            if (fin == nullptr) {
                VLOG(2) << "fail to open file: " << filepath << ", with cmd: " << _pipeline_cmd;
                is_failed = true;
                continue;
            }
            char *buffer = nullptr;
            size_t buffer_size = 0;
            ssize_t line_len = 0;
            while ((line_len = getline(&buffer, &buffer_size, fin.get())) != -1) {
R
rensilin 已提交
503
                // 去掉行尾回车
R
fs_bug  
rensilin 已提交
504 505 506 507 508
                if (line_len > 0 && buffer[line_len - 1] == '\n') {
                    buffer[--line_len] = '\0';
                }
                // 忽略空行
                if (line_len <= 0) {
R
openmp  
rensilin 已提交
509
                    continue;
R
rensilin 已提交
510
                }
R
fix  
rensilin 已提交
511
                DataItem data_item;
R
fs_bug  
rensilin 已提交
512 513 514 515
                if (_parser->parse(buffer, line_len, data_item) == 0) {
                    VLOG(5) << "parse data: " << data_item.id << " " << data_item.data << ", filename: " << filepath << ", thread_num: " << thread_num << ", max_threads: " << max_threads;
                    if (writer == nullptr) {
                        if (!data_channel->Put(std::move(data_item))) {
R
rensilin 已提交
516 517
                            LOG(WARNING) << "fail to put data, thread_num: " << thread_num;
                            is_failed = true;
R
fs_bug  
rensilin 已提交
518 519
                        }
                    } else {
R
rensilin 已提交
520
                        (*writer) << std::move(data_item);
R
rensilin 已提交
521
                    }
R
rensilin 已提交
522
                }
R
fs_bug  
rensilin 已提交
523 524 525 526 527 528 529 530 531 532
            }
            if (buffer != nullptr) {
                free(buffer);
                buffer = nullptr;
                buffer_size = 0;
            }
            if (ferror(fin.get()) != 0) {
                VLOG(2) << "fail to read file: " << filepath;
                is_failed = true;
                continue;
R
rensilin 已提交
533 534
            }
        }
R
fs_bug  
rensilin 已提交
535 536 537 538 539 540 541 542
        // omp end

        for (int i = 0; i < max_threads; ++i) {
            writers[i].Flush();
            if (!writers[i]) {
                VLOG(2) << "writer " << i << " is failed";
                is_failed = true;
            }
R
rensilin 已提交
543
        }
R
rensilin 已提交
544
        data_channel->Close();
R
openmp  
rensilin 已提交
545
        return is_failed ? -1 : 0;
R
rensilin 已提交
546 547 548 549 550
    }

    virtual const DataParser* get_parser() {
        return _parser.get();
    }
R
rensilin 已提交
551

R
rensilin 已提交
552
private:
R
openmp  
rensilin 已提交
553
    std::string _done_file_name;  // without data_dir
R
rensilin 已提交
554
    std::string _filename_prefix;
X
xiexionghang 已提交
555
    std::shared_ptr<FileSystem> _file_system;
R
rensilin 已提交
556
};
X
xiexionghang 已提交
557
REGIST_CLASS(DataReader, LineDataReader);
R
rensilin 已提交
558

R
rensilin 已提交
559 560 561
}  // namespace feed
}  // namespace custom_trainer
}  // namespace paddle