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"; |
| 26 | #pragma omp parallel for |
| 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; |
| 37 | std::cerr << "done: " << done * 100.0 / (STOP-START) << "%" <<std::flush; |
| 38 | } |
| 39 | } |
| 40 | pFile = fopen("file.binary", "wb"); |
| 41 | fwrite(array, STOP*20, sizeof(uint32_t), pFile); |
| 42 | fclose(pFile); |
| 43 | std::cout << std::flush; |
| 44 | } |