Skip to content

ccrawford4/custom-db

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Custom DB

A simple B+tree-based key-value database implementation in Go.

Features

  • 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

Usage

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
}

Building

Build the main executable:

go build .

This creates an executable in the current directory.

Running

Run the program:

./customdb

The program initializes a database with the file data.db and confirms successful initialization.

Testing

Run all tests:

go test ./...

Run tests with verbose output:

go test -v ./...

Run tests for a specific package:

go test ./internal/btree

Implementation Details

  • 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

About

Building a Database From Scratch in Go

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages