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 2021/11/30 14:03:46 UTC
[ignite-3] branch main updated: IGNITE-15939 Fix GetAll wire format in thin clients (#479)
This is an automated email from the ASF dual-hosted git repository.
ptupitsyn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push:
new 41fcd5e IGNITE-15939 Fix GetAll wire format in thin clients (#479)
41fcd5e is described below
commit 41fcd5e31ba8b06f746c08e2d7908e00343eb152
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Tue Nov 30 17:03:38 2021 +0300
IGNITE-15939 Fix GetAll wire format in thin clients (#479)
* Pass null flag with every row in GetAll to be able to identify null rows.
* Fix Java and .NET thin clients.
---
.../java/org/apache/ignite/table/RecordView.java | 4 +-
.../handler/requests/table/ClientTableCommon.java | 85 ++++++++++++++++------
.../table/ClientTupleDeleteAllExactRequest.java | 2 +-
.../table/ClientTupleDeleteAllRequest.java | 2 +-
.../requests/table/ClientTupleGetAllRequest.java | 5 +-
.../table/ClientTupleGetAndDeleteRequest.java | 4 +-
.../table/ClientTupleGetAndReplaceRequest.java | 4 +-
.../ClientTupleGetAndReplaceSchemalessRequest.java | 3 +-
.../table/ClientTupleGetAndUpsertRequest.java | 4 +-
.../ClientTupleGetAndUpsertSchemalessRequest.java | 3 +-
.../requests/table/ClientTupleGetRequest.java | 3 +-
.../table/ClientTupleInsertAllRequest.java | 2 +-
.../ClientTupleInsertAllSchemalessRequest.java | 2 +-
.../client/table/ClientKeyValueBinaryView.java | 2 +-
.../client/table/ClientRecordBinaryView.java | 2 +-
.../ignite/internal/client/table/ClientTable.java | 28 +++++--
.../dotnet/Apache.Ignite.Tests/Table/TableTests.cs | 19 +++--
.../dotnet/Apache.Ignite/Internal/Table/Table.cs | 31 +++++++-
.../dotnet/Apache.Ignite/Table/ITableView.cs | 6 +-
.../schema/registry/SchemaRegistryImpl.java | 7 +-
20 files changed, 155 insertions(+), 63 deletions(-)
diff --git a/modules/api/src/main/java/org/apache/ignite/table/RecordView.java b/modules/api/src/main/java/org/apache/ignite/table/RecordView.java
index b644464..602f00d 100644
--- a/modules/api/src/main/java/org/apache/ignite/table/RecordView.java
+++ b/modules/api/src/main/java/org/apache/ignite/table/RecordView.java
@@ -52,7 +52,9 @@ public interface RecordView<R> {
* Get records from the table.
*
* @param keyRecs Records with key columns set. The records cannot be {@code null}.
- * @return Records with all columns filled from the table.
+ * @return Records with all columns filled from the table. The order of collection elements is
+ * guaranteed to be the same as the order of {@code keyRecs}. If a record does not exist, the
+ * element at the corresponding index of the resulting collection will be null.
*/
Collection<R> getAll(@NotNull Collection<R> keyRecs);
diff --git a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTableCommon.java b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTableCommon.java
index e8ee057..cacd656 100644
--- a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTableCommon.java
+++ b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTableCommon.java
@@ -85,7 +85,7 @@ class ClientTableCommon {
* @param packer Packer.
* @param tuple Tuple.
*/
- public static void writeTuple(ClientMessagePacker packer, Tuple tuple) {
+ public static void writeTupleOrNil(ClientMessagePacker packer, Tuple tuple) {
if (tuple == null) {
packer.packNil();
@@ -103,7 +103,7 @@ class ClientTableCommon {
* @param packer Packer.
* @param tuple Tuple.
*/
- public static void writeTuple(ClientMessagePacker packer, Tuple tuple, TuplePart part) {
+ public static void writeTupleOrNil(ClientMessagePacker packer, Tuple tuple, TuplePart part) {
if (tuple == null) {
packer.packNil();
@@ -166,12 +166,8 @@ class ClientTableCommon {
boolean skipHeader,
TuplePart part
) {
- if (tuple == null) {
- packer.packNil();
-
- return;
- }
-
+ assert tuple != null;
+
if (!skipHeader) {
packer.packInt(schema.version());
}
@@ -192,29 +188,36 @@ class ClientTableCommon {
/**
* Writes multiple tuples.
*
- * @param packer Packer.
- * @param tuples Tuples.
+ * @param packer Packer.
+ * @param tuples Tuples.
* @param schemaRegistry The registry.
+ * @param skipHeader Whether to skip the tuple header.
* @throws IgniteException on failed serialization.
*/
- public static void writeTuples(ClientMessagePacker packer, Collection<Tuple> tuples, SchemaRegistry schemaRegistry) {
- writeTuples(packer, tuples, TuplePart.KEY_AND_VAL, schemaRegistry);
+ public static void writeTuples(
+ ClientMessagePacker packer,
+ Collection<Tuple> tuples,
+ SchemaRegistry schemaRegistry,
+ boolean skipHeader) {
+ writeTuples(packer, tuples, TuplePart.KEY_AND_VAL, schemaRegistry, skipHeader);
}
/**
* Writes multiple tuples.
*
- * @param packer Packer.
- * @param tuples Tuples.
- * @param part Which part of tuple to write.
+ * @param packer Packer.
+ * @param tuples Tuples.
+ * @param part Which part of tuple to write.
* @param schemaRegistry The registry.
+ * @param skipHeader Whether to skip the tuple header.
* @throws IgniteException on failed serialization.
*/
public static void writeTuples(
ClientMessagePacker packer,
Collection<Tuple> tuples,
TuplePart part,
- SchemaRegistry schemaRegistry
+ SchemaRegistry schemaRegistry,
+ boolean skipHeader
) {
if (tuples == null || tuples.isEmpty()) {
packer.packNil();
@@ -228,15 +231,55 @@ class ClientTableCommon {
packer.packInt(tuples.size());
for (Tuple tuple : tuples) {
- if (tuple != null) {
- assert schema.version() == ((SchemaAware) tuple).schema().version();
- }
-
- writeTuple(packer, tuple, schema, true, part);
+ assert tuple != null;
+ assert schema.version() == ((SchemaAware) tuple).schema().version();
+
+ writeTuple(packer, tuple, schema, skipHeader, part);
}
}
/**
+ * Writes multiple tuples with null flags.
+ *
+ * @param packer Packer.
+ * @param tuples Tuples.
+ * @param part Which part of tuple to write.
+ * @param schemaRegistry The registry.
+ * @param skipHeader Whether to skip the tuple header.
+ * @throws IgniteException on failed serialization.
+ */
+ public static void writeTuplesNullable(
+ ClientMessagePacker packer,
+ Collection<Tuple> tuples,
+ TuplePart part,
+ SchemaRegistry schemaRegistry,
+ boolean skipHeader
+ ) {
+ if (tuples == null || tuples.isEmpty()) {
+ packer.packNil();
+
+ return;
+ }
+
+ SchemaDescriptor schema = schemaRegistry.schema();
+
+ packer.packInt(schema.version());
+ packer.packInt(tuples.size());
+
+ for (Tuple tuple : tuples) {
+ if (tuple == null) {
+ packer.packBoolean(false);
+ continue;
+ }
+
+ assert schema.version() == ((SchemaAware) tuple).schema().version();
+
+ packer.packBoolean(true);
+ writeTuple(packer, tuple, schema, skipHeader, part);
+ }
+ }
+
+ /**
* Reads a tuple.
*
* @param unpacker Unpacker.
diff --git a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleDeleteAllExactRequest.java b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleDeleteAllExactRequest.java
index a1104d3..9b914d1 100644
--- a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleDeleteAllExactRequest.java
+++ b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleDeleteAllExactRequest.java
@@ -47,6 +47,6 @@ public class ClientTupleDeleteAllExactRequest {
var tuples = readTuples(in, table, false);
return table.recordView().deleteAllExactAsync(tuples)
- .thenAccept(skippedTuples -> writeTuples(out, skippedTuples, table.schemaView()));
+ .thenAccept(skippedTuples -> writeTuples(out, skippedTuples, table.schemaView(), true));
}
}
diff --git a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleDeleteAllRequest.java b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleDeleteAllRequest.java
index 804b52b..f8f7222 100644
--- a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleDeleteAllRequest.java
+++ b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleDeleteAllRequest.java
@@ -48,6 +48,6 @@ public class ClientTupleDeleteAllRequest {
var tuples = readTuples(in, table, true);
return table.recordView().deleteAllAsync(tuples).thenAccept(skippedTuples ->
- writeTuples(out, skippedTuples, TuplePart.KEY, table.schemaView()));
+ writeTuples(out, skippedTuples, TuplePart.KEY, table.schemaView(), true));
}
}
diff --git a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleGetAllRequest.java b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleGetAllRequest.java
index 4ac6452..803874d 100644
--- a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleGetAllRequest.java
+++ b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleGetAllRequest.java
@@ -19,11 +19,12 @@ package org.apache.ignite.client.handler.requests.table;
import static org.apache.ignite.client.handler.requests.table.ClientTableCommon.readTable;
import static org.apache.ignite.client.handler.requests.table.ClientTableCommon.readTuples;
-import static org.apache.ignite.client.handler.requests.table.ClientTableCommon.writeTuples;
+import static org.apache.ignite.client.handler.requests.table.ClientTableCommon.writeTuplesNullable;
import java.util.concurrent.CompletableFuture;
import org.apache.ignite.internal.client.proto.ClientMessagePacker;
import org.apache.ignite.internal.client.proto.ClientMessageUnpacker;
+import org.apache.ignite.internal.client.proto.TuplePart;
import org.apache.ignite.table.manager.IgniteTables;
/**
@@ -47,6 +48,6 @@ public class ClientTupleGetAllRequest {
var keyTuples = readTuples(in, table, true);
return table.recordView().getAllAsync(keyTuples).thenAccept(tuples ->
- writeTuples(out, tuples, table.schemaView()));
+ writeTuplesNullable(out, tuples, TuplePart.KEY_AND_VAL, table.schemaView(), true));
}
}
diff --git a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleGetAndDeleteRequest.java b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleGetAndDeleteRequest.java
index 132dfd4..c184c4f 100644
--- a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleGetAndDeleteRequest.java
+++ b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleGetAndDeleteRequest.java
@@ -19,7 +19,6 @@ package org.apache.ignite.client.handler.requests.table;
import static org.apache.ignite.client.handler.requests.table.ClientTableCommon.readTable;
import static org.apache.ignite.client.handler.requests.table.ClientTableCommon.readTuple;
-import static org.apache.ignite.client.handler.requests.table.ClientTableCommon.writeTuple;
import java.util.concurrent.CompletableFuture;
import org.apache.ignite.internal.client.proto.ClientMessagePacker;
@@ -47,6 +46,7 @@ public class ClientTupleGetAndDeleteRequest {
var table = readTable(in, tables);
var tuple = readTuple(in, table, true);
- return table.recordView().getAndDeleteAsync(tuple).thenAccept(resTuple -> writeTuple(out, resTuple, TuplePart.VAL));
+ return table.recordView().getAndDeleteAsync(tuple).thenAccept(
+ resTuple -> ClientTableCommon.writeTupleOrNil(out, resTuple, TuplePart.VAL));
}
}
diff --git a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleGetAndReplaceRequest.java b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleGetAndReplaceRequest.java
index 1e61dd1..725e0b7 100644
--- a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleGetAndReplaceRequest.java
+++ b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleGetAndReplaceRequest.java
@@ -19,7 +19,6 @@ package org.apache.ignite.client.handler.requests.table;
import static org.apache.ignite.client.handler.requests.table.ClientTableCommon.readTable;
import static org.apache.ignite.client.handler.requests.table.ClientTableCommon.readTuple;
-import static org.apache.ignite.client.handler.requests.table.ClientTableCommon.writeTuple;
import java.util.concurrent.CompletableFuture;
import org.apache.ignite.internal.client.proto.ClientMessagePacker;
@@ -47,6 +46,7 @@ public class ClientTupleGetAndReplaceRequest {
var table = readTable(in, tables);
var tuple = readTuple(in, table, false);
- return table.recordView().getAndReplaceAsync(tuple).thenAccept(resTuple -> writeTuple(out, resTuple, TuplePart.VAL));
+ return table.recordView().getAndReplaceAsync(tuple).thenAccept(
+ resTuple -> ClientTableCommon.writeTupleOrNil(out, resTuple, TuplePart.VAL));
}
}
diff --git a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleGetAndReplaceSchemalessRequest.java b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleGetAndReplaceSchemalessRequest.java
index c3c91ee..f3c7aff 100644
--- a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleGetAndReplaceSchemalessRequest.java
+++ b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleGetAndReplaceSchemalessRequest.java
@@ -19,7 +19,6 @@ package org.apache.ignite.client.handler.requests.table;
import static org.apache.ignite.client.handler.requests.table.ClientTableCommon.readTable;
import static org.apache.ignite.client.handler.requests.table.ClientTableCommon.readTupleSchemaless;
-import static org.apache.ignite.client.handler.requests.table.ClientTableCommon.writeTuple;
import java.util.concurrent.CompletableFuture;
import org.apache.ignite.internal.client.proto.ClientMessagePacker;
@@ -46,6 +45,6 @@ public class ClientTupleGetAndReplaceSchemalessRequest {
var table = readTable(in, tables);
var tuple = readTupleSchemaless(in);
- return table.recordView().getAndReplaceAsync(tuple).thenAccept(resTuple -> writeTuple(out, resTuple));
+ return table.recordView().getAndReplaceAsync(tuple).thenAccept(resTuple -> ClientTableCommon.writeTupleOrNil(out, resTuple));
}
}
diff --git a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleGetAndUpsertRequest.java b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleGetAndUpsertRequest.java
index 4111995..49fe1bf 100644
--- a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleGetAndUpsertRequest.java
+++ b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleGetAndUpsertRequest.java
@@ -19,7 +19,6 @@ package org.apache.ignite.client.handler.requests.table;
import static org.apache.ignite.client.handler.requests.table.ClientTableCommon.readTable;
import static org.apache.ignite.client.handler.requests.table.ClientTableCommon.readTuple;
-import static org.apache.ignite.client.handler.requests.table.ClientTableCommon.writeTuple;
import java.util.concurrent.CompletableFuture;
import org.apache.ignite.internal.client.proto.ClientMessagePacker;
@@ -47,6 +46,7 @@ public class ClientTupleGetAndUpsertRequest {
var table = readTable(in, tables);
var tuple = readTuple(in, table, false);
- return table.recordView().getAndUpsertAsync(tuple).thenAccept(resTuple -> writeTuple(out, resTuple, TuplePart.VAL));
+ return table.recordView().getAndUpsertAsync(tuple).thenAccept(
+ resTuple -> ClientTableCommon.writeTupleOrNil(out, resTuple, TuplePart.VAL));
}
}
diff --git a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleGetAndUpsertSchemalessRequest.java b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleGetAndUpsertSchemalessRequest.java
index f0e6b69..824f980 100644
--- a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleGetAndUpsertSchemalessRequest.java
+++ b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleGetAndUpsertSchemalessRequest.java
@@ -19,7 +19,6 @@ package org.apache.ignite.client.handler.requests.table;
import static org.apache.ignite.client.handler.requests.table.ClientTableCommon.readTable;
import static org.apache.ignite.client.handler.requests.table.ClientTableCommon.readTupleSchemaless;
-import static org.apache.ignite.client.handler.requests.table.ClientTableCommon.writeTuple;
import java.util.concurrent.CompletableFuture;
import org.apache.ignite.internal.client.proto.ClientMessagePacker;
@@ -46,6 +45,6 @@ public class ClientTupleGetAndUpsertSchemalessRequest {
var table = readTable(in, tables);
var tuple = readTupleSchemaless(in);
- return table.recordView().getAndUpsertAsync(tuple).thenAccept(resTuple -> writeTuple(out, resTuple));
+ return table.recordView().getAndUpsertAsync(tuple).thenAccept(resTuple -> ClientTableCommon.writeTupleOrNil(out, resTuple));
}
}
diff --git a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleGetRequest.java b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleGetRequest.java
index af53efc..039f6aa 100644
--- a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleGetRequest.java
+++ b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleGetRequest.java
@@ -19,7 +19,6 @@ package org.apache.ignite.client.handler.requests.table;
import static org.apache.ignite.client.handler.requests.table.ClientTableCommon.readTable;
import static org.apache.ignite.client.handler.requests.table.ClientTableCommon.readTuple;
-import static org.apache.ignite.client.handler.requests.table.ClientTableCommon.writeTuple;
import java.util.concurrent.CompletableFuture;
import org.apache.ignite.internal.client.proto.ClientMessagePacker;
@@ -47,6 +46,6 @@ public class ClientTupleGetRequest {
var table = readTable(in, tables);
var keyTuple = readTuple(in, table, true);
- return table.recordView().getAsync(keyTuple).thenAccept(t -> writeTuple(out, t, TuplePart.VAL));
+ return table.recordView().getAsync(keyTuple).thenAccept(t -> ClientTableCommon.writeTupleOrNil(out, t, TuplePart.VAL));
}
}
diff --git a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleInsertAllRequest.java b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleInsertAllRequest.java
index 087a10e..07074d5 100644
--- a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleInsertAllRequest.java
+++ b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleInsertAllRequest.java
@@ -47,6 +47,6 @@ public class ClientTupleInsertAllRequest {
var tuples = readTuples(in, table, false);
return table.recordView().insertAllAsync(tuples).thenAccept(skippedTuples ->
- writeTuples(out, skippedTuples, table.schemaView()));
+ writeTuples(out, skippedTuples, table.schemaView(), true));
}
}
diff --git a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleInsertAllSchemalessRequest.java b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleInsertAllSchemalessRequest.java
index ef3456b..db9fec0 100644
--- a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleInsertAllSchemalessRequest.java
+++ b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleInsertAllSchemalessRequest.java
@@ -47,6 +47,6 @@ public class ClientTupleInsertAllSchemalessRequest {
var tuples = readTuplesSchemaless(in);
return table.recordView().insertAllAsync(tuples).thenAccept(skippedTuples ->
- writeTuples(out, skippedTuples, table.schemaView()));
+ writeTuples(out, skippedTuples, table.schemaView(), true));
}
}
diff --git a/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientKeyValueBinaryView.java b/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientKeyValueBinaryView.java
index 053577d..52d4bab 100644
--- a/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientKeyValueBinaryView.java
+++ b/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientKeyValueBinaryView.java
@@ -81,7 +81,7 @@ public class ClientKeyValueBinaryView implements KeyValueView<Tuple, Tuple> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET_ALL,
(s, w) -> tbl.writeTuples(keys, s, w, true),
- tbl::readKvTuples,
+ tbl::readKvTuplesNullable,
Collections.emptyMap());
}
diff --git a/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientRecordBinaryView.java b/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientRecordBinaryView.java
index faa253a..38085f3 100644
--- a/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientRecordBinaryView.java
+++ b/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientRecordBinaryView.java
@@ -81,7 +81,7 @@ public class ClientRecordBinaryView implements RecordView<Tuple> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET_ALL,
(s, w) -> tbl.writeTuples(keyRecs, s, w, true),
- tbl::readTuples,
+ tbl::readTuplesNullable,
Collections.emptyList());
}
diff --git a/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTable.java b/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTable.java
index ecb0ae8..72549fe 100644
--- a/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTable.java
+++ b/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTable.java
@@ -411,10 +411,6 @@ public class ClientTable implements Table {
}
static IgniteBiTuple<Tuple, Tuple> readKvTuple(ClientSchema schema, ClientMessageUnpacker in) {
- if (in.tryUnpackNil()) {
- return null;
- }
-
var keyColCnt = schema.keyColumnCount();
var colCnt = schema.columns().length;
@@ -442,13 +438,16 @@ public class ClientTable implements Table {
* @param in In.
* @return Tuple pairs.
*/
- public Map<Tuple, Tuple> readKvTuples(ClientSchema schema, ClientMessageUnpacker in) {
+ public Map<Tuple, Tuple> readKvTuplesNullable(ClientSchema schema, ClientMessageUnpacker in) {
var cnt = in.unpackInt();
Map<Tuple, Tuple> res = new HashMap<>(cnt);
for (int i = 0; i < cnt; i++) {
- var pair = readKvTuple(schema, in);
- if (pair != null) {
+ var hasValue = in.unpackBoolean();
+
+ if (hasValue) {
+ var pair = readKvTuple(schema, in);
+
res.put(pair.get1(), pair.get2());
}
}
@@ -471,6 +470,21 @@ public class ClientTable implements Table {
return res;
}
+ Collection<Tuple> readTuplesNullable(ClientSchema schema, ClientMessageUnpacker in) {
+ var cnt = in.unpackInt();
+ var res = new ArrayList<Tuple>(cnt);
+
+ for (int i = 0; i < cnt; i++) {
+ var tuple = in.unpackBoolean()
+ ? readTuple(schema, in, false)
+ : null;
+
+ res.add(tuple);
+ }
+
+ return res;
+ }
+
<T> CompletableFuture<T> doSchemaOutInOpAsync(
int opCode,
BiConsumer<ClientSchema, ClientMessagePacker> writer,
diff --git a/modules/platforms/dotnet/Apache.Ignite.Tests/Table/TableTests.cs b/modules/platforms/dotnet/Apache.Ignite.Tests/Table/TableTests.cs
index bd5e6ea..e893b75 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Tests/Table/TableTests.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Tests/Table/TableTests.cs
@@ -351,7 +351,6 @@ namespace Apache.Ignite.Tests.Table
}
[Test]
- [Ignore("IGNITE-15939 TODO asch read null tuples")]
public async Task TestGetAllReturnsRecordsForExistingKeys()
{
var records = Enumerable
@@ -360,25 +359,29 @@ namespace Apache.Ignite.Tests.Table
await Table.UpsertAllAsync(records);
+ // TODO: Key order should be preserved by the server (IGNITE-16004).
var res = await Table.GetAllAsync(Enumerable.Range(9, 4).Select(x => GetTuple(x)));
- var resArr = res.OrderBy(x => x[0]).ToArray();
+ var resArr = res.OrderBy(x => x?[0]).ToArray();
Assert.AreEqual(4, res.Count);
- Assert.AreEqual(9, resArr[0][0]);
- Assert.AreEqual("9", resArr[0][1]);
+ Assert.IsNull(resArr[0]);
+ Assert.IsNull(resArr[1]);
- Assert.AreEqual(10, resArr[1][0]);
- Assert.AreEqual("10", resArr[1][1]);
+ Assert.AreEqual(9, resArr[2]![0]);
+ Assert.AreEqual("9", resArr[2]![1]);
+
+ Assert.AreEqual(10, resArr[3]![0]);
+ Assert.AreEqual("10", resArr[3]![1]);
}
[Test]
- [Ignore("IGNITE-15939 TODO asch read null tuples")]
public async Task TestGetAllNonExistentKeysReturnsEmptyList()
{
var res = await Table.GetAllAsync(new[] { GetTuple(-100) });
- Assert.AreEqual(0, res.Count);
+ Assert.AreEqual(1, res.Count);
+ Assert.IsNull(res[0]);
}
[Test]
diff --git a/modules/platforms/dotnet/Apache.Ignite/Internal/Table/Table.cs b/modules/platforms/dotnet/Apache.Ignite/Internal/Table/Table.cs
index e554d5c..4e2eb18 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Internal/Table/Table.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/Internal/Table/Table.cs
@@ -83,7 +83,7 @@ namespace Apache.Ignite.Internal.Table
}
/// <inheritdoc/>
- public async Task<IList<IIgniteTuple>> GetAllAsync(IEnumerable<IIgniteTuple> keys)
+ public async Task<IList<IIgniteTuple?>> GetAllAsync(IEnumerable<IIgniteTuple> keys)
{
IgniteArgumentCheck.NotNull(keys, nameof(keys));
@@ -102,7 +102,8 @@ namespace Apache.Ignite.Internal.Table
using var resBuf = await _socket.DoOutInOpAsync(ClientOp.TupleGetAll, writer).ConfigureAwait(false);
var resSchema = await ReadSchemaAsync(resBuf, schema).ConfigureAwait(false);
- return ReadTuples(resBuf, resSchema);
+ // TODO: Read value parts only (IGNITE-16022).
+ return ReadTuplesNullable(resBuf, resSchema);
}
/// <inheritdoc/>
@@ -188,6 +189,7 @@ namespace Apache.Ignite.Internal.Table
using var resBuf = await _socket.DoOutInOpAsync(ClientOp.TupleInsertAll, writer).ConfigureAwait(false);
var resSchema = await ReadSchemaAsync(resBuf, schema).ConfigureAwait(false);
+ // TODO: Read value parts only (IGNITE-16022).
return ReadTuples(resBuf, resSchema);
}
@@ -299,6 +301,7 @@ namespace Apache.Ignite.Internal.Table
using var resBuf = await _socket.DoOutInOpAsync(ClientOp.TupleDeleteAll, writer).ConfigureAwait(false);
var resSchema = await ReadSchemaAsync(resBuf, schema).ConfigureAwait(false);
+ // TODO: Read value parts only (IGNITE-16022).
return ReadTuples(resBuf, resSchema, keyOnly: true);
}
@@ -393,6 +396,30 @@ namespace Apache.Ignite.Internal.Table
return res;
}
+ private static IList<IIgniteTuple?> ReadTuplesNullable(PooledBuffer buf, Schema? schema, bool keyOnly = false)
+ {
+ if (schema == null)
+ {
+ return Array.Empty<IIgniteTuple?>();
+ }
+
+ // Skip schema version.
+ var r = buf.GetReader();
+ r.Skip();
+
+ var count = r.ReadInt32();
+ var res = new List<IIgniteTuple?>(count);
+
+ for (var i = 0; i < count; i++)
+ {
+ var hasValue = r.ReadBoolean();
+
+ res.Add(hasValue ? ReadTuple(ref r, schema, keyOnly) : null);
+ }
+
+ return res;
+ }
+
private static int? ReadSchemaVersion(PooledBuffer buf)
{
var reader = buf.GetReader();
diff --git a/modules/platforms/dotnet/Apache.Ignite/Table/ITableView.cs b/modules/platforms/dotnet/Apache.Ignite/Table/ITableView.cs
index d708fbf..2dc2610 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Table/ITableView.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/Table/ITableView.cs
@@ -45,9 +45,11 @@ namespace Apache.Ignite.Table
/// <param name="keys">Collection of records with key columns set.</param>
/// <returns>
/// A <see cref="Task"/> representing the asynchronous operation.
- /// The task result contains matching records with all columns.
+ /// The task result contains matching records with all columns filled from the table. The order of collection
+ /// elements is guaranteed to be the same as the order of <paramref name="keys"/>. If a record does not exist,
+ /// the element at the corresponding index of the resulting collection will be <c>null</c>.
/// </returns>
- Task<IList<T>> GetAllAsync(IEnumerable<T> keys);
+ Task<IList<T?>> GetAllAsync(IEnumerable<T> keys);
/// <summary>
/// Inserts a record into the table if it does not exist or replaces the existing one.
diff --git a/modules/schema/src/main/java/org/apache/ignite/internal/schema/registry/SchemaRegistryImpl.java b/modules/schema/src/main/java/org/apache/ignite/internal/schema/registry/SchemaRegistryImpl.java
index 333942a..3f47225 100644
--- a/modules/schema/src/main/java/org/apache/ignite/internal/schema/registry/SchemaRegistryImpl.java
+++ b/modules/schema/src/main/java/org/apache/ignite/internal/schema/registry/SchemaRegistryImpl.java
@@ -32,7 +32,6 @@ import org.apache.ignite.internal.schema.SchemaRegistry;
import org.apache.ignite.internal.schema.mapping.ColumnMapper;
import org.apache.ignite.internal.schema.mapping.ColumnMapping;
import org.apache.ignite.internal.schema.row.Row;
-import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
@@ -160,8 +159,12 @@ public class SchemaRegistryImpl implements SchemaRegistry {
* @param curSchema The latest available local schema.
* @return Schema-aware rows.
*/
- @NotNull
+ @Nullable
private Row resolveInternal(BinaryRow row, SchemaDescriptor curSchema) {
+ if (row == null) {
+ return null;
+ }
+
final SchemaDescriptor rowSchema = schema(row.schemaVersion());
if (curSchema.version() == rowSchema.version()) {