MCPcopy Create free account
hub / github.com/dmlc/parameter_server / Reload

Method Reload

src/util/filelinereader.cc:16–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14 "line number limit that one data file could read");
15
16void FileLineReader::Reload() {
17 const int kMaxLineLength = 60 * 1024;
18 File* const data_file = File::open(data_conf_, "r");
19 if (data_file == NULL) {
20 loaded_successfully_ = false;
21 return;
22 }
23
24 size_t readed_line_count = 0;
25 std::unique_ptr<char[]> line(new char[kMaxLineLength]);
26 for (;;) {
27 char* const result = data_file->readLine(line.get(), kMaxLineLength);
28 if (result == NULL ||
29 (FLAGS_line_limit > 0 && readed_line_count > FLAGS_line_limit)) {
30 data_file->close();
31 loaded_successfully_ = true;
32 return;
33 }
34 // Chop the last linefeed if present.
35 int len = strlen(result);
36 if (len > 0 && result[len - 1] == '\n') { // Linefeed.
37 result[--len] = '\0';
38 }
39 if (len > 0 && result[len - 1] == '\r') { // Carriage return.
40 result[--len] = '\0';
41 }
42 if (line_callback_) line_callback_(result);
43
44 // increase line counter
45 readed_line_count++;
46 }
47 data_file->close();
48}
49
50
51} // namespace PS

Callers 1

readOneFileMethod · 0.80

Calls 3

readLineMethod · 0.80
closeMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected