adamreeve commented on issue #341: URL: https://github.com/apache/arrow-dotnet/issues/341#issuecomment-4340037101
Yeah I'm not sure how feasible it would be for Flatbuffers to work with an IBufferWriter, but maybe that's not required. The Flatbuffers library currently creates a ReadOnlyMemory buffer that we write to the stream, so we could keep doing something similar. I see there's an [`IBufferWriterExtensions.AsStream` method](https://learn.microsoft.com/en-us/dotnet/api/microsoft.toolkit.highperformance.ibufferwriterextensions.asstream?view=win-comm-toolkit-dotnet-7.1) in the `CommunityToolkit.HighPerformance` NuGet package, so you could use that to create a stream from an `IBufferWriter` to pass to an `ArrowStreamWriter`. Is that sufficient for your needs? I did a quick test and this works: ```c# using var originalBatch = TestData.CreateSampleRecordBatch(length: 100); var bufferWriter = new ArrayBufferWriter<byte>(1024); using (var stream = bufferWriter.AsStream()) { using var writer = new ArrowStreamWriter(stream, originalBatch.Schema); writer.WriteRecordBatch(originalBatch); writer.WriteEnd(); } using var readStream = bufferWriter.WrittenMemory.AsStream(); using (var reader = new ArrowStreamReader(readStream)) { using var newBatch = reader.ReadNextRecordBatch(); ArrowReaderVerifier.CompareBatches(originalBatch, newBatch); } ``` If you'd rather not add a new dependency, the implementation is pretty simple so you could also create your own wrapper class that inherits from `Stream`. -- 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]
