MCPcopy Create free account
hub / github.com/HDT3213/rdb / encodeBacklen

Method encodeBacklen

core/stream.go:605–635  ·  view source on GitHub ↗

encodeBacklen encodes a backlen value

(elementLen uint32)

Source from the content-addressed store, hash-verified

603
604// encodeBacklen encodes a backlen value
605func (enc *Encoder) encodeBacklen(elementLen uint32) []byte {
606 if elementLen <= 127 {
607 return []byte{byte(elementLen)}
608 } else if elementLen < (1<<14)-1 {
609 return []byte{
610 byte(0x80 | (elementLen >> 8)),
611 byte(elementLen & 0xFF),
612 }
613 } else if elementLen < (1<<21)-1 {
614 return []byte{
615 byte(0xC0 | (elementLen >> 16)),
616 byte((elementLen >> 8) & 0xFF),
617 byte(elementLen & 0xFF),
618 }
619 } else if elementLen < (1<<28)-1 {
620 return []byte{
621 byte(0xE0 | (elementLen >> 24)),
622 byte((elementLen >> 16) & 0xFF),
623 byte((elementLen >> 8) & 0xFF),
624 byte(elementLen & 0xFF),
625 }
626 } else {
627 return []byte{
628 0xF0,
629 byte((elementLen >> 24) & 0xFF),
630 byte((elementLen >> 16) & 0xFF),
631 byte((elementLen >> 8) & 0xFF),
632 byte(elementLen & 0xFF),
633 }
634 }
635}
636
637// writeStreamGroups writes stream groups
638func (enc *Encoder) writeStreamGroups(groups []*model.StreamGroup, version uint) error {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected