2024-10-28 02:23:42 +00:00
|
|
|
#include "tapelib/filetape.h"
|
|
|
|
#include <cstddef>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <ctime>
|
|
|
|
#include <fstream>
|
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
|
|
|
|
2024-10-28 10:32:14 +00:00
|
|
|
using std::setfill;
|
|
|
|
using std::setw;
|
|
|
|
using std::string;
|
|
|
|
using std::to_string;
|
|
|
|
using namespace tape;
|
|
|
|
|
2024-10-28 02:23:42 +00:00
|
|
|
/**
|
|
|
|
* Generate big input data sets for external sort testing.
|
|
|
|
* Takes 2 positional arguments - first one is the ouput file name,
|
|
|
|
* secon one is the amount of random cells that will be generated.
|
|
|
|
* Each cell value is in range [0; RAND_MAX]
|
|
|
|
*/
|
|
|
|
int main(int argc, char *argv[]) {
|
|
|
|
if (argc < 3) {
|
|
|
|
std::cerr << "Not enough arguments" << std::endl;
|
|
|
|
return -1;
|
|
|
|
}
|
2024-10-28 10:32:14 +00:00
|
|
|
string out_name = argv[1]; // NOLINT
|
2024-10-28 02:23:42 +00:00
|
|
|
size_t cells = std::stoi(argv[2]); // NOLINT
|
|
|
|
std::ofstream out(out_name);
|
|
|
|
if (!out.is_open()) {
|
|
|
|
std::cerr << "Failed to open file" << std::endl;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
srand(time(nullptr));
|
2024-10-28 10:32:14 +00:00
|
|
|
out << setfill('0') << setw(tape::FT_CELL_SIZE) << to_string(rand());
|
2024-10-28 02:23:42 +00:00
|
|
|
for (size_t i = 1; i < cells; i++) {
|
2024-10-28 10:32:14 +00:00
|
|
|
out << FT_DELIMETER << setfill('0') << setw(tape::FT_CELL_SIZE)
|
|
|
|
<< to_string(rand());
|
2024-10-28 02:23:42 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|