MCPcopy Create free account
hub / github.com/apache/singa / Read

Method Read

src/io/binfile_reader.cc:43–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41}
42
43bool BinFileReader::Read(std::string* key, std::string* value) {
44 CHECK(fdat_.is_open()) << "File not open!";
45 char magic[4];
46 int smagic = sizeof(magic);
47 if (!PrepareNextField(smagic)) return false;
48 memcpy(magic, buf_ + offset_, smagic);
49 offset_ += smagic;
50
51 if (magic[0] == kMagicWord[0] && magic[1] == kMagicWord[1]) {
52 if (magic[2] != 0 && magic[2] != 1)
53 LOG(FATAL) << "File format error: magic word does not match!";
54 if (magic[2] == 1)
55 if (!ReadField(key)) return false;
56 if (!ReadField(value)) return false;
57 }
58 else {
59 LOG(FATAL) << "File format error: magic word does not match!";
60 }
61 return true;
62}
63
64int BinFileReader::Count() {
65 std::ifstream fin(path_, std::ios::in | std::ios::binary);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected