Skip to content

Comments

feat(go): add go desrialization support via io streams#3374

Open
ayush00git wants to merge 6 commits intoapache:mainfrom
ayush00git:feat/go-deserialization
Open

feat(go): add go desrialization support via io streams#3374
ayush00git wants to merge 6 commits intoapache:mainfrom
ayush00git:feat/go-deserialization

Conversation

@ayush00git
Copy link
Contributor

@ayush00git ayush00git commented Feb 20, 2026

Why?

To enable stream-based deserialization in Fory's Go library, allowing for direct reading from io.Reader without pre-buffering the entire payload. This improves efficiency for network and file-based transport.

What does this PR do?

1. go/fory/buffer.go

Enhanced ByteBuffer to support io.Reader with an internal sliding window and automatic filling.

  • Added reader io.Reader and minCap int fields.
  • Implemented fill(n int) bool for on-demand data fetching and compaction.
  • Updated all Read* methods (fixed-size, varint, tagged) to fetch data from the reader if not cached.
func (b *ByteBuffer) fill(n int) bool {
    if b.reader == nil { return false }
    // Compaction and stream reading logic
    ...
}

2. go/fory/fory.go

Added the DeserializeFromReader method as the primary public API for stream deserialization.

  • Integrated io package.
  • Implemented DeserializeFromReader to reset the buffer state and initiate deserialization from a stream.
func (f *Fory) DeserializeFromReader(r io.Reader, v any) error {
    defer f.resetReadState()
    f.readCtx.buffer.ResetWithReader(r, 0)
    // Deserialization logic
    ...
}

3. go/fory/reader.go

Ensured ReadContext correctly manages the buffer state when switching between memory-only and stream-backed modes.

  • Updated SetData to reset the reader field.

Related issues

Closes #3302

Does this PR introduce any user-facing change?

  • Does this PR introduce any public API change?
  • Does this PR introduce any binary protocol compatibility change?

Benchmark

N/A

@ayush00git ayush00git changed the title feat(go): add go desrialization support via transport streams feat(go): add go desrialization support via io streams Feb 20, 2026
@ayush00git
Copy link
Contributor Author

Hey @chaokunyang
Have a review and let me know the changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Go] Streaming Deserialization Support For Go

1 participant