MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / decode

Method decode

IceFireDB-SQLite/pkg/mysql/mysql/mysql_gtid.go:251–281  ·  view source on GitHub ↗
(data []byte)

Source from the content-addressed store, hash-verified

249}
250
251func (s *UUIDSet) decode(data []byte) (int, error) {
252 if len(data) < 24 {
253 return 0, errors.Errorf("invalid uuid set buffer, less 24")
254 }
255
256 pos := 0
257 var err error
258 if s.SID, err = uuid.FromBytes(data[0:16]); err != nil {
259 return 0, err
260 }
261 pos += 16
262
263 n := int64(binary.LittleEndian.Uint64(data[pos : pos+8]))
264 pos += 8
265 if len(data) < int(16*n)+pos {
266 return 0, errors.Errorf("invalid uuid set buffer, must %d, but %d", pos+int(16*n), len(data))
267 }
268
269 s.Intervals = make([]Interval, 0, n)
270
271 var in Interval
272 for i := int64(0); i < n; i++ {
273 in.Start = int64(binary.LittleEndian.Uint64(data[pos : pos+8]))
274 pos += 8
275 in.Stop = int64(binary.LittleEndian.Uint64(data[pos : pos+8]))
276 pos += 8
277 s.Intervals = append(s.Intervals, in)
278 }
279
280 return pos, nil
281}
282
283func (s *UUIDSet) Decode(data []byte) error {
284 n, err := s.decode(data)

Callers 2

DecodeMethod · 0.95
DecodeMysqlGTIDSetFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected