LevelDB C API 整理分类
// 结构体列表 typedef struct leveldb_t leveldb_t; // 数据库 typedef struct leveldb_cache_t leveldb_cache_t; // 缓存 typedef struct leveldb_comparator_t leveldb_comparator_t; // 比较器 typedef struct leveldb_env_t leveldb_env_t; // 环境 typedef struct leveldb_filelock_t leveldb_filelock_t; // 文件锁 typedef struct leveldb_filterpolicy_t leveldb_filterpolicy_t; // 过滤器 typedef struct leveldb_iterator_t leveldb_iterator_t; // 迭代器 typedef struct leveldb_logger_t leveldb_logger_t; // 日志 typedef struct leveldb_options_t leveldb_options_t; // 选项 typedef struct leveldb_randomfile_t leveldb_randomfile_t; // typedef struct leveldb_readoptions_t leveldb_readoptions_t; // 读选项 typedef struct leveldb_seqfile_t leveldb_seqfile_t; // typedef struct leveldb_snapshot_t leveldb_snapshot_t; // 快照 typedef struct leveldb_writablefile_t leveldb_writablefile_t; // typedef struct leveldb_writebatch_t leveldb_writebatch_t; // 批写入 typedef struct leveldb_writeoptions_t leveldb_writeoptions_t; // 写选项 // 函数列表 /************************************************************ 数据库API *********************************************************************/ // 打开数据库 extern leveldb_t* leveldb_open( const leveldb_options_t* options,const char* name,char** errptr); // 关闭数据库 extern void leveldb_close(leveldb_t* db); // 添加k-v extern void leveldb_put(leveldb_t* db,const leveldb_writeoptions_t* options, const char* key, size_t keylen,const char* val, size_t vallen,char** errptr); // 删除k-v extern void leveldb_delete(leveldb_t* db,const leveldb_writeoptions_t* options,const char* key, size_t keylen,char** errptr); // 原子性写入 extern void leveldb_write(leveldb_t* db,const leveldb_writeoptions_t* options,leveldb_writebatch_t* batch,char** errptr); // 获取k-v extern char* leveldb_get(leveldb_t* db,const leveldb_readoptions_t* options,const char* key, size_t keylen,size_t* vallen,char** errptr); // 获取属性值 extern char* leveldb_property_value(leveldb_t* db,const char* propname); // 获取数据库大概的大小 extern void leveldb_approximate_sizes(leveldb_t* db,int num_ranges,const char* const* range_start_key, const size_t* range_start_key_len,const char* const* range_limit_key, const size_t* range_limit_key_len,uint64_t* sizes); // 范围压缩 extern void leveldb_compact_range(leveldb_t* db,const char* start_key, size_t start_key_len,const char* limit_key, size_t limit_key_len); // 销毁数据库 extern void leveldb_destroy_db(const leveldb_options_t* options,const char* name,char** errptr); // 修复数据库 extern void leveldb_repair_db(const leveldb_options_t* options,const char* name,char** errptr); // extern void leveldb_free(void* ptr); /************************************************************ 迭代器API *********************************************************************/ // 创建迭代器 extern leveldb_iterator_t* leveldb_create_iterator(leveldb_t* db,const leveldb_readoptions_t* options); extern void leveldb_iter_destroy(leveldb_iterator_t*); extern unsigned char leveldb_iter_valid(const leveldb_iterator_t*); extern void leveldb_iter_seek_to_first(leveldb_iterator_t*); extern void leveldb_iter_seek_to_last(leveldb_iterator_t*); extern void leveldb_iter_seek(leveldb_iterator_t*, const char* k, size_t klen); extern void leveldb_iter_next(leveldb_iterator_t*); extern void leveldb_iter_prev(leveldb_iterator_t*); extern const char* leveldb_iter_key(const leveldb_iterator_t*, size_t* klen); extern const char* leveldb_iter_value(const leveldb_iterator_t*, size_t* vlen); extern void leveldb_iter_get_error(const leveldb_iterator_t*, char** errptr); /************************************************************ 批量写入API *******************************************************************/ // extern leveldb_writebatch_t* leveldb_writebatch_create(); extern void leveldb_writebatch_destroy(leveldb_writebatch_t*); extern void leveldb_writebatch_clear(leveldb_writebatch_t*); extern void leveldb_writebatch_put(leveldb_writebatch_t*,const char* key, size_t klen,const char* val, size_t vlen); extern void leveldb_writebatch_delete(leveldb_writebatch_t*,const char* key, size_t klen); extern void leveldb_writebatch_iterate(leveldb_writebatch_t*,void* state,void (*put)(void*, const char* k, size_t klen, const char* v, size_t vlen),void (*deleted)(void*, const char* k, size_t klen)); /************************************************************** 选项器API *********************************************************************/ // extern leveldb_options_t* leveldb_options_create(); extern void leveldb_options_destroy(leveldb_options_t*); extern void leveldb_options_set_comparator(leveldb_options_t*,leveldb_comparator_t*); extern void leveldb_options_set_filter_policy(leveldb_options_t*,leveldb_filterpolicy_t*); extern void leveldb_options_set_create_if_missing(leveldb_options_t*, unsigned char); extern void leveldb_options_set_error_if_exists(leveldb_options_t*, unsigned char); extern void leveldb_options_set_paranoid_checks(leveldb_options_t*, unsigned char); extern void leveldb_options_set_env(leveldb_options_t*, leveldb_env_t*); extern void leveldb_options_set_info_log(leveldb_options_t*, leveldb_logger_t*); extern void leveldb_options_set_write_buffer_size(leveldb_options_t*, size_t); extern void leveldb_options_set_max_open_files(leveldb_options_t*, int); extern void leveldb_options_set_cache(leveldb_options_t*, leveldb_cache_t*); extern void leveldb_options_set_block_size(leveldb_options_t*, size_t); extern void leveldb_options_set_block_restart_interval(leveldb_options_t*, int); enum { leveldb_no_compression = 0, leveldb_snappy_compression = 1 }; extern void leveldb_options_set_compression(leveldb_options_t*, int); /************************************************************** 比较器API *********************************************************************/ // extern leveldb_comparator_t* leveldb_comparator_create( void* state, void (*destructor)(void*), int (*compare)( void*, const char* a, size_t alen, const char* b, size_t blen), const char* (*name)(void*)); extern void leveldb_comparator_destroy(leveldb_comparator_t*); /************************************************************** 过滤器API *********************************************************************/ // extern leveldb_filterpolicy_t* leveldb_filterpolicy_create( void* state, void (*destructor)(void*), char* (*create_filter)( void*, const char* const* key_array, const size_t* key_length_array, int num_keys, size_t* filter_length), unsigned char (*key_may_match)( void*, const char* key, size_t length, const char* filter, size_t filter_length), const char* (*name)(void*)); extern void leveldb_filterpolicy_destroy(leveldb_filterpolicy_t*); extern leveldb_filterpolicy_t* leveldb_filterpolicy_create_bloom(int bits_per_key); /************************************************************** 读选项API *********************************************************************/ // extern leveldb_readoptions_t* leveldb_readoptions_create(); extern void leveldb_readoptions_destroy(leveldb_readoptions_t*); extern void leveldb_readoptions_set_verify_checksums(leveldb_readoptions_t*,unsigned char); extern void leveldb_readoptions_set_fill_cache(leveldb_readoptions_t*, unsigned char); extern void leveldb_readoptions_set_snapshot(leveldb_readoptions_t*,const leveldb_snapshot_t*); /************************************************************** 写选项API *********************************************************************/ // 创建写入选项变量 extern leveldb_writeoptions_t* leveldb_writeoptions_create(); // 销毁 extern void leveldb_writeoptions_destroy(leveldb_writeoptions_t*); // 设置写入选项是否异步方式写入 extern void leveldb_writeoptions_set_sync(leveldb_writeoptions_t*, unsigned char); /**************************************************************** 缓存API *********************************************************************/ // 安居lru算法创建缓存 extern leveldb_cache_t* leveldb_cache_create_lru(size_t capacity); // 销毁缓存 extern void leveldb_cache_destroy(leveldb_cache_t* cache); /************************************************************ 环境API **********************************************************************/ // 创建默认环境变量 extern leveldb_env_t* leveldb_create_default_env(); // 销毁环境变量 extern void leveldb_env_destroy(leveldb_env_t*); /************************************************************ 快照API **********************************************************************/ // 创建快照 extern const leveldb_snapshot_t* leveldb_create_snapshot(leveldb_t* db); // 释放快照 extern void leveldb_release_snapshot(leveldb_t* db,const leveldb_snapshot_t* snapshot); /************************************************************ 工具API **********************************************************************/ // 获取主版本好 extern int leveldb_major_version(); // 获取子版本号 extern int leveldb_minor_version();
作者:小熊猫小
出处:http://www.cnblogs.com/pandang/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。