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

using namespace rocksdb;

  
int main(int argc, char** argv) {
  const int START=0;
  const int STOP=1500000;
  int done = 0;
  CollocatorDB cdb = CollocatorDB(argv[1], true);
  std::cerr << "Database " << argv[1] << " opened\n";

  #pragma omp parallel for ordered schedule(static,1)
  for(uint32_t i=START; i< STOP; i++) {
    //    cdb.dumpSparseLlr(i, 5);
    std::vector<rocksdb::Collocator> cs = cdb.get_collocators(i);
    std::stringstream stream;
    // stream << i << "(" << cdb.getWord(i) << "): ";
    if(cs.empty())
      stream << "0 0.0";
    for (rocksdb::Collocator c : cs) {
      stream << c.w2 << " " << c.npmi << " ";
      // stream << c.w2 << "(" << cdb.getWord(c.w2) << ") " << c.llr << " ";
      if(c.raw < 5)
        break;
    }
    stream  << "\n";
    #pragma omp ordered
    std::cout << stream.str();
    if(done++  % 100 == 0) {
      std::cerr <<"\r\033[2K"<<std::flush;
      std::cerr << "done: " << done * 100.0 / (STOP-START) << "%" <<std::flush;
    }
  }
  std::cout << std::flush;
}
