From b219016f8bbeb5ddcc363de3c09960c7891f3b92 Mon Sep 17 00:00:00 2001 From: voidstar69 Date: Sun, 5 Nov 2023 22:40:22 +0000 Subject: [PATCH] Make TotalLength a long instead of int to allow for a larger record batch --- .../src/Apache.Arrow.Flight/Internal/FlightDataStream.cs | 2 +- csharp/src/Apache.Arrow/ArrowBuffer.Builder.cs | 1 - csharp/src/Apache.Arrow/Ipc/ArrowStreamWriter.cs | 8 ++++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/csharp/src/Apache.Arrow.Flight/Internal/FlightDataStream.cs b/csharp/src/Apache.Arrow.Flight/Internal/FlightDataStream.cs index 72c1551be2917..bd84b463e8f6c 100644 --- a/csharp/src/Apache.Arrow.Flight/Internal/FlightDataStream.cs +++ b/csharp/src/Apache.Arrow.Flight/Internal/FlightDataStream.cs @@ -91,7 +91,7 @@ public async Task Write(RecordBatch recordBatch, ByteString applicationMetadata) await _clientStreamWriter.WriteAsync(_currentFlightData).ConfigureAwait(false); } - private protected override ValueTask WriteMessageAsync(MessageHeader headerType, Offset headerOffset, int bodyLength, CancellationToken cancellationToken) + private protected override ValueTask WriteMessageAsync(MessageHeader headerType, Offset headerOffset, long bodyLength, CancellationToken cancellationToken) { Offset messageOffset = Flatbuf.Message.CreateMessage( Builder, CurrentMetadataVersion, headerType, headerOffset.Value, diff --git a/csharp/src/Apache.Arrow/ArrowBuffer.Builder.cs b/csharp/src/Apache.Arrow/ArrowBuffer.Builder.cs index 7c03027feffa2..fdae20837ad82 100644 --- a/csharp/src/Apache.Arrow/ArrowBuffer.Builder.cs +++ b/csharp/src/Apache.Arrow/ArrowBuffer.Builder.cs @@ -250,6 +250,5 @@ private void Reallocate(int numBytes) } } - } } diff --git a/csharp/src/Apache.Arrow/Ipc/ArrowStreamWriter.cs b/csharp/src/Apache.Arrow/Ipc/ArrowStreamWriter.cs index dcb8852bc1f65..8a0b936f88c56 100644 --- a/csharp/src/Apache.Arrow/Ipc/ArrowStreamWriter.cs +++ b/csharp/src/Apache.Arrow/Ipc/ArrowStreamWriter.cs @@ -78,7 +78,7 @@ public Buffer(ArrowBuffer buffer, int offset) public IReadOnlyList Buffers => _buffers; - public int TotalLength { get; private set; } + public long TotalLength { get; private set; } public ArrowRecordBatchFlatBufferBuilder() { @@ -204,7 +204,7 @@ private void CreateBuffers(PrimitiveArray array) private Buffer CreateBuffer(ArrowBuffer buffer) { - int offset = TotalLength; + int offset = checked((int)TotalLength); int paddedLength = checked((int)BitUtility.RoundUpToMultipleOf8(buffer.Length)); TotalLength += paddedLength; @@ -823,7 +823,7 @@ await WriteMessageAsync(Flatbuf.MessageHeader.Schema, schemaOffset, 0, cancellat /// The number of bytes written to the stream. /// private protected long WriteMessage( - Flatbuf.MessageHeader headerType, Offset headerOffset, int bodyLength) + Flatbuf.MessageHeader headerType, Offset headerOffset, long bodyLength) where T : struct { Offset messageOffset = Flatbuf.Message.CreateMessage( @@ -853,7 +853,7 @@ private protected long WriteMessage( /// The number of bytes written to the stream. /// private protected virtual async ValueTask WriteMessageAsync( - Flatbuf.MessageHeader headerType, Offset headerOffset, int bodyLength, + Flatbuf.MessageHeader headerType, Offset headerOffset, long bodyLength, CancellationToken cancellationToken) where T : struct {