blob: 64e93043e4b08de827f9fc1fc3bef939983b83a3 [file] [log] [blame]
Marc Kupietz4b799e92018-01-02 11:04:56 +01001#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 Kupietz4b799e92018-01-02 11:04:56 +01007using namespace rocksdb;
8
9void dumpDb(Collocators& counters) {
10 auto it = std::unique_ptr<CollocatorIterator>(counters.SeekIterator(1000,0,0));
11 for (; it->isValid(); it->Next()) {
12 uint64_t value = it->intValue();
13 uint64_t key = it->intKey();
14 std::cout << "w1:" << W1(key) << ", w2:" << W2(key) << ", dist:" << (int32_t) DIST(key) << " - count:" << value << std::endl;
15 }
16 std::cout << "ready dumping\n";
17 }
18
19 void testCollocators(Collocators& counters) {
20 counters.inc(100,200,5);
21 counters.inc(1000,2000,-5);
22 counters.inc(1000,2000,5);
23 counters.inc(1000,2500,-3);
24 counters.inc(1000,2500,4);
25 counters.inc(1000,2900,3);
26
27 counters.inc(1001,2900,3);
28
29 for(int i=0; i<10000; i++)
30 counters.inc(rand()%1010,rand()%1010,rand()%10-5);
31
32 // dumpDb(db);
33
34 counters.inc(100,200,5);
35 counters.inc(1000,2000,5);
36 counters.inc(1000,2500,4);
37 counters.inc(1000,2900,3);
38
39 counters.inc(1001,2900,3);
40
41 dumpDb(counters);
42 std::cout << "ready testing\n";
43 }
44
45
46int main() {
47 Collocators counters = "/tmp/cdb";
48 std::cout << "testing now\n";
49 testCollocators(counters);
50 std::cout << "ready running\n";
51 return 0;
52}