diff --git a/Directory.Packages.props b/Directory.Packages.props
index 9bc98e93..1e02ec60 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -33,6 +33,7 @@
+
diff --git a/src/Apache.Arrow.Flight.Sql/FlightSqlServer.cs b/src/Apache.Arrow.Flight.Sql/FlightSqlServer.cs
index f2862996..a301c03e 100644
--- a/src/Apache.Arrow.Flight.Sql/FlightSqlServer.cs
+++ b/src/Apache.Arrow.Flight.Sql/FlightSqlServer.cs
@@ -211,6 +211,20 @@ public static Schema GetTableSchema(bool includeTableSchemaField)
}
protected FlightSqlServer(ILoggerFactory? factory = null)
+ : this(context: null, factory)
+ {
+ }
+
+ ///
+ /// Creates a server whose record-batch readers and writers use .
+ ///
+ ///
+ /// Supplies the allocator, compression codec factory and extension type registry; null
+ /// uses the defaults.
+ ///
+ /// Creates the logger for the server; null disables logging.
+ protected FlightSqlServer(ArrowContext? context, ILoggerFactory? factory)
+ : base(context)
{
Logger = factory?.CreateLogger(typeof(FlightSqlServer));
}
diff --git a/src/Apache.Arrow.Flight/Apache.Arrow.Flight.csproj b/src/Apache.Arrow.Flight/Apache.Arrow.Flight.csproj
index de5d495c..6c3cf694 100644
--- a/src/Apache.Arrow.Flight/Apache.Arrow.Flight.csproj
+++ b/src/Apache.Arrow.Flight/Apache.Arrow.Flight.csproj
@@ -9,6 +9,8 @@
+
+
diff --git a/src/Apache.Arrow.Flight/Client/FlightClient.cs b/src/Apache.Arrow.Flight/Client/FlightClient.cs
index 67049c89..ef4bb3af 100644
--- a/src/Apache.Arrow.Flight/Client/FlightClient.cs
+++ b/src/Apache.Arrow.Flight/Client/FlightClient.cs
@@ -19,6 +19,7 @@
using Apache.Arrow.Flight.Protocol;
using Apache.Arrow.Flight.Server.Internal;
using Grpc.Core;
+using Microsoft.Extensions.DependencyInjection;
namespace Apache.Arrow.Flight.Client
{
@@ -30,10 +31,18 @@ public class FlightClient
private readonly ArrowContext _context;
public FlightClient(ChannelBase grpcChannel)
- : this(grpcChannel, null)
+ : this(grpcChannel, context: null)
{
}
+ ///
+ /// Creates a client whose record-batch readers and writers use .
+ ///
+ /// The gRPC channel to the Flight server.
+ ///
+ /// Supplies the allocator, compression codec factory and extension type registry; null
+ /// uses the defaults.
+ ///
public FlightClient(ChannelBase grpcChannel, ArrowContext context)
{
_client = new FlightService.FlightServiceClient(grpcChannel);
@@ -41,11 +50,26 @@ public FlightClient(ChannelBase grpcChannel, ArrowContext context)
}
public FlightClient(CallInvoker callInvoker)
- : this(callInvoker, null)
+ : this(callInvoker, context: null)
{
}
- private FlightClient(CallInvoker callInvoker, ArrowContext context)
+ ///
+ /// Creates a client whose record-batch readers and writers use .
+ ///
+ ///
+ /// Grpc.Net.ClientFactory creates clients through ActivatorUtilities, passing a
+ /// . With two constructors accepting one it could not choose, so
+ /// this one is marked as the constructor to use. A client created that way gets the
+ /// registered for dependency injection, if there is one.
+ ///
+ /// The gRPC call invoker for the Flight server.
+ ///
+ /// Supplies the allocator, compression codec factory and extension type registry; null
+ /// uses the defaults.
+ ///
+ [ActivatorUtilitiesConstructor]
+ public FlightClient(CallInvoker callInvoker, ArrowContext context = null)
{
_client = new FlightService.FlightServiceClient(callInvoker);
_context = context;
@@ -55,8 +79,7 @@ private FlightClient(CallInvoker callInvoker, ArrowContext context)
/// Creates a from a with an .
///
///
- /// A factory method is used instead of a constructor overload so that dependency injection
- /// (e.g. Grpc.Net.ClientFactory) can still resolve the single-argument constructor unambiguously.
+ /// Equivalent to .
///
/// The to use for gRPC calls
/// The carrying the compression codec factory and other reader configuration
@@ -78,7 +101,7 @@ public AsyncServerStreamingCall ListFlights(FlightCriteria criteria,
}
var response = _client.ListFlights(criteria.ToProtocol(), headers, deadline, cancellationToken);
- var convertStream = new StreamReader(response.ResponseStream, inFlight => new FlightInfo(inFlight));
+ var convertStream = new StreamReader(response.ResponseStream, inFlight => new FlightInfo(inFlight, _context?.ExtensionRegistry));
return new AsyncServerStreamingCall(convertStream, response.ResponseHeadersAsync, response.GetStatus, response.GetTrailers, response.Dispose);
}
@@ -119,7 +142,7 @@ public AsyncUnaryCall GetInfo(FlightDescriptor flightDescriptor, Met
var flightInfo = flightInfoResult
.ResponseAsync
- .ContinueWith(async flightInfo => new FlightInfo(await flightInfo.ConfigureAwait(false)))
+ .ContinueWith(async flightInfo => new FlightInfo(await flightInfo.ConfigureAwait(false), _context?.ExtensionRegistry))
.Unwrap();
return new AsyncUnaryCall(
@@ -166,7 +189,7 @@ public Task StartPut(FlightDescriptor flig
public FlightRecordBatchDuplexStreamingCall StartPut(FlightDescriptor flightDescriptor, Metadata headers, System.DateTime? deadline, CancellationToken cancellationToken = default)
{
var channels = _client.DoPut(headers, deadline, cancellationToken);
- var requestStream = new FlightClientRecordBatchStreamWriter(channels.RequestStream, flightDescriptor);
+ var requestStream = new FlightClientRecordBatchStreamWriter(channels.RequestStream, flightDescriptor, _context);
var readStream = new StreamReader(channels.ResponseStream, putResult => new FlightPutResult(putResult));
return new FlightRecordBatchDuplexStreamingCall(
requestStream,
@@ -191,7 +214,7 @@ public FlightRecordBatchDuplexStreamingCall StartPut(FlightDescriptor flightDesc
public async Task StartPut(FlightDescriptor flightDescriptor, Schema schema, Metadata headers, System.DateTime? deadline, CancellationToken cancellationToken = default)
{
var channels = _client.DoPut(headers, deadline, cancellationToken);
- var requestStream = new FlightClientRecordBatchStreamWriter(channels.RequestStream, flightDescriptor);
+ var requestStream = new FlightClientRecordBatchStreamWriter(channels.RequestStream, flightDescriptor, _context);
var readStream = new StreamReader(channels.ResponseStream, putResult => new FlightPutResult(putResult));
var streamingCall = new FlightRecordBatchDuplexStreamingCall(
requestStream,
@@ -233,7 +256,7 @@ public FlightRecordBatchExchangeCall DoExchange(FlightDescriptor flightDescripto
public FlightRecordBatchExchangeCall DoExchange(FlightDescriptor flightDescriptor, Metadata headers, System.DateTime? deadline, CancellationToken cancellationToken = default)
{
var channel = _client.DoExchange(headers, deadline, cancellationToken);
- var requestStream = new FlightClientRecordBatchStreamWriter(channel.RequestStream, flightDescriptor);
+ var requestStream = new FlightClientRecordBatchStreamWriter(channel.RequestStream, flightDescriptor, _context);
var responseStream = new FlightClientRecordBatchStreamReader(channel.ResponseStream, _context);
var call = new FlightRecordBatchExchangeCall(
requestStream,
@@ -269,7 +292,7 @@ public AsyncUnaryCall GetSchema(FlightDescriptor flightDescriptor, Metad
var schema = schemaResult
.ResponseAsync
- .ContinueWith(async schema => FlightMessageSerializer.DecodeSchema((await schemaResult.ResponseAsync.ConfigureAwait(false)).Schema.Memory))
+ .ContinueWith(async schema => FlightMessageSerializer.DecodeSchema((await schemaResult.ResponseAsync.ConfigureAwait(false)).Schema.Memory, _context?.ExtensionRegistry))
.Unwrap();
return new AsyncUnaryCall(
diff --git a/src/Apache.Arrow.Flight/Client/FlightClientRecordBatchStreamWriter.cs b/src/Apache.Arrow.Flight/Client/FlightClientRecordBatchStreamWriter.cs
index 88c5ee88..e74a0652 100644
--- a/src/Apache.Arrow.Flight/Client/FlightClientRecordBatchStreamWriter.cs
+++ b/src/Apache.Arrow.Flight/Client/FlightClientRecordBatchStreamWriter.cs
@@ -27,7 +27,7 @@ public class FlightClientRecordBatchStreamWriter : FlightRecordBatchStreamWriter
{
private readonly IClientStreamWriter _clientStreamWriter;
private bool _completed = false;
- internal FlightClientRecordBatchStreamWriter(IClientStreamWriter clientStreamWriter, FlightDescriptor flightDescriptor) : base(clientStreamWriter, flightDescriptor)
+ internal FlightClientRecordBatchStreamWriter(IClientStreamWriter clientStreamWriter, FlightDescriptor flightDescriptor, ArrowContext context) : base(clientStreamWriter, flightDescriptor, context)
{
_clientStreamWriter = clientStreamWriter;
}
diff --git a/src/Apache.Arrow.Flight/FlightInfo.cs b/src/Apache.Arrow.Flight/FlightInfo.cs
index 17286ee9..db5b4b77 100644
--- a/src/Apache.Arrow.Flight/FlightInfo.cs
+++ b/src/Apache.Arrow.Flight/FlightInfo.cs
@@ -24,9 +24,9 @@ namespace Apache.Arrow.Flight
{
public class FlightInfo
{
- internal FlightInfo(Protocol.FlightInfo flightInfo)
+ internal FlightInfo(Protocol.FlightInfo flightInfo, ExtensionTypeRegistry extensionRegistry = null)
{
- Schema = flightInfo.Schema?.Length > 0 ? FlightMessageSerializer.DecodeSchema(flightInfo.Schema.Memory) : null;
+ Schema = flightInfo.Schema?.Length > 0 ? FlightMessageSerializer.DecodeSchema(flightInfo.Schema.Memory, extensionRegistry) : null;
Descriptor = new FlightDescriptor(flightInfo.FlightDescriptor);
var endpoints = new List();
diff --git a/src/Apache.Arrow.Flight/FlightRecordBatchStreamWriter.cs b/src/Apache.Arrow.Flight/FlightRecordBatchStreamWriter.cs
index 711fa4aa..21af3898 100644
--- a/src/Apache.Arrow.Flight/FlightRecordBatchStreamWriter.cs
+++ b/src/Apache.Arrow.Flight/FlightRecordBatchStreamWriter.cs
@@ -29,11 +29,13 @@ public abstract class FlightRecordBatchStreamWriter : IAsyncStreamWriter _clientStreamWriter;
private readonly FlightDescriptor _flightDescriptor;
+ private readonly ArrowContext _context;
private bool _disposed;
- private protected FlightRecordBatchStreamWriter(IAsyncStreamWriter clientStreamWriter, FlightDescriptor flightDescriptor)
+ private protected FlightRecordBatchStreamWriter(IAsyncStreamWriter clientStreamWriter, FlightDescriptor flightDescriptor, ArrowContext context)
{
+ _context = context;
_clientStreamWriter = clientStreamWriter;
_flightDescriptor = flightDescriptor;
}
@@ -52,7 +54,7 @@ public async Task SetupStream(Schema schema)
{
throw new InvalidOperationException("Flight data stream is already set");
}
- _flightDataStream = new FlightDataStream(_clientStreamWriter, _flightDescriptor, schema);
+ _flightDataStream = new FlightDataStream(_clientStreamWriter, _flightDescriptor, schema, _context);
await _flightDataStream.SendSchema().ConfigureAwait(false);
}
diff --git a/src/Apache.Arrow.Flight/Internal/FlightDataStream.cs b/src/Apache.Arrow.Flight/Internal/FlightDataStream.cs
index 46a7ac20..0e5b76eb 100644
--- a/src/Apache.Arrow.Flight/Internal/FlightDataStream.cs
+++ b/src/Apache.Arrow.Flight/Internal/FlightDataStream.cs
@@ -37,8 +37,8 @@ internal class FlightDataStream : ArrowStreamWriter
private readonly IAsyncStreamWriter _clientStreamWriter;
private Protocol.FlightData _currentFlightData;
- public FlightDataStream(IAsyncStreamWriter clientStreamWriter, FlightDescriptor flightDescriptor, Schema schema)
- : base(new MemoryStream(), schema)
+ public FlightDataStream(IAsyncStreamWriter clientStreamWriter, FlightDescriptor flightDescriptor, Schema schema, ArrowContext context)
+ : base(new MemoryStream(), schema, leaveOpen: false, options: null, context?.Allocator, context?.CompressionCodecFactory)
{
_clientStreamWriter = clientStreamWriter;
_flightDescriptor = flightDescriptor;
diff --git a/src/Apache.Arrow.Flight/Internal/FlightMessageSerializer.cs b/src/Apache.Arrow.Flight/Internal/FlightMessageSerializer.cs
index b0f53778..9cf3768f 100644
--- a/src/Apache.Arrow.Flight/Internal/FlightMessageSerializer.cs
+++ b/src/Apache.Arrow.Flight/Internal/FlightMessageSerializer.cs
@@ -25,7 +25,7 @@ namespace Apache.Arrow.Flight
{
internal static class FlightMessageSerializer
{
- public static Schema DecodeSchema(ReadOnlyMemory buffer)
+ public static Schema DecodeSchema(ReadOnlyMemory buffer, ExtensionTypeRegistry extensionRegistry = null)
{
if (buffer.IsEmpty) return null;
int bufferPosition = 0;
@@ -47,15 +47,15 @@ public static Schema DecodeSchema(ReadOnlyMemory buffer)
ByteBuffer schemaBuffer = ArrowReaderImplementation.CreateByteBuffer(buffer.Slice(bufferPosition));
//DictionaryBatch not supported for now
DictionaryMemo dictionaryMemo = null;
- var schema = MessageSerializer.GetSchema(ArrowReaderImplementation.ReadMessage(schemaBuffer), ref dictionaryMemo);
+ var schema = MessageSerializer.GetSchema(ArrowReaderImplementation.ReadMessage(schemaBuffer), ref dictionaryMemo, extensionRegistry ?? ExtensionTypeRegistry.Default);
return schema;
}
- internal static Schema DecodeSchema(ByteBuffer schemaBuffer)
+ internal static Schema DecodeSchema(ByteBuffer schemaBuffer, ExtensionTypeRegistry extensionRegistry = null)
{
//DictionaryBatch not supported for now
DictionaryMemo dictionaryMemo = null;
- var schema = MessageSerializer.GetSchema(ArrowReaderImplementation.ReadMessage(schemaBuffer), ref dictionaryMemo);
+ var schema = MessageSerializer.GetSchema(ArrowReaderImplementation.ReadMessage(schemaBuffer), ref dictionaryMemo, extensionRegistry ?? ExtensionTypeRegistry.Default);
return schema;
}
}
diff --git a/src/Apache.Arrow.Flight/Internal/RecordBatchReaderImplementation.cs b/src/Apache.Arrow.Flight/Internal/RecordBatchReaderImplementation.cs
index bb4aba7e..14eb6c26 100644
--- a/src/Apache.Arrow.Flight/Internal/RecordBatchReaderImplementation.cs
+++ b/src/Apache.Arrow.Flight/Internal/RecordBatchReaderImplementation.cs
@@ -103,7 +103,7 @@ public override async ValueTask ReadSchemaAsync(CancellationToken cancel
switch (message.HeaderType)
{
case MessageHeader.Schema:
- _schema = FlightMessageSerializer.DecodeSchema(message.ByteBuffer);
+ _schema = FlightMessageSerializer.DecodeSchema(message.ByteBuffer, _extensionRegistry);
break;
default:
throw new Exception($"Expected schema as the first message, but got: {message.HeaderType.ToString()}");
diff --git a/src/Apache.Arrow.Flight/Server/FlightServer.cs b/src/Apache.Arrow.Flight/Server/FlightServer.cs
index b2e521ad..4b715943 100644
--- a/src/Apache.Arrow.Flight/Server/FlightServer.cs
+++ b/src/Apache.Arrow.Flight/Server/FlightServer.cs
@@ -21,6 +21,33 @@ namespace Apache.Arrow.Flight.Server
{
public abstract class FlightServer
{
+ protected FlightServer()
+ : this(context: null)
+ {
+ }
+
+ ///
+ /// Creates a server whose record-batch readers and writers use .
+ ///
+ ///
+ /// This applies however the server is hosted, including when it is created by dependency
+ /// injection: the derived server receives the context in its own constructor and passes it on.
+ ///
+ ///
+ /// Supplies the allocator, compression codec factory and extension type registry; null
+ /// uses the defaults.
+ ///
+ protected FlightServer(ArrowContext context)
+ {
+ Context = context;
+ }
+
+ ///
+ /// The context used for the record batches this server reads and writes, or null
+ /// for the defaults.
+ ///
+ public ArrowContext Context { get; }
+
public virtual Task DoPut(FlightServerRecordBatchStreamReader requestStream, IAsyncStreamWriter responseStream, ServerCallContext context)
{
throw new NotImplementedException();
diff --git a/src/Apache.Arrow.Flight/Server/FlightServerRecordBatchStreamReader.cs b/src/Apache.Arrow.Flight/Server/FlightServerRecordBatchStreamReader.cs
index fb54058b..4e4d9550 100644
--- a/src/Apache.Arrow.Flight/Server/FlightServerRecordBatchStreamReader.cs
+++ b/src/Apache.Arrow.Flight/Server/FlightServerRecordBatchStreamReader.cs
@@ -22,11 +22,20 @@ namespace Apache.Arrow.Flight.Server
public class FlightServerRecordBatchStreamReader : FlightRecordBatchStreamReader
{
public FlightServerRecordBatchStreamReader(IAsyncStreamReader flightDataStream)
- : this(flightDataStream, null)
+ : this(flightDataStream, context: null)
{
}
- public FlightServerRecordBatchStreamReader(IAsyncStreamReader flightDataStream, ArrowContext context) : base(new StreamReader(flightDataStream, data => data.ToProtocol()), context)
+ ///
+ /// Creates a reader that decodes record batches using .
+ ///
+ /// The stream of Flight data to read.
+ ///
+ /// Supplies the allocator, compression codec factory and extension type registry; null
+ /// uses the defaults.
+ ///
+ public FlightServerRecordBatchStreamReader(IAsyncStreamReader flightDataStream, ArrowContext context)
+ : base(new StreamReader(flightDataStream, data => data.ToProtocol()), context)
{
}
diff --git a/src/Apache.Arrow.Flight/Server/FlightServerRecordBatchStreamWriter.cs b/src/Apache.Arrow.Flight/Server/FlightServerRecordBatchStreamWriter.cs
index b7533ef0..88e1872a 100644
--- a/src/Apache.Arrow.Flight/Server/FlightServerRecordBatchStreamWriter.cs
+++ b/src/Apache.Arrow.Flight/Server/FlightServerRecordBatchStreamWriter.cs
@@ -20,11 +20,25 @@ namespace Apache.Arrow.Flight.Server
{
public class FlightServerRecordBatchStreamWriter : FlightRecordBatchStreamWriter, IServerStreamWriter
{
- public FlightServerRecordBatchStreamWriter(IServerStreamWriter clientStreamWriter) : base(new StreamWriter(clientStreamWriter, data => new FlightData(data)), null)
+ public FlightServerRecordBatchStreamWriter(IServerStreamWriter clientStreamWriter)
+ : this(clientStreamWriter, context: null)
{
}
- internal FlightServerRecordBatchStreamWriter(IServerStreamWriter clientStreamWriter) : base(clientStreamWriter, null)
+ ///
+ /// Creates a writer that encodes record batches using .
+ ///
+ /// The stream to write Flight data to.
+ ///
+ /// Supplies the allocator, compression codec factory and extension type registry; null
+ /// uses the defaults.
+ ///
+ public FlightServerRecordBatchStreamWriter(IServerStreamWriter clientStreamWriter, ArrowContext context)
+ : base(new StreamWriter(clientStreamWriter, data => new FlightData(data)), null, context)
+ {
+ }
+
+ internal FlightServerRecordBatchStreamWriter(IServerStreamWriter clientStreamWriter, ArrowContext context) : base(clientStreamWriter, null, context)
{
}
}
diff --git a/src/Apache.Arrow.Flight/Server/Internal/FlightServerImplementation.cs b/src/Apache.Arrow.Flight/Server/Internal/FlightServerImplementation.cs
index 8bf47f96..e2aeed54 100644
--- a/src/Apache.Arrow.Flight/Server/Internal/FlightServerImplementation.cs
+++ b/src/Apache.Arrow.Flight/Server/Internal/FlightServerImplementation.cs
@@ -34,7 +34,7 @@ public FlightServerImplementation(FlightServer flightServer)
public override async Task DoPut(IAsyncStreamReader requestStream, IServerStreamWriter responseStream, ServerCallContext context)
{
- var readStream = new FlightServerRecordBatchStreamReader(requestStream);
+ var readStream = new FlightServerRecordBatchStreamReader(requestStream, _flightServer.Context);
var writeStream = new StreamWriter(responseStream, putResult => putResult.ToProtocol());
await _flightServer.DoPut(readStream, writeStream, context).ConfigureAwait(false);
@@ -43,7 +43,7 @@ public override async Task DoPut(IAsyncStreamReader request
public override Task DoGet(Protocol.Ticket request, IServerStreamWriter responseStream, ServerCallContext context)
{
var flightTicket = new FlightTicket(request.Ticket_);
- var flightServerRecordBatchStreamWriter = new FlightServerRecordBatchStreamWriter(responseStream);
+ var flightServerRecordBatchStreamWriter = new FlightServerRecordBatchStreamWriter(responseStream, _flightServer.Context);
return _flightServer.DoGet(flightTicket, flightServerRecordBatchStreamWriter, context);
}
@@ -84,8 +84,8 @@ public override async Task GetSchema(Protocol.FlightDescriptor req
public override Task DoExchange(IAsyncStreamReader requestStream, IServerStreamWriter responseStream, ServerCallContext context)
{
- var readStream = new FlightServerRecordBatchStreamReader(requestStream);
- var writeStream = new FlightServerRecordBatchStreamWriter(responseStream);
+ var readStream = new FlightServerRecordBatchStreamReader(requestStream, _flightServer.Context);
+ var writeStream = new FlightServerRecordBatchStreamWriter(responseStream, _flightServer.Context);
return _flightServer.DoExchange(readStream, writeStream, context);
}
diff --git a/src/Apache.Arrow.Operations/Shredding/ShreddedVariantArrayBuilder.cs b/src/Apache.Arrow.Operations/Shredding/ShreddedVariantArrayBuilder.cs
index 3428fa18..73ab24b5 100644
--- a/src/Apache.Arrow.Operations/Shredding/ShreddedVariantArrayBuilder.cs
+++ b/src/Apache.Arrow.Operations/Shredding/ShreddedVariantArrayBuilder.cs
@@ -56,7 +56,7 @@ public static VariantArray Build(
// Top-level validity. Children of a null row are emitted as missing
// (value and typed_value both null); metadata is still populated
// because the metadata field is non-nullable.
- ArrowBuffer.BitmapBuilder validity = new ArrowBuffer.BitmapBuilder(rowCount);
+ using ArrowBuffer.BitmapBuilder validity = new ArrowBuffer.BitmapBuilder(rowCount, allocator);
int nullCount = 0;
ShredResult[] childRows = null;
for (int i = 0; i < rowCount; i++)
@@ -83,7 +83,7 @@ public static VariantArray Build(
// metadata column: emit the shared bytes once per row. (A dictionary-encoded
// or run-end-encoded representation would compress this; VariantArray's reader
// already handles those, but for simplicity we emit the plain binary form.)
- BinaryArray.Builder metadataBuilder = new BinaryArray.Builder();
+ using BinaryArray.Builder metadataBuilder = new BinaryArray.Builder(BinaryType.Default, allocator);
for (int i = 0; i < rowCount; i++)
{
metadataBuilder.Append((ReadOnlySpan)metadata);
@@ -125,7 +125,7 @@ public static VariantArray Build(
private static BinaryArray BuildBinaryColumn(IReadOnlyList rows, MemoryAllocator allocator)
{
- BinaryArray.Builder b = new BinaryArray.Builder();
+ using BinaryArray.Builder b = new BinaryArray.Builder(BinaryType.Default, allocator);
foreach (ShredResult r in rows)
{
if (r.Value == null) b.AppendNull();
@@ -189,9 +189,9 @@ private static ListArray BuildArrayTyped(
{
int rowCount = typedValues.Count;
List flatElements = new List();
- ArrowBuffer.Builder offsets = new ArrowBuffer.Builder();
+ using ArrowBuffer.Builder offsets = new ArrowBuffer.Builder(0, allocator);
offsets.Append(0);
- ArrowBuffer.BitmapBuilder validity = new ArrowBuffer.BitmapBuilder();
+ using ArrowBuffer.BitmapBuilder validity = new ArrowBuffer.BitmapBuilder(0, allocator);
int nullCount = 0;
foreach (object tv in typedValues)
@@ -246,7 +246,7 @@ private static StructArray BuildElementGroupArray(
}
// Outer slot validity: non-null iff the slot isn't "missing" (both columns null).
- ArrowBuffer.BitmapBuilder validity = new ArrowBuffer.BitmapBuilder();
+ using ArrowBuffer.BitmapBuilder validity = new ArrowBuffer.BitmapBuilder(0, allocator);
int nullCount = 0;
foreach (ShredResult r in results)
{
@@ -272,7 +272,7 @@ private static IArrowArray BuildPrimitiveTyped(
{
case ShredType.Boolean:
{
- BooleanArray.Builder b = new BooleanArray.Builder();
+ using BooleanArray.Builder b = new BooleanArray.Builder(allocator);
foreach (object v in typedValues)
{
if (v == null) b.AppendNull(); else b.Append((bool)v);
@@ -281,7 +281,7 @@ private static IArrowArray BuildPrimitiveTyped(
}
case ShredType.Int8:
{
- Int8Array.Builder b = new Int8Array.Builder();
+ using Int8Array.Builder b = new Int8Array.Builder(0, allocator);
foreach (object v in typedValues)
{
if (v == null) b.AppendNull(); else b.Append((sbyte)v);
@@ -290,7 +290,7 @@ private static IArrowArray BuildPrimitiveTyped(
}
case ShredType.Int16:
{
- Int16Array.Builder b = new Int16Array.Builder();
+ using Int16Array.Builder b = new Int16Array.Builder(0, allocator);
foreach (object v in typedValues)
{
if (v == null) b.AppendNull(); else b.Append((short)v);
@@ -299,7 +299,7 @@ private static IArrowArray BuildPrimitiveTyped(
}
case ShredType.Int32:
{
- Int32Array.Builder b = new Int32Array.Builder();
+ using Int32Array.Builder b = new Int32Array.Builder(0, allocator);
foreach (object v in typedValues)
{
if (v == null) b.AppendNull(); else b.Append((int)v);
@@ -308,7 +308,7 @@ private static IArrowArray BuildPrimitiveTyped(
}
case ShredType.Int64:
{
- Int64Array.Builder b = new Int64Array.Builder();
+ using Int64Array.Builder b = new Int64Array.Builder(0, allocator);
foreach (object v in typedValues)
{
if (v == null) b.AppendNull(); else b.Append((long)v);
@@ -317,7 +317,7 @@ private static IArrowArray BuildPrimitiveTyped(
}
case ShredType.Float:
{
- FloatArray.Builder b = new FloatArray.Builder();
+ using FloatArray.Builder b = new FloatArray.Builder(0, allocator);
foreach (object v in typedValues)
{
if (v == null) b.AppendNull(); else b.Append((float)v);
@@ -326,7 +326,7 @@ private static IArrowArray BuildPrimitiveTyped(
}
case ShredType.Double:
{
- DoubleArray.Builder b = new DoubleArray.Builder();
+ using DoubleArray.Builder b = new DoubleArray.Builder(0, allocator);
foreach (object v in typedValues)
{
if (v == null) b.AppendNull(); else b.Append((double)v);
@@ -351,7 +351,7 @@ private static IArrowArray BuildPrimitiveTyped(
return BuildTime64(typedValues, allocator);
case ShredType.String:
{
- StringArray.Builder b = new StringArray.Builder();
+ using StringArray.Builder b = new StringArray.Builder(allocator);
foreach (object v in typedValues)
{
if (v == null) b.AppendNull(); else b.Append((string)v);
@@ -360,7 +360,7 @@ private static IArrowArray BuildPrimitiveTyped(
}
case ShredType.Binary:
{
- BinaryArray.Builder b = new BinaryArray.Builder();
+ using BinaryArray.Builder b = new BinaryArray.Builder(BinaryType.Default, allocator);
foreach (object v in typedValues)
{
if (v == null) b.AppendNull(); else b.Append((ReadOnlySpan)(byte[])v);
@@ -401,8 +401,8 @@ private static Time64Array BuildTime64(IList