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

Method Serialize

core/sequences/serialization.go:27–52  ·  view source on GitHub ↗

Serialize returns the Sequence as a byte slice. If the Sequence is nil, then this returns a nil slice.

(ctx context.Context)

Source from the content-addressed store, hash-verified

25
26// Serialize returns the Sequence as a byte slice. If the Sequence is nil, then this returns a nil slice.
27func (sequence *Sequence) Serialize(ctx context.Context) ([]byte, error) {
28 if sequence == nil {
29 return nil, nil
30 }
31
32 // Create the writer
33 writer := utils.NewWriter(256)
34 writer.VariableUint(1) // Version
35 // Write the sequence data
36 writer.Id(sequence.Id.AsId())
37 writer.Id(sequence.DataTypeID.AsId())
38 writer.Uint8(uint8(sequence.Persistence))
39 writer.Int64(sequence.Start)
40 writer.Int64(sequence.Current)
41 writer.Int64(sequence.Increment)
42 writer.Int64(sequence.Minimum)
43 writer.Int64(sequence.Maximum)
44 writer.Int64(sequence.Cache)
45 writer.Bool(sequence.Cycle)
46 writer.Bool(sequence.IsAtEnd)
47 writer.Bool(sequence.HasBeenCalled)
48 writer.Id(sequence.OwnerTable.AsId())
49 writer.String(sequence.OwnerColumn)
50 // Returns the data
51 return writer.Data(), nil
52}
53
54// DeserializeSequence returns the Sequence that was serialized in the byte slice. Returns an empty Sequence if data is
55// nil or empty.

Callers 1

HashOfMethod · 0.95

Calls 9

VariableUintMethod · 0.95
IdMethod · 0.95
Uint8Method · 0.95
Int64Method · 0.95
BoolMethod · 0.95
StringMethod · 0.95
DataMethod · 0.95
NewWriterFunction · 0.92
AsIdMethod · 0.45

Tested by

no test coverage detected