TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: BTree Alternative for Storing to Disk?

7 点作者 JoeOfTexas9 个月前
I am learning how to write a database for fun.<p>The issue with storing BTree to disk are the many operations for balancing on insert and deletion. I want a structure that is very simple to write to disk that doesn&#x27;t require &quot;balancing&quot;.<p>I tried making a HashTree for unique indexing which basically creates a new hashmap on each collisions, which would simplify appending the new hashmap into a file on disk. The issue was the hash function was difficult to craft that avoided going too far in depth through consecutive collisions.<p>I&#x27;m thinking there must be an alternative structure, but my limited understanding and research has yet to reveal anything better than BTree, LSM tree or Skiplists.

3 条评论

hiAndrewQuinn9 个月前
I don&#x27;t think there is, but I&#x27;m glad to see you&#x27;re interested in digging deep into the fundamentals. World&#x27;s a better place with folk like you running around. :)<p>My prior is that SQLite is based off of B-trees, fundamentally, and if anyone&#x27;s going to know everything there is to know about efficiently and robustly reading and writing to a single local disk, it&#x27;s probably going to be Dr. Richard Hipp.
idiocrat9 个月前
Can you try to use a memory-mapped file, so the tree is always stored to disk, without a need of de&#x2F;serialization?
评论 #41296227 未加载
adastra229 个月前
No, a BTree is the right tool for the job. How are you going to iterate keys in order in an index without sorted structure? And the BTtee is the purpose-designed structure for the job.
评论 #41272618 未加载