Pure Go implementation of D. J. Bernstein's cdb constant database library.

cdb

This is a Go package to read and write cdb ("constant database") files.

The cdb file format is a machine-independent format with the following features:

  • Fast lookups: A successful lookup in a large database normally takes just two disk accesses. An unsuccessful lookup takes only one.
  • Low overhead: A database uses 2048 bytes, plus 24 bytes per record, plus the space for keys and data.
  • No random limits: cdb can handle any database up to 4 gigabytes. There are no other restrictions; records don't even have to fit into memory.

See the original cdb specification and C implementation by D. J. Bernstein at http://cr.yp.to/cdb.html.

Installation

Assuming you have a working Go environment, installation is simply:

go get github.com/jbarham/cdb

The package documentation can be viewed online at https://pkg.go.dev/github.com/jbarham/cdb or on the command line by running go doc github.com/jbarham/cdb.

The included self-test program cdb_test.go illustrates usage of the package.

Utilities

The cdb package includes ports of the programs cdbdump and cdbmake from the original implementation.

Owner
Comments
  • Header is not cached, lookups may take 3 seeks rather than claimed 2.

    Header is not cached, lookups may take 3 seeks rather than claimed 2.

    The 2kB header is not stored in cdb.Cdb, so find() calls c.readNums((h << 3) & 2047) on the first lookup after each call to FindStart(). If the OS cache was flushed, this could lead to 3 seeks rather than 2.

  • io.EOF is not returned when a key would be in an empty hash table

    io.EOF is not returned when a key would be in an empty hash table

    The guard around c.hslots == 0 in cdb.(*Cdb).find() calls an empty return, which ultimately results in nil being returned rather than io.EOF, even though the key does not exist in the database.

  • Add DumpN() functions

    Add DumpN() functions

    We use this patch at work which is mainly a change to the Dump() interface, which now calls DumpN(). DumpN() provides a means to perform partial dumps of n records starting at a specific position.

  • Add cdb.Get and command 'cdbget'; no fs dependency in tests

    Add cdb.Get and command 'cdbget'; no fs dependency in tests

    I added an interface to cdb.Get to port 'cdbget' to Golang. I also tweaked the cdb_test.go a little bit by implementing a []byte-backed io.WriteSeeker to avoid any filesystem related dependencies while running tests.

  • Feature Request: iterate keys

    Feature Request: iterate keys

    Python's cdb library has a handy function to iterate all keys in a cdb database: http://pilcrow.madison.wi.us/pycdb_doc.html

    It would be awesome to be able to do the same with go-cdb.

    (Also the function for # of items in a cdb is handy and would be nice)

Related tags
pure golang key database support key have value. 非常高效实用的键值数据库。
pure golang key database support key have value.  非常高效实用的键值数据库。

orderfile32 pure golang key database support key have value The orderfile32 is standard alone fast key value database. It have two version. one is thi

Apr 30, 2022
BadgerDB is an embeddable, persistent and fast key-value (KV) database written in pure Go
BadgerDB is an embeddable, persistent and fast key-value (KV) database written in pure Go

BadgerDB BadgerDB is an embeddable, persistent and fast key-value (KV) database written in pure Go. It is the underlying database for Dgraph, a fast,

Dec 10, 2021
A lightweight document-oriented NoSQL database written in pure Golang.
A lightweight document-oriented NoSQL database written in pure Golang.

Lightweight document-oriented NoSQL Database ???? English | ???? 简体中文 | ???? Spanish CloverDB is a lightweight NoSQL database designed for being simpl

Jan 1, 2023
Owl is a db manager platform,committed to standardizing the data, index in the database and operations to the database, to avoid risks and failures.

Owl is a db manager platform,committed to standardizing the data, index in the database and operations to the database, to avoid risks and failures. capabilities which owl provides include Process approval、sql Audit、sql execute and execute as crontab、data backup and recover .

Nov 9, 2022
This is a simple graph database in SQLite, inspired by "SQLite as a document database".

About This is a simple graph database in SQLite, inspired by "SQLite as a document database". Structure The schema consists of just two structures: No

Jan 3, 2023
Hard Disk Database based on a former database

Hard Disk Database based on a former database

Nov 1, 2021
Simple key value database that use json files to store the database

KValDB Simple key value database that use json files to store the database, the key and the respective value. This simple database have two gRPC metho

Nov 13, 2021
Beerus-DB: a database operation framework, currently only supports Mysql, Use [go-sql-driver/mysql] to do database connection and basic operations

Beerus-DB · Beerus-DB is a database operation framework, currently only supports Mysql, Use [go-sql-driver/mysql] to do database connection and basic

Oct 29, 2022
A rudimentary implementation of a basic document (NoSQL) database in Go
A rudimentary implementation of a basic document (NoSQL) database in Go

tiedot Documentation Keywords: Golang, go, document database, NoSQL, JSON tiedot - Your NoSQL database powered by Golang tiedot is a document database

Dec 11, 2022
A simple, fast, embeddable, persistent key/value store written in pure Go. It supports fully serializable transactions and many data structures such as list, set, sorted set.

NutsDB English | 简体中文 NutsDB is a simple, fast, embeddable and persistent key/value store written in pure Go. It supports fully serializable transacti

Jan 1, 2023
Low-level key/value store in pure Go.
Low-level key/value store in pure Go.

Description Package slowpoke is a simple key/value store written using Go's standard library only. Keys are stored in memory (with persistence), value

Jan 2, 2023
The Monogon Project Monorepo. May contain traces of peanuts and a pure Go Linux userland.

This is the main repository containing the source code for the Monogon Project.

Jan 6, 2023
Eagle - Eagle is a fast and strongly encrypted key-value store written in pure Golang.

EagleDB EagleDB is a fast and simple key-value store written in Golang. It has been designed for handling an exaggerated read/write workload, which su

Dec 10, 2022
An embedded key/value database for Go.

bbolt bbolt is a fork of Ben Johnson's Bolt key/value store. The purpose of this fork is to provide the Go community with an active maintenance and de

Jan 1, 2023
BuntDB is an embeddable, in-memory key/value database for Go with custom indexing and geospatial support
BuntDB is an embeddable, in-memory key/value database for Go with custom indexing and geospatial support

BuntDB is a low-level, in-memory, key/value store in pure Go. It persists to disk, is ACID compliant, and uses locking for multiple readers and a sing

Dec 30, 2022
CockroachDB - the open source, cloud-native distributed SQL database.
CockroachDB - the open source, cloud-native distributed SQL database.

CockroachDB is a cloud-native SQL database for building global, scalable cloud services that survive disasters. What is CockroachDB? Docs Quickstart C

Jan 2, 2023
ACID key-value database.

Coffer Simply ACID* key-value database. At the medium or even low latency it tries to provide greater throughput without losing the ACID properties of

Dec 7, 2022
A decentralized, trusted, high performance, SQL database with blockchain features
A decentralized, trusted, high performance, SQL database with blockchain features

中文简介 CovenantSQL(CQL) is a Byzantine Fault Tolerant relational database built on SQLite: ServerLess: Free, High Availabile, Auto Sync Database Service

Jan 3, 2023
Native GraphQL Database with graph backend
Native GraphQL Database with graph backend

The Only Native GraphQL Database With A Graph Backend. Dgraph is a horizontally scalable and distributed GraphQL database with a graph backend. It pro

Jan 4, 2023