#include <typeinfo>
#include <assert.h>
#include <memory>
#include <iostream>
#include <stdint.h>
#include "../src/collocatordb.h"
#include <thread>
#include <chrono>
#include <sstream> // for ostringstream
#include <fstream>

using namespace rocksdb;

  
int main(int argc, char** argv) {
  const int START=1;
  const int STOP=300000;
  uint32_t *array;
  int done = 0;

  array = (uint32_t *)malloc(STOP * 20 * sizeof(uint32_t));
  memset(array, 0, STOP * 20 * sizeof(uint32_t));
  FILE* pFile;
  CollocatorDB cdb = CollocatorDB(argv[1], true);
  std::cerr << "Database " << argv[1] << " opened\n";
  #pragma omp parallel for schedule(dynamic, 1)
  for(uint32_t i=START; i< STOP; i++) {
    std::vector<rocksdb::Collocator> cs = cdb.get_collocators(i, STOP);
    int j=0;
    for (rocksdb::Collocator c : cs) {
      if(c.w2 != i) {
        array[i*20+j] = (uint32_t) c.w2;
        if(++j >=20)
          break;
      }
    }
    if(done++  % 100 == 0) {
      std::cerr <<"\r\033[2K"<<std::flush;
      std::cerr << "done: " << done * 100.0 / (STOP-START) << "%" << " (todo: " << STOP-START-done << ")" << std::flush;
    }
  }
  pFile = fopen("file.binary", "wb");
  fwrite(array, sizeof(uint32_t), STOP*20, pFile);
  fclose(pFile);
  std::cout << std::flush;
}
