Marc Kupietz | 06c9a9f | 2018-01-02 16:56:43 +0100 | [diff] [blame^] | 1 | #ifdef __cplusplus |
Marc Kupietz | 4b799e9 | 2018-01-02 11:04:56 +0100 | [diff] [blame] | 2 | #include <typeinfo> |
Marc Kupietz | 4b799e9 | 2018-01-02 11:04:56 +0100 | [diff] [blame] | 3 | #include "rocksdb/db.h" |
Marc Kupietz | 06c9a9f | 2018-01-02 16:56:43 +0100 | [diff] [blame^] | 4 | #endif |
| 5 | #include <stdint.h> |
Marc Kupietz | 4b799e9 | 2018-01-02 11:04:56 +0100 | [diff] [blame] | 6 | |
| 7 | #define IS_BIG_ENDIAN (*(uint16_t *)"\0\xff" < 0x100) |
| 8 | #define encodeCollocation(w1, w2, dist) (((uint64_t)dist << 56) | ((uint64_t)w2 << 24) | w1) |
| 9 | #define W1(key) (uint64_t)(key & 0xffffff) |
| 10 | #define W2(key) (uint64_t)((key >> 24) & 0xffffff) |
| 11 | #define DIST(key) (int8_t)((uint64_t)((key >> 56) & 0xff)) |
| 12 | |
Marc Kupietz | 06c9a9f | 2018-01-02 16:56:43 +0100 | [diff] [blame^] | 13 | #ifdef __cplusplus |
Marc Kupietz | 4b799e9 | 2018-01-02 11:04:56 +0100 | [diff] [blame] | 14 | namespace rocksdb { |
| 15 | class CollocatorIterator : public Iterator { |
| 16 | public: |
| 17 | CollocatorIterator(const Iterator& it); |
| 18 | void SeekToFirst(); |
| 19 | void SeekToLast(); |
| 20 | void Seek(const rocksdb::Slice&); |
| 21 | void Prev(); |
| 22 | bool isValid(); |
| 23 | uint64_t intValue(); |
| 24 | uint64_t intKey(); |
| 25 | }; |
| 26 | |
Marc Kupietz | 06c9a9f | 2018-01-02 16:56:43 +0100 | [diff] [blame^] | 27 | extern "C" { |
| 28 | class Collocators { |
| 29 | public: |
Marc Kupietz | 4b799e9 | 2018-01-02 11:04:56 +0100 | [diff] [blame] | 30 | Collocators(const char *db_name); |
| 31 | ~Collocators(); |
| 32 | void inc(const uint32_t w1, const uint32_t w2, const uint8_t dist); |
Marc Kupietz | 06c9a9f | 2018-01-02 16:56:43 +0100 | [diff] [blame^] | 33 | void dump(const uint32_t w1, const uint32_t w2, const uint8_t dist); |
Marc Kupietz | 4b799e9 | 2018-01-02 11:04:56 +0100 | [diff] [blame] | 34 | CollocatorIterator* SeekIterator(uint64_t w1, uint64_t w2, int8_t dist); |
Marc Kupietz | 06c9a9f | 2018-01-02 16:56:43 +0100 | [diff] [blame^] | 35 | }; |
| 36 | |
| 37 | } |
Marc Kupietz | 4b799e9 | 2018-01-02 11:04:56 +0100 | [diff] [blame] | 38 | } |
Marc Kupietz | 06c9a9f | 2018-01-02 16:56:43 +0100 | [diff] [blame^] | 39 | |
| 40 | typedef rocksdb::Collocators COLLOCATORS; |
| 41 | |
| 42 | #else |
| 43 | typedef struct COLLOCATORS COLLOCATORS; |
| 44 | #endif |
| 45 | |
| 46 | extern COLLOCATORS *open_collocators(char *s); |
| 47 | extern void inc_collocators(COLLOCATORS *db, uint64_t w1, uint64_t w2, int8_t dist); |
| 48 | extern void dump_collocators(COLLOCATORS *db, uint32_t w1, uint32_t w2, int8_t dist); |