Zakir032002 commented on PR #3374:
URL: https://github.com/apache/fory/pull/3374#issuecomment-3943044489

   hey @ayush00git, looked through this and the main issue i see is in 
`DeserializeFromReader` —
   it calls `ResetWithReader` at the start of every call:
   
   ```go
   func (f *Fory) DeserializeFromReader(r io.Reader, v any) error {
       defer f.resetReadState()
       f.readCtx.buffer.ResetWithReader(r, 0) // this wipes the prefetch window 
every time
   ```
   so if fill() reads ahead past the first object boundary (which it will), 
those bytes
   are gone on the next call. sequential decode from one stream is broken:
   
   ```go
   for {
       var msg Msg
       f.DeserializeFromReader(conn, &msg) // bytes after first object get 
thrown away
   }
   ```
   if you look at how he handles this for c++/python — the Buffer is constructed
   from the stream once and passed to each deserialize call directly. the 
buffer holds
   state across calls, it's never reset between objects. the python test
   test_stream_deserialize_multiple_objects_from_single_stream shows this 
exactly —
   same reader buffer passed to multiple fory.deserialize() calls.
   
   the go version probably needs something similar — a stream reader type that 
owns the
   buffer and gets reused across deserializations rather than resetting on each 
call.
   
   Happy to discuss if I'm misreading the flow here


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