MCPcopy Create free account
hub / github.com/dolthub/doltgresql / DeserializeCast

Function DeserializeCast

core/casts/serialization.go:46–67  ·  view source on GitHub ↗

DeserializeCast returns the Cast that was serialized in the byte slice. Returns an empty Cast (invalid ID) if data is nil or empty.

(ctx context.Context, data []byte)

Source from the content-addressed store, hash-verified

44// DeserializeCast returns the Cast that was serialized in the byte slice. Returns an empty Cast (invalid ID) if data is
45// nil or empty.
46func DeserializeCast(ctx context.Context, data []byte) (Cast, error) {
47 if len(data) == 0 {
48 return Cast{}, nil
49 }
50 reader := utils.NewReader(data)
51 version := reader.VariableUint()
52 if version != 0 {
53 return Cast{}, errors.Errorf("version %d of casts is not supported, please upgrade the server", version)
54 }
55
56 // Read from the reader
57 t := Cast{}
58 t.ID = id.Cast(reader.Id())
59 t.CastType = CastType(reader.Uint8())
60 t.Function = id.Function(reader.Id())
61 t.UseInOut = reader.Bool()
62 if !reader.IsEmpty() {
63 return Cast{}, errors.Errorf("extra data found while deserializing a cast")
64 }
65 // Return the deserialized object
66 return t, nil
67}

Callers 3

DeserializeRootObjectMethod · 0.85
getCastMethod · 0.85
IterateCastsMethod · 0.85

Calls 10

VariableUintMethod · 0.95
IdMethod · 0.95
Uint8Method · 0.95
BoolMethod · 0.95
IsEmptyMethod · 0.95
NewReaderFunction · 0.92
CastTypeAlias · 0.92
FunctionTypeAlias · 0.92
CastTypeTypeAlias · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected