- 接口- 一个ABC,后面会继承这个类做各种实现 - clean up function- 代码比较好懂,唯一让我感到疑惑的是 clean up function 这部分 - 1 2 // FIXME: 不太理解为什么需要很多个clean up function 3 // Cleanup functions are stored in a single-linked list. 4 // The list's head node is inlined in the iterator. 5 struct CleanupNode { 6 // True if the node is not used. Only …
 阅读更多
- arena时levelDB中的内存池实现 - 接口- 没有太多好说的,都非常直观。 补了些注释 - 1 2class Arena { 3 public: 4 Arena(); 5 6 Arena(const Arena&) = delete; 7 Arena& operator=(const Arena&) = delete; 8 9 ~Arena(); 10 11 // Return a pointer to a newly allocated memory block of "bytes" bytes. 12 char* Allocate(size_t bytes); …
 阅读更多
- FilterPolicy接口- 1 2class LEVELDB_EXPORT FilterPolicy { 3 public: 4 virtual ~FilterPolicy(); 5 6 // Return the name of this policy. Note that if the filter encoding 7 // changes in an incompatible way, the name returned by this method 8 // must be changed. Otherwise, old incompatible filters may be 9 // …
 阅读更多
- Cache接口- 没有太多好说的,可以注意这里用了void*来表示任意类型数据。 在c++17之后可以考虑用std::any代替,参考 std::any 笔记 - 1 2 3namespace leveldb { 4 5class LEVELDB_EXPORT Cache; 6 7// Create a new cache with a fixed size capacity. This implementation 8// of Cache uses a least-recently-used eviction policy. 9LEVELDB_EXPORT Cache* NewLRUCache(size_t …
 阅读更多
- levelDB是一个有序的KV存储,因此key的顺序是十分关键的 levelDB提供用户自己定义key顺序的能力 - 先看下comparator的接口 - 接口 include/leveldb/comparator.h- 1 2// A Comparator object provides a total order across slices that are 3// used as keys in an sstable or a database. A Comparator implementation 4// must be thread-safe since leveldb may invoke its methods …
 阅读更多
- 背景- 最近在做一个智能算力相关的项目,类似美团外卖广告智能算力的探索与实践 其中实现控制系统需要与数据库交互。 虽然最后技术选型并没有使用到levelDB,但是想趁机把代码读了吧。 - 很惊讶的发现我大三的时候声称自己读过部分levelDB代码,甚至还写了几篇相关的博客,比如 
 阅读更多
- 分析levelDB源码的时候遇到的...发现是一个广泛应用的hash算法,而且是纯c写的,于是找来了源码看。 - **MurmurHash** 是一种非[加密](https://zh.wikipedia.org/wiki/)型[哈希函数](https://zh.wikipedia.org/wiki/),适用于一般的哈希检索操 … 
 阅读更多
- 看leveldb源码中遇到的,关于lock-free 和 wait-free..感觉这个讲得不错,我试着翻译一下? - There are two types of [non-blocking thread synchronization](http://en.wikipedia.org/wiki/Non-blocking_synchronization) algorithms - lock-free, and wait-free. Their meaning is often confused. In lock-free systems, while any particular computation may be … 
 阅读更多