A simple B+tree-based key-value database implementation in Go.
- B+tree data structure for efficient key-value storage
- Get, Set, and Delete operations
- Range queries with iterator support
- Page-based storage with 4KB pages
- Support for variable-length keys and values
The database provides a simple KV interface:
type KV interface {
Get(key []byte) (val []byte, ok bool)
Set(key []byte, val []byte)
Del(key []byte)
FindGreaterThan(key []byte) Iterator
}
Build the main executable:
go build .
This creates an executable in the current directory.
Run the program:
./customdb
The program initializes a database with the file data.db
and confirms successful initialization.
Run all tests:
go test ./...
Run tests with verbose output:
go test -v ./...
Run tests for a specific package:
go test ./internal/btree
- Uses B+tree nodes with internal and leaf node types
- Fixed page size of 4KB
- Maximum key size: 1000 bytes
- Maximum value size: 3000 bytes
- Immutable node design for data integrity