| 4 | using namespace PS; |
| 5 | |
| 6 | SArray<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 | |
| 26 | TEST(PREPARE_DATA, KEY) { |
| 27 | auto key1 = readKeyFromFile("../../data/ctrd/part-0000"); |