Documentation ¶
Overview ¶
Package simpledb implements a one-table version of LevelDB
It buffers all writes in memory; to make data durable, call Compact(). This operation re-writes all of the data in the database (including in-memory writes) in a crash-safe manner. Keys in the table are cached for efficient reads.
Index ¶
- func Close(db Database)
- func CloseTable(t Table)
- func Compact(db Database)
- func DecodeUInt64(p []byte) (uint64, uint64)
- func EncodeSlice(data []byte, p []byte) []byte
- func EncodeUInt64(x uint64, p []byte) []byte
- func Read(db Database, k uint64) ([]byte, bool)
- func Shutdown(db Database)
- func Write(db Database, k uint64, v []byte)
- type Database
- type Entry
- type Table
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Close ¶
func Close(db Database)
Close closes an open database cleanly, flushing any in-memory writes.
db should not be used afterward
func Compact ¶
func Compact(db Database)
Compact persists in-memory writes to a new table.
This simple database design must re-write all data to combine in-memory writes with existing writes.
func DecodeUInt64 ¶
DecodeUInt64 is a Decoder(uint64)
All decoders have the shape func(p []byte) (T, uint64)
The uint64 represents the number of bytes consumed; if 0, then decoding failed, and the value of type T should be ignored.
func Read ¶
Read gets a key from the database.
Returns a boolean indicating if the k was found and a non-nil slice with the value if k was in the database.
Reflects any completed in-memory writes.
Types ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database is a handle to an open database.
type Table ¶
A Table provides access to an immutable copy of data on the filesystem, along with an index for fast random access.
func RecoverTable ¶
RecoverTable restores a table from disk on startup.