github.com/ydb-platform/ydb-go-sdk/v3@v3.89.2/internal/topic/topicreadercommon/split_batches.go (about) 1 package topicreadercommon 2 3 import "github.com/ydb-platform/ydb-go-sdk/v3/internal/grpcwrapper/rawtopic/rawtopicreader" 4 5 func ReadRawBatchesToPublicBatches( 6 msg *rawtopicreader.ReadResponse, 7 sessions *PartitionSessionStorage, 8 decoders DecoderMap, 9 ) ([]*PublicBatch, error) { 10 batchesCount := 0 11 for i := range msg.PartitionData { 12 batchesCount += len(msg.PartitionData[i].Batches) 13 } 14 15 var batches []*PublicBatch 16 for pIndex := range msg.PartitionData { 17 p := &msg.PartitionData[pIndex] 18 19 // normal way 20 session, err := sessions.Get(p.PartitionSessionID) 21 if err != nil { 22 return nil, err 23 } 24 25 for bIndex := range p.Batches { 26 batch, err := NewBatchFromStream(decoders, session, p.Batches[bIndex]) 27 if err != nil { 28 return nil, err 29 } 30 batches = append(batches, batch) 31 } 32 } 33 34 if err := splitBytesByMessagesInBatches(batches, msg.BytesSize); err != nil { 35 return nil, err 36 } 37 38 return batches, nil 39 }