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


The following commit(s) were added to refs/heads/ignite-27278 by this push:
     new dc954734b4c Fix allocation
dc954734b4c is described below

commit dc954734b4c14ea137c7e89bfaed8d26859823bc
Author: Pavel Tupitsyn <[email protected]>
AuthorDate: Tue Dec 23 12:19:10 2025 +0200

    Fix allocation
---
 .../dotnet/Apache.Ignite/Compute/JobTarget.cs      | 23 +++++++++++++++++++++-
 .../Apache.Ignite/Internal/Compute/Compute.cs      | 10 +++-------
 2 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/modules/platforms/dotnet/Apache.Ignite/Compute/JobTarget.cs 
b/modules/platforms/dotnet/Apache.Ignite/Compute/JobTarget.cs
index 5d0e5c7093f..37cc3c2dd01 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Compute/JobTarget.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/Compute/JobTarget.cs
@@ -17,8 +17,11 @@
 
 namespace Apache.Ignite.Compute;
 
+using System;
 using System.Collections.Generic;
 using Internal.Common;
+using Internal.Table;
+using Internal.Table.Serialization;
 using Network;
 using Table;
 using Table.Mapper;
@@ -126,5 +129,23 @@ public static class JobTarget
     /// <param name="Mapper">Optional mapper for the key.</param>
     /// <typeparam name="TKey">Key type.</typeparam>
     internal sealed record ColocatedTarget<TKey>(QualifiedName TableName, TKey 
Data, IMapper<TKey>? Mapper) : IJobTarget<TKey>
-        where TKey : notnull;
+        where TKey : notnull
+    {
+        /// <summary>
+        /// Gets the cached serializer handler function.
+        /// </summary>
+        internal Func<Table, IRecordSerializerHandler<TKey>>? 
SerializerHandlerFunc { get; } = GetSerializerHandlerFunc(Mapper);
+
+        private static Func<Table, IRecordSerializerHandler<TKey>>? 
GetSerializerHandlerFunc(IMapper<TKey>? mapper)
+        {
+            if (mapper == null)
+            {
+                return null;
+            }
+
+            var handler = new MapperSerializerHandler<TKey>(mapper);
+
+            return _ => handler;
+        }
+    }
 }
diff --git a/modules/platforms/dotnet/Apache.Ignite/Internal/Compute/Compute.cs 
b/modules/platforms/dotnet/Apache.Ignite/Internal/Compute/Compute.cs
index e330f066ec7..fff192d1d66 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Internal/Compute/Compute.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/Internal/Compute/Compute.cs
@@ -30,7 +30,6 @@ namespace Apache.Ignite.Internal.Compute
     using Ignite.Compute;
     using Ignite.Network;
     using Ignite.Table;
-    using Ignite.Table.Mapper;
     using Marshalling;
     using Network;
     using Proto;
@@ -625,15 +624,12 @@ namespace Apache.Ignite.Internal.Compute
                     .ConfigureAwait(false);
             }
 
-            if (target.Mapper != null)
+            if (target.SerializerHandlerFunc != null)
             {
-                // TODO: Avoid allocation.
-                Func<Table, IRecordSerializerHandler<TKey>> handlerFunc = _ => 
new MapperSerializerHandler<TKey>(target.Mapper);
-
-                return await ExecuteColocatedAsync<TArg, TResult, TKey>(
+                return await ExecuteColocatedAsync(
                         target.TableName,
                         target.Data,
-                        handlerFunc,
+                        target.SerializerHandlerFunc,
                         jobDescriptor,
                         arg,
                         cancellationToken)

Reply via email to