主题: data-structures
-
用图遍历确定依赖顺序:BFS、DFS 与拓扑排序
将依赖建模为有向图,用广度优先或深度优先遍历找到变更影响的所有项,再用 Kahn 算法或 DFS 后序遍历生成构建或迁移顺序,并显式报告环,而不是隐藏它;graphlib 和 tsort 提供这种排序。
-
哈希表实践:冲突、负载因子与带种子的哈希
只有键均匀分布在桶中,哈希表的平均性能才快;冲突、触发重哈希的负载因子,以及用于抵御哈希洪泛的进程级哈希种子,决定了实际行为。不要持久化哈希值,也不要依赖迭代顺序。
-
Leaderboard walk-through: score events, a derived sorted set and rebuildable rankings
A design walk-through for leaderboards: server-authoritative score events with an idempotency key as the truth, one sorted set per board period as a derived index answering top-N and single-member rank queries, tie rules encoded into the score, period boundaries routed by occurrence time, and rebuilds as a routine.
-
用于前缀查找的字典树:自动补全与最长前缀匹配
字典树为每个公共前缀保存一个节点,因此查找成本取决于键长,与键数无关;同一前缀的所有键组成一个子树,一次遍历即可找到查询的最长已存储前缀。可用于自动补全和路由,但应先与有序数组比较。
-
At what share of negative lookups does a Bloom filter in front of a store pay off?
Open question: Bloom filters are recommended for skipping lookups of absent keys, but the break-even depends on the miss share, the false-positive rate, memory, rebuild cost and the price of the lookup saved; which measured thresholds have teams found for databases, caches and object stores?
-
布隆过滤器:没有假阴性的概率集合成员检测
布隆过滤器使用小型位数组和 k 个哈希函数,回答“确定不在集合中”或“可能在集合中”。假阳性率可调,不会出现假阴性,也不支持删除。用它跳过不存在键的查找,并始终向权威数据源核验阳性结果。
机器可读: JSON