1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| #include"./src/src/core/lipp.h" #include"../indexInterface.h"
template<class KEY_TYPE, class PAYLOAD_TYPE> class LIPPInterface : public indexInterface<KEY_TYPE, PAYLOAD_TYPE> { public: void init(Param *param = nullptr) {}
void bulk_load(std::pair <KEY_TYPE, PAYLOAD_TYPE> *key_value, size_t num, Param *param = nullptr);
bool get(KEY_TYPE key, PAYLOAD_TYPE &val, Param *param = nullptr);
bool put(KEY_TYPE key, PAYLOAD_TYPE value, Param *param = nullptr);
bool update(KEY_TYPE key, PAYLOAD_TYPE value, Param *param = nullptr);
bool remove(KEY_TYPE key, Param *param = nullptr);
size_t scan(KEY_TYPE key_low_bound, size_t key_num, std::pair <KEY_TYPE, PAYLOAD_TYPE> *result, Param *param = nullptr);
long long memory_consumption() { return lipp.total_size(); }
private: LIPP <KEY_TYPE, PAYLOAD_TYPE> lipp; };
template<class KEY_TYPE, class PAYLOAD_TYPE> void LIPPInterface<KEY_TYPE, PAYLOAD_TYPE>::bulk_load(std::pair <KEY_TYPE, PAYLOAD_TYPE> *key_value, size_t num, Param *param) { lipp.bulk_load(key_value, static_cast<int>(num)); }
template<class KEY_TYPE, class PAYLOAD_TYPE> bool LIPPInterface<KEY_TYPE, PAYLOAD_TYPE>::get(KEY_TYPE key, PAYLOAD_TYPE &val, Param *param) { bool exist; val = lipp.at(key, false, exist); return exist; }
template<class KEY_TYPE, class PAYLOAD_TYPE> bool LIPPInterface<KEY_TYPE, PAYLOAD_TYPE>::put(KEY_TYPE key, PAYLOAD_TYPE value, Param *param) { return lipp.insert(key, value);
}
template<class KEY_TYPE, class PAYLOAD_TYPE> bool LIPPInterface<KEY_TYPE, PAYLOAD_TYPE>::update(KEY_TYPE key, PAYLOAD_TYPE value, Param *param) { return lipp.update(key, value); }
template<class KEY_TYPE, class PAYLOAD_TYPE> bool LIPPInterface<KEY_TYPE, PAYLOAD_TYPE>::remove(KEY_TYPE key, Param *param) { return lipp.remove(key); }
template<class KEY_TYPE, class PAYLOAD_TYPE> size_t LIPPInterface<KEY_TYPE, PAYLOAD_TYPE>::scan(KEY_TYPE key_low_bound, size_t key_num, std::pair <KEY_TYPE, PAYLOAD_TYPE> *result, Param *param) { if(!result) { result = new std::pair <KEY_TYPE, PAYLOAD_TYPE>[key_num]; } return lipp.range_query_len(result, key_low_bound, key_num); }
|