keys

package
v1.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 1, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxSystemConfigDescID is the maximum system descriptor ID that will be
	// gossiped as part of the SystemConfig. Be careful adding new descriptors to
	// this ID range.
	MaxSystemConfigDescID = 10

	// MaxReservedDescID is the maximum value of reserved descriptor
	// IDs. Reserved IDs are used by namespaces and tables used internally by
	// cockroach.
	MaxReservedDescID = 49

	// VirtualDescriptorID is the ID used by all virtual descriptors.
	VirtualDescriptorID = math.MaxUint32

	// 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 must be <= MaxSystemConfigDescID.
	SystemDatabaseID  = 1
	NamespaceTableID  = 2
	DescriptorTableID = 3
	UsersTableID      = 4
	ZonesTableID      = 5
	SettingsTableID   = 6

	// Reserved IDs for other system tables. Note that some of these IDs refer
	// to "Ranges" instead of a Table - these IDs are needed to store custom
	// configuration for non-table ranges (e.g. Zone Configs).
	// NOTE: IDs must be <= MaxReservedDescID.
	LeaseTableID       = 11
	EventLogTableID    = 12
	RangeEventTableID  = 13
	UITableID          = 14
	JobsTableID        = 15
	MetaRangesID       = 16
	SystemRangesID     = 17
	TimeseriesRangesID = 18
	WebSessionsTableID = 19
)

Various IDs used by the structured data layer. NOTE: these must not change during the lifetime of a cluster.

Variables

View Source
var (

	// LocalMax is the end of the local key range. It is itself a global
	// key.
	LocalMax = roachpb.Key{localMaxByte}

	// 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, for instance in the
	// case of abort 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")))

	// LocalAbortCacheSuffix is the suffix for abort cache entries. The
	// abort cache protects a transaction from re-reading its own intents
	// after it's been aborted.
	LocalAbortCacheSuffix = []byte("abc-")
	// LocalRangeFrozenStatusSuffix is the suffix for a frozen status.
	// No longer used; exists only to reserve the key so we don't use it.
	LocalRangeFrozenStatusSuffix = []byte("fzn-")
	// LocalRangeLastGCSuffix is the suffix for the last GC.
	LocalRangeLastGCSuffix = []byte("lgc-")
	// LocalRaftAppliedIndexSuffix is the suffix for the raft applied index.
	LocalRaftAppliedIndexSuffix = []byte("rfta")
	// LocalRaftTombstoneSuffix is the suffix for the raft tombstone.
	LocalRaftTombstoneSuffix = []byte("rftb")
	// LocalRaftTruncatedStateSuffix is the suffix for the RaftTruncatedState.
	LocalRaftTruncatedStateSuffix = []byte("rftt")
	// LocalRangeLeaseSuffix is the suffix for a range lease.
	LocalRangeLeaseSuffix = []byte("rll-")
	// LocalLeaseAppliedIndexSuffix is the suffix for the applied lease index.
	LocalLeaseAppliedIndexSuffix = []byte("rlla")
	// LocalRangeStatsSuffix is the suffix for range statistics.
	LocalRangeStatsSuffix = []byte("stat")
	// LocalTxnSpanGCThresholdSuffix is the suffix for the last txn span GC's
	// threshold.
	LocalTxnSpanGCThresholdSuffix = []byte("tst-")

	// LocalRaftHardStateSuffix is the Suffix for the raft HardState.
	LocalRaftHardStateSuffix = []byte("rfth")
	// LocalRaftLastIndexSuffix is the suffix for raft's last index.
	LocalRaftLastIndexSuffix = []byte("rfti")
	// LocalRaftLogSuffix is the suffix for the raft log.
	LocalRaftLogSuffix = []byte("rftl")
	// LocalRangeLastReplicaGCTimestampSuffix is the suffix for a range's
	// last replica GC timestamp (for GC of old replicas).
	LocalRangeLastReplicaGCTimestampSuffix = []byte("rlrt")
	// LocalRangeLastVerificationTimestampSuffixDeprecated is the suffix for a range's
	// last verification timestamp (for checking integrity of on-disk data).
	// Note: DEPRECATED.
	LocalRangeLastVerificationTimestampSuffixDeprecated = []byte("rlvt")
	// LocalRangeReplicaDestroyedErrorSuffix is the suffix for a range's replica
	// destroyed error (for marking replicas as dead).
	LocalRangeReplicaDestroyedErrorSuffix = []byte("rrde")

	// 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")
	// LocalTransactionSuffix specifies the key suffix for
	// transaction records. The additional detail is the transaction id.
	// NOTE: if this value changes, it must be updated in C++
	// (storage/engine/rocksdb/db.cc).
	LocalTransactionSuffix = roachpb.RKey("txn-")
	// LocalQueueLastProcessedSuffix is the suffix for replica queue state keys.
	LocalQueueLastProcessedSuffix = roachpb.RKey("qlpt")

	// Meta1Prefix is the first level of key addressing. It is selected such that
	// all range addressing records sort before any system tables which they
	// might describe. The value is a RangeDescriptor struct.
	Meta1Prefix = roachpb.Key{meta1PrefixByte}
	// Meta2Prefix is the second level of key addressing. The value is a
	// RangeDescriptor struct.
	Meta2Prefix = roachpb.Key{meta2PrefixByte}
	// 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))

	// MetaMin is the start of the range of addressing keys.
	MetaMin = Meta1Prefix
	// MetaMax is the end of the range of addressing keys.
	MetaMax = roachpb.Key{metaMaxByte}

	// SystemPrefix indicates the beginning of the key range for
	// global, system data which are replicated across the cluster.
	SystemPrefix = roachpb.Key{systemPrefixByte}
	SystemMax    = roachpb.Key{systemMaxByte}

	// NodeLivenessPrefix specifies the key prefix for the node liveness
	// table.  Note that this should sort before the rest of the system
	// keyspace in order to limit the number of ranges which must use
	// expiration-based range leases instead of the more efficient
	// node-liveness epoch-based range leases (see
	// https://github.com/cockroachdb/cockroach/blob/master/docs/RFCS/range_leases.md)
	NodeLivenessPrefix = roachpb.Key(makeKey(SystemPrefix, roachpb.RKey("\x00liveness-")))

	// NodeLivenessKeyMax is the maximum value for any node liveness key.
	NodeLivenessKeyMax = NodeLivenessPrefix.PrefixEnd()

	// BootstrapVersion is the key at which clusters bootstrapped with a version
	// > 1.0 persist the version at which they were bootstrapped.
	BootstrapVersionKey = roachpb.Key(makeKey(SystemPrefix, roachpb.RKey("bootstrap-version")))

	// MigrationPrefix specifies the key prefix to store all migration details.
	MigrationPrefix = roachpb.Key(makeKey(SystemPrefix, roachpb.RKey("system-version/")))

	// MigrationLease is the key that nodes must take a lease on in order to run
	// system migrations on the cluster.
	MigrationLease = roachpb.Key(makeKey(MigrationPrefix, roachpb.RKey("lease")))

	// MigrationKeyMax is the maximum value for any system migration key.
	MigrationKeyMax = MigrationPrefix.PrefixEnd()

	// 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")))

	// StatusPrefix specifies the key prefix to store all status details.
	StatusPrefix = roachpb.Key(makeKey(SystemPrefix, roachpb.RKey("status-")))
	// StatusNodePrefix stores all status info for nodes.
	StatusNodePrefix = roachpb.Key(makeKey(StatusPrefix, roachpb.RKey("node-")))

	// TimeseriesPrefix is the key prefix for all timeseries data.
	TimeseriesPrefix = roachpb.Key(makeKey(SystemPrefix, roachpb.RKey("tsd")))

	// TableDataMin is the start of the range of table data keys.
	TableDataMin = roachpb.Key(encoding.EncodeVarintAscending(nil, 0))
	// TableDataMin is the end of the range of table data keys.
	TableDataMax = roachpb.Key(encoding.EncodeVarintAscending(nil, math.MaxInt64))

	// SystemConfigSplitKey is the key to split at immediately prior to the
	// system config span. NB: Split keys need to be valid column keys.
	// TODO(bdarnell): this should be either roachpb.Key or RKey, not []byte.
	SystemConfigSplitKey = []byte(TableDataMin)
	// SystemConfigTableDataMax is the end key of system config span.
	SystemConfigTableDataMax = roachpb.Key(MakeTablePrefix(MaxSystemConfigDescID + 1))

	// UserTableDataMin is the start key of user structured data.
	UserTableDataMin = roachpb.Key(MakeTablePrefix(MaxReservedDescID + 1))

	// MaxKey is the infinity marker which is larger than any other key.
	MaxKey = roachpb.KeyMax
	// MinKey is a minimum key value which sorts before all other keys.
	MinKey = roachpb.KeyMin
)

Constants for system-reserved keys in the KV map.

Note: preserve group-wise ordering when adding new constants.

View Source
var (
	// MetaSpan holds all the addressing records.
	//
	// TODO(peter): Allow splitting of meta2 records. This requires enhancement
	// to range lookup. See #16266.
	//
	//  Meta1Span = roachpb.Span{Key: roachpb.KeyMin, EndKey: Meta2Prefix}
	MetaSpan = roachpb.Span{Key: roachpb.KeyMin, EndKey: MetaMax}

	// NodeLivenessSpan holds the liveness records for nodes in the cluster.
	NodeLivenessSpan = roachpb.Span{Key: NodeLivenessPrefix, EndKey: NodeLivenessKeyMax}

	// SystemConfigSpan is the range of system objects which will be gossiped.
	SystemConfigSpan = roachpb.Span{Key: SystemConfigSplitKey, EndKey: SystemConfigTableDataMax}

	// NoSplitSpans describes the ranges that should never be split.
	// MetaSpan: needed to find other ranges.
	// NodeLivenessSpan: liveness information on nodes in the cluster.
	// SystemConfigSpan: system objects which will be gossiped.
	NoSplitSpans = []roachpb.Span{MetaSpan, NodeLivenessSpan, SystemConfigSpan}
)
View Source
var PrettyPrintTimeseriesKey func(key roachpb.Key) string

PrettyPrintTimeseriesKey is a hook for pretty printing a timeseries key. The timeseries key prefix will already have been stripped off.

Functions

func AbortCacheKey

func AbortCacheKey(rangeID roachpb.RangeID, txnID uuid.UUID) roachpb.Key

AbortCacheKey returns a range-local key by Range ID for an abort cache entry, with detail specified by encoding the supplied transaction ID.

func Addr

func Addr(k roachpb.Key) (roachpb.RKey, error)

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, the address is the inner encoded key, with the local key prefix and the suffix and optional detail removed. This address unwrapping is performed repeatedly in the case of doubly-local keys. 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.

Logically, the keys are arranged as follows:

k1 /local/k1/KeyMin ... /local/k1/KeyMax k1\x00 /local/k1/x00/KeyMin ...

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. abort cache entries, and range stats).

See AddrEndKey which is to be used when `k` is the EndKey of an interval.

func AddrUpperBound

func AddrUpperBound(k roachpb.Key) (roachpb.RKey, error)

AddrUpperBound returns the address of an (exclusive) EndKey, used to lookup ranges containing the keys strictly smaller than that key. However, unlike Addr, it will return the following key that local range keys address to. This is necessary because range-local keys exist conceptually in the space between regular keys. Addr() returns the regular key that is just to the left of a range-local key, which is guaranteed to be located on the same range. AddrUpperBound() returns the regular key that is just to the right, which may not be on the same range but is suitable for use as the EndKey of a span involving a range-local key.

Logically, the keys are arranged as follows:

k1 /local/k1/KeyMin ... /local/k1/KeyMax k1\x00 /local/k1/x00/KeyMin ...

and so any end key /local/k1/x corresponds to an address-resolved end key of k1\x00.

func DecodeAbortCacheKey

func DecodeAbortCacheKey(key roachpb.Key, dest []byte) (uuid.UUID, error)

DecodeAbortCacheKey decodes the provided abort cache entry, returning the transaction ID.

func DecodeRangeIDKey

func DecodeRangeIDKey(
	key roachpb.Key,
) (rangeID roachpb.RangeID, infix, suffix, detail roachpb.Key, err error)

DecodeRangeIDKey parses a local range ID key into range ID, infix, suffix, and detail.

func DecodeRangeKey

func DecodeRangeKey(key roachpb.Key) (startKey, suffix, detail roachpb.Key, err error)

DecodeRangeKey decodes the range key into range start key, suffix and optional detail (may be nil).

func DecodeTablePrefix

func DecodeTablePrefix(key roachpb.Key) ([]byte, uint64, error)

DecodeTablePrefix validates that the given key has a table prefix, returning the remainder of the key (with the prefix removed) and the decoded descriptor ID of the table.

func EnsureSafeSplitKey

func EnsureSafeSplitKey(key roachpb.Key) (roachpb.Key, error)

EnsureSafeSplitKey transforms an SQL table key such that it is a valid split key (i.e. does not occur in the middle of a row).

func GetRowPrefixLength added in v1.1.0

func GetRowPrefixLength(key roachpb.Key) (int, error)

GetRowPrefixLength returns the length of the row prefix of the key. A table key's row prefix is defined as the maximal prefix of the key that is also a prefix of every key for the same row. (Any key with this maximal prefix is also guaranteed to be part of the input key's row.) For secondary index keys, the row prefix is defined as the entire key.

func IsLocal

func IsLocal(k roachpb.Key) bool

IsLocal performs a cheap check that returns true iff a range-local key is passed, that is, a key for which `Addr` would return a non-identical RKey (or a decoding error).

TODO(tschottdorf): we need a better name for these keys as only some of them are local and it's been identified as an area that is not understood by many of the team's developers. An obvious suggestion is "system" (as opposed to "user") keys, but unfortunately that name has already been claimed by a related (but not identical) concept.

func LeaseAppliedIndexKey

func LeaseAppliedIndexKey(rangeID roachpb.RangeID) roachpb.Key

LeaseAppliedIndexKey returns a system-local key for a lease applied index.

func MakeFamilyKey

func MakeFamilyKey(key []byte, famID uint32) []byte

MakeFamilyKey returns the key for the family in the given row by appending to the passed key.

func MakeRangeIDPrefix

func MakeRangeIDPrefix(rangeID roachpb.RangeID) roachpb.Key

MakeRangeIDPrefix creates a range-local key prefix from rangeID for both replicated and unreplicated data.

func MakeRangeIDReplicatedPrefix

func MakeRangeIDReplicatedPrefix(rangeID roachpb.RangeID) roachpb.Key

MakeRangeIDReplicatedPrefix creates a range-local key prefix from rangeID for all Raft replicated data.

func MakeRangeIDUnreplicatedPrefix

func MakeRangeIDUnreplicatedPrefix(rangeID roachpb.RangeID) roachpb.Key

MakeRangeIDUnreplicatedPrefix creates a range-local key prefix from rangeID for all unreplicated data.

func MakeRangeKey

func MakeRangeKey(key, suffix, detail roachpb.RKey) roachpb.Key

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

func MakeRangeKeyPrefix(key roachpb.RKey) roachpb.Key

MakeRangeKeyPrefix creates a key prefix under which all range-local keys can be found.

func MakeStoreKey

func MakeStoreKey(suffix, detail roachpb.RKey) roachpb.Key

MakeStoreKey creates a store-local key based on the metadata key suffix, and optional detail.

func MakeTablePrefix

func MakeTablePrefix(tableID uint32) []byte

MakeTablePrefix returns the key prefix used for the table's data.

func MassagePrettyPrintedSpanForTest

func MassagePrettyPrintedSpanForTest(span string, dirs []encoding.Direction) string

MassagePrettyPrintedSpanForTest does some transformations on pretty-printed spans and keys: - if dirs is not nil, replace all ints with their ones' complement for descendingly-encoded columns. - strips line numbers from error messages.

func MetaReverseScanBounds

func MetaReverseScanBounds(key roachpb.RKey) (roachpb.RSpan, error)

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

func MetaScanBounds(key roachpb.RKey) (roachpb.RSpan, error)

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 MustAddr

func MustAddr(k roachpb.Key) roachpb.RKey

MustAddr calls Addr and panics on errors.

func NodeLivenessKey

func NodeLivenessKey(nodeID roachpb.NodeID) roachpb.Key

NodeLivenessKey returns the key for the node liveness record.

func NodeStatusKey

func NodeStatusKey(nodeID roachpb.NodeID) roachpb.Key

NodeStatusKey returns the key for accessing the node status for the specified node ID.

func PrettyPrint

func PrettyPrint(key roachpb.Key) string

PrettyPrint prints the key in a human readable format:

Key's Format Key's Value /Local/... "\x01"+...

/Store/...                                     "\x01s"+...
/RangeID/...                                   "\x01s"+[rangeid]
	/[rangeid]/AbortCache/[id]                   "\x01s"+[rangeid]+"abc-"+[id]
	/[rangeid]/Lease						                 "\x01s"+[rangeid]+"rfll"
	/[rangeid]/RaftTombstone                     "\x01s"+[rangeid]+"rftb"
	/[rangeid]/RaftHardState						         "\x01s"+[rangeid]+"rfth"
	/[rangeid]/RaftAppliedIndex						       "\x01s"+[rangeid]+"rfta"
	/[rangeid]/RaftLog/logIndex:[logIndex]       "\x01s"+[rangeid]+"rftl"+[logIndex]
	/[rangeid]/RaftTruncatedState                "\x01s"+[rangeid]+"rftt"
	/[rangeid]/RaftLastIndex                     "\x01s"+[rangeid]+"rfti"
	/[rangeid]/RangeLastReplicaGCTimestamp       "\x01s"+[rangeid]+"rlrt"
	/[rangeid]/RangeLastVerificationTimestamp    "\x01s"+[rangeid]+"rlvt"
	/[rangeid]/RangeStats                        "\x01s"+[rangeid]+"stat"
/Range/...                                     "\x01k"+...
	[key]/RangeDescriptor                        "\x01k"+[key]+"rdsc"
	[key]/Transaction/[id]	                     "\x01k"+[key]+"txn-"+[txn-id]
	[key]/QueueLastProcessed/[queue]             "\x01k"+[key]+"qlpt"+[queue]

/Local/Max "\x02"

/Meta1/[key] "\x02"+[key] /Meta2/[key] "\x03"+[key] /System/... "\x04"

/NodeLiveness/[key]                            "\x04\0x00liveness-"+[key]
/StatusNode/[key]                              "\x04status-node-"+[key]

/System/Max "\x05"

/Table/[key] [key]

/Min "" /Max "\xff\xff"

func PrettyPrintRange

func PrettyPrintRange(start, end roachpb.Key, maxChars int) string

PrettyPrintRange pretty prints a compact representation of a key range. The output is of the form:

commonPrefix{remainingStart-remainingEnd}

It prints at most maxChars, truncating components as needed. See TestPrettyPrintRange for some examples.

func QueueLastProcessedKey

func QueueLastProcessedKey(key roachpb.RKey, queue string) roachpb.Key

QueueLastProcessedKey returns a range-local key for last processed timestamps for the named queue. These keys represent per-range last processed times.

func RaftAppliedIndexKey

func RaftAppliedIndexKey(rangeID roachpb.RangeID) roachpb.Key

RaftAppliedIndexKey returns a system-local key for a raft applied index.

func RaftHardStateKey

func RaftHardStateKey(rangeID roachpb.RangeID) roachpb.Key

RaftHardStateKey returns a system-local key for a Raft HardState.

func RaftLastIndexKey

func RaftLastIndexKey(rangeID roachpb.RangeID) roachpb.Key

RaftLastIndexKey returns a system-local key for the last index of the Raft log.

func RaftLogKey

func RaftLogKey(rangeID roachpb.RangeID, logIndex uint64) roachpb.Key

RaftLogKey returns a system-local key for a Raft log entry.

func RaftLogPrefix

func RaftLogPrefix(rangeID roachpb.RangeID) roachpb.Key

RaftLogPrefix returns the system-local prefix shared by all entries in a Raft log.

func RaftTombstoneKey

func RaftTombstoneKey(rangeID roachpb.RangeID) roachpb.Key

RaftTombstoneKey returns a system-local key for a raft tombstone.

func RaftTruncatedStateKey

func RaftTruncatedStateKey(rangeID roachpb.RangeID) roachpb.Key

RaftTruncatedStateKey returns a system-local key for a RaftTruncatedState.

func Range

func Range(ba roachpb.BatchRequest) (roachpb.RSpan, error)

Range returns a key range encompassing all the keys in the Batch.

func RangeDescriptorKey

func RangeDescriptorKey(key roachpb.RKey) roachpb.Key

RangeDescriptorKey returns a range-local key for the descriptor for the range with specified key.

func RangeFrozenStatusKey

func RangeFrozenStatusKey(rangeID roachpb.RangeID) roachpb.Key

RangeFrozenStatusKey returns a system-local key for the frozen status.

func RangeLastGCKey

func RangeLastGCKey(rangeID roachpb.RangeID) roachpb.Key

RangeLastGCKey returns a system-local key for last used GC threshold on the user keyspace. Reads and writes <= this timestamp will not be served.

TODO(tschottdorf): should be renamed to RangeGCThresholdKey.

func RangeLastReplicaGCTimestampKey

func RangeLastReplicaGCTimestampKey(rangeID roachpb.RangeID) roachpb.Key

RangeLastReplicaGCTimestampKey returns a range-local key for the range's last replica GC timestamp.

func RangeLastVerificationTimestampKeyDeprecated

func RangeLastVerificationTimestampKeyDeprecated(rangeID roachpb.RangeID) roachpb.Key

RangeLastVerificationTimestampKeyDeprecated returns a range-local key for the range's last verification timestamp.

func RangeLeaseKey

func RangeLeaseKey(rangeID roachpb.RangeID) roachpb.Key

RangeLeaseKey returns a system-local key for a range lease.

func RangeMetaKey

func RangeMetaKey(key roachpb.RKey) roachpb.Key

RangeMetaKey returns a range metadata (meta1, meta2) indexing key for the given key.

- For RKeyMin, KeyMin is returned. - For a meta1 key, KeyMin is returned. - For a meta2 key, a meta1 key is returned. - For an ordinary key, a meta2 key is returned.

func RangeStatsKey

func RangeStatsKey(rangeID roachpb.RangeID) roachpb.Key

RangeStatsKey returns the key for accessing the MVCCStats struct for the specified Range ID.

func RangeTxnSpanGCThresholdKey

func RangeTxnSpanGCThresholdKey(rangeID roachpb.RangeID) roachpb.Key

RangeTxnSpanGCThresholdKey returns a system-local key for last used GC threshold on the txn span.

func StoreClusterVersionKey added in v1.1.0

func StoreClusterVersionKey() roachpb.Key

StoreClusterVersionKey returns a store-local key for the cluster version.

func StoreGossipKey

func StoreGossipKey() roachpb.Key

StoreGossipKey returns a store-local key for the gossip bootstrap metadata.

func StoreIdentKey

func StoreIdentKey() roachpb.Key

StoreIdentKey returns a store-local key for the store metadata.

func StoreLastUpKey

func StoreLastUpKey() roachpb.Key

StoreLastUpKey returns the key for the store's "last up" timestamp.

func TransactionKey

func TransactionKey(key roachpb.Key, txnID uuid.UUID) roachpb.Key

TransactionKey returns a transaction key based on the provided transaction key and ID. The base key is encoded in order to guarantee that all transaction records for a range sort together.

func UglyPrint

func UglyPrint(input string) (_ roachpb.Key, rErr error)

UglyPrint is a partial right inverse to PrettyPrint: it takes a key formatted for human consumption and attempts to translate it into a roachpb.Key. Not all key types are supported and no optimization has been performed. This is intended for use in debugging only.

func UserKey

func UserKey(key roachpb.RKey) roachpb.RKey

UserKey returns an ordinary key for the given range metadata (meta1, meta2) indexing key.

- For RKeyMin, Meta1Prefix is returned. - For a meta1 key, a meta2 key is returned. - For a meta2 key, an ordinary key is returned. - For an ordinary key, the input key is returned.

Types

type InvalidRangeMetaKeyError

type InvalidRangeMetaKeyError struct {
	Msg string
	Key roachpb.Key
}

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.

type RangeIDPrefixBuf

type RangeIDPrefixBuf roachpb.Key

RangeIDPrefixBuf provides methods for generating range ID local keys while avoiding an allocation on every key generated. The generated keys are only valid until the next call to one of the key generation methods.

func MakeRangeIDPrefixBuf

func MakeRangeIDPrefixBuf(rangeID roachpb.RangeID) RangeIDPrefixBuf

MakeRangeIDPrefixBuf creates a new range ID prefix buf suitable for generating the various range ID local keys.

func (RangeIDPrefixBuf) AbortCacheKey

func (b RangeIDPrefixBuf) AbortCacheKey(txnID uuid.UUID) roachpb.Key

AbortCacheKey returns a range-local key by Range ID for an abort cache entry, with detail specified by encoding the supplied transaction ID.

func (RangeIDPrefixBuf) LeaseAppliedIndexKey

func (b RangeIDPrefixBuf) LeaseAppliedIndexKey() roachpb.Key

LeaseAppliedIndexKey returns a system-local key for a lease applied index.

func (RangeIDPrefixBuf) RaftAppliedIndexKey

func (b RangeIDPrefixBuf) RaftAppliedIndexKey() roachpb.Key

RaftAppliedIndexKey returns a system-local key for a raft applied index.

func (RangeIDPrefixBuf) RaftHardStateKey

func (b RangeIDPrefixBuf) RaftHardStateKey() roachpb.Key

RaftHardStateKey returns a system-local key for a Raft HardState.

func (RangeIDPrefixBuf) RaftLastIndexKey

func (b RangeIDPrefixBuf) RaftLastIndexKey() roachpb.Key

RaftLastIndexKey returns a system-local key for the last index of the Raft log.

func (RangeIDPrefixBuf) RaftLogKey

func (b RangeIDPrefixBuf) RaftLogKey(logIndex uint64) roachpb.Key

RaftLogKey returns a system-local key for a Raft log entry.

func (RangeIDPrefixBuf) RaftLogPrefix

func (b RangeIDPrefixBuf) RaftLogPrefix() roachpb.Key

RaftLogPrefix returns the system-local prefix shared by all entries in a Raft log.

func (RangeIDPrefixBuf) RaftTombstoneKey

func (b RangeIDPrefixBuf) RaftTombstoneKey() roachpb.Key

RaftTombstoneKey returns a system-local key for a raft tombstone.

func (RangeIDPrefixBuf) RaftTruncatedStateKey

func (b RangeIDPrefixBuf) RaftTruncatedStateKey() roachpb.Key

RaftTruncatedStateKey returns a system-local key for a RaftTruncatedState.

func (RangeIDPrefixBuf) RangeFrozenStatusKey

func (b RangeIDPrefixBuf) RangeFrozenStatusKey() roachpb.Key

RangeFrozenStatusKey returns a system-local key for the frozen status.

func (RangeIDPrefixBuf) RangeLastGCKey

func (b RangeIDPrefixBuf) RangeLastGCKey() roachpb.Key

RangeLastGCKey returns a system-local key for the last GC.

func (RangeIDPrefixBuf) RangeLastReplicaGCTimestampKey

func (b RangeIDPrefixBuf) RangeLastReplicaGCTimestampKey() roachpb.Key

RangeLastReplicaGCTimestampKey returns a range-local key for the range's last replica GC timestamp.

func (RangeIDPrefixBuf) RangeLastVerificationTimestampKeyDeprecated

func (b RangeIDPrefixBuf) RangeLastVerificationTimestampKeyDeprecated() roachpb.Key

RangeLastVerificationTimestampKeyDeprecated returns a range-local key for the range's last verification timestamp.

func (RangeIDPrefixBuf) RangeLeaseKey

func (b RangeIDPrefixBuf) RangeLeaseKey() roachpb.Key

RangeLeaseKey returns a system-local key for a range lease.

func (RangeIDPrefixBuf) RangeReplicaDestroyedErrorKey

func (b RangeIDPrefixBuf) RangeReplicaDestroyedErrorKey() roachpb.Key

RangeReplicaDestroyedErrorKey returns a range-local key for the range's replica destroyed error.

func (RangeIDPrefixBuf) RangeStatsKey

func (b RangeIDPrefixBuf) RangeStatsKey() roachpb.Key

RangeStatsKey returns the key for accessing the MVCCStats struct for the specified Range ID.

func (RangeIDPrefixBuf) RangeTxnSpanGCThresholdKey

func (b RangeIDPrefixBuf) RangeTxnSpanGCThresholdKey() roachpb.Key

RangeTxnSpanGCThresholdKey returns a system-local key for last used GC threshold on the txn span.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL