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++) { |
Marc Kupietz | d7d40aa | 2018-10-13 14:20:37 +0200 | [diff] [blame] | 28 | std::vector<rocksdb::Collocator> cs = cdb.get_collocators(i, STOP); |
Marc Kupietz | b5bb194 | 2018-10-07 17:59:43 +0200 | [diff] [blame] | 29 | int j=0; |
| 30 | for (rocksdb::Collocator c : cs) { |
Marc Kupietz | d7d40aa | 2018-10-13 14:20:37 +0200 | [diff] [blame] | 31 | if(c.w2 != i) { |
| 32 | array[i*20+j] = (uint32_t) c.w2; |
| 33 | if(++j >=20) |
| 34 | break; |
| 35 | } |
Marc Kupietz | b5bb194 | 2018-10-07 17:59:43 +0200 | [diff] [blame] | 36 | } |
| 37 | if(done++ % 100 == 0) { |
| 38 | std::cerr <<"\r\033[2K"<<std::flush; |
Marc Kupietz | 9dc01b7 | 2018-10-13 14:16:39 +0200 | [diff] [blame] | 39 | 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] | 40 | } |
| 41 | } |
| 42 | pFile = fopen("file.binary", "wb"); |
Marc Kupietz | 9dc01b7 | 2018-10-13 14:16:39 +0200 | [diff] [blame] | 43 | fwrite(array, sizeof(uint32_t), STOP*20, pFile); |
Marc Kupietz | b5bb194 | 2018-10-07 17:59:43 +0200 | [diff] [blame] | 44 | fclose(pFile); |
| 45 | std::cout << std::flush; |
| 46 | } |