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

Function readKeyFromFile

src/test/prepare_test_data.cc:6–24  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4using namespace PS;
5
6SArray<Key> readKeyFromFile(string filename) {
7 ExampleParser parser;
8 parser.init(DataConfig::ADFEA, true);
9 auto file = File::openOrDie(filename, "r");
10 const int bs = 100000;
11 char* buf = new char[bs];
12 Example ex;
13 SArray<Key> key;
14 while (true) {
15 char* line = file->readLine(buf, bs);
16 if (line == NULL) break;
17 parser.toProto(line, &ex);
18 const auto& slot = ex.slot(1);
19 for (int j = 0; j < slot.key_size(); ++j) {
20 key.pushBack(slot.key(j));
21 }
22 }
23 return key;
24}
25
26TEST(PREPARE_DATA, KEY) {
27 auto key1 = readKeyFromFile("../../data/ctrd/part-0000");

Callers 1

TESTFunction · 0.85

Calls 6

readLineMethod · 0.80
toProtoMethod · 0.80
key_sizeMethod · 0.80
pushBackMethod · 0.80
keyMethod · 0.80
initMethod · 0.45

Tested by

no test coverage detected