Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

marselester/rascaldb

Open more actions menu

Repository files navigation

RascalDB 😜

Documentation Go Report Card

RascalDB is a key-value log-structured storage engine with hash map index. All keys must fit in RAM since the hash map is kept in memory. This type of a storage is optimal for writes workload.

Note, this pet project is not intended for production use.

Key ideas:

  • key-values are immutable, appended to a log
  • log is represented as a sequence of segment files
  • key-value is stored as a record prefixed with its length (4 bytes)
  • key is looked up from segment files using in-memory hash map index which maintains a byte offset of a key
  • hash map index is loaded from a segment file when db is opened
  • sequence of database segments is stored in a trunk file
  • old log segments are compacted (old records of duplicate keys are removed)
  • old segments are merged
  • there is only one writer to make sure keys are written linearly
  • ignore corrupted segments if a file's checksum doesn't match when db crashed

Usage Example

package main

import (
	"fmt"
	"log"

	"github.com/marselester/rascaldb"
)

func main() {
	db, err := rascaldb.Open("my.db")
	if err != nil {
		log.Fatal(err)
	}
	defer db.Close()

	name := []byte("Moist von Lipwig")
	if err = db.Set("name", name); err != nil {
		log.Fatal(err)
	}

	if name, err = db.Get("name"); err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%s\n", name)
}

About

RascalDB is a key-value log-structured storage engine with hash map index.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.