In-memory database code.
This repository has been archived on 2022-07-30. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
Go to file
jdl 5a9e355df8 wip 2022-07-26 14:02:53 +02:00
keyedmutex wip 2022-07-26 14:02:53 +02:00
kvstore wip 2022-07-26 14:01:52 +02:00
testconn wip 2022-07-26 14:02:53 +02:00
.gitignore Initial commit 2022-07-23 07:28:33 +00:00
README.md wip 2022-07-26 14:01:52 +02:00
btreeindex.go WIP 2022-07-26 14:02:32 +02:00
btreeindex_test.go WIP 2022-07-26 14:02:32 +02:00
btreeiterator.go WIP 2022-07-26 14:02:32 +02:00
codec.go WIP 2022-07-26 14:02:32 +02:00
collection.go WIP 2022-07-26 14:02:32 +02:00
collection_test.go WIP 2022-07-26 14:02:32 +02:00
database.go WIP 2022-07-26 14:02:32 +02:00
database_test.go WIP 2022-07-26 14:02:32 +02:00
errors.go WIP 2022-07-26 14:02:32 +02:00
go.mod wip 2022-07-26 14:02:53 +02:00
go.sum wip 2022-07-26 14:02:53 +02:00
itemmap.go WIP 2022-07-26 14:02:32 +02:00
mapindex.go WIP 2022-07-26 14:02:32 +02:00
mapindex_test.go WIP 2022-07-26 14:02:32 +02:00
shipping_test.go WIP 2022-07-26 14:02:32 +02:00
types.go WIP 2022-07-26 14:02:32 +02:00
util.go WIP 2022-07-26 14:02:32 +02:00
util_test.go WIP 2022-07-26 14:02:32 +02:00

README.md

mdb

An in-process, in-memory database for Go.

TO DO

  • kvstore: tests

Structure

Files

wal/<id>/data
wal/<id>/length
wal/<id>/archived
max-committed-id
write-lock
commit-lock

<day-ts> is the unix timestamp / 86400. Therefore a new segment will be created every day. The data file is append-only, and the length is written atomically.

write-lock is used by flock to ensure there's only one writer. commit-lock is used by the commit routine. This routine will commit data to the database and update max-committed-id atomically.

Code

retry/
wal/
  segment/
storage/

WAL File Format

The WAL file consists of an 8 byte minimum ID followed by a stream of entries of the form

(4)           Data length
(Data length) Data
(8)           ID.

This allows us to quickly get the min and max IDs from the file, and iterate though the segment from the beginning.