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 7abec0e04ed TestExecuteColocatedObjectKeyRoutesRequestToPrimaryNode
with mapper done
7abec0e04ed is described below
commit 7abec0e04ed147b06e05c3781e26d81a37036ea8
Author: Pavel Tupitsyn <[email protected]>
AuthorDate: Wed Dec 24 14:30:26 2025 +0200
TestExecuteColocatedObjectKeyRoutesRequestToPrimaryNode with mapper done
---
.../Apache.Ignite.Tests/PartitionAwarenessTests.cs | 26 +++++++++++++++++-----
.../dotnet/Apache.Ignite/Compute/JobTarget.cs | 12 ++++++++++
2 files changed, 33 insertions(+), 5 deletions(-)
diff --git
a/modules/platforms/dotnet/Apache.Ignite.Tests/PartitionAwarenessTests.cs
b/modules/platforms/dotnet/Apache.Ignite.Tests/PartitionAwarenessTests.cs
index fab3dc9fd83..e58ce786c40 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Tests/PartitionAwarenessTests.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Tests/PartitionAwarenessTests.cs
@@ -49,6 +49,12 @@ public class PartitionAwarenessTests
new object[] { int.MinValue, 2 }
};
+ private static readonly object[] KeyNodeCasesWithMapper = KeyNodeCases
+ .Cast<object[]>()
+ .SelectMany(arr => new[] { true, false }.Select(withMapper =>
(object[])[.. arr, withMapper]))
+ .Cast<object>()
+ .ToArray();
+
private FakeServer _server1 = null!;
private FakeServer _server2 = null!;
@@ -384,14 +390,17 @@ public class PartitionAwarenessTests
}
[Test]
- [TestCaseSource(nameof(KeyNodeCases))]
- public async Task
TestExecuteColocatedObjectKeyRoutesRequestToPrimaryNode(int keyId, int node)
+ [TestCaseSource(nameof(KeyNodeCasesWithMapper))]
+ public async Task
TestExecuteColocatedObjectKeyRoutesRequestToPrimaryNode(int keyId, int node,
bool withMapper)
{
using var client = await GetClient();
var expectedNode = node == 1 ? _server1 : _server2;
var key = new SimpleKey(keyId);
- var jobTarget = JobTarget.Colocated(FakeServer.ExistingTableName, key);
+ var jobTarget = withMapper
+ ? JobTarget.Colocated(FakeServer.ExistingTableName, key, new
SimpleKeyMapper())
+ : JobTarget.Colocated(FakeServer.ExistingTableName, key);
+
var jobDescriptor = new JobDescriptor<object?, object?>("job");
// Warm up.
@@ -534,8 +543,6 @@ public class PartitionAwarenessTests
// ReSharper disable NotAccessedPositionalProperty.Local
private record CompositeKey(string IdStr, Guid IdGuid);
- private record SimpleKey(int Id);
-
private sealed class CompositeKeyMapper : IMapper<CompositeKey>
{
public void Write(CompositeKey obj, ref RowWriter rowWriter,
IMapperSchema schema)
@@ -547,4 +554,13 @@ public class PartitionAwarenessTests
public CompositeKey Read(ref RowReader rowReader, IMapperSchema
schema) =>
new(rowReader.ReadString()!, rowReader.ReadGuid()!.Value);
}
+
+ private record SimpleKey(int Id);
+
+ private sealed class SimpleKeyMapper : IMapper<SimpleKey>
+ {
+ public void Write(SimpleKey obj, ref RowWriter rowWriter,
IMapperSchema schema) => rowWriter.WriteInt(obj.Id);
+
+ public SimpleKey Read(ref RowReader rowReader, IMapperSchema schema)
=> new(rowReader.ReadInt()!.Value);
+ }
}
diff --git a/modules/platforms/dotnet/Apache.Ignite/Compute/JobTarget.cs
b/modules/platforms/dotnet/Apache.Ignite/Compute/JobTarget.cs
index 37cc3c2dd01..16897d263f2 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Compute/JobTarget.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/Compute/JobTarget.cs
@@ -109,6 +109,18 @@ public static class JobTarget
where TKey : notnull =>
Colocated(QualifiedName.Parse(tableName), key);
+ /// <summary>
+ /// Creates a colocated job target for a specific table and key.
+ /// </summary>
+ /// <param name="tableName">Table name.</param>
+ /// <param name="key">Key.</param>
+ /// <param name="mapper">Mapper for the key.</param>
+ /// <typeparam name="TKey">Key type.</typeparam>
+ /// <returns>Colocated job target.</returns>
+ public static IJobTarget<TKey> Colocated<TKey>(string tableName, TKey key,
IMapper<TKey> mapper)
+ where TKey : notnull =>
+ Colocated(QualifiedName.Parse(tableName), key, mapper);
+
/// <summary>
/// Single node job target.
/// </summary>