MCPcopy Create free account
hub / github.com/apache/thrift / writeCollectionBegin

Method writeCollectionBegin

lib/go/thrift/compact_protocol.go:684–694  ·  view source on GitHub ↗

Internal writing methods Abstract method for writing the start of lists and sets. List and sets on the wire differ only by the type indicator.

(elemType TType, size int)

Source from the content-addressed store, hash-verified

682// Abstract method for writing the start of lists and sets. List and sets on
683// the wire differ only by the type indicator.
684func (p *TCompactProtocol) writeCollectionBegin(elemType TType, size int) (int, error) {
685 if size <= 14 {
686 return 1, p.writeByteDirect(byte(int32(size<<4) | int32(p.getCompactType(elemType))))
687 }
688 err := p.writeByteDirect(0xf0 | byte(p.getCompactType(elemType)))
689 if err != nil {
690 return 0, err
691 }
692 m, err := p.writeVarint32(int32(size))
693 return 1 + m, err
694}
695
696// Write an i32 as a varint. Results in 1-5 bytes on the wire.
697// TODO(pomack): make a permanent buffer like writeVarint64?

Callers 2

WriteListBeginMethod · 0.95
WriteSetBeginMethod · 0.95

Calls 3

writeByteDirectMethod · 0.95
getCompactTypeMethod · 0.95
writeVarint32Method · 0.95

Tested by

no test coverage detected