blob: 8c3bf56ba3f306de51fd9c815395d7231c6d1c8a [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>
Marc Kupietzc2e43212021-03-13 18:05:14 +01006#include "../src/collocatordb.h"
Marc Kupietzb5bb1942018-10-07 17:59:43 +02007#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++) {
Marc Kupietzd7d40aa2018-10-13 14:20:37 +020028 std::vector<rocksdb::Collocator> cs = cdb.get_collocators(i, STOP);
Marc Kupietzb5bb1942018-10-07 17:59:43 +020029 int j=0;
30 for (rocksdb::Collocator c : cs) {
Marc Kupietzd7d40aa2018-10-13 14:20:37 +020031 if(c.w2 != i) {
32 array[i*20+j] = (uint32_t) c.w2;
33 if(++j >=20)
34 break;
35 }
Marc Kupietzb5bb1942018-10-07 17:59:43 +020036 }
37 if(done++ % 100 == 0) {
38 std::cerr <<"\r\033[2K"<<std::flush;
Marc Kupietz9dc01b72018-10-13 14:16:39 +020039 std::cerr << "done: " << done * 100.0 / (STOP-START) << "%" << " (todo: " << STOP-START-done << ")" << std::flush;
Marc Kupietzb5bb1942018-10-07 17:59:43 +020040 }
41 }
42 pFile = fopen("file.binary", "wb");
Marc Kupietz9dc01b72018-10-13 14:16:39 +020043 fwrite(array, sizeof(uint32_t), STOP*20, pFile);
Marc Kupietzb5bb1942018-10-07 17:59:43 +020044 fclose(pFile);
45 std::cout << std::flush;
46}