MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / UndoPrefixEnd

Function UndoPrefixEnd

pkg/util/encoding/encoding.go:2442–2450  ·  view source on GitHub ↗

UndoPrefixEnd is a partial inverse for roachpb.Key.PrefixEnd. In general, we can't undo PrefixEnd because it is lossy; we don't know how many FFs were stripped from the original key. For example: - key: 01 02 03 FF FF - PrefixEnd: 01 02 04 - UndoPrefixEnd: 01 02 03 Some keys are n

(b []byte)

Source from the content-addressed store, hash-verified

2440// UndoPrefixEnd is implemented here to avoid a circular dependency on roachpb,
2441// but arguably belongs in a byte-manipulation utility package.
2442func UndoPrefixEnd(b []byte) (_ []byte, ok bool) {
2443 if len(b) == 0 || b[len(b)-1] == 0 {
2444 // Not a possible result of PrefixEnd.
2445 return nil, false
2446 }
2447 out := append([]byte(nil), b...)
2448 out[len(out)-1]--
2449 return out, true
2450}
2451
2452// MaxNonsortingVarintLen is the maximum length of an EncodeNonsortingVarint
2453// encoded value.

Callers 2

PrettyPrintValueFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…