Marc Kupietz | b5bb194 | 2018-10-07 17:59:43 +0200 | [diff] [blame] | 1 | #include <typeinfo> |
| 2 | #include <assert.h> |
| 3 | #include <memory> |
| 4 | #include <iostream> |
| 5 | #include <stdint.h> |
| 6 | #include "collocatordb.h" |
| 7 | #include <thread> |
| 8 | #include <chrono> |
| 9 | #include <sstream> // for ostringstream |
| 10 | #include <fstream> |
| 11 | |
| 12 | using namespace rocksdb; |
| 13 | |
| 14 | |
| 15 | int main(int argc, char** argv) { |
| 16 | const int START=1; |
| 17 | const int STOP=300000; |
| 18 | uint32_t *array; |
| 19 | int done = 0; |
| 20 | |
| 21 | array = (uint32_t *)malloc(STOP * 20 * sizeof(uint32_t)); |
| 22 | memset(array, 0, STOP * 20 * sizeof(uint32_t)); |
| 23 | FILE* pFile; |
| 24 | CollocatorDB cdb = CollocatorDB(argv[1], true); |
| 25 | std::cerr << "Database " << argv[1] << " opened\n"; |
Marc Kupietz | 9dc01b7 | 2018-10-13 14:16:39 +0200 | [diff] [blame^] | 26 | #pragma omp parallel for schedule(dynamic, 1) |
Marc Kupietz | b5bb194 | 2018-10-07 17:59:43 +0200 | [diff] [blame] | 27 | for(uint32_t i=START; i< STOP; i++) { |
| 28 | std::vector<rocksdb::Collocator> cs = cdb.get_collocators(i); |
| 29 | int j=0; |
| 30 | for (rocksdb::Collocator c : cs) { |
| 31 | array[i*20+j] = (uint32_t) c.w2; |
| 32 | if(++j >=20) |
| 33 | break; |
| 34 | } |
| 35 | if(done++ % 100 == 0) { |
| 36 | std::cerr <<"\r\033[2K"<<std::flush; |
Marc Kupietz | 9dc01b7 | 2018-10-13 14:16:39 +0200 | [diff] [blame^] | 37 | std::cerr << "done: " << done * 100.0 / (STOP-START) << "%" << " (todo: " << STOP-START-done << ")" << std::flush; |
Marc Kupietz | b5bb194 | 2018-10-07 17:59:43 +0200 | [diff] [blame] | 38 | } |
| 39 | } |
| 40 | pFile = fopen("file.binary", "wb"); |
Marc Kupietz | 9dc01b7 | 2018-10-13 14:16:39 +0200 | [diff] [blame^] | 41 | fwrite(array, sizeof(uint32_t), STOP*20, pFile); |
Marc Kupietz | b5bb194 | 2018-10-07 17:59:43 +0200 | [diff] [blame] | 42 | fclose(pFile); |
| 43 | std::cout << std::flush; |
| 44 | } |