Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Support lazy load/zero copy when using shared memory #207

Open
vtk9 opened this issue Nov 27, 2024 · 1 comment · May be fixed by #216
Open

[Feature Request] Support lazy load/zero copy when using shared memory #207

vtk9 opened this issue Nov 27, 2024 · 1 comment · May be fixed by #216
Labels
Type: enhancement New feature or request

Comments

@vtk9
Copy link

vtk9 commented Nov 27, 2024

Describe the enhancement requested

Use case: there is an arrow table in shared memory. It was written using Python's Arrow RecordBatchStreamWriter (although even if it was written using RecordBatchFileWriter, I believe the same problem would exist due to the current state of the Go Arrow implementation). We would like to load it lazily and stream it directly to an arrow flight client. We would do so by opening up the file in process memory (lazily), then we would first aggregate the list of records (lazily) and then read the contents of the records for the first time when streaming the data to the client.

via

func (s *MyServer) DoGet(
	ticket *flight.Ticket,
	server flight.FlightService_DoGetServer,
) error {
    ...
	w := flight.NewRecordWriter(server, writerOpts...)
	for _, r := range s.recordsInTable {
		if err = w.Write(r); err != nil {
			return err
		}
	}

Ideally, up until the records sent, no data would be actually copied/ready. However, this doesn't appear to be possible at the moment since there is a copy done when processing the records https://github.com/apache/arrow-go/blob/main/arrow/ipc/message.go#L217 instead or referencing the already allocated/used shared memory. Instead, there might need to be a new MessageReader implementation where this copy is avoided.

Thank you!

Component(s)

Other

@vtk9 vtk9 added the Type: enhancement New feature or request label Nov 27, 2024
@zeroshade
Copy link
Member

@vtk9 Could you provide an example of the code for writing to shared memory and getting the address / access to the memory in Go?

I want to make sure that whatever solution I come up with will work for your use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants