worryg0d commented on code in PR #1822:
URL: 
https://github.com/apache/cassandra-gocql-driver/pull/1822#discussion_r1808577805


##########
frame.go:
##########
@@ -2070,3 +2133,247 @@ func (f *framer) writeBytesMap(m map[string][]byte) {
                f.writeBytes(v)
        }
 }
+
+func (f *framer) prepareModernLayout() error {
+       // Ensure protocol version is V5 or higher
+       if f.proto < protoVersion5 {
+               panic("Modern layout is not supported with version V4 or less")
+       }
+
+       selfContained := true
+
+       var (
+               adjustedBuf []byte
+               tempBuf     []byte
+               err         error
+       )
+
+       // Process the buffer in chunks if it exceeds the max payload size
+       for len(f.buf) > maxPayloadSize {
+               if f.compres != nil {
+                       tempBuf, err = 
newCompressedFrame(f.buf[:maxPayloadSize], false, f.compres)
+               } else {
+                       tempBuf, err = 
newUncompressedFrame(f.buf[:maxPayloadSize], false)
+               }
+               if err != nil {
+                       return err
+               }
+
+               adjustedBuf = append(adjustedBuf, tempBuf...)

Review Comment:
   Yeah, this is a weak spot of the implementation. I had an idea on in-place 
sending segments to C* instead of collecting them into a single buffer but it 
wasn't natural for the current codebase, so I decided to leave it as it is.
   However, since we have agreed on Segments->NewFormatFrames and 
Frames->OldFormatFrames, then I could do this frame segmentation process on the 
`Conn` layer instead of the `framer`. You may look at the implementation 
[here](https://github.com/worryg0d/gocql/commit/4e1a7807dc4b6870a3df0bcf2166ef77e53a0330)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to