blob: 41fd4a393b67f2724eb7be587eb2b4967544ebec [file] [log] [blame]
Marc Kupietzb5bb1942018-10-07 17:59:43 +02001#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
12using namespace rocksdb;
13
14
15int 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 Kupietz9dc01b72018-10-13 14:16:39 +020026 #pragma omp parallel for schedule(dynamic, 1)
Marc Kupietzb5bb1942018-10-07 17:59:43 +020027 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 Kupietz9dc01b72018-10-13 14:16:39 +020037 std::cerr << "done: " << done * 100.0 / (STOP-START) << "%" << " (todo: " << STOP-START-done << ")" << std::flush;
Marc Kupietzb5bb1942018-10-07 17:59:43 +020038 }
39 }
40 pFile = fopen("file.binary", "wb");
Marc Kupietz9dc01b72018-10-13 14:16:39 +020041 fwrite(array, sizeof(uint32_t), STOP*20, pFile);
Marc Kupietzb5bb1942018-10-07 17:59:43 +020042 fclose(pFile);
43 std::cout << std::flush;
44}