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

Function DeserializeSequence

core/sequences/serialization.go:56–89  ·  view source on GitHub ↗

DeserializeSequence returns the Sequence that was serialized in the byte slice. Returns an empty Sequence if data is nil or empty.

(_ context.Context, data []byte)

Source from the content-addressed store, hash-verified

54// DeserializeSequence returns the Sequence that was serialized in the byte slice. Returns an empty Sequence if data is
55// nil or empty.
56func DeserializeSequence(_ context.Context, data []byte) (*Sequence, error) {
57 if len(data) == 0 {
58 return nil, nil
59 }
60 reader := utils.NewReader(data)
61 version := reader.VariableUint()
62 if version > 1 {
63 return nil, errors.Errorf("version %d of sequences is not supported, please upgrade the server", version)
64 }
65
66 // Read from the reader
67 sequence := &Sequence{}
68 sequence.Id = id.Sequence(reader.Id())
69 sequence.DataTypeID = id.Type(reader.Id())
70 sequence.Persistence = Persistence(reader.Uint8())
71 sequence.Start = reader.Int64()
72 sequence.Current = reader.Int64()
73 sequence.Increment = reader.Int64()
74 sequence.Minimum = reader.Int64()
75 sequence.Maximum = reader.Int64()
76 sequence.Cache = reader.Int64()
77 sequence.Cycle = reader.Bool()
78 sequence.IsAtEnd = reader.Bool()
79 if version >= 1 {
80 sequence.HasBeenCalled = reader.Bool()
81 }
82 sequence.OwnerTable = id.Table(reader.Id())
83 sequence.OwnerColumn = reader.String()
84 if !reader.IsEmpty() {
85 return nil, errors.Errorf("extra data found while deserializing a sequence")
86 }
87 // Return the deserialized object
88 return sequence, nil
89}

Callers 3

DeserializeRootObjectMethod · 0.85
cacheAllSequencesMethod · 0.85
getSequenceMethod · 0.85

Calls 13

VariableUintMethod · 0.95
IdMethod · 0.95
Uint8Method · 0.95
Int64Method · 0.95
BoolMethod · 0.95
StringMethod · 0.95
IsEmptyMethod · 0.95
NewReaderFunction · 0.92
SequenceTypeAlias · 0.92
TypeTypeAlias · 0.92
TableTypeAlias · 0.92
PersistenceTypeAlias · 0.70

Tested by

no test coverage detected