Cdb:添加对cdb64的支持
Cdb: Add support for cdb64

原始链接: https://cdb.cr.yp.to/download.html

## CDB 摘要 CDB 是一个用于创建和查询简单数据库的软件库和工具。最新版本 **2025.10.21** 引入了对 **cdb64**(在 64 位系统上)的支持,以及通过 **`./configure`,`make` 和 `make install`** 进行的标准安装方式。 重要的内部更改包括切换到 `long long` 整数以提高兼容性和性能,通过删除未使用的函数和包装器来简化代码,以及使 C 代码风格现代化。已添加编译器标志以提高鲁棒性并解决警告。文档也已更新。 之前的版本解决了关键错误(例如 **0.75** 中的数据库创建失败),并在 **0.70** 中进行了重大的 API 重写,利用 `mmap` 以提高效率。初始版本(**0.55**,1996 年)为这个不断发展的工具奠定了基础。 要下载,请使用 `wget` 获取最新的归档文件并使用 `tar` 解压缩。

Hacker News 的讨论围绕着 CDB,这是一种针对读取密集、写入稀少的数据库格式,具有随机查找功能——非常适合电子邮件别名或运费查询等场景,这些场景的数据变化不频繁但需要快速访问。最近的更新增加了对 cdb64 的支持,本质上扩展了格式内的地址大小。 虽然 CDB 在其预期用途上速度非常快,但更新需要重写整个文件。Redis 或 SQLite 等现代替代方案通常更受欢迎,因为它们具有更大的灵活性(例如范围查询),尽管 CDB 在特定的小众情况下仍然可以提供性能优势。 几位评论者分享了经验和替代方案,提到了 RocksDB 和 Tokyo Cabinet 等数据库。对话强调了 CDB 的简单性和效率,但也承认了它的局限性以及选择它而不是更通用的数据库解决方案的权衡。它最适合特定的、定义明确的问题,在这些问题中,其独特的特性能够发挥作用。
相关文章

原文

cdb: Download

To download and unpack the latest version of cdb:

wget -m https://cdb.cr.yp.to/cdb-latest-version.txt
version=$(cat cdb.cr.yp.to/cdb-latest-version.txt)
wget -m https://cdb.cr.yp.to/cdb-$version.tar.gz
tar -xzf cdb.cr.yp.to/cdb-$version.tar.gz
cd cdb-$version

Then install and test.

Archives and changelog (reverse chronological)

cdb-20251021.tar.gz browse

Add support for cdb64 (at least on 64-bit platforms).

Support ./configure, ./configure --prefix=..., and make install.

Switch almost all internal integers to num, defined as long long. Replace various uint32, fmt, scan functions with num functions.

For tests, avoid depending on csh; depend on ulimit instead of softlimit; increase limit to handle current process bloat.

Split buffer interface into inbuf and outbuf.

Clean up hier interface.

Remove various function definitions and declarations not used in cdb.

Eliminate some wrappers: str_len, alloc, uint32, exit, error, systype.

Tweak code to avoid deprecated C features (old-style function definitions, empty prototypes, old-style main definitions).

Make more use of const and static. Eliminate register. Add -Wall to compiler options. Tweak code to avoid -Wall complaints.

Add some don't-be-stupid compiler options: -fwrapv, -fno-delete-null-pointer-checks, -fno-strict-aliasing, and -fno-strict-overflow.

Many updates to documentation.

cdb-0.75.tar.gz (20000219) browse

Fixed bug pointed out by Uwe Ohse: cdb_make_addbegin didn't explicitly return 0, so database creation could fail on systems that didn't follow the traditional C return behavior.

Added testzero to regression-test suite.

Increased bspace in cdb_make.h from 1024 to 8192.

Switched cdbmake to use PUTC and GETC; 3x speedup in one test.

UI: posplus sets ENOMEM if it passes 4GB.

cdb-0.70.tar.gz (20000217) browse

API: rewrote almost everything from scratch. Thanks to Ken Lalonde for suggesting mmap.

UI: cdbget supports skip.

cdb-0.55.tar.gz (19960922) browse

First release.


Version: This is version 2025.10.21 of the "Download" web page.
联系我们 contact @ memedata.com