A B+Tree Storage Engine
Go 100.0%
44 1 0

Clone this repository

https://tangled.org/jobala.tngl.sh/petro https://tangled.org/did:plc:qcqdzn5ohjxyp2ilrunon6kn/petro
git@tangled.org:jobala.tngl.sh/petro git@tangled.org:did:plc:qcqdzn5ohjxyp2ilrunon6kn/petro

For self-hosted knots, clone URLs may differ based on your setup.

Download tar.gz
README.md

petro#

A simple key value storage engine

Getting Started#

Installation#

go get github.com/jobala/petro

Put#

store, err := index.New[string, int]("index", dbFile)
ok, err := store.Put("age", 25)

Get#

store := index.New[string, int]("index", dbFile)
val, err := store.Get("age")

Delete#

store := index.New[string, int]("index", dbFile)
val, err := store.Delete("age")

PutBatch#

ages := map[string]int{
    "john": 30,
    "jane": 20,
    "doe": 45
}

store := index.New[string, int]("index", dbFile)
err := store.PutBatch(ages)

GetKeyRange#

ages := map[string]int{
    "john": 30,
    "jane": 20,
    "doe": 45
}

store := index.New[string, int]("index", dbFile)
store.GetKeyRange("doe", "jane")

Iterate#

ages := map[string]int{
    "john": 30,
    "jane": 20,
    "doe": 45
}

store := index.New[string, int]("index", dbFile)
storeIter := store.GetIterator()

for !storeIter.IsEnd() {
    key, val, err := storeIter.Next()
}

durability#

call store.flush() to ensure that your data is written to disk

Design Notes#

Roadmap#

  • Disk Management
  • Bufferpool Management
  • Index Management
    • GetValue
    • Insert
    • Iterator
    • Delete
    • Support duplicate keys
  • Transactions
  • Recovery