blob: 406ea5db4a5e51525964c321f6e9c7f8336a32aa [file] [log] [blame]
Marc Kupietz06c9a9f2018-01-02 16:56:43 +01001#ifdef __cplusplus
Marc Kupietz4b799e92018-01-02 11:04:56 +01002#include <typeinfo>
Marc Kupietz4b799e92018-01-02 11:04:56 +01003#include "rocksdb/db.h"
Marc Kupietz06c9a9f2018-01-02 16:56:43 +01004#endif
5#include <stdint.h>
Marc Kupietz4b799e92018-01-02 11:04:56 +01006
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 Kupietz06c9a9f2018-01-02 16:56:43 +010013#ifdef __cplusplus
Marc Kupietz4b799e92018-01-02 11:04:56 +010014namespace 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 Kupietz06c9a9f2018-01-02 16:56:43 +010027 extern "C" {
28 class Collocators {
29 public:
Marc Kupietz4b799e92018-01-02 11:04:56 +010030 Collocators(const char *db_name);
31 ~Collocators();
32 void inc(const uint32_t w1, const uint32_t w2, const uint8_t dist);
Marc Kupietz06c9a9f2018-01-02 16:56:43 +010033 void dump(const uint32_t w1, const uint32_t w2, const uint8_t dist);
Marc Kupietz4b799e92018-01-02 11:04:56 +010034 CollocatorIterator* SeekIterator(uint64_t w1, uint64_t w2, int8_t dist);
Marc Kupietz06c9a9f2018-01-02 16:56:43 +010035 };
36
37 }
Marc Kupietz4b799e92018-01-02 11:04:56 +010038}
Marc Kupietz06c9a9f2018-01-02 16:56:43 +010039
40typedef rocksdb::Collocators COLLOCATORS;
41
42#else
43typedef struct COLLOCATORS COLLOCATORS;
44#endif
45
46extern COLLOCATORS *open_collocators(char *s);
Marc Kupietz6bb27762018-01-09 17:53:01 +010047extern COLLOCATORS *open_collocators_for_read(char *s);
Marc Kupietz06c9a9f2018-01-02 16:56:43 +010048extern void inc_collocators(COLLOCATORS *db, uint64_t w1, uint64_t w2, int8_t dist);
49extern void dump_collocators(COLLOCATORS *db, uint32_t w1, uint32_t w2, int8_t dist);
Marc Kupietz37359b12018-01-09 21:11:37 +010050extern void get_collocators(COLLOCATORS *db, uint32_t w1);
51extern char *get_collocators_as_json(COLLOCATORS *db, uint32_t w1);
Marc Kupietzc8ddf452018-01-07 21:33:12 +010052