Marc Kupietz | 4b799e9 | 2018-01-02 11:04:56 +0100 | [diff] [blame] | 1 | #include <typeinfo> |
| 2 | #include <assert.h> |
| 3 | #include <memory> |
| 4 | #include <iostream> |
| 5 | #include <stdint.h> |
Marc Kupietz | c2e4321 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 6 | #include "../src/collocatordb.h" |
Marc Kupietz | 4b799e9 | 2018-01-02 11:04:56 +0100 | [diff] [blame] | 7 | using namespace rocksdb; |
| 8 | |
| 9 | void 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 | |
| 46 | int 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 | } |