↓ 跳过正文

111qqz

ML Infra Engineer | ex-ICPCer@HUST

最近的文章

levelDB 代码阅读笔记 02 comparator

·3968 字·8 分钟
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 concurrently 5// from multiple threads. 6class LEVELDB_EXPORT Comparator { 7 public: 8 virtual ~Comparator(); 9 10 // Three-way comparison. Returns value: 11 // < 0 iff "a" < "b", 12 // == 0 iff "a" == "b", 13 // > 0 iff "a" > "b" 14 virtual int Compare(const Slice& a, const Slice& b) const = 0; 15 16 // The name of the comparator. Used to check for comparator 17 // mismatches (i.e., a DB created with one comparator is 18 // accessed using a different comparator. 19 // 20 // The client of this package should switch to a new name whenever 21 // the comparator implementation changes in a way that will cause 22 // the relative ordering of any two keys to change. 23 // 24 // Names starting with "leveldb." are reserved and should not be used 25 // by any clients of this package. 26 virtual const char* Name() const = 0; 27 28 // Advanced functions: these are used to reduce the space requirements 29 // for internal data structures like index blocks. 30 31 // If *start < limit, changes *start to a short string in [start,limit). 32 // Simple comparator implementations may return with *start unchanged, 33 // i.e., an implementation of this method that does nothing is correct. 34 virtual void FindShortestSeparator(std::string* start, 35 const Slice& limit) const = 0; 36 37 // Changes *key to a short string >= *key. 38 // Simple comparator implementations may return with *key unchanged, 39 // i.e., an implementation of this method that does nothing is correct. 40 virtual void FindShortSuccessor(std::string* key) const = 0; 41}; 比较让人迷惑的应该是 FindShortestSeparator 和 FindShortSuccessor 函数。 其实可以简单理解成为了节省存储,而对key做了一定修改。 这个实现是不确定的,甚至完全什么都不做也是合法的。

levelDB 代码阅读笔记 01 db.h

·1551 字·4 分钟
背景 # 最近在做一个智能算力相关的项目,类似美团外卖广告智能算力的探索与实践 其中实现控制系统需要与数据库交互。虽然最后技术选型并没有使用到levelDB,但是想趁机把代码读了吧。

博客除草

·469 字·1 分钟
博客要长草了。。趁着过年时间多,打理一下。。 添加google analytics # hugo本身已经集成了这个功能 要点是集成的是旧版本的universal analytics (对应的是UA-ID) 而目前google主推得其实是新版本google analytics 4(对应的是GA4-ID)

[施工完成] CSAPP shell lab

·1205 字·3 分钟
背景 # 动手实现一个简单的 Lab,主要依赖于课本第八章的内容。 感觉主要是 05 比较难:一开始发现执行的顺序不太对,原因是 SIGCHLD 里 waitpid 的参数没写对,后面就相对简单了。 累计大概花了 10 个小时的样子。

[施工完成] CSAPP Malloc lab

·3238 字·7 分钟
背景 # 动手实现一个 memory allocator,体会 core 到爆炸的乐趣(不是 trace file 结构分析 # trace file 是对 allocator 输入的描述,可以从 mdriver.c 中的

【推荐系统】Toward the Next Generation of Recommender Systems: A Survey of the State-of-the-Art and Possible Extensions

·1797 字·4 分钟
迫于生计,从今天开始学习推荐系统相关的内容,先来读一篇推荐系统领域的综述 Toward the next generation of recommender systems: a survey of the state-of-the-art and possible extensions 由于目前的工作其实偏向推荐系统的 serving、训练的开发,因此这些 paper 可能都是粗读,也不会把 paper 中的内容逐句翻译,而是找出我认为最为重要的一些概念加以记录。

[施工完成] CSAPP Cachelab

·1870 字·4 分钟
背景 # CSAPP:3e 的配套实验 地址 分成了两个部分,第一部分是模拟一下 cache 的 miss、hit、evict 的规则,第二部分是优化一个矩阵的转置,使得 miss 尽可能少。