Documentation
¶
Index ¶
- Constants
- Variables
- func Addr(k roachpb.Key) roachpb.RKey
- func DecodeRangeKey(key roachpb.Key) (startKey, suffix, detail roachpb.Key, err error)
- func MakeKey(keys ...[]byte) []byte
- func MakeRangeIDKey(rangeID roachpb.RangeID, suffix, detail roachpb.RKey) roachpb.Key
- func MakeRangeIDPrefix(rangeID roachpb.RangeID) roachpb.Key
- func MakeRangeKey(key, suffix, detail roachpb.RKey) roachpb.Key
- func MakeRangeKeyPrefix(key roachpb.RKey) roachpb.Key
- func MakeStoreKey(suffix, detail roachpb.RKey) roachpb.Key
- func MakeTablePrefix(tableID uint32) []byte
- func MetaReverseScanBounds(key roachpb.RKey) (roachpb.Key, roachpb.Key, error)
- func MetaScanBounds(key roachpb.RKey) (roachpb.Key, roachpb.Key, error)
- func NodeStatusKey(nodeID int32) roachpb.Key
- func RaftAppliedIndexKey(rangeID roachpb.RangeID) roachpb.Key
- func RaftHardStateKey(rangeID roachpb.RangeID) roachpb.Key
- func RaftLastIndexKey(rangeID roachpb.RangeID) roachpb.Key
- func RaftLeaderLeaseKey(rangeID roachpb.RangeID) roachpb.Key
- func RaftLogKey(rangeID roachpb.RangeID, logIndex uint64) roachpb.Key
- func RaftLogPrefix(rangeID roachpb.RangeID) roachpb.Key
- func RaftTombstoneKey(rangeID roachpb.RangeID) roachpb.Key
- func RaftTruncatedStateKey(rangeID roachpb.RangeID) roachpb.Key
- func Range(ba roachpb.BatchRequest) roachpb.RSpan
- func RangeDescriptorKey(key roachpb.RKey) roachpb.Key
- func RangeGCMetadataKey(rangeID roachpb.RangeID) roachpb.Key
- func RangeLastVerificationTimestampKey(rangeID roachpb.RangeID) roachpb.Key
- func RangeMetaKey(key roachpb.RKey) roachpb.Key
- func RangeStatsKey(rangeID roachpb.RangeID) roachpb.Key
- func RangeTreeNodeKey(key roachpb.RKey) roachpb.Key
- func ResponseCacheKey(rangeID roachpb.RangeID, family []byte) roachpb.Key
- func StoreIdentKey() roachpb.Key
- func StoreStatusKey(storeID int32) roachpb.Key
- func TransactionKey(key roachpb.Key, id []byte) roachpb.Key
- type InvalidRangeMetaKeyError
Constants ¶
const ( // MaxReservedDescID is the maximum value of the system IDs // under 'TableDataPrefix'. // It is here only so that we may define keys/ranges using it. MaxReservedDescID = 999 // RootNamespaceID is the ID of the root namespace. RootNamespaceID = 0 // SystemDatabaseID and following are the database/table IDs for objects // in the system span. // NOTE: IDs should remain <= MaxReservedDescID. SystemDatabaseID = 1 NamespaceTableID = 2 DescriptorTableID = 3 LeaseTableID = 4 UsersTableID = 5 ZonesTableID = 6 )
Various IDs used by the structured data layer. NOTE: these must not change during the lifetime of a cluster.
Variables ¶
var ( // LocalRangeIDPrefix is the prefix identifying per-range data // indexed by Range ID. The Range ID is appended to this prefix, // encoded using EncodeUvarint. The specific sort of per-range // metadata is identified by one of the suffixes listed below, along // with potentially additional encoded key info, such as a command // ID in the case of response cache entry. // // NOTE: LocalRangeIDPrefix must be kept in sync with the value // in storage/engine/rocksdb/db.cc. LocalRangeIDPrefix = roachpb.RKey(MakeKey(localPrefix, roachpb.Key("i"))) // LocalResponseCacheSuffix is the suffix for keys storing // command responses used to guarantee idempotency (see ResponseCache). // NOTE: if this value changes, it must be updated in C++ // (storage/engine/rocksdb/db.cc). LocalResponseCacheSuffix = []byte("res-") // LocalRangePrefix is the prefix identifying per-range data indexed // by range key (either start key, or some key in the range). The // key is appended to this prefix, encoded using EncodeBytes. The // specific sort of per-range metadata is identified by one of the // suffixes listed below, along with potentially additional encoded // key info, such as the txn ID in the case of a transaction record. // // NOTE: LocalRangePrefix must be kept in sync with the value in // storage/engine/rocksdb/db.cc. LocalRangePrefix = roachpb.Key(MakeKey(localPrefix, roachpb.RKey("k"))) LocalRangeMax = LocalRangePrefix.PrefixEnd() // LocalRangeDescriptorSuffix is the suffix for keys storing // range descriptors. The value is a struct of type RangeDescriptor. LocalRangeDescriptorSuffix = roachpb.RKey("rdsc") // LocalMax is the end of the local key range. LocalMax = roachpb.Key(localPrefix).PrefixEnd() // SystemPrefix indicates the beginning of the key range for // global, system data which are replicated across the cluster. SystemPrefix = roachpb.Key("\x00") SystemMax = roachpb.Key("\x01") // MetaPrefix is the prefix for range metadata keys. Notice that // an extra null character in the prefix causes all range addressing // records to sort before any system tables which they might describe. MetaPrefix = MakeKey(SystemPrefix, roachpb.RKey("\x00meta")) // Meta1Prefix is the first level of key addressing. The value is a // RangeDescriptor struct. Meta1Prefix = roachpb.Key(MakeKey(MetaPrefix, roachpb.RKey("1"))) // Meta2Prefix is the second level of key addressing. The value is a // RangeDescriptor struct. Meta2Prefix = roachpb.Key(MakeKey(MetaPrefix, roachpb.RKey("2"))) // Meta1KeyMax is the end of the range of the first level of key addressing. // The value is a RangeDescriptor struct. Meta1KeyMax = roachpb.Key(MakeKey(Meta1Prefix, roachpb.RKeyMax)) // Meta2KeyMax is the end of the range of the second level of key addressing. // The value is a RangeDescriptor struct. Meta2KeyMax = roachpb.Key(MakeKey(Meta2Prefix, roachpb.RKeyMax)) // MetaMax is the end of the range of addressing keys. MetaMax = roachpb.Key(MakeKey(SystemPrefix, roachpb.RKey("\x01"))) // DescIDGenerator is the global descriptor ID generator sequence used for // table and namespace IDs. DescIDGenerator = roachpb.Key(MakeKey(SystemPrefix, roachpb.RKey("desc-idgen"))) // NodeIDGenerator is the global node ID generator sequence. NodeIDGenerator = roachpb.Key(MakeKey(SystemPrefix, roachpb.RKey("node-idgen"))) // RangeIDGenerator is the global range ID generator sequence. RangeIDGenerator = roachpb.Key(MakeKey(SystemPrefix, roachpb.RKey("range-idgen"))) // StoreIDGenerator is the global store ID generator sequence. StoreIDGenerator = roachpb.Key(MakeKey(SystemPrefix, roachpb.RKey("store-idgen"))) // RangeTreeRoot specifies the root range in the range tree. RangeTreeRoot = roachpb.Key(MakeKey(SystemPrefix, roachpb.RKey("range-tree-root"))) // StatusPrefix specifies the key prefix to store all status details. StatusPrefix = roachpb.Key(MakeKey(SystemPrefix, roachpb.RKey("status-"))) // StatusStorePrefix stores all status info for stores. StatusStorePrefix = roachpb.Key(MakeKey(StatusPrefix, roachpb.RKey("store-"))) // StatusNodePrefix stores all status info for nodes. StatusNodePrefix = roachpb.Key(MakeKey(StatusPrefix, roachpb.RKey("node-"))) // TableDataPrefix prefixes all table data. It is specifically chosen to // occur after the range of common user data prefixes so that tests which use // those prefixes will not see table data. TableDataPrefix = roachpb.Key("\xff") // UserTableDataMin is the start key of user structured data. UserTableDataMin = roachpb.Key(MakeTablePrefix(MaxReservedDescID + 1)) )
Constants for system-reserved keys in the KV map.
var ( // Meta1Span holds all first level addressing. Meta1Span = roachpb.Span{Key: roachpb.KeyMin, EndKey: Meta2Prefix} // UserDataSpan is the non-meta and non-structured portion of the key space. UserDataSpan = roachpb.Span{Key: SystemMax, EndKey: TableDataPrefix} // SystemDBSpan is the range of system objects for structured data. SystemDBSpan = roachpb.Span{Key: TableDataPrefix, EndKey: UserTableDataMin} // NoSplitSpans describes the ranges that should never be split. // Meta1Span: needed to find other ranges. // SystemDBSpan: system objects have interdepencies. NoSplitSpans = []roachpb.Span{Meta1Span, SystemDBSpan} )
Functions ¶
func Addr ¶
Addr returns the address for the key, used to lookup the range containing the key. In the normal case, this is simply the key's value. However, for local keys, such as transaction records, range-spanning binary tree node pointers, the address is the trailing suffix of the key, with the local key prefix removed. In this way, local keys address to the same range as non-local keys, but are stored separately so that they don't collide with user-space or global system keys.
However, not all local keys are addressable in the global map. Only range local keys incorporating a range key (start key or transaction key) are addressable (e.g. range metadata and txn records). Range local keys incorporating the Range ID are not (e.g. response cache entries, and range stats).
TODO(pmattis): Should KeyAddress return an error when the key is malformed?
func DecodeRangeKey ¶
DecodeRangeKey decodes the range key into range start key, suffix and optional detail (may be nil).
func MakeRangeIDKey ¶
MakeRangeIDKey creates a range-local key based on the range's Range ID, metadata key suffix, and optional detail (e.g. the encoded command ID for a response cache entry, etc.).
func MakeRangeIDPrefix ¶
MakeRangeIDPrefix creates a range-local key prefix from rangeID.
func MakeRangeKey ¶
MakeRangeKey creates a range-local key based on the range start key, metadata key suffix, and optional detail (e.g. the transaction ID for a txn record, etc.).
func MakeRangeKeyPrefix ¶
MakeRangeKeyPrefix creates a key prefix under which all range-local keys can be found.
func MakeStoreKey ¶
MakeStoreKey creates a store-local key based on the metadata key suffix, and optional detail.
func MakeTablePrefix ¶
MakeTablePrefix returns the key prefix used for the table's data.
func MetaReverseScanBounds ¶
MetaReverseScanBounds returns the range [start,end) within which the desired meta record can be found by means of a reverse engine scan. The given key must be a valid RangeMetaKey as defined by validateRangeMetaKey.
func MetaScanBounds ¶
MetaScanBounds returns the range [start,end) within which the desired meta record can be found by means of an engine scan. The given key must be a valid RangeMetaKey as defined by validateRangeMetaKey. TODO(tschottdorf): a lot of casting going on inside.
func NodeStatusKey ¶
NodeStatusKey returns the key for accessing the node status for the specified node ID.
func RaftAppliedIndexKey ¶
RaftAppliedIndexKey returns a system-local key for a raft applied index.
func RaftHardStateKey ¶
RaftHardStateKey returns a system-local key for a Raft HardState.
func RaftLastIndexKey ¶
RaftLastIndexKey returns a system-local key for a raft last index.
func RaftLeaderLeaseKey ¶
RaftLeaderLeaseKey returns a system-local key for a raft leader lease.
func RaftLogKey ¶
RaftLogKey returns a system-local key for a Raft log entry.
func RaftLogPrefix ¶
RaftLogPrefix returns the system-local prefix shared by all entries in a Raft log.
func RaftTombstoneKey ¶
RaftTombstoneKey returns a system-local key for a raft tombstone.
func RaftTruncatedStateKey ¶
RaftTruncatedStateKey returns a system-local key for a RaftTruncatedState.
func Range ¶
func Range(ba roachpb.BatchRequest) roachpb.RSpan
Range returns a key range encompassing all the keys in the Batch. TODO(tschottdorf): there is no protection for doubly-local keys here; maybe Range should return an error.
func RangeDescriptorKey ¶
RangeDescriptorKey returns a range-local key for the descriptor for the range with specified key.
func RangeGCMetadataKey ¶
RangeGCMetadataKey returns a range-local key for range garbage collection metadata.
func RangeLastVerificationTimestampKey ¶
RangeLastVerificationTimestampKey returns a range-local key for the range's last verification timestamp.
func RangeMetaKey ¶
RangeMetaKey returns a range metadata (meta1, meta2) indexing key for the given key. For ordinary keys this returns a level 2 metadata key - for level 2 keys, it returns a level 1 key. For level 1 keys and local keys, KeyMin is returned.
func RangeStatsKey ¶
RangeStatsKey returns the key for accessing the MVCCStats struct for the specified Range ID.
func RangeTreeNodeKey ¶
RangeTreeNodeKey returns a range-local key for the the range's node in the range tree.
func ResponseCacheKey ¶
ResponseCacheKey returns a range-local key by Range ID for a response cache entry, with detail specified by encoding the supplied client command ID.
func StoreIdentKey ¶
StoreIdentKey returns a store-local key for the store metadata.
func StoreStatusKey ¶
StoreStatusKey returns the key for accessing the store status for the specified store ID.
Types ¶
type InvalidRangeMetaKeyError ¶
InvalidRangeMetaKeyError indicates that a Range Metadata key is somehow invalid.
func NewInvalidRangeMetaKeyError ¶
func NewInvalidRangeMetaKeyError(msg string, k []byte) *InvalidRangeMetaKeyError
NewInvalidRangeMetaKeyError returns a new InvalidRangeMetaKeyError
func (*InvalidRangeMetaKeyError) Error ¶
func (i *InvalidRangeMetaKeyError) Error() string
Error formats error string.