This is an automated email from the ASF dual-hosted git repository.

ptupitsyn pushed a commit to branch ignite-27278
in repository https://gitbox.apache.org/repos/asf/ignite-3.git

commit d2e96767b2cf4ccb1271d21c38901ddf1386e542
Author: Pavel Tupitsyn <[email protected]>
AuthorDate: Tue Dec 23 15:26:02 2025 +0200

    wip
---
 .../dotnet/Apache.Ignite/Internal/Sql/ResultSet.cs | 10 +++++--
 .../Apache.Ignite/Internal/Sql/RowReaderFactory.cs |  3 +-
 .../dotnet/Apache.Ignite/Internal/Sql/Sql.cs       | 32 +++++++++++++++++-----
 3 files changed, 35 insertions(+), 10 deletions(-)

diff --git a/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/ResultSet.cs 
b/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/ResultSet.cs
index db541ff3ec8..91f081900b4 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/ResultSet.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/ResultSet.cs
@@ -62,8 +62,14 @@ namespace Apache.Ignite.Internal.Sql
         /// <param name="socket">Socket.</param>
         /// <param name="buf">Buffer to read initial data from.</param>
         /// <param name="rowReaderFactory">Row reader factory.</param>
+        /// <param name="rowReaderFactoryArg">Row reader factory 
argument.</param>
         /// <param name="cancellationToken">Cancellation token.</param>
-        public ResultSet(ClientSocket socket, PooledBuffer buf, 
RowReaderFactory<T> rowReaderFactory, CancellationToken cancellationToken)
+        public ResultSet(
+            ClientSocket socket,
+            PooledBuffer buf,
+            RowReaderFactory<T> rowReaderFactory,
+            object? rowReaderFactoryArg,
+            CancellationToken cancellationToken)
         {
             _socket = socket;
             _cancellationToken = cancellationToken;
@@ -79,7 +85,7 @@ namespace Apache.Ignite.Internal.Sql
             AffectedRows = reader.ReadInt64();
 
             _metadata = HasRowSet ? ReadMeta(ref reader) : null;
-            _rowReader = _metadata != null ? rowReaderFactory(_metadata) : 
null;
+            _rowReader = _metadata != null ? rowReaderFactory(_metadata, 
rowReaderFactoryArg) : null;
 
             if (HasRowSet)
             {
diff --git 
a/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/RowReaderFactory.cs 
b/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/RowReaderFactory.cs
index 73889c97ec7..73ee3548b94 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/RowReaderFactory.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/RowReaderFactory.cs
@@ -21,6 +21,7 @@ namespace Apache.Ignite.Internal.Sql;
 /// Row reader factory.
 /// </summary>
 /// <param name="metadata">Metadata.</param>
+/// <param name="arg">Argument.</param>
 /// <typeparam name="T">Result type.</typeparam>
 /// <returns>Resulting row.</returns>
-internal delegate RowReader<T> RowReaderFactory<out T>(ResultSetMetadata 
metadata);
+internal delegate RowReader<T> RowReaderFactory<out T>(ResultSetMetadata 
metadata, object? arg);
diff --git a/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/Sql.cs 
b/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/Sql.cs
index 182d5dc528e..da63f07b466 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/Sql.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/Sql.cs
@@ -44,7 +44,7 @@ namespace Apache.Ignite.Internal.Sql
         private static readonly RowReader<IIgniteTuple> TupleReader =
             static (ResultSetMetadata metadata, ref BinaryTupleReader reader) 
=> ReadTuple(metadata.Columns, ref reader);
 
-        private static readonly RowReaderFactory<IIgniteTuple> 
TupleReaderFactory = static _ => TupleReader;
+        private static readonly RowReaderFactory<IIgniteTuple> 
TupleReaderFactory = static (_, _) => TupleReader;
 
         /** Underlying connection. */
         private readonly ClientFailoverSocket _socket;
@@ -61,7 +61,14 @@ namespace Apache.Ignite.Internal.Sql
         /// <inheritdoc/>
         public async Task<IResultSet<IIgniteTuple>> ExecuteAsync(
             ITransaction? transaction, SqlStatement statement, 
CancellationToken cancellationToken, params object?[]? args) =>
-            await ExecuteAsyncInternal(transaction, statement, 
TupleReaderFactory, args, cancellationToken).ConfigureAwait(false);
+            await ExecuteAsyncInternal(
+                transaction,
+                statement,
+                TupleReaderFactory,
+                rowReaderFactoryArg: null,
+                args,
+                cancellationToken)
+                .ConfigureAwait(false);
 
         /// <inheritdoc/>
         [RequiresUnreferencedCode(ReflectionUtils.TrimWarning)]
@@ -70,7 +77,8 @@ namespace Apache.Ignite.Internal.Sql
             await ExecuteAsyncInternal(
                     transaction,
                     statement,
-                    static meta => GetReaderFactory<T>(meta),
+                    static (meta, _) => GetReaderFactory<T>(meta),
+                    rowReaderFactoryArg: null,
                     args,
                     cancellationToken)
                 .ConfigureAwait(false);
@@ -83,12 +91,14 @@ namespace Apache.Ignite.Internal.Sql
             CancellationToken cancellationToken,
             params object?[]? args)
         {
-            // TODO: Cache or avoid allocation?
-            RowReaderFactory<T> rowReaderFactory = _ =>
+            // TODO: avoid allocation
+            RowReaderFactory<T> rowReaderFactory = static (meta, arg) =>
             {
                 return (ResultSetMetadata meta, ref BinaryTupleReader reader) 
=>
                 {
                     var mapperReader = new RowReader(ref reader, meta);
+                    var mapper = (IMapper<T>)arg!;
+
                     return mapper.Read(ref mapperReader, meta);
                 };
             };
@@ -97,6 +107,7 @@ namespace Apache.Ignite.Internal.Sql
                     transaction,
                     statement,
                     rowReaderFactory,
+                    rowReaderFactoryArg: mapper,
                     args,
                     cancellationToken)
                 .ConfigureAwait(false);
@@ -107,7 +118,12 @@ namespace Apache.Ignite.Internal.Sql
             ITransaction? transaction, SqlStatement statement, 
CancellationToken cancellationToken, params object?[]? args)
         {
             var resultSet = await ExecuteAsyncInternal<object>(
-                transaction, statement, _ => null!, args, 
cancellationToken).ConfigureAwait(false);
+                transaction,
+                statement,
+                static (_, _) => null!,
+                rowReaderFactoryArg: null,
+                args,
+                cancellationToken).ConfigureAwait(false);
 
             if (!resultSet.HasRowSet)
             {
@@ -243,6 +259,7 @@ namespace Apache.Ignite.Internal.Sql
         /// <param name="transaction">Optional transaction.</param>
         /// <param name="statement">Statement to execute.</param>
         /// <param name="rowReaderFactory">Row reader factory.</param>
+        /// <param name="rowReaderFactoryArg">Row reader factory arg.</param>
         /// <param name="args">Arguments for the statement.</param>
         /// <param name="cancellationToken">Cancellation token.</param>
         /// <typeparam name="T">Row type.</typeparam>
@@ -251,6 +268,7 @@ namespace Apache.Ignite.Internal.Sql
             ITransaction? transaction,
             SqlStatement statement,
             RowReaderFactory<T> rowReaderFactory,
+            object? rowReaderFactoryArg,
             ICollection<object?>? args,
             CancellationToken cancellationToken)
         {
@@ -270,7 +288,7 @@ namespace Apache.Ignite.Internal.Sql
                     ClientOp.SqlExec, tx, bufferWriter, cancellationToken: 
cancellationToken).ConfigureAwait(false);
 
                 // ResultSet will dispose the pooled buffer.
-                return new ResultSet<T>(socket, buf, rowReaderFactory, 
cancellationToken);
+                return new ResultSet<T>(socket, buf, rowReaderFactory, 
rowReaderFactoryArg, cancellationToken);
             }
             catch (SqlException e)
             {

Reply via email to