예제 #1
0
파일: mvcc.go 프로젝트: bigrats/cockroach
// 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
}
예제 #2
0
파일: mvcc.go 프로젝트: embark/cockroach
// 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
}
예제 #3
0
파일: keys.go 프로젝트: ming-hai/cockroach
// SequenceCacheKey returns a range-local key by Range ID for a
// sequence cache entry, with detail specified by encoding the
// supplied transaction ID, epoch and sequence number.
func SequenceCacheKey(rangeID roachpb.RangeID, id []byte, epoch uint32, seq uint32) roachpb.Key {
	return MakeRangeIDKey(rangeID, LocalSequenceCacheSuffix,
		encoding.EncodeUint32Decreasing(
			encoding.EncodeUint32Decreasing(
				encoding.EncodeBytes(nil, id), epoch), seq))
}