cockroachdb/cockroach
keys
pkg/keys/ defines CockroachDB's canonical keyspace layout. Everything that lives in the KV map — system tables, range descriptors, locks, raft logs, time series — has a constant or constructor here.
High-level layout
\x00 ... local keys (per-replica state, raft log, range descriptor)
\x01 ... system tenant data (ranges, descriptors, ...)
\x02 ... range descriptors (meta1, meta2)
\x03 ... system tenant SQL data
\xfe ... tenant prefix: \xfe<tenantID>...The full layout is documented inline in pkg/keys/constants.go and pkg/keys/printer.go.
What's in the package
constants.go— every reserved key prefix.keys.go— constructors (e.g.MakeRangeKey,MakeRangeDescriptorKey,LocalRangeAppliedStateKey).addressing.go— the meta-range addressing scheme.printer.go— pretty-printing for debug output.version.go— version-key handling.system.go— system-tenant key constructors.keysbase/— small subset reused by tools that can't import the rest.
Why this matters
Every key lookup, range bound, and admin tool implicitly assumes the layout in this package. Adding a new top-level prefix is rare and requires a cluster-version gate plus careful migration; it is much more common to extend an existing prefix (e.g., a new system table ID).
Related pages
- Storage / MVCC — how keys are encoded.
- KV server —
keys.LocalRangeAppliedStateKeyand friends are central. - packages/roachpb —
RangeDescriptorkeys are produced here.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.