MCPcopy Create free account
hub / github.com/datastax/cql-proxy / EncodedLength

Method EncodedLength

codecs/partial_codecs.go:298–319  ·  view source on GitHub ↗
(msg message.Message, version primitive.ProtocolVersion)

Source from the content-addressed store, hash-verified

296}
297
298func (p partialBatchCodec) EncodedLength(msg message.Message, version primitive.ProtocolVersion) (int, error) {
299 switch batch := msg.(type) {
300 case *PartialBatch:
301 length := primitive.LengthOfByte // Batch type (logged, unlogged, etc.)
302 length += primitive.LengthOfShort // Number of queries
303 for _, query := range batch.Queries {
304 length += primitive.LengthOfByte // Query kind
305 switch q := query.QueryOrId.(type) {
306 case string:
307 length += primitive.LengthOfLongString(q)
308 case []byte:
309 length += primitive.LengthOfShortBytes(q)
310 }
311 length += len(query.Values) // Positional query parameters
312 }
313 length += primitive.LengthOfShort // Consistency level
314 length += len(batch.Parameters) // Remaining flags/parameters
315 return length, nil
316 default:
317 return builtinBatchCodec.EncodedLength(msg, version)
318 }
319}
320
321func (p partialBatchCodec) Decode(source io.Reader, version primitive.ProtocolVersion) (msg message.Message, err error) {
322 var (

Callers 1

Calls 1

EncodedLengthMethod · 0.45

Tested by 1