12 This program writes run-length encoded PLCP of the collection into a file.
17 main(int argc, char** argv)
19 std::cout << "PLCP builder" << std::endl;
22 std::cout << "Usage: build_plcp base_name [block_size]" << std::endl;
26 std::string base_name = argv[1];
27 std::string plcp_name = base_name + PLCP_EXTENSION;
28 std::cout << "PLCP: " << plcp_name << std::endl;
29 std::ofstream plcp_file(plcp_name.c_str(), std::ios_base::binary);
32 std::cerr << "Error creating PLCP file!" << std::endl;
36 usint block_size = 32;
37 if(argc > 2) { block_size = atoi(argv[2]); }
38 std::cout << "Block size: " << block_size << std::endl;
39 std::cout << std::endl;
40 RLCSA rlcsa(base_name);
42 clock_t start = clock();
43 RLEVector* plcp = rlcsa.buildPLCP(block_size);
44 plcp->writeTo(plcp_file);
45 clock_t stop = clock();
47 double time = ((stop - start) / (double)CLOCKS_PER_SEC);
48 double megabytes = rlcsa.getSize() / (double)MEGABYTE;
49 double size = plcp->reportSize() / (double)MEGABYTE;
50 RLEVector::Iterator iter(*plcp);
51 usint runs = iter.countRuns();
53 std::cout << megabytes << " megabytes in " << time << " seconds (" << (megabytes / time) << " MB/s)" << std::endl;
54 std::cout << "PLCP size: " << size << " MB" << std::endl;
55 std::cout << "Runs: " << runs << std::endl;
56 std::cout << std::endl;