| Open |
rocksdb::DB::Open(options, name, &db) |
BeachDB.Open(path string, opts ...Option) (*DB, error) |
| Close |
delete db; / RAII wrappers |
db.Close() error |
| Put |
db->Put(WriteOptions, key, value) |
db.Put(ctx context.Context, key, value []byte) error |
| Get |
db->Get(ReadOptions, key, &value) |
db.Get(ctx context.Context, key []byte) ([]byte, error) |
| Delete |
db->Delete(WriteOptions, key) |
db.Delete(ctx context.Context, key []byte) error |
| WriteBatch apply |
db->Write(WriteOptions, &batch) |
db.Write(ctx context.Context, b *Batch) error |
| Batch builder |
rocksdb::WriteBatch with Put/Delete |
type Batch struct { ... } with b.Put/b.Delete, db.Write(ctx, b) |
| Read options |
ReadOptions{snapshot, verify_checksums, fill_cache, ...} |
db.Get(ctx, key, opts ...ReadOption) / db.NewIter(opts ...IterOption) |
| Write options |
WriteOptions{sync, disableWAL, ...} |
db.Put(ctx, k, v, opts ...WriteOption) / default safe; override via options |
| Sync per write (fsync) |
WriteOptions.sync=true |
default: fsync each batch (override with WithSync(false) later) |
| Snapshots |
db->GetSnapshot()/ReleaseSnapshot() |
snap := db.Snapshot(); defer snap.Close() or snap := db.Snapshot(); db.Get(ctx, key, WithSnapshot(snap)) |
| Iterator create |
db->NewIterator(ReadOptions) |
it := db.NewIterator(opts ...IterOption) |
| Iterator seek |
it->Seek(key) |
it.Seek(key []byte) bool |
| Iterator advance |
it->Next() |
it.Next() bool |
| Iterator validity |
it->Valid() |
it.Valid() bool or bool returned by Seek/Next |
| Iterator key/value access |
it->key()/it->value() |
it.Key() []byte, it.Value() []byte |
| Iterator lifecycle |
delete it; |
it.Close() error |
| Range scan helper |
user loops iterator |
db.Scan(ctx, start, end []byte, fn func(k,v []byte) bool, opts ...ScanOption) error (optional ergonomic layer) |
| Errors |
Status return values |
error (typed/sentinel errors e.g. ErrNotFound, ErrCorrupt) |
| Thread safety contract |
documented; internal mutexes |
explicit in GoDoc (e.g. DB safe for concurrent reads; writes serialized) |
| Context / cancellation |
not built-in |
context.Context on public APIs that may block (I/O, scans, compaction triggers) |
| Metrics |
rocksdb::Statistics / properties |
db.Stats() Stats + expvar/Prometheus hooks |
| File inspection tools |
sst_dump, ldb |
cmd/BeachDB + tools/*_dump (Go binaries) |
| Internal memtable |
skiplist/arena allocators |
internal/memtable (skiplist or btree), simpler alloc story |
| Internal WAL |
log writer w/ options |
internal/wal with explicit Append(batch) + Sync() and syscall notes |
| Internal versioning |
VersionSet/ColumnFamily |
internal/version (one CF only v0.1), manifest as append-only edits |
| Internal comparator |
pluggable comparator |
fixed lexicographic []byte comparator (v0.1) |
| Public config style |
giant Options struct |
functional options: Option, ReadOption, WriteOption, IterOption |
| Private invariants |
implicit, spread |
explicit internal/invariants checks + test helpers |