You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by pt...@apache.org on 2025/02/24 11:01:29 UTC
(ignite-3) 07/09: Add checks in .NET client
This is an automated email from the ASF dual-hosted git repository.
ptupitsyn pushed a commit to branch ignite-24581
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
commit 54f948455005927c48503fa328d2c8778b023470
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Fri Feb 21 12:38:46 2025 +0200
Add checks in .NET client
---
modules/platforms/dotnet/Apache.Ignite/Internal/Table/DataStreamer.cs | 2 +-
.../dotnet/Apache.Ignite/Internal/Table/DataStreamerWithReceiver.cs | 2 +-
modules/platforms/dotnet/Apache.Ignite/Internal/Table/Table.cs | 4 ++++
3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/modules/platforms/dotnet/Apache.Ignite/Internal/Table/DataStreamer.cs b/modules/platforms/dotnet/Apache.Ignite/Internal/Table/DataStreamer.cs
index 8fe516fc963..1ff6ae28057 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Internal/Table/DataStreamer.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/Internal/Table/DataStreamer.cs
@@ -217,7 +217,7 @@ internal static class DataStreamer
var keyOnly = item.OperationType == DataStreamerOperationType.Remove;
writer.Write(ref tupleBuilder, item.Data, schema0, keyOnly: keyOnly, noValueSetRef);
- var partitionId = Math.Abs(tupleBuilder.GetHash() % partitionCount);
+ var partitionId = partitionCount <= 0 ? 0 : Math.Abs(tupleBuilder.GetHash() % partitionCount);
var batch = GetOrCreateBatch(partitionId);
lock (batch)
diff --git a/modules/platforms/dotnet/Apache.Ignite/Internal/Table/DataStreamerWithReceiver.cs b/modules/platforms/dotnet/Apache.Ignite/Internal/Table/DataStreamerWithReceiver.cs
index 9537085964c..ec23dc22618 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Internal/Table/DataStreamerWithReceiver.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/Internal/Table/DataStreamerWithReceiver.cs
@@ -216,7 +216,7 @@ internal static class DataStreamerWithReceiver
var key = keySelector(item);
keyWriter.Write(ref tupleBuilder, key, schema, keyOnly: true, Span<byte>.Empty);
- var partitionId = Math.Abs(tupleBuilder.GetHash() % partitionCount);
+ var partitionId = partitionCount <= 0 ? 0 : Math.Abs(tupleBuilder.GetHash() % partitionCount);
var batch = GetOrCreateBatch(partitionId);
var payload = payloadSelector(item);
diff --git a/modules/platforms/dotnet/Apache.Ignite/Internal/Table/Table.cs b/modules/platforms/dotnet/Apache.Ignite/Internal/Table/Table.cs
index 82d02ace5cc..bd3efb0dc37 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Internal/Table/Table.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/Internal/Table/Table.cs
@@ -208,6 +208,10 @@ namespace Apache.Ignite.Internal.Table
}
var assignment = await GetPartitionAssignmentAsync().ConfigureAwait(false);
+ if (assignment.Length == 0)
+ {
+ return default;
+ }
var partition = Math.Abs(colocationHash % assignment.Length);
var nodeConsistentId = assignment[partition];