njnu-seafish commented on PR #18717:
URL: 
https://github.com/apache/dolphinscheduler/pull/18717#issuecomment-6262593976

   > Each candidate row is now serialized once, but every truncation iteration 
still rebuilds the remaining JSON content and UTF-8 encodes it to check the 
byte budget. The overall worst-case complexity therefore remains quadratic in 
the number of candidate rows, rather than O(rows).
   
   You're right — the assemble-and-measure version in d0e4c23e2a was O(rows²) 
in the worst case, since every dropped row rebuilt and re-encoded the remaining 
content just to check its byte length.
   
   Addressed in a78f26a7ed: the byte budget is now enforced with running byte 
arithmetic. Each row is still serialized only once; the drop loop additionally 
tracks the cumulative UTF-8 size, subtracting one row's bytes per drop 
(O(1)/row — the omission marker stays a tiny ~30-byte string), and the final 
content is assembled only once it fits. Overall complexity is back to O(rows): 
one serialization per row plus one final assembly.
   
   Output is unchanged — all 38 tests pass, including the exact byte-boundary 
and UTF-8 byte-counting cases, so the alert content stays byte-for-byte 
identical.


-- 
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]

Reply via email to