| 35 | } |
| 36 | |
| 37 | std::vector<uint32_t> SplitMultiCopyRandom::getLineEnds(std::string path) const { |
| 38 | RandomEngine random(seed[0], seed[1]); |
| 39 | spdlog::info("RANDOM GENERATOR used seed: {} {}", seed[0], seed[1]); |
| 40 | std::ifstream file(path); |
| 41 | if (!file.is_open()) { |
| 42 | throw TestException(std::format("Error opening file: {}, errno: {}.", path, errno)); |
| 43 | } |
| 44 | // determine # lines in each split file |
| 45 | std::string line; |
| 46 | uint32_t linecnt = 0; |
| 47 | while (getline(file, line)) { |
| 48 | if (!line.empty()) { |
| 49 | linecnt++; |
| 50 | } |
| 51 | } |
| 52 | std::vector<uint32_t> lineEnds; |
| 53 | for (auto i = 0u; i < numSplit - 1; i++) { |
| 54 | lineEnds.push_back(random.nextRandomInteger(linecnt)); |
| 55 | } |
| 56 | lineEnds.push_back(linecnt); |
| 57 | std::sort(lineEnds.begin(), lineEnds.end()); |
| 58 | return lineEnds; |
| 59 | } |
| 60 | |
| 61 | void SplitMultiCopyRandom::init() { |
| 62 | genSeedIfNecessary(); |
nothing calls this directly
no test coverage detected