#include <typeinfo>
#include <assert.h>
#include <memory>
#include <iostream>
#include <stdint.h>
#include "collocatordb.h"
using namespace rocksdb;

void dumpDb(Collocators& counters) {
    auto it = std::unique_ptr<CollocatorIterator>(counters.SeekIterator(1000,0,0));
    for (; it->isValid(); it->Next()) {
      uint64_t value = it->intValue();
      uint64_t key = it->intKey();
      std::cout << "w1:" << W1(key) << ", w2:" << W2(key) << ", dist:" << (int32_t) DIST(key) << " - count:" << value << std::endl;
    }
    std::cout << "ready dumping\n";
  }

  void testCollocators(Collocators& counters) {
    counters.inc(100,200,5);
    counters.inc(1000,2000,-5);
    counters.inc(1000,2000,5);
    counters.inc(1000,2500,-3);
    counters.inc(1000,2500,4);
    counters.inc(1000,2900,3);

    counters.inc(1001,2900,3);

    for(int i=0; i<10000; i++)
      counters.inc(rand()%1010,rand()%1010,rand()%10-5);

    //  dumpDb(db);

    counters.inc(100,200,5);
    counters.inc(1000,2000,5);
    counters.inc(1000,2500,4);
    counters.inc(1000,2900,3);

    counters.inc(1001,2900,3);

    dumpDb(counters);
    std::cout << "ready testing\n";
  }

  
int main() {
    Collocators counters = "/tmp/cdb";
    std::cout << "testing now\n";
    testCollocators(counters);
    std::cout << "ready running\n";
    return 0;
}
