LegacyRevToRevTreeEncodedVersion creates a version that has a specific source ID that can be recognized. The version is made up of: - The upper 24 bits of the version are the generation. - The lower 40 bits of the version are the first 40 bits of the digest, which is right padded.
(legacyRev string)
| 973 | // - The upper 24 bits of the version are the generation. |
| 974 | // - The lower 40 bits of the version are the first 40 bits of the digest, which is right padded. |
| 975 | func LegacyRevToRevTreeEncodedVersion(legacyRev string) (Version, error) { |
| 976 | generation, digest, err := parseRevID(legacyRev) |
| 977 | if err != nil { |
| 978 | return Version{}, err |
| 979 | } |
| 980 | // trim to 40 bits (10 hex characters) |
| 981 | if len(digest) > 10 { |
| 982 | digest = digest[:10] |
| 983 | } else if len(digest) < 10 { |
| 984 | digest += strings.Repeat("0", 10-len(digest)) |
| 985 | } |
| 986 | value, err := strconv.ParseUint(digest, 16, 64) |
| 987 | if err != nil { |
| 988 | return Version{}, err |
| 989 | } |
| 990 | return Version{ |
| 991 | SourceID: encodedRevTreeSourceID, |
| 992 | Value: (uint64(generation) << 40) | value, |
| 993 | }, nil |
| 994 | } |
| 995 | |
| 996 | func (hlv *HybridLogicalVector) HasRevEncodedCV() bool { |
| 997 | return hlv.SourceID == encodedRevTreeSourceID |