MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / getLineEnds

Method getLineEnds

test/test_runner/multi_copy_split.cpp:37–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37std::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
61void SplitMultiCopyRandom::init() {
62 genSeedIfNecessary();

Callers

nothing calls this directly

Calls 6

TestExceptionClass · 0.85
nextRandomIntegerMethod · 0.80
emptyMethod · 0.45
push_backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected