// mvccEncodeKey makes a timestamped key which is the concatenation of // the given key and the corresponding timestamp. The key is expected // to have been encoded using EncodeBinary. func mvccEncodeKey(key Key, timestamp proto.Timestamp) Key { if timestamp.WallTime < 0 || timestamp.Logical < 0 { panic(fmt.Sprintf("negative values disallowed in timestamps: %+v", timestamp)) } k := append([]byte{}, key...) k = encoding.EncodeUint64Decreasing(k, uint64(timestamp.WallTime)) k = encoding.EncodeUint32Decreasing(k, uint32(timestamp.Logical)) return k }
// mvccEncodeKey makes a timestamped key which is the concatenation of // the given key and the corresponding timestamp. The key is expected // to have been encoded using EncodeBinary. func mvccEncodeKey(key Key, timestamp proto.Timestamp) Key { if timestamp.WallTime < 0 || timestamp.Logical < 0 { // TODO(Spencer): Reevaluate this panic vs. returning an error, see // https://github.com/cockroachdb/cockroach/pull/50/files#diff-6d2dccecc0623fb6dd5456ae18bbf19eR611 panic(fmt.Sprintf("negative values disallowed in timestamps: %+v", timestamp)) } k := append([]byte{}, key...) k = encoding.EncodeUint64Decreasing(k, uint64(timestamp.WallTime)) k = encoding.EncodeUint32Decreasing(k, uint32(timestamp.Logical)) return k }
// RaftLogKey returns a system-local key for a Raft log entry. func RaftLogKey(raftID int64, logIndex uint64) proto.Key { // The log is stored "backwards" so we can easily find the highest index stored. return MakeRangeIDKey(raftID, KeyLocalRaftLogSuffix, encoding.EncodeUint64Decreasing(nil, logIndex)) }