You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ib...@apache.org on 2021/09/27 09:08:14 UTC
[ignite-3] branch revert-353-ignite-15548 created (now 55fff70)
This is an automated email from the ASF dual-hosted git repository.
ibessonov pushed a change to branch revert-353-ignite-15548
in repository https://gitbox.apache.org/repos/asf/ignite-3.git.
at 55fff70 Revert "IGNITE-15548 Fix Table API classes hierarchy (#353)"
This branch includes the following new commits:
new 55fff70 Revert "IGNITE-15548 Fix Table API classes hierarchy (#353)"
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[ignite-3] 01/01: Revert "IGNITE-15548 Fix Table API classes
hierarchy (#353)"
Posted by ib...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ibessonov pushed a commit to branch revert-353-ignite-15548
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
commit 55fff70ddfcf60250666ec30567f6381648b4a9c
Author: ibessonov <be...@gmail.com>
AuthorDate: Mon Sep 27 12:08:07 2021 +0300
Revert "IGNITE-15548 Fix Table API classes hierarchy (#353)"
This reverts commit 0c82a79220df82f304ea60a1c624e5effbac936d.
---
assembly/README.md | 2 +-
docs/_docs/quick-start/getting-started-guide.adoc | 2 +-
examples/README.md | 2 +-
.../example/table/KeyValueBinaryViewExample.java | 8 +-
.../apache/ignite/example/table/TableExample.java | 5 +-
.../apache/ignite/table/KeyValueBinaryView.java | 29 ++
.../java/org/apache/ignite/table/KeyValueView.java | 2 +-
.../java/org/apache/ignite/table/RecordView.java | 358 ++-----------------
.../main/java/org/apache/ignite/table/Table.java | 41 ++-
.../table/{RecordView.java => TableView.java} | 8 +-
.../table/ClientTupleContainsKeyRequest.java | 2 +-
.../table/ClientTupleDeleteAllExactRequest.java | 2 +-
.../table/ClientTupleDeleteAllRequest.java | 2 +-
.../table/ClientTupleDeleteExactRequest.java | 2 +-
.../requests/table/ClientTupleDeleteRequest.java | 2 +-
.../requests/table/ClientTupleGetAllRequest.java | 2 +-
.../table/ClientTupleGetAndDeleteRequest.java | 2 +-
.../table/ClientTupleGetAndReplaceRequest.java | 2 +-
.../ClientTupleGetAndReplaceSchemalessRequest.java | 2 +-
.../table/ClientTupleGetAndUpsertRequest.java | 2 +-
.../ClientTupleGetAndUpsertSchemalessRequest.java | 2 +-
.../requests/table/ClientTupleGetRequest.java | 2 +-
.../table/ClientTupleInsertAllRequest.java | 2 +-
.../ClientTupleInsertAllSchemalessRequest.java | 2 +-
.../requests/table/ClientTupleInsertRequest.java | 2 +-
.../table/ClientTupleInsertSchemalessRequest.java | 2 +-
.../table/ClientTupleReplaceExactRequest.java | 2 +-
.../ClientTupleReplaceExactSchemalessRequest.java | 2 +-
.../requests/table/ClientTupleReplaceRequest.java | 2 +-
.../table/ClientTupleReplaceSchemalessRequest.java | 2 +-
.../table/ClientTupleUpsertAllRequest.java | 2 +-
.../ClientTupleUpsertAllSchemalessRequest.java | 2 +-
.../requests/table/ClientTupleUpsertRequest.java | 2 +-
.../table/ClientTupleUpsertSchemalessRequest.java | 2 +-
.../client/table/ClientKeyValueBinaryView.java | 33 +-
.../client/table/ClientRecordBinaryView.java | 319 -----------------
.../ignite/internal/client/table/ClientTable.java | 308 ++++++++++++++++-
.../ignite/internal/client/table/ClientTables.java | 6 +-
.../ignite/internal/client/table/ClientTuple.java | 4 +-
.../client/ClientKeyValueBinaryViewTest.java | 52 +--
.../org/apache/ignite/client/ClientTableTest.java | 39 ++-
.../ignite/client/fakes/FakeIgniteTables.java | 1 +
.../runner/app/ITDynamicTableCreationTest.java | 51 ++-
.../runner/app/ITIgniteNodeRestartTest.java | 4 +-
.../runner/app/ITLiveSchemaChangeKVViewTest.java | 26 +-
.../runner/app/ITLiveSchemaChangeTableTest.java | 79 ++---
.../runner/app/ITSchemaChangeKVViewTest.java | 12 +-
.../runner/app/ITSchemaChangeTableViewTest.java | 14 +-
.../internal/runner/app/ITTableCreationTest.java | 39 +--
.../runner/app/ITThinClientConnectionTest.java | 11 +-
.../runner/app/jdbc/ITJdbcMetadataSelfTest.java | 4 +-
.../ignite/distributed/ITDistributedTableTest.java | 13 +-
.../ignite/internal/table/AbstractTableView.java | 30 +-
...ueBinaryViewImpl.java => KVBinaryViewImpl.java} | 10 +-
.../{KeyValueViewImpl.java => KVViewImpl.java} | 8 +-
.../internal/table/RecordBinaryViewImpl.java | 377 ---------------------
.../ignite/internal/table/RecordViewImpl.java | 18 +
.../apache/ignite/internal/table/TableImpl.java | 359 ++++++++++++++++++--
.../internal/table/distributed/TableManager.java | 7 +-
.../org/apache/ignite/internal/table/Example.java | 28 +-
...nsTest.java => KVBinaryViewOperationsTest.java} | 32 +-
.../internal/table/StrictSchemaOperationsTest.java | 31 +-
...est.java => TableBinaryViewOperationsTest.java} | 27 +-
.../org/apache/ignite/internal/table/TxTest.java | 37 +-
64 files changed, 1052 insertions(+), 1432 deletions(-)
diff --git a/assembly/README.md b/assembly/README.md
index 982f40b..b67644c 100644
--- a/assembly/README.md
+++ b/assembly/README.md
@@ -38,7 +38,7 @@ To start running you simply need to import provided `pom.xml` file into your fav
The following examples are included:
* `TableExample` - demonstrates the usage of the `org.apache.ignite.table.Table` API
-* `KeyValueBinaryViewExample` - demonstrates the usage of the `org.apache.ignite.table.KeyValueView` API
+* `KeyValueBinaryViewExample` - demonstrates the usage of the `org.apache.ignite.table.KeyValueBinaryView` API
To run an example, do the following:
1. Import the examples project into you IDE.
diff --git a/docs/_docs/quick-start/getting-started-guide.adoc b/docs/_docs/quick-start/getting-started-guide.adoc
index 5b7e527..e04dacd 100644
--- a/docs/_docs/quick-start/getting-started-guide.adoc
+++ b/docs/_docs/quick-start/getting-started-guide.adoc
@@ -187,7 +187,7 @@ Ignite 3.0 alpha 2 comes with examples that are configured as a separate Maven p
The project includes the following examples:
* `TableExample` demonstrates the usage of the `org.apache.ignite.table.Table` API to create a table. It also shows how to get data from a table, or insert a line into a table.
-* `KeyValueBinaryViewExample` - demonstrates the usage of the `org.apache.ignite.table.KeyValueView` API to insert a line into a table.
+* `KeyValueBinaryViewExample` - demonstrates the usage of the `org.apache.ignite.table.KeyValueBinaryView` API to insert a line into a table.
To run an example:
diff --git a/examples/README.md b/examples/README.md
index ad4d977..98934bc 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -7,7 +7,7 @@ to import provided `pom.xml` file into your favourite IDE.
The following examples are included:
* `TableExample` - demonstrates the usage of the `org.apache.ignite.table.Table` API
-* `KeyValueBinaryViewExample` - demonstrates the usage of the `org.apache.ignite.table.KeyValueView` API
+* `KeyValueBinaryViewExample` - demonstrates the usage of the `org.apache.ignite.table.KeyValueBinaryView` API
To run an example, do the following:
1. Import the examples project into you IDE.
diff --git a/examples/src/main/java/org/apache/ignite/example/table/KeyValueBinaryViewExample.java b/examples/src/main/java/org/apache/ignite/example/table/KeyValueBinaryViewExample.java
index 4173ace..63511ed 100644
--- a/examples/src/main/java/org/apache/ignite/example/table/KeyValueBinaryViewExample.java
+++ b/examples/src/main/java/org/apache/ignite/example/table/KeyValueBinaryViewExample.java
@@ -21,12 +21,12 @@ import java.nio.file.Files;
import java.nio.file.Path;
import org.apache.ignite.app.Ignite;
import org.apache.ignite.app.IgnitionManager;
-import org.apache.ignite.table.KeyValueView;
+import org.apache.ignite.table.KeyValueBinaryView;
import org.apache.ignite.table.Table;
import org.apache.ignite.table.Tuple;
/**
- * This example demonstrates the usage of the {@link KeyValueView} API.
+ * This example demonstrates the usage of the {@link KeyValueBinaryView} API.
* <p>
* To run the example, do the following:
* <ol>
@@ -79,7 +79,7 @@ public class KeyValueBinaryViewExample {
)
);
- KeyValueView<Tuple, Tuple> kvView = accounts.keyValueView();
+ KeyValueBinaryView kvView = accounts.kvView();
//---------------------------------------------------------------------------------
//
@@ -103,7 +103,7 @@ public class KeyValueBinaryViewExample {
//
//---------------------------------------------------------------------------------
- value = accounts.recordView().get(key);
+ value = accounts.get(key);
System.out.println(
"Retrieved using Key-Value API\n" +
diff --git a/examples/src/main/java/org/apache/ignite/example/table/TableExample.java b/examples/src/main/java/org/apache/ignite/example/table/TableExample.java
index 0affc66..6fdd0f4 100644
--- a/examples/src/main/java/org/apache/ignite/example/table/TableExample.java
+++ b/examples/src/main/java/org/apache/ignite/example/table/TableExample.java
@@ -21,7 +21,6 @@ import java.nio.file.Files;
import java.nio.file.Path;
import org.apache.ignite.app.Ignite;
import org.apache.ignite.app.IgnitionManager;
-import org.apache.ignite.table.RecordView;
import org.apache.ignite.table.Table;
import org.apache.ignite.table.Tuple;
@@ -62,7 +61,7 @@ public class TableExample {
//
//---------------------------------------------------------------------------------
- RecordView<Tuple> accounts = ignite.tables().createTable("PUBLIC.accounts", tbl -> tbl
+ Table accounts = ignite.tables().createTable("PUBLIC.accounts", tbl -> tbl
.changeName("PUBLIC.accounts")
.changeColumns(cols -> cols
.create("0", c -> c.changeName("accountNumber").changeType(t -> t.changeType("int32")).changeNullable(false))
@@ -77,7 +76,7 @@ public class TableExample {
.changeColumns(cols -> cols.create("0", c -> c.changeName("accountNumber").changeAsc(true)))
)
)
- ).recordView();
+ );
//---------------------------------------------------------------------------------
//
diff --git a/modules/api/src/main/java/org/apache/ignite/table/KeyValueBinaryView.java b/modules/api/src/main/java/org/apache/ignite/table/KeyValueBinaryView.java
new file mode 100644
index 0000000..98b3157
--- /dev/null
+++ b/modules/api/src/main/java/org/apache/ignite/table/KeyValueBinaryView.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.table;
+
+import org.apache.ignite.tx.Transaction;
+
+/**
+ * Key-value view of table provides methods to access the data using key-value approach and
+ * regarding the binary object concept.
+ */
+public interface KeyValueBinaryView extends KeyValueView<Tuple, Tuple> {
+ /** {@inheritDoc} */
+ @Override KeyValueBinaryView withTransaction(Transaction tx);
+}
diff --git a/modules/api/src/main/java/org/apache/ignite/table/KeyValueView.java b/modules/api/src/main/java/org/apache/ignite/table/KeyValueView.java
index 8275474..ebd2021 100644
--- a/modules/api/src/main/java/org/apache/ignite/table/KeyValueView.java
+++ b/modules/api/src/main/java/org/apache/ignite/table/KeyValueView.java
@@ -399,7 +399,7 @@ public interface KeyValueView<K, V> {
@Nullable Transaction transaction();
/**
- * Enlists a view into the transaction.
+ * Enslists a view into the transaction.
*
* @param tx The transaction.
* @return Transactional view.
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 1352515..eb404be 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
@@ -17,353 +17,43 @@
package org.apache.ignite.table;
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.Map;
import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.table.mapper.Mappers;
import org.apache.ignite.tx.Transaction;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
/**
- * Table view interface provides methods to access table records.
+ * Record view of table provides methods to access table records.
+ * <p>
*
- * @param <R> Mapped record type.
+ * @param <R> Record type.
+ * @apiNote 'Record class field' >-< 'table column' mapping laid down in implementation.
+ * @apiNote Some methods require a record with the only key fields set. This is not mandatory requirement
+ * and value fields will be just ignored.
+ * @see Mappers
*/
-public interface RecordView<R> {
+public interface RecordView<R> extends TableView<R> {
/**
- * Gets a record with same key columns values as given one from the table.
+ * Fills given record with the values from the table.
+ * Similar to {@link #get(Object)}, but return original object with filled value fields.
+ * <p>
+ * All value fields of given object will be rewritten.
*
- * @param keyRec A record with key columns set.
- * The record cannot be {@code null}.
- * @return A record with all columns filled from the table.
+ * @param recObjToFill Record object with key fields to be filled.
+ * @return Record with all fields filled from the table.
*/
- R get(@NotNull R keyRec);
+ R fill(R recObjToFill);
/**
- * Asynchronously gets a record with same key columns values as given one from the table.
+ * Asynchronously fills given record with the values from the table.
+ * Similar to {@link #get(Object)}, but return original object with filled value fields.
+ * <p>
+ * All value fields of given object will be rewritten.
*
- * @param keyRec A record with key columns set.
- * The record cannot be {@code null}.
+ * @param recObjToFill Record object with key fields to be filled.
* @return Future representing pending completion of the operation.
*/
- @NotNull CompletableFuture<R> getAsync(@NotNull R keyRec);
+ CompletableFuture<R> fillAsync(R recObjToFill);
- /**
- * 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.
- */
- Collection<R> getAll(@NotNull Collection<R> keyRecs);
-
- /**
- * Asynchronously get records from the table.
- *
- * @param keyRecs Records with key columns set.
- * The records cannot be {@code null}.
- * @return Future representing pending completion of the operation.
- */
- @NotNull CompletableFuture<Collection<R>> getAllAsync(@NotNull Collection<R> keyRecs);
-
- /**
- * Inserts a record into the table if does not exist or replaces the existed one.
- *
- * @param rec A record to insert into the table.
- * The record cannot be {@code null}.
- */
- void upsert(@NotNull R rec);
-
- /**
- * Asynchronously inserts a record into the table if does not exist or replaces the existed one.
- *
- * @param rec A record to insert into the table.
- * The record cannot be {@code null}.
- * @return Future representing pending completion of the operation.
- */
- @NotNull CompletableFuture<Void> upsertAsync(@NotNull R rec);
-
- /**
- * Insert records into the table if does not exist or replaces the existed one.
- *
- * @param recs Records to insert into the table.
- * The records cannot be {@code null}.
- */
- void upsertAll(@NotNull Collection<R> recs);
-
- /**
- * Asynchronously inserts a record into the table if does not exist or replaces the existed one.
- *
- * @param recs Records to insert into the table.
- * The records cannot be {@code null}.
- * @return Future representing pending completion of the operation.
- */
- @NotNull CompletableFuture<Void> upsertAllAsync(@NotNull Collection<R> recs);
-
- /**
- * Inserts a record into the table or replaces if exists and return replaced previous record.
- *
- * @param rec A record to insert into the table.
- * The record cannot be {@code null}.
- * @return Replaced record or {@code null} if not existed.
- */
- R getAndUpsert(@NotNull R rec);
-
- /**
- * Asynchronously inserts a record into the table or replaces if exists and return replaced previous record.
- *
- * @param rec A record to insert into the table.
- * The record cannot be {@code null}.
- * @return Future representing pending completion of the operation.
- */
- @NotNull CompletableFuture<R> getAndUpsertAsync(@NotNull R rec);
-
- /**
- * Inserts a record into the table if not exists.
- *
- * @param rec A record to insert into the table.
- * The record cannot be {@code null}.
- * @return {@code True} if successful, {@code false} otherwise.
- */
- boolean insert(@NotNull R rec);
-
- /**
- * Asynchronously inserts a record into the table if not exists.
- *
- * @param rec A record to insert into the table.
- * The record cannot be {@code null}.
- * @return Future representing pending completion of the operation.
- */
- @NotNull CompletableFuture<Boolean> insertAsync(@NotNull R rec);
-
- /**
- * Insert records into the table which do not exist, skipping existed ones.
- *
- * @param recs Records to insert into the table.
- * The records cannot be {@code null}.
- * @return Skipped records.
- */
- Collection<R> insertAll(@NotNull Collection<R> recs);
-
- /**
- * Asynchronously insert records into the table which do not exist, skipping existed ones.
- *
- * @param recs Records to insert into the table.
- * The records cannot be {@code null}.
- * @return Future representing pending completion of the operation.
- */
- @NotNull CompletableFuture<Collection<R>> insertAllAsync(@NotNull Collection<R> recs);
-
- /**
- * Replaces an existed record associated with the same key columns values as the given one has.
- *
- * @param rec A record to replace with.
- * The record cannot be {@code null}.
- * @return {@code True} if old record was found and replaced successfully, {@code false} otherwise.
- */
- boolean replace(@NotNull R rec);
-
- /**
- * Asynchronously replaces an existed record associated with the same key columns values as the given one has.
- *
- * @param rec A record to replace with.
- * The record cannot be {@code null}.
- * @return Future representing pending completion of the operation.
- */
- @NotNull CompletableFuture<Boolean> replaceAsync(@NotNull R rec);
-
- /**
- * Replaces an expected record in the table with the given new one.
- *
- * @param oldRec A record to replace.
- * The record cannot be {@code null}.
- * @param newRec A record to replace with.
- * The record cannot be {@code null}.
- * @return {@code True} if the old record replaced successfully, {@code false} otherwise.
- */
- boolean replace(@NotNull R oldRec, @NotNull R newRec);
-
- /**
- * Asynchronously replaces an expected record in the table with the given new one.
- *
- * @param oldRec A record to replace.
- * The record cannot be {@code null}.
- * @param newRec A record to replace with.
- * The record cannot be {@code null}.
- * @return Future representing pending completion of the operation.
- */
- @NotNull CompletableFuture<Boolean> replaceAsync(@NotNull R oldRec, @NotNull R newRec);
-
- /**
- * Gets an existed record associated with the same key columns values as the given one has,
- * then replaces with the given one.
- *
- * @param rec A record to replace with.
- * The record cannot be {@code null}.
- * @return Replaced record or {@code null} if not existed.
- */
- R getAndReplace(@NotNull R rec);
-
- /**
- * Asynchronously gets an existed record associated with the same key columns values as the given one has,
- * then replaces with the given one.
- *
- * @param rec A record to replace with.
- * The record cannot be {@code null}.
- * @return Future representing pending completion of the operation.
- */
- @NotNull CompletableFuture<R> getAndReplaceAsync(@NotNull R rec);
-
- /**
- * Deletes a record with the same key columns values as the given one from the table.
- *
- * @param keyRec A record with key columns set.
- * The record cannot be {@code null}.
- * @return {@code True} if removed successfully, {@code false} otherwise.
- */
- boolean delete(@NotNull R keyRec);
-
- /**
- * Asynchronously deletes a record with the same key columns values as the given one from the table.
- *
- * @param keyRec A record with key columns set.
- * The record cannot be {@code null}.
- * @return Future representing pending completion of the operation.
- */
- @NotNull CompletableFuture<Boolean> deleteAsync(@NotNull R keyRec);
-
- /**
- * Deletes the given record from the table.
- *
- * @param rec A record to delete.
- * The record cannot be {@code null}.
- * @return {@code True} if removed successfully, {@code false} otherwise.
- */
- boolean deleteExact(@NotNull R rec);
-
- /**
- * Asynchronously deletes given record from the table.
- *
- * @param rec A record to delete.
- * The record cannot be {@code null}.
- * @return Future representing pending completion of the operation.
- */
- @NotNull CompletableFuture<Boolean> deleteExactAsync(@NotNull R rec);
-
- /**
- * Gets then deletes a record with the same key columns values from the table.
- *
- * @param rec A record with key columns set.
- * The record cannot be {@code null}.
- * @return Removed record or {@code null} if not existed.
- */
- R getAndDelete(@NotNull R rec);
-
- /**
- * Asynchronously gets then deletes a record with the same key columns values from the table.
- *
- * @param rec A record with key columns set.
- * The record cannot be {@code null}.
- * @return Future representing pending completion of the operation.
- */
- @NotNull CompletableFuture<R> getAndDeleteAsync(@NotNull R rec);
-
- /**
- * Remove records with the same key columns values as the given one has from the table.
- *
- * @param recs Records with key columns set.
- * The records cannot be {@code null}.
- * @return Records with key columns set that did not exist.
- */
- Collection<R> deleteAll(@NotNull Collection<R> recs);
-
- /**
- * Asynchronously remove records with the same key columns values as the given one has from the table.
- *
- * @param recs Records with key columns set.
- * The records cannot be {@code null}.
- * @return Future representing pending completion of the operation.
- */
- @NotNull CompletableFuture<Collection<R>> deleteAllAsync(@NotNull Collection<R> recs);
-
- /**
- * Remove given records from the table.
- *
- * @param recs Records to delete.
- * The records cannot be {@code null}.
- * @return Records that were not deleted.
- */
- Collection<R> deleteAllExact(@NotNull Collection<R> recs);
-
- /**
- * Asynchronously remove given records from the table.
- *
- * @param recs Records to delete.
- * The records cannot be {@code null}.
- * @return Future representing pending completion of the operation.
- */
- @NotNull CompletableFuture<Collection<R>> deleteAllExactAsync(@NotNull Collection<R> recs);
-
- /**
- * Executes an InvokeProcessor code against a record with the same key columns values as the given one has.
- *
- * @param keyRec A record with key columns set.
- * The record cannot be {@code null}.
- * @param proc Invoke processor.
- * @param <T> InvokeProcessor result type.
- * @return Results of the processing.
- */
- <T extends Serializable> T invoke(@NotNull R keyRec, InvokeProcessor<R, R, T> proc);
-
- /**
- * Asynchronously executes an InvokeProcessor code against a record
- * with the same key columns values as the given one has.
- *
- * @param keyRec A record with key columns set.
- * The record cannot be {@code null}.
- * @param proc Invoke processor.
- * @param <T> InvokeProcessor result type.
- * @return Future representing pending completion of the operation.
- */
- @NotNull <T extends Serializable> CompletableFuture<T> invokeAsync(@NotNull R keyRec, InvokeProcessor<R, R, T> proc);
-
- /**
- * Executes an InvokeProcessor code against records with the same key columns values as the given ones has.
- *
- * @param keyRecs Records with key columns set.
- * The records cannot be {@code null}.
- * @param proc Invoke processor.
- * @param <T> InvokeProcessor result type.
- * @return Results of the processing.
- */
- <T extends Serializable> Map<R, T> invokeAll(@NotNull Collection<R> keyRecs, InvokeProcessor<R, R, T> proc);
-
- /**
- * Asynchronously executes an InvokeProcessor against records with the same key columns values as the given ones
- * has.
- *
- * @param keyRecs Records with key columns set.
- * The records cannot be {@code null}.
- * @param proc Invoke processor.
- * @param <T> InvokeProcessor result type.
- * @return Results of the processing.
- */
- @NotNull <T extends Serializable> CompletableFuture<Map<R, T>> invokeAllAsync(@NotNull Collection<R> keyRecs,
- InvokeProcessor<R, R, T> proc);
-
- /**
- * Returns current transaction.
- *
- * @return Current transaction or null if a table is not enlisted in a transaction.
- */
- @Nullable Transaction transaction();
-
- /**
- * Enlists a view into the transaction.
- *
- * @param tx The transaction.
- * @return Transactional view.
- */
- RecordView<R> withTransaction(Transaction tx);
+ /** {@inheritDoc} */
+ @Override RecordView<R> withTransaction(Transaction tx);
}
diff --git a/modules/api/src/main/java/org/apache/ignite/table/Table.java b/modules/api/src/main/java/org/apache/ignite/table/Table.java
index cd5be9e..f57b396 100644
--- a/modules/api/src/main/java/org/apache/ignite/table/Table.java
+++ b/modules/api/src/main/java/org/apache/ignite/table/Table.java
@@ -21,18 +21,26 @@ import org.apache.ignite.table.mapper.KeyMapper;
import org.apache.ignite.table.mapper.Mappers;
import org.apache.ignite.table.mapper.RecordMapper;
import org.apache.ignite.table.mapper.ValueMapper;
+import org.apache.ignite.tx.IgniteTransactions;
+import org.apache.ignite.tx.Transaction;
import org.jetbrains.annotations.NotNull;
/**
- * Table provides different views (key-value vs record) and approaches (mapped-object vs binary) to reach the data.
+ * Table view of table provides methods to access table records regarding binary object concept.
* <p>
- * Binary table views might be useful in cases (but not limited) when user key-value classes are not in classpath
- * and/or when deserialization of whole table record is unwanted due to performance reasons.
+ * Provided different views (key-value vs record) and approaches (mapped-object vs binary) to reach the data.
+ * <p>
+ * Binary table views might be useful in cases (but not limited) if user key-value classes are not in classpath
+ * or serialization/deserialization is unwanted due to performance reasons.
*
+ * @apiNote Some methods require a record with the only key columns set. This is not mandatory requirement
+ * and value columns will be just ignored.
* @see RecordView
+ * @see Table
* @see KeyValueView
+ * @see KeyValueBinaryView
*/
-public interface Table {
+public interface Table extends TableView<Tuple> {
/**
* Gets a name of the table.
*
@@ -50,13 +58,6 @@ public interface Table {
<R> RecordView<R> recordView(RecordMapper<R> recMapper);
/**
- * Creates record view of table regarding the binary object concept.
- *
- * @return Table record view.
- */
- RecordView<Tuple> recordView();
-
- /**
* Creates key-value view of table for key-value class mappers provided.
*
* @param keyMapper Key class mapper.
@@ -65,14 +66,24 @@ public interface Table {
* @param <V> Value type.
* @return Table key-value view.
*/
- <K, V> KeyValueView<K, V> keyValueView(KeyMapper<K> keyMapper, ValueMapper<V> valMapper);
+ <K, V> KeyValueView<K, V> kvView(KeyMapper<K> keyMapper, ValueMapper<V> valMapper);
/**
* Creates key-value view of table regarding the binary object concept.
*
* @return Table key-value view.
*/
- KeyValueView<Tuple, Tuple> keyValueView();
+ KeyValueBinaryView kvView();
+
+ /**
+ * Creates a transactional view of the table.
+ *
+ * @param tx The transaction.
+ * @return Transactional table view.
+ * @see Transaction
+ * @see IgniteTransactions
+ */
+ @Override Table withTransaction(Transaction tx);
/**
* Creates record view of table for record class provided.
@@ -94,7 +105,7 @@ public interface Table {
* @param <V> Value type.
* @return Table key-value view.
*/
- default <K, V> KeyValueView<K, V> keyValueView(Class<K> keyCls, Class<V> valCls) {
- return keyValueView(Mappers.ofKeyClass(keyCls), Mappers.ofValueClass(valCls));
+ default <K, V> KeyValueView<K, V> kvView(Class<K> keyCls, Class<V> valCls) {
+ return kvView(Mappers.ofKeyClass(keyCls), Mappers.ofValueClass(valCls));
}
}
diff --git a/modules/api/src/main/java/org/apache/ignite/table/RecordView.java b/modules/api/src/main/java/org/apache/ignite/table/TableView.java
similarity index 97%
copy from modules/api/src/main/java/org/apache/ignite/table/RecordView.java
copy to modules/api/src/main/java/org/apache/ignite/table/TableView.java
index 1352515..d85c8bd 100644
--- a/modules/api/src/main/java/org/apache/ignite/table/RecordView.java
+++ b/modules/api/src/main/java/org/apache/ignite/table/TableView.java
@@ -29,8 +29,10 @@ import org.jetbrains.annotations.Nullable;
* Table view interface provides methods to access table records.
*
* @param <R> Mapped record type.
+ * @apiNote Some methods require a record with the only key columns set. This is not mandatory requirement
+ * and value columns will be just ignored.
*/
-public interface RecordView<R> {
+public interface TableView<R> {
/**
* Gets a record with same key columns values as given one from the table.
*
@@ -360,10 +362,10 @@ public interface RecordView<R> {
@Nullable Transaction transaction();
/**
- * Enlists a view into the transaction.
+ * Enslists a view into the transaction.
*
* @param tx The transaction.
* @return Transactional view.
*/
- RecordView<R> withTransaction(Transaction tx);
+ TableView<R> withTransaction(Transaction tx);
}
diff --git a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleContainsKeyRequest.java b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleContainsKeyRequest.java
index 134894f..d45d726 100644
--- a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleContainsKeyRequest.java
+++ b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleContainsKeyRequest.java
@@ -45,6 +45,6 @@ public class ClientTupleContainsKeyRequest {
var table = readTable(in, tables);
var keyTuple = readTuple(in, table, true);
- return table.recordView().getAsync(keyTuple).thenAccept(t -> out.packBoolean(t != null));
+ return table.getAsync(keyTuple).thenAccept(t -> out.packBoolean(t != null));
}
}
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 2ab1346..28e428d 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
@@ -46,6 +46,6 @@ public class ClientTupleDeleteAllExactRequest {
var table = readTable(in, tables);
var tuples = readTuples(in, table, false);
- return table.recordView().deleteAllExactAsync(tuples).thenAccept(skippedTuples -> writeTuples(out, skippedTuples));
+ return table.deleteAllExactAsync(tuples).thenAccept(skippedTuples -> writeTuples(out, skippedTuples));
}
}
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 48da6c1..55a4786 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
@@ -47,6 +47,6 @@ public class ClientTupleDeleteAllRequest {
var table = readTable(in, tables);
var tuples = readTuples(in, table, true);
- return table.recordView().deleteAllAsync(tuples).thenAccept(skippedTuples -> writeTuples(out, skippedTuples, TuplePart.KEY));
+ return table.deleteAllAsync(tuples).thenAccept(skippedTuples -> writeTuples(out, skippedTuples, TuplePart.KEY));
}
}
diff --git a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleDeleteExactRequest.java b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleDeleteExactRequest.java
index 70aad7b..aa6f685 100644
--- a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleDeleteExactRequest.java
+++ b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleDeleteExactRequest.java
@@ -45,6 +45,6 @@ public class ClientTupleDeleteExactRequest {
var table = readTable(in, tables);
var tuple = readTuple(in, table, false);
- return table.recordView().deleteExactAsync(tuple).thenAccept(out::packBoolean);
+ return table.deleteExactAsync(tuple).thenAccept(out::packBoolean);
}
}
diff --git a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleDeleteRequest.java b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleDeleteRequest.java
index 0334104..00a9774 100644
--- a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleDeleteRequest.java
+++ b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleDeleteRequest.java
@@ -45,6 +45,6 @@ public class ClientTupleDeleteRequest {
var table = readTable(in, tables);
var tuple = readTuple(in, table, true);
- return table.recordView().deleteAsync(tuple).thenAccept(out::packBoolean);
+ return table.deleteAsync(tuple).thenAccept(out::packBoolean);
}
}
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 ad29f4c..a0eda84 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
@@ -46,6 +46,6 @@ public class ClientTupleGetAllRequest {
var table = readTable(in, tables);
var keyTuples = readTuples(in, table, true);
- return table.recordView().getAllAsync(keyTuples).thenAccept(tuples -> writeTuples(out, tuples));
+ return table.getAllAsync(keyTuples).thenAccept(tuples -> writeTuples(out, tuples));
}
}
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 53ad10d..1e57c44 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
@@ -47,6 +47,6 @@ 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.getAndDeleteAsync(tuple).thenAccept(resTuple -> writeTuple(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 431df9c..12d2654 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
@@ -47,6 +47,6 @@ 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.getAndReplaceAsync(tuple).thenAccept(resTuple -> writeTuple(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 f4ab17b..fad9917 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
@@ -46,6 +46,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.getAndReplaceAsync(tuple).thenAccept(resTuple -> writeTuple(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 59a749a..4b32399 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
@@ -47,6 +47,6 @@ 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.getAndUpsertAsync(tuple).thenAccept(resTuple -> writeTuple(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 b43e715..1f19a36 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
@@ -46,6 +46,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.getAndUpsertAsync(tuple).thenAccept(resTuple -> writeTuple(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 a7fafcd..e4ec08f 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
@@ -47,6 +47,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.getAsync(keyTuple).thenAccept(t -> writeTuple(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 19c1391..aa689f4 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
@@ -46,6 +46,6 @@ public class ClientTupleInsertAllRequest {
var table = readTable(in, tables);
var tuples = readTuples(in, table, false);
- return table.recordView().insertAllAsync(tuples).thenAccept(skippedTuples -> writeTuples(out, skippedTuples));
+ return table.insertAllAsync(tuples).thenAccept(skippedTuples -> writeTuples(out, skippedTuples));
}
}
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 be5b1ef..34cd9be 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
@@ -46,6 +46,6 @@ public class ClientTupleInsertAllSchemalessRequest {
var table = readTable(in, tables);
var tuples = readTuplesSchemaless(in);
- return table.recordView().insertAllAsync(tuples).thenAccept(skippedTuples -> writeTuples(out, skippedTuples));
+ return table.insertAllAsync(tuples).thenAccept(skippedTuples -> writeTuples(out, skippedTuples));
}
}
diff --git a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleInsertRequest.java b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleInsertRequest.java
index 0403000..7b73cbd 100644
--- a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleInsertRequest.java
+++ b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleInsertRequest.java
@@ -45,6 +45,6 @@ public class ClientTupleInsertRequest {
var table = readTable(in, tables);
var tuple = readTuple(in, table, false);
- return table.recordView().insertAsync(tuple).thenAccept(out::packBoolean);
+ return table.insertAsync(tuple).thenAccept(out::packBoolean);
}
}
diff --git a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleInsertSchemalessRequest.java b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleInsertSchemalessRequest.java
index 50a569b..fdf0831 100644
--- a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleInsertSchemalessRequest.java
+++ b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleInsertSchemalessRequest.java
@@ -45,6 +45,6 @@ public class ClientTupleInsertSchemalessRequest {
var table = readTable(in, tables);
var tuple = readTupleSchemaless(in);
- return table.recordView().insertAsync(tuple).thenAccept(out::packBoolean);
+ return table.insertAsync(tuple).thenAccept(out::packBoolean);
}
}
diff --git a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleReplaceExactRequest.java b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleReplaceExactRequest.java
index 1b5701d..7dce25c 100644
--- a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleReplaceExactRequest.java
+++ b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleReplaceExactRequest.java
@@ -49,6 +49,6 @@ public class ClientTupleReplaceExactRequest {
var oldTuple = readTuple(in, false, schema);
var newTuple = readTuple(in, false, schema);
- return table.recordView().replaceAsync(oldTuple, newTuple).thenAccept(out::packBoolean);
+ return table.replaceAsync(oldTuple, newTuple).thenAccept(out::packBoolean);
}
}
diff --git a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleReplaceExactSchemalessRequest.java b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleReplaceExactSchemalessRequest.java
index ef84689..cff276f 100644
--- a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleReplaceExactSchemalessRequest.java
+++ b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleReplaceExactSchemalessRequest.java
@@ -47,6 +47,6 @@ public class ClientTupleReplaceExactSchemalessRequest {
var oldTuple = readTupleSchemaless(in);
var newTuple = readTupleSchemaless(in);
- return table.recordView().replaceAsync(oldTuple, newTuple).thenAccept(out::packBoolean);
+ return table.replaceAsync(oldTuple, newTuple).thenAccept(out::packBoolean);
}
}
diff --git a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleReplaceRequest.java b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleReplaceRequest.java
index 68ff3d9..d4afcf4 100644
--- a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleReplaceRequest.java
+++ b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleReplaceRequest.java
@@ -45,6 +45,6 @@ public class ClientTupleReplaceRequest {
var table = readTable(in, tables);
var tuple = readTuple(in, table, false);
- return table.recordView().replaceAsync(tuple).thenAccept(out::packBoolean);
+ return table.replaceAsync(tuple).thenAccept(out::packBoolean);
}
}
diff --git a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleReplaceSchemalessRequest.java b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleReplaceSchemalessRequest.java
index 06a429e..7b4ac23 100644
--- a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleReplaceSchemalessRequest.java
+++ b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleReplaceSchemalessRequest.java
@@ -45,6 +45,6 @@ public class ClientTupleReplaceSchemalessRequest {
var table = readTable(in, tables);
var tuple = readTupleSchemaless(in);
- return table.recordView().replaceAsync(tuple).thenAccept(out::packBoolean);
+ return table.replaceAsync(tuple).thenAccept(out::packBoolean);
}
}
diff --git a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleUpsertAllRequest.java b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleUpsertAllRequest.java
index 8ab8d18..f8ad392 100644
--- a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleUpsertAllRequest.java
+++ b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleUpsertAllRequest.java
@@ -39,6 +39,6 @@ public class ClientTupleUpsertAllRequest {
var table = readTable(in, tables);
var tuples = readTuples(in, table, false);
- return table.recordView().upsertAllAsync(tuples);
+ return table.upsertAllAsync(tuples);
}
}
diff --git a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleUpsertAllSchemalessRequest.java b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleUpsertAllSchemalessRequest.java
index a30bc91..163b08e 100644
--- a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleUpsertAllSchemalessRequest.java
+++ b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleUpsertAllSchemalessRequest.java
@@ -39,6 +39,6 @@ public class ClientTupleUpsertAllSchemalessRequest {
var table = readTable(in, tables);
var tuples = readTuplesSchemaless(in);
- return table.recordView().upsertAllAsync(tuples);
+ return table.upsertAllAsync(tuples);
}
}
diff --git a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleUpsertRequest.java b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleUpsertRequest.java
index efbac5f..c33dc2e 100644
--- a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleUpsertRequest.java
+++ b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleUpsertRequest.java
@@ -39,6 +39,6 @@ public class ClientTupleUpsertRequest {
var table = readTable(in, tables);
var tuple = readTuple(in, table, false);
- return table.recordView().upsertAsync(tuple);
+ return table.upsertAsync(tuple);
}
}
diff --git a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleUpsertSchemalessRequest.java b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleUpsertSchemalessRequest.java
index fc6a30c..26f4181 100644
--- a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleUpsertSchemalessRequest.java
+++ b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTupleUpsertSchemalessRequest.java
@@ -39,6 +39,6 @@ public class ClientTupleUpsertSchemalessRequest {
var table = readTable(in, tables);
var tuple = readTupleSchemaless(in);
- return table.recordView().upsertAsync(tuple);
+ return table.upsertAsync(tuple);
}
}
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 cc0d7cf..73d8cfb 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
@@ -26,7 +26,7 @@ import java.util.concurrent.CompletableFuture;
import org.apache.ignite.internal.client.proto.ClientMessageUnpacker;
import org.apache.ignite.internal.client.proto.ClientOp;
import org.apache.ignite.table.InvokeProcessor;
-import org.apache.ignite.table.KeyValueView;
+import org.apache.ignite.table.KeyValueBinaryView;
import org.apache.ignite.table.Tuple;
import org.apache.ignite.tx.Transaction;
import org.jetbrains.annotations.NotNull;
@@ -35,7 +35,7 @@ import org.jetbrains.annotations.Nullable;
/**
* Client key-value view implementation for binary user-object representation.
*/
-public class ClientKeyValueBinaryView implements KeyValueView<Tuple, Tuple> {
+public class ClientKeyValueBinaryView implements KeyValueBinaryView {
/** Underlying table. */
private final ClientTable tbl;
@@ -161,12 +161,7 @@ public class ClientKeyValueBinaryView implements KeyValueView<Tuple, Tuple> {
/** {@inheritDoc} */
@Override public @NotNull CompletableFuture<Boolean> removeAsync(@NotNull Tuple key) {
- Objects.requireNonNull(key);
-
- return tbl.doSchemaOutOpAsync(
- ClientOp.TUPLE_DELETE,
- (s, w) -> tbl.writeTuple(key, s, w, true),
- ClientMessageUnpacker::unpackBoolean);
+ return tbl.deleteAsync(key);
}
/** {@inheritDoc} */
@@ -192,13 +187,7 @@ public class ClientKeyValueBinaryView implements KeyValueView<Tuple, Tuple> {
/** {@inheritDoc} */
@Override public @NotNull CompletableFuture<Collection<Tuple>> removeAllAsync(@NotNull Collection<Tuple> keys) {
- Objects.requireNonNull(keys);
-
- return tbl.doSchemaOutInOpAsync(
- ClientOp.TUPLE_DELETE_ALL,
- (s, w) -> tbl.writeTuples(keys, s, w, true),
- (schema, in) -> tbl.readTuples(schema, in, true),
- Collections.emptyList());
+ return tbl.deleteAllAsync(keys);
}
/** {@inheritDoc} */
@@ -268,7 +257,7 @@ public class ClientKeyValueBinaryView implements KeyValueView<Tuple, Tuple> {
InvokeProcessor<Tuple, Tuple, R> proc,
Serializable... args
) {
- throw new UnsupportedOperationException("Not implemented yet.");
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
@@ -277,7 +266,7 @@ public class ClientKeyValueBinaryView implements KeyValueView<Tuple, Tuple> {
InvokeProcessor<Tuple, Tuple, R> proc,
Serializable... args
) {
- throw new UnsupportedOperationException("Not implemented yet.");
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
@@ -286,7 +275,7 @@ public class ClientKeyValueBinaryView implements KeyValueView<Tuple, Tuple> {
InvokeProcessor<Tuple, Tuple, R> proc,
Serializable... args
) {
- throw new UnsupportedOperationException("Not implemented yet.");
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
@@ -295,18 +284,18 @@ public class ClientKeyValueBinaryView implements KeyValueView<Tuple, Tuple> {
InvokeProcessor<Tuple, Tuple, R> proc,
Serializable... args
) {
- throw new UnsupportedOperationException("Not implemented yet.");
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
@Override public @Nullable Transaction transaction() {
// TODO: Transactions IGNITE-15240
- throw new UnsupportedOperationException("Not implemented yet.");
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
- @Override public KeyValueView<Tuple, Tuple> withTransaction(Transaction tx) {
+ @Override public KeyValueBinaryView withTransaction(Transaction tx) {
// TODO: Transactions IGNITE-15240
- throw new UnsupportedOperationException("Not implemented yet.");
+ throw new UnsupportedOperationException();
}
}
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
deleted file mode 100644
index 033348c..0000000
--- a/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientRecordBinaryView.java
+++ /dev/null
@@ -1,319 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.client.table;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Objects;
-import java.util.concurrent.CompletableFuture;
-import org.apache.ignite.internal.client.proto.ClientMessageUnpacker;
-import org.apache.ignite.internal.client.proto.ClientOp;
-import org.apache.ignite.table.InvokeProcessor;
-import org.apache.ignite.table.RecordView;
-import org.apache.ignite.table.Tuple;
-import org.apache.ignite.tx.Transaction;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Client record view implementation for binary user-object representation.
- */
-public class ClientRecordBinaryView implements RecordView<Tuple> {
- /** Underlying table. */
- private final ClientTable tbl;
-
- /**
- * Constructor.
- *
- * @param tbl Table.
- */
- public ClientRecordBinaryView(ClientTable tbl) {
- assert tbl != null;
-
- this.tbl = tbl;
- }
-
- /** {@inheritDoc} */
- @Override public Tuple get(@NotNull Tuple keyRec) {
- return getAsync(keyRec).join();
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull CompletableFuture<Tuple> getAsync(@NotNull Tuple keyRec) {
- Objects.requireNonNull(keyRec);
-
- return tbl.doSchemaOutInOpAsync(
- ClientOp.TUPLE_GET,
- (schema, out) -> tbl.writeTuple(keyRec, schema, out, true),
- (inSchema, in) -> ClientTable.readValueTuple(inSchema, in, keyRec));
- }
-
- /** {@inheritDoc} */
- @Override public Collection<Tuple> getAll(@NotNull Collection<Tuple> keyRecs) {
- return getAllAsync(keyRecs).join();
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull CompletableFuture<Collection<Tuple>> getAllAsync(@NotNull Collection<Tuple> keyRecs) {
- Objects.requireNonNull(keyRecs);
-
- return tbl.doSchemaOutInOpAsync(
- ClientOp.TUPLE_GET_ALL,
- (s, w) -> tbl.writeTuples(keyRecs, s, w, true),
- tbl::readTuples,
- Collections.emptyList());
- }
-
- /** {@inheritDoc} */
- @Override public void upsert(@NotNull Tuple rec) {
- upsertAsync(rec).join();
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull CompletableFuture<Void> upsertAsync(@NotNull Tuple rec) {
- Objects.requireNonNull(rec);
-
- // TODO IGNITE-15194: Convert Tuple to a schema-order Array as a first step.
- // If it does not match the latest schema, then request latest and convert again.
- return tbl.doSchemaOutOpAsync(
- ClientOp.TUPLE_UPSERT,
- (s, w) -> tbl.writeTuple(rec, s, w),
- r -> null);
- }
-
- /** {@inheritDoc} */
- @Override public void upsertAll(@NotNull Collection<Tuple> recs) {
- upsertAllAsync(recs).join();
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull CompletableFuture<Void> upsertAllAsync(@NotNull Collection<Tuple> recs) {
- Objects.requireNonNull(recs);
-
- return tbl.doSchemaOutOpAsync(
- ClientOp.TUPLE_UPSERT_ALL,
- (s, w) -> tbl.writeTuples(recs, s, w, false),
- r -> null);
- }
-
- /** {@inheritDoc} */
- @Override public Tuple getAndUpsert(@NotNull Tuple rec) {
- return getAndUpsertAsync(rec).join();
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull CompletableFuture<Tuple> getAndUpsertAsync(@NotNull Tuple rec) {
- Objects.requireNonNull(rec);
-
- return tbl.doSchemaOutInOpAsync(
- ClientOp.TUPLE_GET_AND_UPSERT,
- (s, w) -> tbl.writeTuple(rec, s, w, false),
- (schema, in) -> ClientTable.readValueTuple(schema, in, rec));
- }
-
- /** {@inheritDoc} */
- @Override public boolean insert(@NotNull Tuple rec) {
- return insertAsync(rec).join();
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull CompletableFuture<Boolean> insertAsync(@NotNull Tuple rec) {
- Objects.requireNonNull(rec);
-
- return tbl.doSchemaOutOpAsync(
- ClientOp.TUPLE_INSERT,
- (s, w) -> tbl.writeTuple(rec, s, w, false),
- ClientMessageUnpacker::unpackBoolean);
- }
-
- /** {@inheritDoc} */
- @Override public Collection<Tuple> insertAll(@NotNull Collection<Tuple> recs) {
- return insertAllAsync(recs).join();
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull CompletableFuture<Collection<Tuple>> insertAllAsync(@NotNull Collection<Tuple> recs) {
- Objects.requireNonNull(recs);
-
- return tbl.doSchemaOutInOpAsync(
- ClientOp.TUPLE_INSERT_ALL,
- (s, w) -> tbl.writeTuples(recs, s, w, false),
- tbl::readTuples,
- Collections.emptyList());
- }
-
- /** {@inheritDoc} */
- @Override public boolean replace(@NotNull Tuple rec) {
- return replaceAsync(rec).join();
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull CompletableFuture<Boolean> replaceAsync(@NotNull Tuple rec) {
- Objects.requireNonNull(rec);
-
- return tbl.doSchemaOutOpAsync(
- ClientOp.TUPLE_REPLACE,
- (s, w) -> tbl.writeTuple(rec, s, w, false),
- ClientMessageUnpacker::unpackBoolean);
- }
-
- /** {@inheritDoc} */
- @Override public boolean replace(@NotNull Tuple oldRec, @NotNull Tuple newRec) {
- return replaceAsync(oldRec, newRec).join();
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull CompletableFuture<Boolean> replaceAsync(@NotNull Tuple oldRec, @NotNull Tuple newRec) {
- Objects.requireNonNull(oldRec);
- Objects.requireNonNull(newRec);
-
- return tbl.doSchemaOutOpAsync(
- ClientOp.TUPLE_REPLACE_EXACT,
- (s, w) -> {
- tbl.writeTuple(oldRec, s, w, false, false);
- tbl.writeTuple(newRec, s, w, false, true);
- },
- ClientMessageUnpacker::unpackBoolean);
- }
-
- /** {@inheritDoc} */
- @Override public Tuple getAndReplace(@NotNull Tuple rec) {
- return getAndReplaceAsync(rec).join();
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull CompletableFuture<Tuple> getAndReplaceAsync(@NotNull Tuple rec) {
- Objects.requireNonNull(rec);
-
- return tbl.doSchemaOutInOpAsync(
- ClientOp.TUPLE_GET_AND_REPLACE,
- (s, w) -> tbl.writeTuple(rec, s, w, false),
- (schema, in) -> ClientTable.readValueTuple(schema, in, rec));
- }
-
- /** {@inheritDoc} */
- @Override public boolean delete(@NotNull Tuple keyRec) {
- return deleteAsync(keyRec).join();
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull CompletableFuture<Boolean> deleteAsync(@NotNull Tuple keyRec) {
- Objects.requireNonNull(keyRec);
-
- return tbl.doSchemaOutOpAsync(
- ClientOp.TUPLE_DELETE,
- (s, w) -> tbl.writeTuple(keyRec, s, w, true),
- ClientMessageUnpacker::unpackBoolean);
- }
-
- /** {@inheritDoc} */
- @Override public boolean deleteExact(@NotNull Tuple rec) {
- return deleteExactAsync(rec).join();
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull CompletableFuture<Boolean> deleteExactAsync(@NotNull Tuple rec) {
- Objects.requireNonNull(rec);
-
- return tbl.doSchemaOutOpAsync(
- ClientOp.TUPLE_DELETE_EXACT,
- (s, w) -> tbl.writeTuple(rec, s, w, false),
- ClientMessageUnpacker::unpackBoolean);
- }
-
- /** {@inheritDoc} */
- @Override public Tuple getAndDelete(@NotNull Tuple rec) {
- return getAndDeleteAsync(rec).join();
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull CompletableFuture<Tuple> getAndDeleteAsync(@NotNull Tuple rec) {
- Objects.requireNonNull(rec);
-
- return tbl.doSchemaOutInOpAsync(
- ClientOp.TUPLE_GET_AND_DELETE,
- (s, w) -> tbl.writeTuple(rec, s, w, false),
- (schema, in) -> ClientTable.readValueTuple(schema, in, rec));
- }
-
- /** {@inheritDoc} */
- @Override public Collection<Tuple> deleteAll(@NotNull Collection<Tuple> recs) {
- return deleteAllAsync(recs).join();
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull CompletableFuture<Collection<Tuple>> deleteAllAsync(@NotNull Collection<Tuple> recs) {
- Objects.requireNonNull(recs);
-
- return tbl.doSchemaOutInOpAsync(
- ClientOp.TUPLE_DELETE_ALL,
- (s, w) -> tbl.writeTuples(recs, s, w, true),
- (schema, in) -> tbl.readTuples(schema, in, true),
- Collections.emptyList());
- }
-
- /** {@inheritDoc} */
- @Override public Collection<Tuple> deleteAllExact(@NotNull Collection<Tuple> recs) {
- return deleteAllExactAsync(recs).join();
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull CompletableFuture<Collection<Tuple>> deleteAllExactAsync(@NotNull Collection<Tuple> recs) {
- Objects.requireNonNull(recs);
-
- return tbl.doSchemaOutInOpAsync(
- ClientOp.TUPLE_DELETE_ALL_EXACT,
- (s, w) -> tbl.writeTuples(recs, s, w, false),
- tbl::readTuples,
- Collections.emptyList());
- }
-
- /** {@inheritDoc} */
- @Override public <T extends Serializable> T invoke(@NotNull Tuple keyRec, InvokeProcessor<Tuple, Tuple, T> proc) {
- throw new UnsupportedOperationException("Not implemented yet.");
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull <T extends Serializable> CompletableFuture<T> invokeAsync(@NotNull Tuple keyRec, InvokeProcessor<Tuple, Tuple, T> proc) {
- throw new UnsupportedOperationException("Not implemented yet.");
- }
-
- /** {@inheritDoc} */
- @Override public <T extends Serializable> Map<Tuple, T> invokeAll(@NotNull Collection<Tuple> keyRecs, InvokeProcessor<Tuple, Tuple, T> proc) {
- throw new UnsupportedOperationException("Not implemented yet.");
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull <T extends Serializable> CompletableFuture<Map<Tuple, T>> invokeAllAsync(@NotNull Collection<Tuple> keyRecs, InvokeProcessor<Tuple, Tuple, T> proc) {
- throw new UnsupportedOperationException("Not implemented yet.");
- }
-
- /** {@inheritDoc} */
- @Override public @Nullable Transaction transaction() {
- // TODO: Transactions IGNITE-15240
- throw new UnsupportedOperationException("Not implemented yet.");
- }
-
- /** {@inheritDoc} */
- @Override public ClientRecordBinaryView withTransaction(Transaction tx) {
- // TODO: Transactions IGNITE-15240
- throw new UnsupportedOperationException("Not implemented yet.");
- }
-}
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 188f775..d8b9fe2 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
@@ -17,16 +17,20 @@
package org.apache.ignite.internal.client.table;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Function;
+
import org.apache.ignite.client.IgniteClientException;
import org.apache.ignite.internal.client.ReliableChannel;
import org.apache.ignite.internal.client.proto.ClientMessagePacker;
@@ -35,6 +39,8 @@ import org.apache.ignite.internal.client.proto.ClientOp;
import org.apache.ignite.internal.tostring.IgniteToStringBuilder;
import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.table.InvokeProcessor;
+import org.apache.ignite.table.KeyValueBinaryView;
import org.apache.ignite.table.KeyValueView;
import org.apache.ignite.table.RecordView;
import org.apache.ignite.table.Table;
@@ -42,6 +48,7 @@ import org.apache.ignite.table.Tuple;
import org.apache.ignite.table.mapper.KeyMapper;
import org.apache.ignite.table.mapper.RecordMapper;
import org.apache.ignite.table.mapper.ValueMapper;
+import org.apache.ignite.tx.Transaction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.msgpack.core.MessageFormat;
@@ -68,6 +75,9 @@ public class ClientTable implements Table {
/** */
private final Object latestSchemaLock = new Object();
+ /** */
+ private final KeyValueBinaryView kvView;
+
/**
* Constructor.
*
@@ -83,6 +93,7 @@ public class ClientTable implements Table {
this.ch = ch;
this.id = id;
this.name = name;
+ this.kvView = new ClientKeyValueBinaryView(this);
}
/**
@@ -101,21 +112,284 @@ public class ClientTable implements Table {
/** {@inheritDoc} */
@Override public <R> RecordView<R> recordView(RecordMapper<R> recMapper) {
- throw new UnsupportedOperationException("Not implemented yet.");
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ @Override public <K, V> KeyValueView<K, V> kvView(KeyMapper<K> keyMapper, ValueMapper<V> valMapper) {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ @Override public KeyValueBinaryView kvView() {
+ return kvView;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Table withTransaction(Transaction tx) {
+ // TODO: Transactions IGNITE-15240
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ @Override public Tuple get(@NotNull Tuple keyRec) {
+ return getAsync(keyRec).join();
+ }
+
+ /** {@inheritDoc} */
+ @Override public @NotNull CompletableFuture<Tuple> getAsync(@NotNull Tuple keyRec) {
+ Objects.requireNonNull(keyRec);
+
+ return doSchemaOutInOpAsync(
+ ClientOp.TUPLE_GET,
+ (schema, out) -> writeTuple(keyRec, schema, out, true),
+ (inSchema, in) -> readValueTuple(inSchema, in, keyRec));
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<Tuple> getAll(@NotNull Collection<Tuple> keyRecs) {
+ return getAllAsync(keyRecs).join();
+ }
+
+ /** {@inheritDoc} */
+ @Override public @NotNull CompletableFuture<Collection<Tuple>> getAllAsync(@NotNull Collection<Tuple> keyRecs) {
+ Objects.requireNonNull(keyRecs);
+
+ return doSchemaOutInOpAsync(
+ ClientOp.TUPLE_GET_ALL,
+ (s, w) -> writeTuples(keyRecs, s, w, true),
+ this::readTuples,
+ Collections.emptyList());
+ }
+
+ /** {@inheritDoc} */
+ @Override public void upsert(@NotNull Tuple rec) {
+ upsertAsync(rec).join();
+ }
+
+ /** {@inheritDoc} */
+ @Override public @NotNull CompletableFuture<Void> upsertAsync(@NotNull Tuple rec) {
+ Objects.requireNonNull(rec);
+
+ // TODO IGNITE-15194: Convert Tuple to a schema-order Array as a first step.
+ // If it does not match the latest schema, then request latest and convert again.
+ return doSchemaOutOpAsync(
+ ClientOp.TUPLE_UPSERT,
+ (s, w) -> writeTuple(rec, s, w),
+ r -> null);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void upsertAll(@NotNull Collection<Tuple> recs) {
+ upsertAllAsync(recs).join();
+ }
+
+ /** {@inheritDoc} */
+ @Override public @NotNull CompletableFuture<Void> upsertAllAsync(@NotNull Collection<Tuple> recs) {
+ Objects.requireNonNull(recs);
+
+ return doSchemaOutOpAsync(
+ ClientOp.TUPLE_UPSERT_ALL,
+ (s, w) -> writeTuples(recs, s, w, false),
+ r -> null);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Tuple getAndUpsert(@NotNull Tuple rec) {
+ return getAndUpsertAsync(rec).join();
+ }
+
+ /** {@inheritDoc} */
+ @Override public @NotNull CompletableFuture<Tuple> getAndUpsertAsync(@NotNull Tuple rec) {
+ Objects.requireNonNull(rec);
+
+ return doSchemaOutInOpAsync(
+ ClientOp.TUPLE_GET_AND_UPSERT,
+ (s, w) -> writeTuple(rec, s, w, false),
+ (schema, in) -> readValueTuple(schema, in, rec));
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean insert(@NotNull Tuple rec) {
+ return insertAsync(rec).join();
+ }
+
+ /** {@inheritDoc} */
+ @Override public @NotNull CompletableFuture<Boolean> insertAsync(@NotNull Tuple rec) {
+ Objects.requireNonNull(rec);
+
+ return doSchemaOutOpAsync(
+ ClientOp.TUPLE_INSERT,
+ (s, w) -> writeTuple(rec, s, w, false),
+ ClientMessageUnpacker::unpackBoolean);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<Tuple> insertAll(@NotNull Collection<Tuple> recs) {
+ return insertAllAsync(recs).join();
+ }
+
+ /** {@inheritDoc} */
+ @Override public @NotNull CompletableFuture<Collection<Tuple>> insertAllAsync(@NotNull Collection<Tuple> recs) {
+ Objects.requireNonNull(recs);
+
+ return doSchemaOutInOpAsync(
+ ClientOp.TUPLE_INSERT_ALL,
+ (s, w) -> writeTuples(recs, s, w, false),
+ this::readTuples,
+ Collections.emptyList());
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean replace(@NotNull Tuple rec) {
+ return replaceAsync(rec).join();
+ }
+
+ /** {@inheritDoc} */
+ @Override public @NotNull CompletableFuture<Boolean> replaceAsync(@NotNull Tuple rec) {
+ Objects.requireNonNull(rec);
+
+ return doSchemaOutOpAsync(
+ ClientOp.TUPLE_REPLACE,
+ (s, w) -> writeTuple(rec, s, w, false),
+ ClientMessageUnpacker::unpackBoolean);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean replace(@NotNull Tuple oldRec, @NotNull Tuple newRec) {
+ return replaceAsync(oldRec, newRec).join();
+ }
+
+ /** {@inheritDoc} */
+ @Override public @NotNull CompletableFuture<Boolean> replaceAsync(@NotNull Tuple oldRec, @NotNull Tuple newRec) {
+ Objects.requireNonNull(oldRec);
+ Objects.requireNonNull(newRec);
+
+ return doSchemaOutOpAsync(
+ ClientOp.TUPLE_REPLACE_EXACT,
+ (s, w) -> {
+ writeTuple(oldRec, s, w, false, false);
+ writeTuple(newRec, s, w, false, true);
+ },
+ ClientMessageUnpacker::unpackBoolean);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Tuple getAndReplace(@NotNull Tuple rec) {
+ return getAndReplaceAsync(rec).join();
+ }
+
+ /** {@inheritDoc} */
+ @Override public @NotNull CompletableFuture<Tuple> getAndReplaceAsync(@NotNull Tuple rec) {
+ Objects.requireNonNull(rec);
+
+ return doSchemaOutInOpAsync(
+ ClientOp.TUPLE_GET_AND_REPLACE,
+ (s, w) -> writeTuple(rec, s, w, false),
+ (schema, in) -> readValueTuple(schema, in, rec));
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean delete(@NotNull Tuple keyRec) {
+ return deleteAsync(keyRec).join();
+ }
+
+ /** {@inheritDoc} */
+ @Override public @NotNull CompletableFuture<Boolean> deleteAsync(@NotNull Tuple keyRec) {
+ Objects.requireNonNull(keyRec);
+
+ return doSchemaOutOpAsync(
+ ClientOp.TUPLE_DELETE,
+ (s, w) -> writeTuple(keyRec, s, w, true),
+ ClientMessageUnpacker::unpackBoolean);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean deleteExact(@NotNull Tuple rec) {
+ return deleteExactAsync(rec).join();
+ }
+
+ /** {@inheritDoc} */
+ @Override public @NotNull CompletableFuture<Boolean> deleteExactAsync(@NotNull Tuple rec) {
+ Objects.requireNonNull(rec);
+
+ return doSchemaOutOpAsync(
+ ClientOp.TUPLE_DELETE_EXACT,
+ (s, w) -> writeTuple(rec, s, w, false),
+ ClientMessageUnpacker::unpackBoolean);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Tuple getAndDelete(@NotNull Tuple rec) {
+ return getAndDeleteAsync(rec).join();
+ }
+
+ /** {@inheritDoc} */
+ @Override public @NotNull CompletableFuture<Tuple> getAndDeleteAsync(@NotNull Tuple rec) {
+ Objects.requireNonNull(rec);
+
+ return doSchemaOutInOpAsync(
+ ClientOp.TUPLE_GET_AND_DELETE,
+ (s, w) -> writeTuple(rec, s, w, false),
+ (schema, in) -> readValueTuple(schema, in, rec));
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<Tuple> deleteAll(@NotNull Collection<Tuple> recs) {
+ return deleteAllAsync(recs).join();
+ }
+
+ /** {@inheritDoc} */
+ @Override public @NotNull CompletableFuture<Collection<Tuple>> deleteAllAsync(@NotNull Collection<Tuple> recs) {
+ Objects.requireNonNull(recs);
+
+ return doSchemaOutInOpAsync(
+ ClientOp.TUPLE_DELETE_ALL,
+ (s, w) -> writeTuples(recs, s, w, true),
+ (schema, in) -> readTuples(schema, in, true),
+ Collections.emptyList());
}
/** {@inheritDoc} */
- @Override public <K, V> KeyValueView<K, V> keyValueView(KeyMapper<K> keyMapper, ValueMapper<V> valMapper) {
- throw new UnsupportedOperationException("Not implemented yet.");
+ @Override public Collection<Tuple> deleteAllExact(@NotNull Collection<Tuple> recs) {
+ return deleteAllExactAsync(recs).join();
}
- @Override public RecordView<Tuple> recordView() {
- return new ClientRecordBinaryView(this);
+ /** {@inheritDoc} */
+ @Override public @NotNull CompletableFuture<Collection<Tuple>> deleteAllExactAsync(@NotNull Collection<Tuple> recs) {
+ Objects.requireNonNull(recs);
+
+ return doSchemaOutInOpAsync(
+ ClientOp.TUPLE_DELETE_ALL_EXACT,
+ (s, w) -> writeTuples(recs, s, w, false),
+ this::readTuples,
+ Collections.emptyList());
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T extends Serializable> T invoke(@NotNull Tuple keyRec, InvokeProcessor<Tuple, Tuple, T> proc) {
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
- @Override public KeyValueView<Tuple, Tuple> keyValueView() {
- return new ClientKeyValueBinaryView(this);
+ @Override public @NotNull <T extends Serializable> CompletableFuture<T> invokeAsync(@NotNull Tuple keyRec, InvokeProcessor<Tuple, Tuple, T> proc) {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T extends Serializable> Map<Tuple, T> invokeAll(@NotNull Collection<Tuple> keyRecs, InvokeProcessor<Tuple, Tuple, T> proc) {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ @Override public @NotNull <T extends Serializable> CompletableFuture<Map<Tuple, T>> invokeAllAsync(@NotNull Collection<Tuple> keyRecs, InvokeProcessor<Tuple, Tuple, T> proc) {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ @Override public @Nullable Transaction transaction() {
+ // TODO: Transactions IGNITE-15240
+ throw new UnsupportedOperationException();
}
private CompletableFuture<ClientSchema> getLatestSchema() {
@@ -310,6 +584,10 @@ public class ClientTable implements Table {
writeTuple(tuple, schema, out, keyOnly, true);
}
+ public static Tuple readTuple(ClientSchema schema, ClientMessageUnpacker in) {
+ return readTuple(schema, in, false);
+ }
+
private static Tuple readTuple(ClientSchema schema, ClientMessageUnpacker in, boolean keyOnly) {
var tuple = new ClientTuple(schema);
@@ -321,7 +599,7 @@ public class ClientTable implements Table {
return tuple;
}
- static Tuple readValueTuple(ClientSchema schema, ClientMessageUnpacker in, Tuple keyTuple) {
+ public static Tuple readValueTuple(ClientSchema schema, ClientMessageUnpacker in, Tuple keyTuple) {
var tuple = new ClientTuple(schema);
for (var i = 0; i < schema.columns().length; i++) {
@@ -337,7 +615,7 @@ public class ClientTable implements Table {
return tuple;
}
- static Tuple readValueTuple(ClientSchema schema, ClientMessageUnpacker in) {
+ public static Tuple readValueTuple(ClientSchema schema, ClientMessageUnpacker in) {
var keyColCnt = schema.keyColumnCount();
var colCnt = schema.columns().length;
@@ -353,7 +631,7 @@ public class ClientTable implements Table {
return valTuple;
}
- static IgniteBiTuple<Tuple, Tuple> readKvTuple(ClientSchema schema, ClientMessageUnpacker in) {
+ public static IgniteBiTuple<Tuple, Tuple> readKvTuple(ClientSchema schema, ClientMessageUnpacker in) {
var keyColCnt = schema.keyColumnCount();
var colCnt = schema.columns().length;
@@ -385,11 +663,11 @@ public class ClientTable implements Table {
return res;
}
- Collection<Tuple> readTuples(ClientSchema schema, ClientMessageUnpacker in) {
+ public Collection<Tuple> readTuples(ClientSchema schema, ClientMessageUnpacker in) {
return readTuples(schema, in, false);
}
- Collection<Tuple> readTuples(ClientSchema schema, ClientMessageUnpacker in, boolean keyOnly) {
+ private Collection<Tuple> readTuples(ClientSchema schema, ClientMessageUnpacker in, boolean keyOnly) {
var cnt = in.unpackInt();
var res = new ArrayList<Tuple>(cnt);
@@ -399,7 +677,7 @@ public class ClientTable implements Table {
return res;
}
- <T> CompletableFuture<T> doSchemaOutInOpAsync(
+ public <T> CompletableFuture<T> doSchemaOutInOpAsync(
int opCode,
BiConsumer<ClientSchema, ClientMessagePacker> writer,
BiFunction<ClientSchema, ClientMessageUnpacker, T> reader
@@ -407,7 +685,7 @@ public class ClientTable implements Table {
return doSchemaOutInOpAsync(opCode, writer, reader, null);
}
- <T> CompletableFuture<T> doSchemaOutInOpAsync(
+ public <T> CompletableFuture<T> doSchemaOutInOpAsync(
int opCode,
BiConsumer<ClientSchema, ClientMessagePacker> writer,
BiFunction<ClientSchema, ClientMessageUnpacker, T> reader,
@@ -421,7 +699,7 @@ public class ClientTable implements Table {
.thenCompose(t -> loadSchemaAndReadData(t, reader));
}
- <T> CompletableFuture<T> doSchemaOutOpAsync(
+ protected <T> CompletableFuture<T> doSchemaOutOpAsync(
int opCode,
BiConsumer<ClientSchema, ClientMessagePacker> writer,
Function<ClientMessageUnpacker, T> reader) {
diff --git a/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTables.java b/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTables.java
index eb0a139..49d2854 100644
--- a/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTables.java
+++ b/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTables.java
@@ -54,7 +54,7 @@ public class ClientTables implements IgniteTables {
Objects.requireNonNull(name);
Objects.requireNonNull(tableInitChange);
- throw new UnsupportedOperationException("Not implemented yet.");
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
@@ -67,7 +67,7 @@ public class ClientTables implements IgniteTables {
Objects.requireNonNull(name);
Objects.requireNonNull(tableChange);
- throw new UnsupportedOperationException("Not implemented yet.");
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
@@ -80,7 +80,7 @@ public class ClientTables implements IgniteTables {
Objects.requireNonNull(name);
Objects.requireNonNull(tableInitChange);
- throw new UnsupportedOperationException("Not implemented yet.");
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
diff --git a/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTuple.java b/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTuple.java
index 6665cfa..3fc9fc5 100644
--- a/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTuple.java
+++ b/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTuple.java
@@ -135,12 +135,12 @@ public final class ClientTuple implements Tuple {
/** {@inheritDoc} */
@Override public BinaryObject binaryObjectValue(@NotNull String columnName) {
- throw new UnsupportedOperationException("Not implemented yet.");
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
@Override public BinaryObject binaryObjectValue(int columnIndex) {
- throw new UnsupportedOperationException("Not implemented yet.");
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
diff --git a/modules/client/src/test/java/org/apache/ignite/client/ClientKeyValueBinaryViewTest.java b/modules/client/src/test/java/org/apache/ignite/client/ClientKeyValueBinaryViewTest.java
index d45ba7c..64fd808 100644
--- a/modules/client/src/test/java/org/apache/ignite/client/ClientKeyValueBinaryViewTest.java
+++ b/modules/client/src/test/java/org/apache/ignite/client/ClientKeyValueBinaryViewTest.java
@@ -21,7 +21,7 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletionException;
-import org.apache.ignite.table.KeyValueView;
+import org.apache.ignite.table.KeyValueBinaryView;
import org.apache.ignite.table.Table;
import org.apache.ignite.table.Tuple;
import org.junit.jupiter.api.Test;
@@ -34,23 +34,23 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
- * Binary KeyValueView tests.
+ * KeyValueBinaryView tests.
*/
public class ClientKeyValueBinaryViewTest extends AbstractClientTableTest {
@Test
public void testGetMissingRowReturnsNull() {
Table table = defaultTable();
- KeyValueView<Tuple, Tuple> kvView = table.keyValueView();
+ KeyValueBinaryView kvView = table.kvView();
assertNull(kvView.get(defaultTupleKey()));
}
@Test
- public void testRecordUpsertKvGet() {
+ public void testTableUpsertKvGet() {
Table table = defaultTable();
- table.recordView().upsert(tuple());
+ table.upsert(tuple());
- KeyValueView<Tuple, Tuple> kvView = table.keyValueView();
+ KeyValueBinaryView kvView = table.kvView();
Tuple key = defaultTupleKey();
Tuple val = kvView.get(key);
@@ -61,15 +61,15 @@ public class ClientKeyValueBinaryViewTest extends AbstractClientTableTest {
}
@Test
- public void testKvPutRecordGet() {
+ public void testKvPutTableGet() {
Table table = defaultTable();
- KeyValueView<Tuple, Tuple> kvView = table.keyValueView();
+ KeyValueBinaryView kvView = table.kvView();
Tuple key = defaultTupleKey();
Tuple val = Tuple.create().set("name", "bar");
kvView.put(key, val);
- Tuple res = table.recordView().get(key);
+ Tuple res = table.get(key);
assertEquals("bar", res.stringValue("name"));
assertEquals(DEFAULT_ID, res.longValue("id"));
@@ -78,7 +78,7 @@ public class ClientKeyValueBinaryViewTest extends AbstractClientTableTest {
@Test
public void testPutGet() {
Table table = defaultTable();
- KeyValueView<Tuple, Tuple> kvView = table.keyValueView();
+ KeyValueBinaryView kvView = table.kvView();
Tuple key = defaultTupleKey();
Tuple val = Tuple.create().set("name", DEFAULT_NAME);
@@ -92,7 +92,7 @@ public class ClientKeyValueBinaryViewTest extends AbstractClientTableTest {
@Test
public void testGetUpdatePut() {
Table table = defaultTable();
- KeyValueView<Tuple, Tuple> kvView = table.keyValueView();
+ KeyValueBinaryView kvView = table.kvView();
Tuple key = defaultTupleKey();
Tuple val = Tuple.create().set("name", DEFAULT_NAME);
@@ -109,7 +109,7 @@ public class ClientKeyValueBinaryViewTest extends AbstractClientTableTest {
@Test
public void testGetAll() {
- KeyValueView<Tuple, Tuple> kvView = defaultTable().keyValueView();
+ KeyValueBinaryView kvView = defaultTable().kvView();
kvView.put(tupleKey(1L), tupleVal("1"));
kvView.put(tupleKey(2L), tupleVal("2"));
@@ -130,7 +130,7 @@ public class ClientKeyValueBinaryViewTest extends AbstractClientTableTest {
@Test
public void testGetAllEmptyKeysReturnsEmptyMap() {
- KeyValueView<Tuple, Tuple> kvView = defaultTable().keyValueView();
+ KeyValueBinaryView kvView = defaultTable().kvView();
kvView.put(tupleKey(1L), tupleVal("1"));
Map<Tuple, Tuple> res = kvView.getAll(List.of());
@@ -139,7 +139,7 @@ public class ClientKeyValueBinaryViewTest extends AbstractClientTableTest {
@Test
public void testGetAllNonExistentKeysReturnsEmptyMap() {
- KeyValueView<Tuple, Tuple> kvView = defaultTable().keyValueView();
+ KeyValueBinaryView kvView = defaultTable().kvView();
kvView.put(tupleKey(1L), tupleVal("1"));
Map<Tuple, Tuple> res = kvView.getAll(List.of(tupleKey(-1L)));
@@ -148,7 +148,7 @@ public class ClientKeyValueBinaryViewTest extends AbstractClientTableTest {
@Test
public void testContains() {
- KeyValueView<Tuple, Tuple> kvView = defaultTable().keyValueView();
+ KeyValueBinaryView kvView = defaultTable().kvView();
kvView.put(tupleKey(1L), tupleVal("1"));
assertTrue(kvView.contains(tupleKey(1L)));
@@ -157,7 +157,7 @@ public class ClientKeyValueBinaryViewTest extends AbstractClientTableTest {
@Test
public void testContainsThrowsOnEmptyKey() {
- KeyValueView<Tuple, Tuple> kvView = defaultTable().keyValueView();
+ KeyValueBinaryView kvView = defaultTable().kvView();
var ex = assertThrows(CompletionException.class, () -> kvView.contains(Tuple.create()));
assertTrue(ex.getMessage().contains("Missed key column: id"), ex.getMessage());
@@ -165,7 +165,7 @@ public class ClientKeyValueBinaryViewTest extends AbstractClientTableTest {
@Test
public void testPutAll() {
- KeyValueView<Tuple, Tuple> kvView = defaultTable().keyValueView();
+ KeyValueBinaryView kvView = defaultTable().kvView();
kvView.putAll(Map.of(tupleKey(1L), tupleVal("1"), tupleKey(2L), tupleVal("2")));
assertEquals("1", kvView.get(tupleKey(1L)).stringValue("name"));
@@ -174,7 +174,7 @@ public class ClientKeyValueBinaryViewTest extends AbstractClientTableTest {
@Test
public void testPutIfAbsent() {
- KeyValueView<Tuple, Tuple> kvView = defaultTable().keyValueView();
+ KeyValueBinaryView kvView = defaultTable().kvView();
assertTrue(kvView.putIfAbsent(tupleKey(1L), tupleVal("1")));
assertFalse(kvView.putIfAbsent(tupleKey(1L), tupleVal("1")));
@@ -184,7 +184,7 @@ public class ClientKeyValueBinaryViewTest extends AbstractClientTableTest {
@Test
public void testRemove() {
- KeyValueView<Tuple, Tuple> kvView = defaultTable().keyValueView();
+ KeyValueBinaryView kvView = defaultTable().kvView();
kvView.put(tupleKey(1L), tupleVal("1"));
assertFalse(kvView.remove(tupleKey(2L)));
@@ -195,7 +195,7 @@ public class ClientKeyValueBinaryViewTest extends AbstractClientTableTest {
@Test
public void testRemoveExact() {
- KeyValueView<Tuple, Tuple> kvView = defaultTable().keyValueView();
+ KeyValueBinaryView kvView = defaultTable().kvView();
kvView.put(tupleKey(1L), tupleVal("1"));
assertFalse(kvView.remove(tupleKey(1L), tupleVal("2")));
@@ -208,7 +208,7 @@ public class ClientKeyValueBinaryViewTest extends AbstractClientTableTest {
@Test
public void testRemoveAll() {
- KeyValueView<Tuple, Tuple> kvView = defaultTable().keyValueView();
+ KeyValueBinaryView kvView = defaultTable().kvView();
kvView.putAll(Map.of(tupleKey(1L), tupleVal("1"), tupleKey(2L), tupleVal("2")));
Collection<Tuple> res = kvView.removeAll(List.of(tupleKey(2L), tupleKey(3L)));
@@ -222,7 +222,7 @@ public class ClientKeyValueBinaryViewTest extends AbstractClientTableTest {
@Test
public void testReplace() {
- KeyValueView<Tuple, Tuple> kvView = defaultTable().keyValueView();
+ KeyValueBinaryView kvView = defaultTable().kvView();
kvView.put(tupleKey(1L), tupleVal("1"));
assertFalse(kvView.replace(tupleKey(3L), tupleVal("3")));
@@ -232,7 +232,7 @@ public class ClientKeyValueBinaryViewTest extends AbstractClientTableTest {
@Test
public void testReplaceExact() {
- KeyValueView<Tuple, Tuple> kvView = defaultTable().keyValueView();
+ KeyValueBinaryView kvView = defaultTable().kvView();
kvView.put(tupleKey(1L), tupleVal("1"));
assertFalse(kvView.replace(tupleKey(1L), tupleVal("2"), tupleVal("3")));
@@ -242,7 +242,7 @@ public class ClientKeyValueBinaryViewTest extends AbstractClientTableTest {
@Test
public void testGetAndReplace() {
- KeyValueView<Tuple, Tuple> kvView = defaultTable().keyValueView();
+ KeyValueBinaryView kvView = defaultTable().kvView();
kvView.put(tupleKey(1L), tupleVal("1"));
assertNull(kvView.getAndReplace(tupleKey(2L), tupleVal("2")));
@@ -254,7 +254,7 @@ public class ClientKeyValueBinaryViewTest extends AbstractClientTableTest {
@Test
public void testGetAndRemove() {
- KeyValueView<Tuple, Tuple> kvView = defaultTable().keyValueView();
+ KeyValueBinaryView kvView = defaultTable().kvView();
kvView.put(tupleKey(1L), tupleVal("1"));
Tuple removed = kvView.getAndRemove(tupleKey(1L));
@@ -270,7 +270,7 @@ public class ClientKeyValueBinaryViewTest extends AbstractClientTableTest {
@Test
public void testGetAndPut() {
- KeyValueView<Tuple, Tuple> kvView = defaultTable().keyValueView();
+ KeyValueBinaryView kvView = defaultTable().kvView();
kvView.put(tupleKey(1L), tupleVal("1"));
Tuple res1 = kvView.getAndPut(tupleKey(2L), tupleVal("2"));
diff --git a/modules/client/src/test/java/org/apache/ignite/client/ClientTableTest.java b/modules/client/src/test/java/org/apache/ignite/client/ClientTableTest.java
index 944a323..7484406 100644
--- a/modules/client/src/test/java/org/apache/ignite/client/ClientTableTest.java
+++ b/modules/client/src/test/java/org/apache/ignite/client/ClientTableTest.java
@@ -22,7 +22,7 @@ import java.util.List;
import java.util.concurrent.CompletionException;
import org.apache.ignite.client.fakes.FakeSchemaRegistry;
import org.apache.ignite.internal.client.table.ClientTuple;
-import org.apache.ignite.table.RecordView;
+import org.apache.ignite.table.Table;
import org.apache.ignite.table.Tuple;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
@@ -40,7 +40,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class ClientTableTest extends AbstractClientTableTest {
@Test
public void testGetWithMissedKeyColumnThrowsException() {
- var table = defaultTable().recordView();
+ var table = defaultTable();
var key = Tuple.create().set("name", "123");
@@ -52,7 +52,7 @@ public class ClientTableTest extends AbstractClientTableTest {
@Test
public void testUpsertGet() {
- var table = defaultTable().recordView();
+ var table = defaultTable();
var tuple = tuple();
table.upsert(tuple);
@@ -87,7 +87,7 @@ public class ClientTableTest extends AbstractClientTableTest {
@Test
public void testUpsertGetAsync() {
- var table = defaultTable().recordView();
+ var table = defaultTable();
var tuple = tuple(42L, "Jack");
var key = Tuple.create().set("id", 42L);
@@ -105,14 +105,13 @@ public class ClientTableTest extends AbstractClientTableTest {
FakeSchemaRegistry.setLastVer(2);
var table = defaultTable();
- var recView = table.recordView();
Tuple tuple = tuple();
- recView.upsert(tuple);
+ table.upsert(tuple);
FakeSchemaRegistry.setLastVer(1);
try (var client2 = startClient()) {
- RecordView<Tuple> table2 = client2.tables().table(table.tableName()).recordView();
+ Table table2 = client2.tables().table(table.tableName());
var tuple2 = tuple();
var resTuple = table2.get(tuple2);
@@ -126,7 +125,7 @@ public class ClientTableTest extends AbstractClientTableTest {
@Test
public void testInsert() {
- var table = defaultTable().recordView();
+ var table = defaultTable();
var tuple = tuple();
var tuple2 = tuple(DEFAULT_ID, "abc");
@@ -141,7 +140,7 @@ public class ClientTableTest extends AbstractClientTableTest {
@Test
public void testInsertCustomTuple() {
- var table = defaultTable().recordView();
+ var table = defaultTable();
var tuple = new CustomTuple(25L, "Foo");
assertTrue(table.insert(tuple));
@@ -154,7 +153,7 @@ public class ClientTableTest extends AbstractClientTableTest {
@Test
public void testGetAll() {
- var table = defaultTable().recordView();
+ var table = defaultTable();
table.insert(tuple(1L, "1"));
table.insert(tuple(2L, "2"));
table.insert(tuple(3L, "3"));
@@ -173,7 +172,7 @@ public class ClientTableTest extends AbstractClientTableTest {
@Test
public void testUpsertAll() {
- var table = defaultTable().recordView();
+ var table = defaultTable();
List<Tuple> data = Arrays.asList(tuple(1L, "1"), tuple(2L, "2"));
table.upsertAll(data);
@@ -191,7 +190,7 @@ public class ClientTableTest extends AbstractClientTableTest {
@Test
public void testInsertAll() {
- var table = defaultTable().recordView();
+ var table = defaultTable();
List<Tuple> data = Arrays.asList(tuple(1L, "1"), tuple(2L, "2"));
var skippedTuples = table.insertAll(data);
@@ -212,7 +211,7 @@ public class ClientTableTest extends AbstractClientTableTest {
@Test
public void testReplace() {
- var table = defaultTable().recordView();
+ var table = defaultTable();
table.insert(tuple(1L, "1"));
assertFalse(table.replace(tuple(3L, "3")));
@@ -224,7 +223,7 @@ public class ClientTableTest extends AbstractClientTableTest {
@Test
public void testReplaceExact() {
- var table = defaultTable().recordView();
+ var table = defaultTable();
table.insert(tuple(1L, "1"));
assertFalse(table.replace(tuple(3L, "3"), tuple(3L, "4")));
@@ -237,7 +236,7 @@ public class ClientTableTest extends AbstractClientTableTest {
@Test
public void testGetAndReplace() {
- var table = defaultTable().recordView();
+ var table = defaultTable();
var tuple = tuple(1L, "1");
table.insert(tuple);
@@ -251,7 +250,7 @@ public class ClientTableTest extends AbstractClientTableTest {
@Test
public void testDelete() {
- var table = defaultTable().recordView();
+ var table = defaultTable();
table.insert(tuple(1L, "1"));
assertFalse(table.delete(tuple(2L)));
@@ -261,7 +260,7 @@ public class ClientTableTest extends AbstractClientTableTest {
@Test
public void testDeleteExact() {
- var table = defaultTable().recordView();
+ var table = defaultTable();
table.insert(tuple(1L, "1"));
table.insert(tuple(2L, "2"));
@@ -277,7 +276,7 @@ public class ClientTableTest extends AbstractClientTableTest {
@Test
public void testGetAndDelete() {
- var table = defaultTable().recordView();
+ var table = defaultTable();
var tuple = tuple(1L, "1");
table.insert(tuple);
@@ -290,7 +289,7 @@ public class ClientTableTest extends AbstractClientTableTest {
@Test
public void testDeleteAll() {
- var table = defaultTable().recordView();
+ var table = defaultTable();
List<Tuple> data = Arrays.asList(tuple(1L, "1"), tuple(2L, "2"));
table.insertAll(data);
@@ -311,7 +310,7 @@ public class ClientTableTest extends AbstractClientTableTest {
@Test
public void testDeleteAllExact() {
- var table = defaultTable().recordView();
+ var table = defaultTable();
List<Tuple> data = Arrays.asList(tuple(1L, "1"), tuple(2L, "2"));
table.insertAll(data);
diff --git a/modules/client/src/test/java/org/apache/ignite/client/fakes/FakeIgniteTables.java b/modules/client/src/test/java/org/apache/ignite/client/fakes/FakeIgniteTables.java
index 032199a..e48ef8c 100644
--- a/modules/client/src/test/java/org/apache/ignite/client/fakes/FakeIgniteTables.java
+++ b/modules/client/src/test/java/org/apache/ignite/client/fakes/FakeIgniteTables.java
@@ -134,6 +134,7 @@ public class FakeIgniteTables implements IgniteTables, IgniteTablesInternal {
return new TableImpl(
new FakeInternalTable(name, new IgniteUuid(UUID.randomUUID(), 0)),
new FakeSchemaRegistry(this::getSchema),
+ null,
null
);
}
diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITDynamicTableCreationTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITDynamicTableCreationTest.java
index dc65651..50d60d7 100644
--- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITDynamicTableCreationTest.java
+++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITDynamicTableCreationTest.java
@@ -33,8 +33,7 @@ import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.schema.SchemaBuilders;
import org.apache.ignite.schema.definition.ColumnType;
import org.apache.ignite.schema.definition.TableDefinition;
-import org.apache.ignite.table.KeyValueView;
-import org.apache.ignite.table.RecordView;
+import org.apache.ignite.table.KeyValueBinaryView;
import org.apache.ignite.table.Table;
import org.apache.ignite.table.Tuple;
import org.junit.jupiter.api.AfterEach;
@@ -121,28 +120,26 @@ class ITDynamicTableCreationTest {
// Put data on node 1.
Table tbl1 = clusterNodes.get(1).tables().table(schTbl1.canonicalName());
- RecordView<Tuple> recView1 = tbl1.recordView();
- KeyValueView<Tuple, Tuple> kvView1 = tbl1.keyValueView();
+ KeyValueBinaryView kvView1 = tbl1.kvView();
- recView1.insert(Tuple.create().set("key", 1L).set("val", 111));
+ tbl1.insert(Tuple.create().set("key", 1L).set("val", 111));
kvView1.put(Tuple.create().set("key", 2L), Tuple.create().set("val", 222));
// Get data on node 2.
Table tbl2 = clusterNodes.get(2).tables().table(schTbl1.canonicalName());
- RecordView<Tuple> recView2 = tbl2.recordView();
- KeyValueView<Tuple, Tuple> kvView2 = tbl2.keyValueView();
+ KeyValueBinaryView kvView2 = tbl2.kvView();
final Tuple keyTuple1 = Tuple.create().set("key", 1L);
final Tuple keyTuple2 = Tuple.create().set("key", 2L);
assertThrows(IllegalArgumentException.class, () -> kvView2.get(keyTuple1).value("key"));
assertThrows(IllegalArgumentException.class, () -> kvView2.get(keyTuple2).value("key"));
- assertEquals(1, (Long)recView2.get(keyTuple1).value("key"));
- assertEquals(2, (Long)recView2.get(keyTuple2).value("key"));
+ assertEquals(1, (Long)tbl2.get(keyTuple1).value("key"));
+ assertEquals(2, (Long)tbl2.get(keyTuple2).value("key"));
- assertEquals(111, (Integer)recView2.get(keyTuple1).value("val"));
+ assertEquals(111, (Integer)tbl2.get(keyTuple1).value("val"));
assertEquals(111, (Integer)kvView2.get(keyTuple1).value("val"));
- assertEquals(222, (Integer)recView2.get(keyTuple2).value("val"));
+ assertEquals(222, (Integer)tbl2.get(keyTuple2).value("val"));
assertEquals(222, (Integer)kvView2.get(keyTuple2).value("val"));
assertThrows(IllegalArgumentException.class, () -> kvView1.get(keyTuple1).value("key"));
@@ -184,10 +181,9 @@ class ITDynamicTableCreationTest {
// Put data on node 1.
Table tbl1 = clusterNodes.get(1).tables().table(scmTbl1.canonicalName());
- RecordView<Tuple> recView1 = tbl1.recordView();
- KeyValueView<Tuple, Tuple> kvView1 = tbl1.keyValueView();
+ KeyValueBinaryView kvView1 = tbl1.kvView();
- recView1.insert(Tuple.create().set("key", uuid).set("affKey", 42L)
+ tbl1.insert(Tuple.create().set("key", uuid).set("affKey", 42L)
.set("valStr", "String value").set("valInt", 73).set("valNull", null));
kvView1.put(Tuple.create().set("key", uuid2).set("affKey", 4242L),
@@ -195,8 +191,7 @@ class ITDynamicTableCreationTest {
// Get data on node 2.
Table tbl2 = clusterNodes.get(2).tables().table(scmTbl1.canonicalName());
- RecordView<Tuple> recView2 = tbl2.recordView();
- KeyValueView<Tuple, Tuple> kvView2 = tbl2.keyValueView();
+ KeyValueBinaryView kvView2 = tbl2.kvView();
final Tuple keyTuple1 = Tuple.create().set("key", uuid).set("affKey", 42L);
final Tuple keyTuple2 = Tuple.create().set("key", uuid2).set("affKey", 4242L);
@@ -208,18 +203,18 @@ class ITDynamicTableCreationTest {
assertThrows(IllegalArgumentException.class, () -> kvView2.get(keyTuple2).value("affKey"));
// Record binary view MUST return key columns in value.
- assertEquals(uuid, recView2.get(keyTuple1).value("key"));
- assertEquals(42L, (Long)recView2.get(keyTuple1).value("affKey"));
- assertEquals(uuid2, recView2.get(keyTuple2).value("key"));
- assertEquals(4242L, (Long)recView2.get(keyTuple2).value("affKey"));
-
- assertEquals("String value", recView2.get(keyTuple1).value("valStr"));
- assertEquals(73, (Integer)recView2.get(keyTuple1).value("valInt"));
- assertNull(recView2.get(keyTuple1).value("valNull"));
-
- assertEquals("String value 2", recView2.get(keyTuple2).value("valStr"));
- assertEquals(7373, (Integer)recView2.get(keyTuple2).value("valInt"));
- assertNull(recView2.get(keyTuple2).value("valNull"));
+ assertEquals(uuid, tbl2.get(keyTuple1).value("key"));
+ assertEquals(42L, (Long)tbl2.get(keyTuple1).value("affKey"));
+ assertEquals(uuid2, tbl2.get(keyTuple2).value("key"));
+ assertEquals(4242L, (Long)tbl2.get(keyTuple2).value("affKey"));
+
+ assertEquals("String value", tbl2.get(keyTuple1).value("valStr"));
+ assertEquals(73, (Integer)tbl2.get(keyTuple1).value("valInt"));
+ assertNull(tbl2.get(keyTuple1).value("valNull"));
+
+ assertEquals("String value 2", tbl2.get(keyTuple2).value("valStr"));
+ assertEquals(7373, (Integer)tbl2.get(keyTuple2).value("valInt"));
+ assertNull(tbl2.get(keyTuple2).value("valNull"));
assertEquals("String value", kvView2.get(keyTuple1).value("valStr"));
assertEquals(73, (Integer)kvView2.get(keyTuple1).value("valInt"));
diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITIgniteNodeRestartTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITIgniteNodeRestartTest.java
index 62e683c..eb375a5 100644
--- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITIgniteNodeRestartTest.java
+++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITIgniteNodeRestartTest.java
@@ -175,7 +175,7 @@ public class ITIgniteNodeRestartTest extends IgniteAbstractTest {
Tuple key = Tuple.create().set("id", i);
Tuple val = Tuple.create().set("name", "name " + i);
- table.keyValueView().put(key, val);
+ table.kvView().put(key, val);
}
IgnitionManager.stop(NODE_NAME);
@@ -185,7 +185,7 @@ public class ITIgniteNodeRestartTest extends IgniteAbstractTest {
assertNotNull(ignite.tables().table(TABLE_NAME));
for (int i = 0; i < 100; i++) {
- assertEquals("name " + i, table.keyValueView().get(Tuple.create()
+ assertEquals("name " + i, table.kvView().get(Tuple.create()
.set("id", i))
.stringValue("name"));
}
diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITLiveSchemaChangeKVViewTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITLiveSchemaChangeKVViewTest.java
index 311fc35..edcd8e5 100644
--- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITLiveSchemaChangeKVViewTest.java
+++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITLiveSchemaChangeKVViewTest.java
@@ -23,7 +23,7 @@ import org.apache.ignite.internal.schema.SchemaDescriptor;
import org.apache.ignite.internal.schema.SchemaMismatchException;
import org.apache.ignite.internal.table.TableImpl;
import org.apache.ignite.schema.definition.SchemaManagementMode;
-import org.apache.ignite.table.KeyValueView;
+import org.apache.ignite.table.KeyValueBinaryView;
import org.apache.ignite.table.Table;
import org.apache.ignite.table.Tuple;
import org.junit.jupiter.api.Test;
@@ -45,7 +45,7 @@ class ITLiveSchemaChangeKVViewTest extends AbstractSchemaChangeTest {
createTable(grid);
- KeyValueView<Tuple, Tuple> view = grid.get(0).tables().table(TABLE).keyValueView();
+ KeyValueBinaryView view = grid.get(0).tables().table(TABLE).kvView();
assertThrows(SchemaMismatchException.class, () -> view.put(Tuple.create().set("key", 1L), Tuple.create().set("unknownColumn", 10)));
}
@@ -61,9 +61,9 @@ class ITLiveSchemaChangeKVViewTest extends AbstractSchemaChangeTest {
Table tbl = grid.get(1).tables().table(TABLE);
- ((TableImpl)tbl).schemaMode(SchemaManagementMode.LIVE);
+ ((TableImpl)tbl).schemaType(SchemaManagementMode.LIVE);
- KeyValueView<Tuple, Tuple> kvBinaryView = tbl.keyValueView();
+ KeyValueBinaryView kvBinaryView = tbl.kvView();
Tuple key = Tuple.create().set("key", 1L);
Tuple val = Tuple.create().set("valStrNew", "111").set("valIntNew", 333);
@@ -86,9 +86,9 @@ class ITLiveSchemaChangeKVViewTest extends AbstractSchemaChangeTest {
Table tbl = grid.get(0).tables().table(TABLE);
- ((TableImpl)tbl).schemaMode(SchemaManagementMode.LIVE);
+ ((TableImpl)tbl).schemaType(SchemaManagementMode.LIVE);
- KeyValueView<Tuple, Tuple> kvBinaryView = tbl.keyValueView();
+ KeyValueBinaryView kvBinaryView = tbl.kvView();
Tuple key = Tuple.create().set("key", 1L);
Tuple val = Tuple.create().set("valStrNew", "111").set("valIntNew", 333);
@@ -99,7 +99,7 @@ class ITLiveSchemaChangeKVViewTest extends AbstractSchemaChangeTest {
assertEquals("111", res.value("valStrNew"));
assertEquals(Integer.valueOf(333), res.value("valIntNew"));
- ((TableImpl)tbl).schemaMode(SchemaManagementMode.STRICT);
+ ((TableImpl)tbl).schemaType(SchemaManagementMode.STRICT);
Tuple anotherKey = Tuple.create().set("key", 2L);
Tuple anotherVal = Tuple.create().set("valStrNew", "111").set("valIntNew", 333);
@@ -125,9 +125,9 @@ class ITLiveSchemaChangeKVViewTest extends AbstractSchemaChangeTest {
Table tbl = grid.get(1).tables().table(TABLE);
- ((TableImpl)tbl).schemaMode(SchemaManagementMode.LIVE);
+ ((TableImpl)tbl).schemaType(SchemaManagementMode.LIVE);
- KeyValueView<Tuple, Tuple> view = tbl.keyValueView();
+ KeyValueBinaryView view = tbl.kvView();
Tuple oldSchemaKey = Tuple.create().set("key", 32L);
Tuple oldSchemaVal = Tuple.create().set("valInt", 111).set("valStr", "str");
@@ -155,9 +155,9 @@ class ITLiveSchemaChangeKVViewTest extends AbstractSchemaChangeTest {
Table tbl = grid.get(1).tables().table(TABLE);
- ((TableImpl)tbl).schemaMode(SchemaManagementMode.LIVE);
+ ((TableImpl)tbl).schemaType(SchemaManagementMode.LIVE);
- KeyValueView<Tuple, Tuple> view = tbl.keyValueView();
+ KeyValueBinaryView view = tbl.kvView();
Tuple oldSchemaKey = Tuple.create().set("key", 32L);
@@ -187,9 +187,9 @@ class ITLiveSchemaChangeKVViewTest extends AbstractSchemaChangeTest {
Table tbl = grid.get(0).tables().table(TABLE);
- ((TableImpl)tbl).schemaMode(SchemaManagementMode.LIVE);
+ ((TableImpl)tbl).schemaType(SchemaManagementMode.LIVE);
- KeyValueView<Tuple, Tuple> view = tbl.keyValueView();
+ KeyValueBinaryView view = tbl.kvView();
Tuple oldSchemaKey = Tuple.create().set("key", 32L);
Tuple oldSchemaVal = Tuple.create().set("valInt", 111).set("valStr", "str");
diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITLiveSchemaChangeTableTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITLiveSchemaChangeTableTest.java
index 7278d61..d80703c 100644
--- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITLiveSchemaChangeTableTest.java
+++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITLiveSchemaChangeTableTest.java
@@ -25,7 +25,6 @@ import org.apache.ignite.internal.schema.SchemaDescriptor;
import org.apache.ignite.internal.schema.SchemaMismatchException;
import org.apache.ignite.internal.table.TableImpl;
import org.apache.ignite.schema.definition.SchemaManagementMode;
-import org.apache.ignite.table.RecordView;
import org.apache.ignite.table.Table;
import org.apache.ignite.table.Tuple;
import org.junit.jupiter.api.Test;
@@ -50,9 +49,7 @@ class ITLiveSchemaChangeTableTest extends AbstractSchemaChangeTest {
Table tbl = grid.get(0).tables().table(TABLE);
- Tuple tuple = Tuple.create().set("key", 1L).set("unknownColumn", 10);
-
- assertThrows(SchemaMismatchException.class, () -> tbl.recordView().insert(tuple));
+ assertThrows(SchemaMismatchException.class, () -> tbl.insert(Tuple.create().set("key", 1L).set("unknownColumn", 10)));
}
/**
@@ -65,15 +62,14 @@ class ITLiveSchemaChangeTableTest extends AbstractSchemaChangeTest {
createTable(grid);
Table tbl = grid.get(0).tables().table(TABLE);
- RecordView<Tuple> recView = tbl.recordView();
- ((TableImpl)tbl).schemaMode(SchemaManagementMode.LIVE);
+ ((TableImpl)tbl).schemaType(SchemaManagementMode.LIVE);
Tuple row = Tuple.create().set("key", 1L).set("valStrNew", "111").set("valIntNew", 333);
- recView.insert(row);
+ tbl.insert(row);
- Tuple res = recView.get(Tuple.create().set("key", 1L));
+ Tuple res = tbl.get(Tuple.create().set("key", 1L));
assertEquals("111", res.value("valStrNew"));
assertEquals(Integer.valueOf(333), res.value("valIntNew"));
@@ -89,19 +85,18 @@ class ITLiveSchemaChangeTableTest extends AbstractSchemaChangeTest {
createTable(grid);
Table tbl = grid.get(0).tables().table(TABLE);
- RecordView<Tuple> recView = tbl.recordView();
Tuple oldSchemaTuple = Tuple.create().set("key", 32L).set("valInt", 111).set("valStr", "str");
- recView.insert(oldSchemaTuple);
+ tbl.insert(oldSchemaTuple);
- ((TableImpl)tbl).schemaMode(SchemaManagementMode.LIVE);
+ ((TableImpl)tbl).schemaType(SchemaManagementMode.LIVE);
Tuple upsertOldSchemaTuple = Tuple.create().set("key", 32L).set("valStrNew", "111").set("valIntNew", 333);
- recView.upsert(upsertOldSchemaTuple);
+ tbl.upsert(upsertOldSchemaTuple);
- Tuple oldSchemaRes = recView.get(Tuple.create().set("key", 32L));
+ Tuple oldSchemaRes = tbl.get(Tuple.create().set("key", 32L));
assertEquals("111", oldSchemaRes.value("valStrNew"));
assertEquals(Integer.valueOf(333), oldSchemaRes.value("valIntNew"));
@@ -117,18 +112,17 @@ class ITLiveSchemaChangeTableTest extends AbstractSchemaChangeTest {
createTable(grid);
Table tbl = grid.get(0).tables().table(TABLE);
- RecordView<Tuple> recView = tbl.recordView();
Tuple oldSchemaTuple = Tuple.create().set("key", 32L).set("valInt", 111).set("valStr", "str");
- ((TableImpl)tbl).schemaMode(SchemaManagementMode.LIVE);
+ ((TableImpl)tbl).schemaType(SchemaManagementMode.LIVE);
Tuple row = Tuple.create().set("key", 1L).set("valStrNew", "111").set("valIntNew", 333);
- recView.insert(row);
- recView.insert(oldSchemaTuple);
+ tbl.insert(row);
+ tbl.insert(oldSchemaTuple);
- Tuple res = recView.get(Tuple.create().set("key", 1L));
+ Tuple res = tbl.get(Tuple.create().set("key", 1L));
assertEquals("111", res.value("valStrNew"));
assertEquals(Integer.valueOf(333), res.value("valIntNew"));
@@ -149,30 +143,29 @@ class ITLiveSchemaChangeTableTest extends AbstractSchemaChangeTest {
createTable(grid);
Table tbl = grid.get(0).tables().table(TABLE);
- RecordView<Tuple> recView = tbl.recordView();
- ((TableImpl)tbl).schemaMode(SchemaManagementMode.LIVE);
+ ((TableImpl)tbl).schemaType(SchemaManagementMode.LIVE);
Tuple val = Tuple.create().set("key", 1L).set("valStrNew", "111").set("valIntNew", 333);
- recView.insert(val);
+ tbl.insert(val);
- Tuple res = recView.get(Tuple.create().set("key", 1L));
+ Tuple res = tbl.get(Tuple.create().set("key", 1L));
assertEquals("111", res.value("valStrNew"));
assertEquals(Integer.valueOf(333), res.value("valIntNew"));
- ((TableImpl)tbl).schemaMode(SchemaManagementMode.STRICT);
+ ((TableImpl)tbl).schemaType(SchemaManagementMode.STRICT);
Tuple anotherKey = Tuple.create().set("key", 2L).set("valStrNew", "111").set("valIntNew", 333);
- recView.insert(anotherKey);
+ tbl.insert(anotherKey);
- Tuple newRes = recView.get(Tuple.create().set("key", 2L));
+ Tuple newRes = tbl.get(Tuple.create().set("key", 2L));
assertEquals("111", newRes.value("valStrNew"));
assertEquals(Integer.valueOf(333), newRes.value("valIntNew"));
- assertThrows(SchemaMismatchException.class, () -> recView.insert(Tuple.create().set("key", 1L).set("unknownColumn", 10)));
+ assertThrows(SchemaMismatchException.class, () -> tbl.insert(Tuple.create().set("key", 1L).set("unknownColumn", 10)));
}
/**
@@ -185,19 +178,18 @@ class ITLiveSchemaChangeTableTest extends AbstractSchemaChangeTest {
createTable(grid);
Table tbl = grid.get(0).tables().table(TABLE);
- RecordView<Tuple> recView = tbl.recordView();
- ((TableImpl)tbl).schemaMode(SchemaManagementMode.LIVE);
+ ((TableImpl)tbl).schemaType(SchemaManagementMode.LIVE);
Tuple oldSchemaVal = Tuple.create().set("key", 32L).set("valInt", 111).set("valStr", "str");
Tuple upsertOldSchemaVal = Tuple.create().set("key", 32L).set("valStrNew", "111").set("valIntNew", 333);
Tuple secondUpsertOldSchemaVal = Tuple.create().set("key", 32L).set("valStrNew", "111").set("valIntNew", 333).set("anotherNewVal", 48L);
- recView.insert(oldSchemaVal);
- recView.upsert(upsertOldSchemaVal);
- recView.upsert(secondUpsertOldSchemaVal);
+ tbl.insert(oldSchemaVal);
+ tbl.upsert(upsertOldSchemaVal);
+ tbl.upsert(secondUpsertOldSchemaVal);
- Tuple oldSchemaRes = recView.get(Tuple.create().set("key", 32L));
+ Tuple oldSchemaRes = tbl.get(Tuple.create().set("key", 32L));
assertEquals("111", oldSchemaRes.value("valStrNew"));
assertEquals(Integer.valueOf(333), oldSchemaRes.value("valIntNew"));
@@ -214,9 +206,8 @@ class ITLiveSchemaChangeTableTest extends AbstractSchemaChangeTest {
createTable(grid);
Table tbl = grid.get(0).tables().table(TABLE);
- RecordView<Tuple> recView = tbl.recordView();
- ((TableImpl)tbl).schemaMode(SchemaManagementMode.LIVE);
+ ((TableImpl)tbl).schemaType(SchemaManagementMode.LIVE);
UUID uuid = UUID.randomUUID();
@@ -231,9 +222,9 @@ class ITLiveSchemaChangeTableTest extends AbstractSchemaChangeTest {
.set("valStrNew", "111")
.set("valUUIDNew", uuid);
- recView.insert(row);
+ tbl.insert(row);
- Tuple res = recView.get(Tuple.create().set("key", 1L));
+ Tuple res = tbl.get(Tuple.create().set("key", 1L));
assertEquals(Byte.valueOf((byte)10), res.value("valByteNew"));
assertEquals(Short.valueOf((short)48), res.value("valShortNew"));
@@ -247,9 +238,9 @@ class ITLiveSchemaChangeTableTest extends AbstractSchemaChangeTest {
Tuple secondRow = Tuple.create().set("key", 2L);
- recView.insert(secondRow);
+ tbl.insert(secondRow);
- Tuple nullRes = recView.get(secondRow);
+ Tuple nullRes = tbl.get(secondRow);
assertNull(nullRes.value("valByteNew"));
assertNull(nullRes.value("valShortNew"));
@@ -271,9 +262,8 @@ class ITLiveSchemaChangeTableTest extends AbstractSchemaChangeTest {
createTable(grid);
Table tbl = grid.get(0).tables().table(TABLE);
- RecordView<Tuple> recView = tbl.recordView();
- ((TableImpl)tbl).schemaMode(SchemaManagementMode.LIVE);
+ ((TableImpl)tbl).schemaType(SchemaManagementMode.LIVE);
UUID uuid = UUID.randomUUID();
@@ -288,7 +278,7 @@ class ITLiveSchemaChangeTableTest extends AbstractSchemaChangeTest {
.set("valStrNew", "111")
.set("valUUIDNew", uuid);
- recView.insert(row);
+ tbl.insert(row);
SchemaDescriptor schema = ((TableImpl)tbl).schemaView().schema();
@@ -305,16 +295,15 @@ class ITLiveSchemaChangeTableTest extends AbstractSchemaChangeTest {
createTable(grid);
Table tbl = grid.get(0).tables().table(TABLE);
- RecordView<Tuple> recView = tbl.recordView();
- ((TableImpl)tbl).schemaMode(SchemaManagementMode.LIVE);
+ ((TableImpl)tbl).schemaType(SchemaManagementMode.LIVE);
Tuple rowWithObject = Tuple.create().set("key", 1L).set("newBrokenColumn", new Object());
- assertThrows(InvalidTypeException.class, () -> recView.insert(rowWithObject));
+ assertThrows(InvalidTypeException.class, () -> tbl.insert(rowWithObject));
Tuple rowWithNull = Tuple.create().set("key", 1L).set("valStrNew", null).set("valIntNew", 333);
- assertThrows(InvalidTypeException.class, () -> recView.insert(rowWithNull));
+ assertThrows(InvalidTypeException.class, () -> tbl.insert(rowWithNull));
}
}
diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITSchemaChangeKVViewTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITSchemaChangeKVViewTest.java
index a0a4278..94f673b 100644
--- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITSchemaChangeKVViewTest.java
+++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITSchemaChangeKVViewTest.java
@@ -25,7 +25,7 @@ import org.apache.ignite.internal.schema.SchemaMismatchException;
import org.apache.ignite.schema.SchemaBuilders;
import org.apache.ignite.schema.definition.ColumnDefinition;
import org.apache.ignite.schema.definition.ColumnType;
-import org.apache.ignite.table.KeyValueView;
+import org.apache.ignite.table.KeyValueBinaryView;
import org.apache.ignite.table.Tuple;
import org.junit.jupiter.api.Test;
@@ -46,7 +46,7 @@ class ITSchemaChangeKVViewTest extends AbstractSchemaChangeTest {
createTable(grid);
- KeyValueView<Tuple, Tuple> kvView = grid.get(0).tables().table(TABLE).keyValueView();
+ KeyValueBinaryView kvView = grid.get(0).tables().table(TABLE).kvView();
{
kvView.put(
@@ -90,7 +90,7 @@ class ITSchemaChangeKVViewTest extends AbstractSchemaChangeTest {
createTable(grid);
- KeyValueView<Tuple, Tuple> kvView = grid.get(0).tables().table(TABLE).keyValueView();
+ KeyValueBinaryView kvView = grid.get(0).tables().table(TABLE).kvView();
{
kvView.put(Tuple.create().set("key", 1L), Tuple.create().set("valInt", 111));
@@ -132,7 +132,7 @@ class ITSchemaChangeKVViewTest extends AbstractSchemaChangeTest {
createTable(grid);
- KeyValueView<Tuple, Tuple> kvView = grid.get(0).tables().table(TABLE).keyValueView();
+ KeyValueBinaryView kvView = grid.get(0).tables().table(TABLE).kvView();
{
kvView.put(Tuple.create().set("key", 1L), Tuple.create().set("valInt", 111));
@@ -183,7 +183,7 @@ class ITSchemaChangeKVViewTest extends AbstractSchemaChangeTest {
final ColumnDefinition column = SchemaBuilders.column("val", ColumnType.string()).asNullable().withDefaultValueExpression("default").build();
- KeyValueView<Tuple, Tuple> kvView = grid.get(0).tables().table(TABLE).keyValueView();
+ KeyValueBinaryView kvView = grid.get(0).tables().table(TABLE).kvView();
{
kvView.put(Tuple.create().set("key", 1L), Tuple.create().set("valInt", 111));
@@ -262,7 +262,7 @@ class ITSchemaChangeKVViewTest extends AbstractSchemaChangeTest {
createTable(grid);
- KeyValueView<Tuple, Tuple> kvView = grid.get(0).tables().table(TABLE).keyValueView();
+ KeyValueBinaryView kvView = grid.get(0).tables().table(TABLE).kvView();
final String colName = "valStr";
diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITSchemaChangeTableViewTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITSchemaChangeTableViewTest.java
index 834ad5e..f823abf 100644
--- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITSchemaChangeTableViewTest.java
+++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITSchemaChangeTableViewTest.java
@@ -25,7 +25,7 @@ import org.apache.ignite.internal.schema.SchemaMismatchException;
import org.apache.ignite.schema.SchemaBuilders;
import org.apache.ignite.schema.definition.ColumnDefinition;
import org.apache.ignite.schema.definition.ColumnType;
-import org.apache.ignite.table.RecordView;
+import org.apache.ignite.table.Table;
import org.apache.ignite.table.Tuple;
import org.junit.jupiter.api.Test;
@@ -46,7 +46,7 @@ class ITSchemaChangeTableViewTest extends AbstractSchemaChangeTest {
createTable(grid);
- RecordView<Tuple> tbl = grid.get(0).tables().table(TABLE).recordView();
+ final Table tbl = grid.get(0).tables().table(TABLE);
{
tbl.insert(Tuple.create().set("key", 1L).set("valInt", 111).set("valStr", "str"));
@@ -87,7 +87,7 @@ class ITSchemaChangeTableViewTest extends AbstractSchemaChangeTest {
createTable(grid);
- RecordView<Tuple> tbl = grid.get(0).tables().table(TABLE).recordView();
+ Table tbl = grid.get(0).tables().table(TABLE);
{
tbl.insert(Tuple.create().set("key", 1L).set("valInt", 111));
@@ -125,7 +125,7 @@ class ITSchemaChangeTableViewTest extends AbstractSchemaChangeTest {
createTable(grid);
- RecordView<Tuple> tbl = grid.get(0).tables().table(TABLE).recordView();
+ Table tbl = grid.get(0).tables().table(TABLE);
{
tbl.insert(Tuple.create().set("key", 1L).set("valInt", 111));
@@ -170,7 +170,7 @@ class ITSchemaChangeTableViewTest extends AbstractSchemaChangeTest {
createTable(grid);
- RecordView<Tuple> tbl = grid.get(0).tables().table(TABLE).recordView();
+ Table tbl = grid.get(0).tables().table(TABLE);
{
tbl.insert(Tuple.create().set("key", 1L).set("valInt", 111));
@@ -216,7 +216,7 @@ class ITSchemaChangeTableViewTest extends AbstractSchemaChangeTest {
final ColumnDefinition column = SchemaBuilders.column("val", ColumnType.string()).asNullable().withDefaultValueExpression("default").build();
- RecordView<Tuple> tbl = grid.get(0).tables().table(TABLE).recordView();
+ Table tbl = grid.get(0).tables().table(TABLE);
{
tbl.insert(Tuple.create().set("key", 1L).set("valInt", 111));
@@ -288,7 +288,7 @@ class ITSchemaChangeTableViewTest extends AbstractSchemaChangeTest {
createTable(grid);
- RecordView<Tuple> tbl = grid.get(0).tables().table(TABLE).recordView();
+ Table tbl = grid.get(0).tables().table(TABLE);
final String colName = "valStr";
diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTableCreationTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTableCreationTest.java
index b8f9c00..1635f78 100644
--- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTableCreationTest.java
+++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTableCreationTest.java
@@ -27,8 +27,7 @@ import org.apache.ignite.app.IgnitionManager;
import org.apache.ignite.internal.testframework.WorkDirectory;
import org.apache.ignite.internal.testframework.WorkDirectoryExtension;
import org.apache.ignite.internal.util.IgniteUtils;
-import org.apache.ignite.table.KeyValueView;
-import org.apache.ignite.table.RecordView;
+import org.apache.ignite.table.KeyValueBinaryView;
import org.apache.ignite.table.Table;
import org.apache.ignite.table.Tuple;
import org.junit.jupiter.api.AfterEach;
@@ -183,23 +182,21 @@ class ITTableCreationTest {
{ /* Table 1. */
Table tbl1 = clusterNodes.get(1).tables().table("tbl1");
- RecordView<Tuple> recView = tbl1.recordView();
- KeyValueView<Tuple, Tuple> kvView1 = tbl1.keyValueView();
+ KeyValueBinaryView kvView1 = tbl1.kvView();
- recView.insert(Tuple.create().set("key", 1L).set("val", 111));
+ tbl1.insert(Tuple.create().set("key", 1L).set("val", 111));
kvView1.put(Tuple.create().set("key", 2L), Tuple.create().set("val", 222));
Table tbl2 = clusterNodes.get(2).tables().table("tbl1");
- RecordView<Tuple> recView2 = tbl2.recordView();
- KeyValueView<Tuple, Tuple> kvView2 = tbl2.keyValueView();
+ KeyValueBinaryView kvView2 = tbl2.kvView();
final Tuple keyTuple1 = Tuple.create().set("key", 1L);
final Tuple keyTuple2 = Tuple.create().set("key", 2L);
- assertEquals(111, (Integer)recView2.get(keyTuple1).value("val"));
- assertEquals(111, (Integer)kvView2.get(keyTuple1).value("val"));
- assertEquals(222, (Integer)recView2.get(keyTuple2).value("val"));
- assertEquals(222, (Integer)kvView2.get(keyTuple2).value("val"));
+ assertEquals(111, (Integer)tbl2.get(keyTuple1).value("val"));
+ assertEquals(111, (Integer)kvView1.get(keyTuple1).value("val"));
+ assertEquals(222, (Integer)tbl2.get(keyTuple2).value("val"));
+ assertEquals(222, (Integer)kvView1.get(keyTuple2).value("val"));
}
{ /* Table 2. */
@@ -208,10 +205,9 @@ class ITTableCreationTest {
// Put data on node 1.
Table tbl1 = clusterNodes.get(1).tables().table("tbl1");
- RecordView<Tuple> recView = tbl1.recordView();
- KeyValueView<Tuple, Tuple> kvView1 = tbl1.keyValueView();
+ KeyValueBinaryView kvView1 = tbl1.kvView();
- recView.insert(Tuple.create().set("key", uuid).set("affKey", 42L)
+ tbl1.insert(Tuple.create().set("key", uuid).set("affKey", 42L)
.set("valStr", "String value").set("valInt", 73).set("valNullable", null));
kvView1.put(Tuple.create().set("key", uuid2).set("affKey", 4242L),
@@ -219,23 +215,22 @@ class ITTableCreationTest {
// Get data on node 2.
Table tbl2 = clusterNodes.get(2).tables().table("tbl1");
- RecordView<Tuple> recView2 = tbl2.recordView();
- KeyValueView<Tuple, Tuple> kvView2 = tbl2.keyValueView();
+ KeyValueBinaryView kvView2 = tbl2.kvView();
final Tuple keyTuple1 = Tuple.create().set("key", uuid).set("affKey", 42L);
final Tuple keyTuple2 = Tuple.create().set("key", uuid2).set("affKey", 4242L);
- assertEquals("String value", recView2.get(keyTuple1).value("valStr"));
+ assertEquals("String value", tbl2.get(keyTuple1).value("valStr"));
assertEquals("String value", kvView2.get(keyTuple1).value("valStr"));
- assertEquals("String value 2", recView2.get(keyTuple2).value("valStr"));
+ assertEquals("String value 2", tbl2.get(keyTuple2).value("valStr"));
assertEquals("String value 2", kvView2.get(keyTuple2).value("valStr"));
- assertEquals(73, (Integer)recView2.get(keyTuple1).value("valInt"));
+ assertEquals(73, (Integer)tbl2.get(keyTuple1).value("valInt"));
assertEquals(73, (Integer)kvView2.get(keyTuple1).value("valInt"));
- assertEquals(7373, (Integer)recView2.get(keyTuple2).value("valInt"));
+ assertEquals(7373, (Integer)tbl2.get(keyTuple2).value("valInt"));
assertEquals(7373, (Integer)kvView2.get(keyTuple2).value("valInt"));
- assertNull(recView2.get(keyTuple1).value("valNullable"));
+ assertNull(tbl2.get(keyTuple1).value("valNullable"));
assertNull(kvView2.get(keyTuple1).value("valNullable"));
- assertNull(recView2.get(keyTuple2).value("valNullable"));
+ assertNull(tbl2.get(keyTuple2).value("valNullable"));
assertNull(kvView2.get(keyTuple2).value("valNullable"));
}
}
diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITThinClientConnectionTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITThinClientConnectionTest.java
index 08e0403..ff92c7b 100644
--- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITThinClientConnectionTest.java
+++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITThinClientConnectionTest.java
@@ -34,7 +34,6 @@ import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.schema.SchemaBuilders;
import org.apache.ignite.schema.definition.ColumnType;
import org.apache.ignite.schema.definition.TableDefinition;
-import org.apache.ignite.table.RecordView;
import org.apache.ignite.table.Table;
import org.apache.ignite.table.Tuple;
import org.junit.jupiter.api.AfterEach;
@@ -125,15 +124,13 @@ public class ITThinClientConnectionTest extends IgniteAbstractTest {
var tuple = Tuple.create().set(keyCol, 1).set(valCol, "Hello");
var keyTuple = Tuple.create().set(keyCol, 1);
- RecordView<Tuple> recView = table.recordView();
+ table.upsert(tuple);
+ assertEquals("Hello", table.get(keyTuple).stringValue(valCol));
- recView.upsert(tuple);
- assertEquals("Hello", recView.get(keyTuple).stringValue(valCol));
-
- var kvView = table.keyValueView();
+ var kvView = table.kvView();
assertEquals("Hello", kvView.get(keyTuple).stringValue(valCol));
- assertTrue(recView.delete(keyTuple));
+ assertTrue(table.delete(keyTuple));
}
}
}
diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/jdbc/ITJdbcMetadataSelfTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/jdbc/ITJdbcMetadataSelfTest.java
index f6d345f..ef27ca9 100644
--- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/jdbc/ITJdbcMetadataSelfTest.java
+++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/jdbc/ITJdbcMetadataSelfTest.java
@@ -92,8 +92,8 @@ public class ITJdbcMetadataSelfTest extends AbstractJdbcSelfTest {
Table tbl1 = clusterNodes.get(0).tables().table(perTbl.canonicalName());
Table tbl2 = clusterNodes.get(0).tables().table(orgTbl.canonicalName());
- tbl1.recordView().insert(Tuple.create().set("ORGID", 1).set("NAME", "111").set("AGE", 111));
- tbl2.recordView().insert(Tuple.create().set("ID", 1).set("NAME", "AAA").set("BIGDATA", BigDecimal.valueOf(10)));
+ tbl1.insert(Tuple.create().set("ORGID", 1).set("NAME", "111").set("AGE", 111));
+ tbl2.insert(Tuple.create().set("ID", 1).set("NAME", "AAA").set("BIGDATA", BigDecimal.valueOf(10)));
}
/**
diff --git a/modules/table/src/integrationTest/java/org/apache/ignite/distributed/ITDistributedTableTest.java b/modules/table/src/integrationTest/java/org/apache/ignite/distributed/ITDistributedTableTest.java
index ae32af4..b2fec0d 100644
--- a/modules/table/src/integrationTest/java/org/apache/ignite/distributed/ITDistributedTableTest.java
+++ b/modules/table/src/integrationTest/java/org/apache/ignite/distributed/ITDistributedTableTest.java
@@ -63,8 +63,7 @@ import org.apache.ignite.raft.client.Peer;
import org.apache.ignite.raft.client.service.RaftGroupService;
import org.apache.ignite.raft.jraft.RaftMessagesFactory;
import org.apache.ignite.raft.jraft.rpc.impl.RaftGroupServiceImpl;
-import org.apache.ignite.table.KeyValueView;
-import org.apache.ignite.table.RecordView;
+import org.apache.ignite.table.KeyValueBinaryView;
import org.apache.ignite.table.Table;
import org.apache.ignite.table.Tuple;
import org.apache.ignite.utils.ClusterServiceTestUtils;
@@ -301,11 +300,11 @@ public class ITDistributedTableTest {
@Override public Row resolve(BinaryRow row) {
return new Row(SCHEMA, row);
}
- }, null);
+ }, null, null);
- partitionedTableRecordView(tbl.recordView(), PARTS * 10);
+ partitionedTableView(tbl, PARTS * 10);
- partitionedTableKeyValueView(tbl.keyValueView(), PARTS * 10);
+ partitionedTableKVBinaryView(tbl.kvView(), PARTS * 10);
}
/**
@@ -314,7 +313,7 @@ public class ITDistributedTableTest {
* @param view Table view.
* @param keysCnt Count of keys.
*/
- public void partitionedTableRecordView(RecordView<Tuple> view, int keysCnt) {
+ public void partitionedTableView(Table view, int keysCnt) {
LOG.info("Test for Table view [keys={}]", keysCnt);
for (int i = 0; i < keysCnt; i++) {
@@ -405,7 +404,7 @@ public class ITDistributedTableTest {
* @param view Table view.
* @param keysCnt Count of keys.
*/
- public void partitionedTableKeyValueView(KeyValueView<Tuple, Tuple> view, int keysCnt) {
+ public void partitionedTableKVBinaryView(KeyValueBinaryView view, int keysCnt) {
LOG.info("Tes for Key-Value binary view [keys={}]", keysCnt);
for (int i = 0; i < keysCnt; i++) {
diff --git a/modules/table/src/main/java/org/apache/ignite/internal/table/AbstractTableView.java b/modules/table/src/main/java/org/apache/ignite/internal/table/AbstractTableView.java
index 931e996..aab4ad0 100644
--- a/modules/table/src/main/java/org/apache/ignite/internal/table/AbstractTableView.java
+++ b/modules/table/src/main/java/org/apache/ignite/internal/table/AbstractTableView.java
@@ -22,6 +22,7 @@ import java.util.concurrent.ExecutionException;
import org.apache.ignite.internal.schema.SchemaRegistry;
import org.apache.ignite.lang.IgniteInternalException;
import org.apache.ignite.tx.Transaction;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
@@ -32,7 +33,7 @@ abstract class AbstractTableView {
protected final InternalTable tbl;
/** Schema registry. */
- protected final SchemaRegistry schemaReg;
+ final SchemaRegistry schemaReg;
/** The transaction */
protected final @Nullable Transaction tx;
@@ -50,6 +51,26 @@ abstract class AbstractTableView {
}
/**
+ * @return Schema registry for the table.
+ */
+ public @NotNull SchemaRegistry schemaRegistry() {
+ return schemaReg;
+ }
+
+ /**
+ * @return Current transaction.
+ */
+ public @Nullable Transaction transaction() {
+ return tx;
+ }
+
+ /**
+ * @param tx The transaction.
+ * @return Transactional view.
+ */
+ public abstract AbstractTableView withTransaction(Transaction tx);
+
+ /**
* Waits for operation completion.
*
* @param fut Future to wait to.
@@ -71,11 +92,4 @@ abstract class AbstractTableView {
throw new IgniteInternalException(e);
}
}
-
- /**
- * @return Current transaction.
- */
- public @Nullable Transaction transaction() {
- return tx;
- }
}
diff --git a/modules/table/src/main/java/org/apache/ignite/internal/table/KeyValueBinaryViewImpl.java b/modules/table/src/main/java/org/apache/ignite/internal/table/KVBinaryViewImpl.java
similarity index 96%
rename from modules/table/src/main/java/org/apache/ignite/internal/table/KeyValueBinaryViewImpl.java
rename to modules/table/src/main/java/org/apache/ignite/internal/table/KVBinaryViewImpl.java
index 31ea280..4134b43 100644
--- a/modules/table/src/main/java/org/apache/ignite/internal/table/KeyValueBinaryViewImpl.java
+++ b/modules/table/src/main/java/org/apache/ignite/internal/table/KVBinaryViewImpl.java
@@ -29,7 +29,7 @@ import org.apache.ignite.internal.schema.marshaller.TupleMarshaller;
import org.apache.ignite.internal.schema.row.Row;
import org.apache.ignite.internal.table.distributed.TableManager;
import org.apache.ignite.table.InvokeProcessor;
-import org.apache.ignite.table.KeyValueView;
+import org.apache.ignite.table.KeyValueBinaryView;
import org.apache.ignite.table.Tuple;
import org.apache.ignite.tx.Transaction;
import org.jetbrains.annotations.NotNull;
@@ -37,7 +37,7 @@ import org.jetbrains.annotations.NotNull;
/**
* Key-value view implementation for binary user-object representation.
*/
-public class KeyValueBinaryViewImpl extends AbstractTableView implements KeyValueView<Tuple, Tuple> {
+public class KVBinaryViewImpl extends AbstractTableView implements KeyValueBinaryView {
/** Marshaller. */
private final TupleMarshallerImpl marsh;
@@ -50,7 +50,7 @@ public class KeyValueBinaryViewImpl extends AbstractTableView implements KeyValu
* @param tbl Table storage.
* @param schemaReg Schema registry.
*/
- public KeyValueBinaryViewImpl(InternalTable tbl, SchemaRegistry schemaReg, TableManager tblMgr, Transaction tx) {
+ public KVBinaryViewImpl(InternalTable tbl, SchemaRegistry schemaReg, TableManager tblMgr, Transaction tx) {
super(tbl, schemaReg, tx);
this.tblMgr = tblMgr;
@@ -296,8 +296,8 @@ public class KeyValueBinaryViewImpl extends AbstractTableView implements KeyValu
}
/** {@inheritDoc} */
- @Override public KeyValueBinaryViewImpl withTransaction(Transaction tx) {
- return new KeyValueBinaryViewImpl(tbl, schemaReg, tblMgr, tx);
+ @Override public KVBinaryViewImpl withTransaction(Transaction tx) {
+ return new KVBinaryViewImpl(tbl, schemaReg, tblMgr, tx);
}
/**
diff --git a/modules/table/src/main/java/org/apache/ignite/internal/table/KeyValueViewImpl.java b/modules/table/src/main/java/org/apache/ignite/internal/table/KVViewImpl.java
similarity index 96%
rename from modules/table/src/main/java/org/apache/ignite/internal/table/KeyValueViewImpl.java
rename to modules/table/src/main/java/org/apache/ignite/internal/table/KVViewImpl.java
index a0c4b5c..07d04a0 100644
--- a/modules/table/src/main/java/org/apache/ignite/internal/table/KeyValueViewImpl.java
+++ b/modules/table/src/main/java/org/apache/ignite/internal/table/KVViewImpl.java
@@ -38,7 +38,7 @@ import org.jetbrains.annotations.Nullable;
/**
* Key-value view implementation.
*/
-public class KeyValueViewImpl<K, V> extends AbstractTableView implements KeyValueView<K, V> {
+public class KVViewImpl<K, V> extends AbstractTableView implements KeyValueView<K, V> {
/**
* Constructor.
* @param tbl Table storage.
@@ -47,8 +47,8 @@ public class KeyValueViewImpl<K, V> extends AbstractTableView implements KeyValu
* @param valueMapper Value class mapper.
* @param tx The transaction.
*/
- public KeyValueViewImpl(InternalTable tbl, SchemaRegistry schemaReg, KeyMapper<K> keyMapper,
- ValueMapper<V> valueMapper, @Nullable Transaction tx) {
+ public KVViewImpl(InternalTable tbl, SchemaRegistry schemaReg, KeyMapper<K> keyMapper,
+ ValueMapper<V> valueMapper, @Nullable Transaction tx) {
super(tbl, schemaReg, tx);
}
@@ -232,7 +232,7 @@ public class KeyValueViewImpl<K, V> extends AbstractTableView implements KeyValu
}
/** {@inheritDoc} */
- @Override public KeyValueViewImpl<K, V> withTransaction(Transaction tx) {
+ @Override public KVViewImpl<K, V> withTransaction(Transaction tx) {
throw new UnsupportedOperationException("Not implemented yet.");
}
diff --git a/modules/table/src/main/java/org/apache/ignite/internal/table/RecordBinaryViewImpl.java b/modules/table/src/main/java/org/apache/ignite/internal/table/RecordBinaryViewImpl.java
deleted file mode 100644
index b5843fe..0000000
--- a/modules/table/src/main/java/org/apache/ignite/internal/table/RecordBinaryViewImpl.java
+++ /dev/null
@@ -1,377 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.table;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Objects;
-import java.util.concurrent.CompletableFuture;
-import java.util.stream.Collectors;
-import org.apache.ignite.internal.schema.BinaryRow;
-import org.apache.ignite.internal.schema.SchemaRegistry;
-import org.apache.ignite.internal.schema.marshaller.TupleMarshaller;
-import org.apache.ignite.internal.schema.row.Row;
-import org.apache.ignite.internal.table.distributed.TableManager;
-import org.apache.ignite.table.InvokeProcessor;
-import org.apache.ignite.table.RecordView;
-import org.apache.ignite.table.Tuple;
-import org.apache.ignite.tx.Transaction;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Table view implementation for binary objects.
- */
-public class RecordBinaryViewImpl extends AbstractTableView implements RecordView<Tuple> {
- /** Marshaller. */
- private final TupleMarshallerImpl marsh;
-
- /** Table manager. */
- private final TableManager tblMgr;
-
- /**
- * Constructor.
- *
- * @param tbl Table.
- * @param schemaReg Table schema registry.
- * @param tblMgr Table manager.
- * @param tx The transaction.
- */
- public RecordBinaryViewImpl(InternalTable tbl, SchemaRegistry schemaReg, TableManager tblMgr, @Nullable Transaction tx) {
- super(tbl, schemaReg, tx);
-
- marsh = new TupleMarshallerImpl(tblMgr, tbl, schemaReg);
-
- this.tblMgr = tblMgr;
- }
-
-
- /** {@inheritDoc} */
- @Override public RecordBinaryViewImpl withTransaction(Transaction tx) {
- return new RecordBinaryViewImpl(tbl, schemaReg, tblMgr, tx);
- }
-
- /** {@inheritDoc} */
- @Override public Tuple get(@NotNull Tuple keyRec) {
- return sync(getAsync(keyRec));
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull CompletableFuture<Tuple> getAsync(@NotNull Tuple keyRec) {
- Objects.requireNonNull(keyRec);
-
- final Row keyRow = marshaller().marshalKey(keyRec); // Convert to portable format to pass TX/storage layer.
-
- return tbl.get(keyRow, tx).thenApply(this::wrap);
- }
-
- /** {@inheritDoc} */
- @Override public Collection<Tuple> getAll(@NotNull Collection<Tuple> keyRecs) {
- return sync(getAllAsync(keyRecs));
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull CompletableFuture<Collection<Tuple>> getAllAsync(@NotNull Collection<Tuple> keyRecs) {
- Objects.requireNonNull(keyRecs);
-
- HashSet<BinaryRow> keys = new HashSet<>(keyRecs.size());
-
- for (Tuple keyRec : keyRecs) {
- final Row keyRow = marshaller().marshalKey(keyRec);
-
- keys.add(keyRow);
- }
-
- return tbl.getAll(keys, tx).thenApply(this::wrap);
- }
-
- /** {@inheritDoc} */
- @Override public void upsert(@NotNull Tuple rec) {
- sync(upsertAsync(rec));
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull CompletableFuture<Void> upsertAsync(@NotNull Tuple rec) {
- Objects.requireNonNull(rec);
-
- final Row keyRow = marshaller().marshal(rec);
-
- return tbl.upsert(keyRow, tx);
- }
-
- /** {@inheritDoc} */
- @Override public void upsertAll(@NotNull Collection<Tuple> recs) {
- sync(upsertAllAsync(recs));
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull CompletableFuture<Void> upsertAllAsync(@NotNull Collection<Tuple> recs) {
- Objects.requireNonNull(recs);
-
- HashSet<BinaryRow> keys = new HashSet<>(recs.size());
-
- for (Tuple keyRec : recs) {
- final Row keyRow = marshaller().marshal(keyRec);
-
- keys.add(keyRow);
- }
-
- return tbl.upsertAll(keys, tx);
- }
-
- /** {@inheritDoc} */
- @Override public Tuple getAndUpsert(@NotNull Tuple rec) {
- return sync(getAndUpsertAsync(rec));
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull CompletableFuture<Tuple> getAndUpsertAsync(@NotNull Tuple rec) {
- Objects.requireNonNull(rec);
-
- final Row keyRow = marshaller().marshal(rec);
-
- return tbl.getAndUpsert(keyRow, tx).thenApply(this::wrap);
- }
-
- /** {@inheritDoc} */
- @Override public boolean insert(@NotNull Tuple rec) {
- return sync(insertAsync(rec));
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull CompletableFuture<Boolean> insertAsync(@NotNull Tuple rec) {
- Objects.requireNonNull(rec);
-
- final Row keyRow = marshaller().marshal(rec);
-
- return tbl.insert(keyRow, tx);
- }
-
- /** {@inheritDoc} */
- @Override public Collection<Tuple> insertAll(@NotNull Collection<Tuple> recs) {
- return sync(insertAllAsync(recs));
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull CompletableFuture<Collection<Tuple>> insertAllAsync(@NotNull Collection<Tuple> recs) {
- Objects.requireNonNull(recs);
-
- HashSet<BinaryRow> keys = new HashSet<>(recs.size());
-
- for (Tuple keyRec : recs) {
- final Row keyRow = marshaller().marshal(keyRec);
-
- keys.add(keyRow);
- }
-
- return tbl.insertAll(keys, tx).thenApply(this::wrap);
- }
-
- /** {@inheritDoc} */
- @Override public boolean replace(@NotNull Tuple rec) {
- return sync(replaceAsync(rec));
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull CompletableFuture<Boolean> replaceAsync(@NotNull Tuple rec) {
- Objects.requireNonNull(rec);
-
- final Row keyRow = marshaller().marshal(rec);
-
- return tbl.replace(keyRow, tx);
- }
-
- /** {@inheritDoc} */
- @Override public boolean replace(@NotNull Tuple oldRec, @NotNull Tuple newRec) {
- return sync(replaceAsync(oldRec, newRec));
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull CompletableFuture<Boolean> replaceAsync(@NotNull Tuple oldRec, @NotNull Tuple newRec) {
- Objects.requireNonNull(oldRec);
- Objects.requireNonNull(newRec);
-
- final Row oldRow = marshaller().marshal(oldRec);
- final Row newRow = marshaller().marshal(newRec);
-
- return tbl.replace(oldRow, newRow, tx);
- }
-
- /** {@inheritDoc} */
- @Override public Tuple getAndReplace(@NotNull Tuple rec) {
- return sync(getAndReplaceAsync(rec));
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull CompletableFuture<Tuple> getAndReplaceAsync(@NotNull Tuple rec) {
- Objects.requireNonNull(rec);
-
- final Row keyRow = marshaller().marshal(rec);
-
- return tbl.getAndReplace(keyRow, tx).thenApply(this::wrap);
- }
-
- /** {@inheritDoc} */
- @Override public boolean delete(@NotNull Tuple keyRec) {
- return sync(deleteAsync(keyRec));
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull CompletableFuture<Boolean> deleteAsync(@NotNull Tuple keyRec) {
- Objects.requireNonNull(keyRec);
-
- final Row keyRow = marshaller().marshalKey(keyRec);
-
- return tbl.delete(keyRow, tx);
- }
-
- /** {@inheritDoc} */
- @Override public boolean deleteExact(@NotNull Tuple rec) {
- return sync(deleteExactAsync(rec));
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull CompletableFuture<Boolean> deleteExactAsync(@NotNull Tuple rec) {
- Objects.requireNonNull(rec);
-
- final Row row = marshaller().marshal(rec);
-
- return tbl.deleteExact(row, tx);
- }
-
- /** {@inheritDoc} */
- @Override public Tuple getAndDelete(@NotNull Tuple rec) {
- return sync(getAndDeleteAsync(rec));
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull CompletableFuture<Tuple> getAndDeleteAsync(@NotNull Tuple rec) {
- Objects.requireNonNull(rec);
-
- final Row row = marshaller().marshalKey(rec);
-
- return tbl.getAndDelete(row, tx).thenApply(this::wrap);
- }
-
- /** {@inheritDoc} */
- @Override public Collection<Tuple> deleteAll(@NotNull Collection<Tuple> recs) {
- return sync(deleteAllAsync(recs));
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull CompletableFuture<Collection<Tuple>> deleteAllAsync(@NotNull Collection<Tuple> recs) {
- Objects.requireNonNull(recs);
-
- HashSet<BinaryRow> keys = new HashSet<>(recs.size());
-
- for (Tuple keyRec : recs) {
- final Row keyRow = marshaller().marshalKey(keyRec);
-
- keys.add(keyRow);
- }
-
- return tbl.deleteAll(keys, tx).thenApply(this::wrap);
- }
-
- /** {@inheritDoc} */
- @Override public Collection<Tuple> deleteAllExact(@NotNull Collection<Tuple> recs) {
- return sync(deleteAllExactAsync(recs));
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull CompletableFuture<Collection<Tuple>> deleteAllExactAsync(
- @NotNull Collection<Tuple> recs
- ) {
- Objects.requireNonNull(recs);
-
- HashSet<BinaryRow> keys = new HashSet<>(recs.size());
-
- for (Tuple keyRec : recs) {
- final Row keyRow = marshaller().marshal(keyRec);
-
- keys.add(keyRow);
- }
-
- return tbl.deleteAllExact(keys, tx).thenApply(this::wrap);
- }
-
- /** {@inheritDoc} */
- @Override public <T extends Serializable> T invoke(
- @NotNull Tuple keyRec,
- InvokeProcessor<Tuple, Tuple, T> proc
- ) {
- throw new UnsupportedOperationException("Not implemented yet.");
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull <T extends Serializable> CompletableFuture<T> invokeAsync(
- @NotNull Tuple keyRec,
- InvokeProcessor<Tuple, Tuple, T> proc
- ) {
- throw new UnsupportedOperationException("Not implemented yet.");
- }
-
- /** {@inheritDoc} */
- @Override public <T extends Serializable> Map<Tuple, T> invokeAll(
- @NotNull Collection<Tuple> keyRecs,
- InvokeProcessor<Tuple, Tuple, T> proc
- ) {
- throw new UnsupportedOperationException("Not implemented yet.");
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull <T extends Serializable> CompletableFuture<Map<Tuple, T>> invokeAllAsync(
- @NotNull Collection<Tuple> keyRecs,
- InvokeProcessor<Tuple, Tuple, T> proc
- ) {
- throw new UnsupportedOperationException("Not implemented yet.");
- }
-
- /**
- * @return Marshaller.
- */
- private TupleMarshaller marshaller() {
- return marsh;
- }
-
- /**
- * @param row Binary row.
- * @return Table row tuple.
- */
- private Tuple wrap(BinaryRow row) {
- if (row == null)
- return null;
-
- final Row wrapped = schemaReg.resolve(row);
-
- return TableRow.tuple(wrapped);
- }
-
- /**
- * @param rows Binary rows.
- * @return Table rows.
- */
- private Collection<Tuple> wrap(Collection<BinaryRow> rows) {
- if (rows == null)
- return null;
-
- return rows.stream().filter(Objects::nonNull).map(this::wrap).collect(Collectors.toSet());
- }
-}
diff --git a/modules/table/src/main/java/org/apache/ignite/internal/table/RecordViewImpl.java b/modules/table/src/main/java/org/apache/ignite/internal/table/RecordViewImpl.java
index 8bdcc44..709f113 100644
--- a/modules/table/src/main/java/org/apache/ignite/internal/table/RecordViewImpl.java
+++ b/modules/table/src/main/java/org/apache/ignite/internal/table/RecordViewImpl.java
@@ -50,6 +50,24 @@ public class RecordViewImpl<R> extends AbstractTableView implements RecordView<R
}
/** {@inheritDoc} */
+ @Override public R fill(R recObjToFill) {
+ return sync(fillAsync(recObjToFill));
+ }
+
+ /** {@inheritDoc} */
+ @Override public CompletableFuture<R> fillAsync(R recObjToFill) {
+ Objects.requireNonNull(recObjToFill);
+
+ RecordSerializer<R> marsh = serializer();
+
+ Row kRow = marsh.serialize(recObjToFill); // Convert to portable format to pass TX/storage layer.
+
+ return tbl.get(kRow, tx) // Load async.
+ .thenApply(this::wrap) // Binary -> schema-aware row
+ .thenApply(r -> marsh.deserialize(r, recObjToFill)); // Deserialize and fill record.
+ }
+
+ /** {@inheritDoc} */
@Override public R get(@NotNull R keyRec) {
return sync(getAsync(keyRec));
}
diff --git a/modules/table/src/main/java/org/apache/ignite/internal/table/TableImpl.java b/modules/table/src/main/java/org/apache/ignite/internal/table/TableImpl.java
index 34e27d2..3cca8b2 100644
--- a/modules/table/src/main/java/org/apache/ignite/internal/table/TableImpl.java
+++ b/modules/table/src/main/java/org/apache/ignite/internal/table/TableImpl.java
@@ -17,10 +17,22 @@
package org.apache.ignite.internal.table;
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.CompletableFuture;
+import java.util.stream.Collectors;
+import org.apache.ignite.internal.schema.BinaryRow;
import org.apache.ignite.internal.schema.SchemaRegistry;
+import org.apache.ignite.internal.schema.marshaller.TupleMarshaller;
+import org.apache.ignite.internal.schema.row.Row;
import org.apache.ignite.internal.table.distributed.TableManager;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.schema.definition.SchemaManagementMode;
+import org.apache.ignite.table.InvokeProcessor;
+import org.apache.ignite.table.KeyValueBinaryView;
import org.apache.ignite.table.KeyValueView;
import org.apache.ignite.table.RecordView;
import org.apache.ignite.table.Table;
@@ -28,31 +40,33 @@ import org.apache.ignite.table.Tuple;
import org.apache.ignite.table.mapper.KeyMapper;
import org.apache.ignite.table.mapper.RecordMapper;
import org.apache.ignite.table.mapper.ValueMapper;
+import org.apache.ignite.tx.Transaction;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
/**
* Table view implementation for binary objects.
*/
-public class TableImpl implements Table {
+public class TableImpl extends AbstractTableView implements Table {
+ /** Marshaller. */
+ private final TupleMarshallerImpl marsh;
+
/** Table manager. */
private final TableManager tblMgr;
- /** Internal table. */
- private final InternalTable tbl;
-
- /** Schema registry. */
- private final SchemaRegistry schemaReg;
-
/**
* Constructor.
*
* @param tbl Table.
* @param schemaReg Table schema registry.
* @param tblMgr Table manager.
+ * @param tx The transaction.
*/
- public TableImpl(InternalTable tbl, SchemaRegistry schemaReg, TableManager tblMgr) {
- this.tbl = tbl;
- this.schemaReg = schemaReg;
+ public TableImpl(InternalTable tbl, SchemaRegistry schemaReg, TableManager tblMgr, @Nullable Transaction tx) {
+ super(tbl, schemaReg, tx);
+
+ marsh = new TupleMarshallerImpl(tblMgr, tbl, schemaReg);
+
this.tblMgr = tblMgr;
}
@@ -81,28 +95,335 @@ public class TableImpl implements Table {
/** {@inheritDoc} */
@Override public <R> RecordView<R> recordView(RecordMapper<R> recMapper) {
- return new RecordViewImpl<>(tbl, schemaReg, recMapper, null);
+ return new RecordViewImpl<>(tbl, schemaReg, recMapper, tx);
+ }
+
+ /** {@inheritDoc} */
+ @Override public <K, V> KeyValueView<K, V> kvView(KeyMapper<K> keyMapper, ValueMapper<V> valMapper) {
+ return new KVViewImpl<>(tbl, schemaReg, keyMapper, valMapper, tx);
+ }
+
+ /** {@inheritDoc} */
+ @Override public KeyValueBinaryView kvView() {
+ return new KVBinaryViewImpl(tbl, schemaReg, tblMgr, tx);
+ }
+
+ /** {@inheritDoc} */
+ @Override public TableImpl withTransaction(Transaction tx) {
+ return new TableImpl(tbl, schemaReg, tblMgr, tx);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Tuple get(@NotNull Tuple keyRec) {
+ return sync(getAsync(keyRec));
+ }
+
+ /** {@inheritDoc} */
+ @Override public @NotNull CompletableFuture<Tuple> getAsync(@NotNull Tuple keyRec) {
+ Objects.requireNonNull(keyRec);
+
+ final Row keyRow = marshaller().marshalKey(keyRec); // Convert to portable format to pass TX/storage layer.
+
+ return tbl.get(keyRow, tx).thenApply(this::wrap);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<Tuple> getAll(@NotNull Collection<Tuple> keyRecs) {
+ return sync(getAllAsync(keyRecs));
+ }
+
+ /** {@inheritDoc} */
+ @Override public @NotNull CompletableFuture<Collection<Tuple>> getAllAsync(@NotNull Collection<Tuple> keyRecs) {
+ Objects.requireNonNull(keyRecs);
+
+ HashSet<BinaryRow> keys = new HashSet<>(keyRecs.size());
+
+ for (Tuple keyRec : keyRecs) {
+ final Row keyRow = marshaller().marshalKey(keyRec);
+
+ keys.add(keyRow);
+ }
+
+ return tbl.getAll(keys, tx).thenApply(this::wrap);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void upsert(@NotNull Tuple rec) {
+ sync(upsertAsync(rec));
+ }
+
+ /** {@inheritDoc} */
+ @Override public @NotNull CompletableFuture<Void> upsertAsync(@NotNull Tuple rec) {
+ Objects.requireNonNull(rec);
+
+ final Row keyRow = marshaller().marshal(rec);
+
+ return tbl.upsert(keyRow, tx);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void upsertAll(@NotNull Collection<Tuple> recs) {
+ sync(upsertAllAsync(recs));
+ }
+
+ /** {@inheritDoc} */
+ @Override public @NotNull CompletableFuture<Void> upsertAllAsync(@NotNull Collection<Tuple> recs) {
+ Objects.requireNonNull(recs);
+
+ HashSet<BinaryRow> keys = new HashSet<>(recs.size());
+
+ for (Tuple keyRec : recs) {
+ final Row keyRow = marshaller().marshal(keyRec);
+
+ keys.add(keyRow);
+ }
+
+ return tbl.upsertAll(keys, tx);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Tuple getAndUpsert(@NotNull Tuple rec) {
+ return sync(getAndUpsertAsync(rec));
+ }
+
+ /** {@inheritDoc} */
+ @Override public @NotNull CompletableFuture<Tuple> getAndUpsertAsync(@NotNull Tuple rec) {
+ Objects.requireNonNull(rec);
+
+ final Row keyRow = marshaller().marshal(rec);
+
+ return tbl.getAndUpsert(keyRow, tx).thenApply(this::wrap);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean insert(@NotNull Tuple rec) {
+ return sync(insertAsync(rec));
+ }
+
+ /** {@inheritDoc} */
+ @Override public @NotNull CompletableFuture<Boolean> insertAsync(@NotNull Tuple rec) {
+ Objects.requireNonNull(rec);
+
+ final Row keyRow = marshaller().marshal(rec);
+
+ return tbl.insert(keyRow, tx);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<Tuple> insertAll(@NotNull Collection<Tuple> recs) {
+ return sync(insertAllAsync(recs));
+ }
+
+ /** {@inheritDoc} */
+ @Override public @NotNull CompletableFuture<Collection<Tuple>> insertAllAsync(@NotNull Collection<Tuple> recs) {
+ Objects.requireNonNull(recs);
+
+ HashSet<BinaryRow> keys = new HashSet<>(recs.size());
+
+ for (Tuple keyRec : recs) {
+ final Row keyRow = marshaller().marshal(keyRec);
+
+ keys.add(keyRow);
+ }
+
+ return tbl.insertAll(keys, tx).thenApply(this::wrap);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean replace(@NotNull Tuple rec) {
+ return sync(replaceAsync(rec));
+ }
+
+ /** {@inheritDoc} */
+ @Override public @NotNull CompletableFuture<Boolean> replaceAsync(@NotNull Tuple rec) {
+ Objects.requireNonNull(rec);
+
+ final Row keyRow = marshaller().marshal(rec);
+
+ return tbl.replace(keyRow, tx);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean replace(@NotNull Tuple oldRec, @NotNull Tuple newRec) {
+ return sync(replaceAsync(oldRec, newRec));
+ }
+
+ /** {@inheritDoc} */
+ @Override public @NotNull CompletableFuture<Boolean> replaceAsync(@NotNull Tuple oldRec, @NotNull Tuple newRec) {
+ Objects.requireNonNull(oldRec);
+ Objects.requireNonNull(newRec);
+
+ final Row oldRow = marshaller().marshal(oldRec);
+ final Row newRow = marshaller().marshal(newRec);
+
+ return tbl.replace(oldRow, newRow, tx);
}
/** {@inheritDoc} */
- @Override public RecordView<Tuple> recordView() {
- return new RecordBinaryViewImpl(tbl, schemaReg, tblMgr, null);
+ @Override public Tuple getAndReplace(@NotNull Tuple rec) {
+ return sync(getAndReplaceAsync(rec));
}
/** {@inheritDoc} */
- @Override public <K, V> KeyValueView<K, V> keyValueView(KeyMapper<K> keyMapper, ValueMapper<V> valMapper) {
- return new KeyValueViewImpl<>(tbl, schemaReg, keyMapper, valMapper, null);
+ @Override public @NotNull CompletableFuture<Tuple> getAndReplaceAsync(@NotNull Tuple rec) {
+ Objects.requireNonNull(rec);
+
+ final Row keyRow = marshaller().marshal(rec);
+
+ return tbl.getAndReplace(keyRow, tx).thenApply(this::wrap);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean delete(@NotNull Tuple keyRec) {
+ return sync(deleteAsync(keyRec));
+ }
+
+ /** {@inheritDoc} */
+ @Override public @NotNull CompletableFuture<Boolean> deleteAsync(@NotNull Tuple keyRec) {
+ Objects.requireNonNull(keyRec);
+
+ final Row keyRow = marshaller().marshalKey(keyRec);
+
+ return tbl.delete(keyRow, tx);
}
/** {@inheritDoc} */
- @Override public KeyValueView<Tuple, Tuple> keyValueView() {
- return new KeyValueBinaryViewImpl(tbl, schemaReg, tblMgr, null);
+ @Override public boolean deleteExact(@NotNull Tuple rec) {
+ return sync(deleteExactAsync(rec));
+ }
+
+ /** {@inheritDoc} */
+ @Override public @NotNull CompletableFuture<Boolean> deleteExactAsync(@NotNull Tuple rec) {
+ Objects.requireNonNull(rec);
+
+ final Row row = marshaller().marshal(rec);
+
+ return tbl.deleteExact(row, tx);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Tuple getAndDelete(@NotNull Tuple rec) {
+ return sync(getAndDeleteAsync(rec));
+ }
+
+ /** {@inheritDoc} */
+ @Override public @NotNull CompletableFuture<Tuple> getAndDeleteAsync(@NotNull Tuple rec) {
+ Objects.requireNonNull(rec);
+
+ final Row row = marshaller().marshalKey(rec);
+
+ return tbl.getAndDelete(row, tx).thenApply(this::wrap);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<Tuple> deleteAll(@NotNull Collection<Tuple> recs) {
+ return sync(deleteAllAsync(recs));
+ }
+
+ /** {@inheritDoc} */
+ @Override public @NotNull CompletableFuture<Collection<Tuple>> deleteAllAsync(@NotNull Collection<Tuple> recs) {
+ Objects.requireNonNull(recs);
+
+ HashSet<BinaryRow> keys = new HashSet<>(recs.size());
+
+ for (Tuple keyRec : recs) {
+ final Row keyRow = marshaller().marshalKey(keyRec);
+
+ keys.add(keyRow);
+ }
+
+ return tbl.deleteAll(keys, tx).thenApply(this::wrap);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<Tuple> deleteAllExact(@NotNull Collection<Tuple> recs) {
+ return sync(deleteAllExactAsync(recs));
+ }
+
+ /** {@inheritDoc} */
+ @Override public @NotNull CompletableFuture<Collection<Tuple>> deleteAllExactAsync(
+ @NotNull Collection<Tuple> recs
+ ) {
+ Objects.requireNonNull(recs);
+
+ HashSet<BinaryRow> keys = new HashSet<>(recs.size());
+
+ for (Tuple keyRec : recs) {
+ final Row keyRow = marshaller().marshal(keyRec);
+
+ keys.add(keyRow);
+ }
+
+ return tbl.deleteAllExact(keys, tx).thenApply(this::wrap);
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T extends Serializable> T invoke(
+ @NotNull Tuple keyRec,
+ InvokeProcessor<Tuple, Tuple, T> proc
+ ) {
+ throw new UnsupportedOperationException("Not implemented yet.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public @NotNull <T extends Serializable> CompletableFuture<T> invokeAsync(
+ @NotNull Tuple keyRec,
+ InvokeProcessor<Tuple, Tuple, T> proc
+ ) {
+ throw new UnsupportedOperationException("Not implemented yet.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T extends Serializable> Map<Tuple, T> invokeAll(
+ @NotNull Collection<Tuple> keyRecs,
+ InvokeProcessor<Tuple, Tuple, T> proc
+ ) {
+ throw new UnsupportedOperationException("Not implemented yet.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public @NotNull <T extends Serializable> CompletableFuture<Map<Tuple, T>> invokeAllAsync(
+ @NotNull Collection<Tuple> keyRecs,
+ InvokeProcessor<Tuple, Tuple, T> proc
+ ) {
+ throw new UnsupportedOperationException("Not implemented yet.");
+ }
+
+ /**
+ * @return Marshaller.
+ */
+ private TupleMarshaller marshaller() {
+ return marsh;
+ }
+
+ /**
+ * @param row Binary row.
+ * @return Table row tuple.
+ */
+ private Tuple wrap(BinaryRow row) {
+ if (row == null)
+ return null;
+
+ final Row wrapped = schemaReg.resolve(row);
+
+ return TableRow.tuple(wrapped);
+ }
+
+ /**
+ * @param rows Binary rows.
+ * @return Table rows.
+ */
+ private Collection<Tuple> wrap(Collection<BinaryRow> rows) {
+ if (rows == null)
+ return null;
+
+ return rows.stream().filter(Objects::nonNull).map(this::wrap).collect(Collectors.toSet());
}
/**
- * @param schemaMode New schema management mode.
+ * @param schemaMode New schema type.
*/
- public void schemaMode(SchemaManagementMode schemaMode) {
+ public void schemaType(SchemaManagementMode schemaMode) {
this.tbl.schema(schemaMode);
}
}
diff --git a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
index eb10ede..b6b2fb1 100644
--- a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
+++ b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
@@ -164,7 +164,7 @@ public class TableManager extends Producer<TableEvent, TableEventParameters> imp
@Override public @NotNull CompletableFuture<?> onCreate(
@NotNull ConfigurationNotificationEvent<SchemaView> schemasCtx) {
try {
- ((SchemaRegistryImpl)tables.get(ctx.newValue().name()).schemaView()).
+ ((SchemaRegistryImpl)tables.get(ctx.newValue().name()).schemaRegistry()).
onSchemaRegistered((SchemaDescriptor)ByteUtils.
fromBytes(schemasCtx.newValue().schema()));
@@ -305,7 +305,8 @@ public class TableManager extends Producer<TableEvent, TableEventParameters> imp
var table = new TableImpl(
internalTable,
schemaRegistry,
- TableManager.this
+ TableManager.this,
+ null
);
tables.put(name, table);
@@ -533,7 +534,7 @@ public class TableManager extends Producer<TableEvent, TableEventParameters> imp
);
descriptor.columnMapping(SchemaUtils.columnMapper(
- tablesById.get(tblId).schemaView().schema(currTableView.schemas().size()),
+ tablesById.get(tblId).schemaRegistry().schema(currTableView.schemas().size()),
currTableView,
descriptor,
tblCh
diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/Example.java b/modules/table/src/test/java/org/apache/ignite/internal/table/Example.java
index 0fbd12a..b002232 100644
--- a/modules/table/src/test/java/org/apache/ignite/internal/table/Example.java
+++ b/modules/table/src/test/java/org/apache/ignite/internal/table/Example.java
@@ -43,7 +43,7 @@ public class Example {
* @return Table implementation.
*/
private static List<Table> tableFactory() {
- return Collections.singletonList(new TableImpl(new DummyInternalTableImpl(), null, null));
+ return Collections.singletonList(new TableImpl(new DummyInternalTableImpl(), null, null, null));
}
/**
@@ -59,7 +59,7 @@ public class Example {
@MethodSource("tableFactory")
public void useCase1(Table t) {
// Search row will allow nulls even in non-null columns.
- Tuple res = t.recordView().get(Tuple.create().set("id", 1).set("orgId", 1));
+ Tuple res = t.get(Tuple.create().set("id", 1).set("orgId", 1));
String name = res.value("name");
String lastName = res.value("latName");
@@ -137,7 +137,7 @@ public class Example {
int department;
}
- KeyValueView<EmployeeKey, Employee> employeeKv = t.keyValueView(EmployeeKey.class, Employee.class);
+ KeyValueView<EmployeeKey, Employee> employeeKv = t.kvView(EmployeeKey.class, Employee.class);
employeeKv.get(new EmployeeKey(1, 1));
@@ -147,7 +147,7 @@ public class Example {
String lastName;
}
- KeyValueView<EmployeeKey, TruncatedEmployee> truncatedEmployeeKv = t.keyValueView(EmployeeKey.class, TruncatedEmployee.class);
+ KeyValueView<EmployeeKey, TruncatedEmployee> truncatedEmployeeKv = t.kvView(EmployeeKey.class, TruncatedEmployee.class);
TruncatedEmployee te = truncatedEmployeeKv.get(new EmployeeKey(1, 1));
}
@@ -179,14 +179,14 @@ public class Example {
String bankName;
}
- KeyValueView<Long, CreditCard> credCardKvView = t.keyValueView(Long.class, CreditCard.class);
+ KeyValueView<Long, CreditCard> credCardKvView = t.kvView(Long.class, CreditCard.class);
CreditCard creditCard = credCardKvView.get(1L);
- KeyValueView<Long, BankAccount> backAccKvView = t.keyValueView(Long.class, BankAccount.class);
+ KeyValueView<Long, BankAccount> backAccKvView = t.kvView(Long.class, BankAccount.class);
BankAccount bankAccount = backAccKvView.get(2L);
// Truncated view.
- KeyValueView<Long, BillingDetails> billingDetailsKVView = t.keyValueView(Long.class, BillingDetails.class);
+ KeyValueView<Long, BillingDetails> billingDetailsKVView = t.kvView(Long.class, BillingDetails.class);
BillingDetails billingDetails = billingDetailsKVView.get(2L);
// Without discriminator it is impossible to deserialize to correct type automatically.
@@ -255,7 +255,7 @@ public class Example {
String bankName;
}
- KeyValueView<OrderKey, OrderValue> orderKvView = t.keyValueView(Mappers.ofKeyClass(OrderKey.class),
+ KeyValueView<OrderKey, OrderValue> orderKvView = t.kvView(Mappers.ofKeyClass(OrderKey.class),
Mappers.ofValueClassBuilder(OrderValue.class)
.map("billingDetails", (row) -> {
BinaryObject bObj = row.binaryObjectValue("conditionalDetails");
@@ -269,7 +269,7 @@ public class Example {
OrderValue ov = orderKvView.get(new OrderKey(1, 1));
// Same with direct Row access and BinaryObject wrapper.
- Tuple res = t.recordView().get(Tuple.create().set("id", 1).set("orgId", 1));
+ Tuple res = t.get(Tuple.create().set("id", 1).set("orgId", 1));
byte[] objData = res.value("billingDetails");
BinaryObject binObj = BinaryObjects.wrap(objData);
@@ -318,7 +318,7 @@ public class Example {
@ParameterizedTest
@MethodSource("tableFactory")
public void useCase5(Table t) {
- Tuple res = t.recordView().get(Tuple.create().set("id", 1).set("orgId", 1));
+ Tuple res = t.get(Tuple.create().set("id", 1).set("orgId", 1));
byte[] objData = res.value("originalObject");
BinaryObject binObj = BinaryObjects.wrap(objData);
@@ -402,7 +402,7 @@ public class Example {
@MethodSource("tableFactory")
public void useCase6(Table t) {
// Search row will allow nulls even in non-null columns.
- Tuple res = t.recordView().get(Tuple.create().set("id", 1));
+ Tuple res = t.get(Tuple.create().set("id", 1));
String name = res.value("name");
String lastName = res.value("latName");
@@ -424,7 +424,7 @@ public class Example {
long id;
}
- KeyValueView<Long, Employee> employeeView = t.keyValueView(Long.class, Employee.class);
+ KeyValueView<Long, Employee> employeeView = t.kvView(Long.class, Employee.class);
Employee e = employeeView.get(1L);
}
@@ -449,11 +449,11 @@ public class Example {
int department;
}
- KeyValueView<Long, BinaryObject> employeeView = t.keyValueView(Long.class, BinaryObject.class);
+ KeyValueView<Long, BinaryObject> employeeView = t.kvView(Long.class, BinaryObject.class);
employeeView.put(1L, BinaryObjects.wrap(new byte[0] /* serialized Employee */));
- t.keyValueView(
+ t.kvView(
Mappers.identity(),
Mappers.ofValueClassBuilder(BinaryObject.class).deserializeTo(Employee.class).build());
}
diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/KeyValueBinaryViewOperationsTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/KVBinaryViewOperationsTest.java
similarity index 90%
rename from modules/table/src/test/java/org/apache/ignite/internal/table/KeyValueBinaryViewOperationsTest.java
rename to modules/table/src/test/java/org/apache/ignite/internal/table/KVBinaryViewOperationsTest.java
index ef4a133..5196553 100644
--- a/modules/table/src/test/java/org/apache/ignite/internal/table/KeyValueBinaryViewOperationsTest.java
+++ b/modules/table/src/test/java/org/apache/ignite/internal/table/KVBinaryViewOperationsTest.java
@@ -22,7 +22,7 @@ import org.apache.ignite.internal.schema.NativeTypes;
import org.apache.ignite.internal.schema.SchemaDescriptor;
import org.apache.ignite.internal.table.impl.DummyInternalTableImpl;
import org.apache.ignite.internal.table.impl.DummySchemaManagerImpl;
-import org.apache.ignite.table.KeyValueView;
+import org.apache.ignite.table.KeyValueBinaryView;
import org.apache.ignite.table.Tuple;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -40,7 +40,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
* TODO: IGNITE-14487 Check non-key fields in Tuple is ignored for keys.
* TODO: IGNITE-14487 Check key fields in Tuple is ignored for value or exception is thrown?
*/
-public class KeyValueBinaryViewOperationsTest {
+public class KVBinaryViewOperationsTest {
/**
*
*/
@@ -52,8 +52,8 @@ public class KeyValueBinaryViewOperationsTest {
new Column[] {new Column("val", NativeTypes.INT64, false)}
);
- KeyValueView<Tuple, Tuple> tbl =
- new KeyValueBinaryViewImpl(new DummyInternalTableImpl(), new DummySchemaManagerImpl(schema), null, null);
+ KeyValueBinaryView tbl =
+ new KVBinaryViewImpl(new DummyInternalTableImpl(), new DummySchemaManagerImpl(schema), null, null);
final Tuple key = Tuple.create().set("id", 1L);
final Tuple val = Tuple.create().set("val", 11L);
@@ -95,8 +95,8 @@ public class KeyValueBinaryViewOperationsTest {
new Column[] {new Column("val", NativeTypes.INT64, false)}
);
- KeyValueView<Tuple, Tuple> tbl =
- new KeyValueBinaryViewImpl(new DummyInternalTableImpl(), new DummySchemaManagerImpl(schema), null, null);
+ KeyValueBinaryView tbl =
+ new KVBinaryViewImpl(new DummyInternalTableImpl(), new DummySchemaManagerImpl(schema), null, null);
final Tuple key = Tuple.create().set("id", 1L);
final Tuple val = Tuple.create().set("val", 11L);
@@ -128,8 +128,8 @@ public class KeyValueBinaryViewOperationsTest {
new Column[] {new Column("val", NativeTypes.INT64, false)}
);
- KeyValueView<Tuple, Tuple> tbl =
- new KeyValueBinaryViewImpl(new DummyInternalTableImpl(), new DummySchemaManagerImpl(schema), null, null);
+ KeyValueBinaryView tbl =
+ new KVBinaryViewImpl(new DummyInternalTableImpl(), new DummySchemaManagerImpl(schema), null, null);
final Tuple key = Tuple.create().set("id", 1L);
final Tuple val = Tuple.create().set("val", 11L);
@@ -162,8 +162,8 @@ public class KeyValueBinaryViewOperationsTest {
new Column[] {new Column("val", NativeTypes.INT64, false)}
);
- KeyValueView<Tuple, Tuple> tbl =
- new KeyValueBinaryViewImpl(new DummyInternalTableImpl(), new DummySchemaManagerImpl(schema), null, null);
+ KeyValueBinaryView tbl =
+ new KVBinaryViewImpl(new DummyInternalTableImpl(), new DummySchemaManagerImpl(schema), null, null);
final Tuple key = Tuple.create().set("id", 1L);
final Tuple key2 = Tuple.create().set("id", 2L);
@@ -205,8 +205,8 @@ public class KeyValueBinaryViewOperationsTest {
new Column[] {new Column("val", NativeTypes.INT64, false)}
);
- final KeyValueView<Tuple, Tuple> tbl =
- new KeyValueBinaryViewImpl(new DummyInternalTableImpl(), new DummySchemaManagerImpl(schema), null, null);
+ final KeyValueBinaryView tbl =
+ new KVBinaryViewImpl(new DummyInternalTableImpl(), new DummySchemaManagerImpl(schema), null, null);
final Tuple key = Tuple.create().set("id", 1L);
final Tuple key2 = Tuple.create().set("id", 2L);
@@ -260,8 +260,8 @@ public class KeyValueBinaryViewOperationsTest {
new Column[] {new Column("val", NativeTypes.INT64, false)}
);
- KeyValueView<Tuple, Tuple> tbl =
- new KeyValueBinaryViewImpl(new DummyInternalTableImpl(), new DummySchemaManagerImpl(schema), null, null);
+ KeyValueBinaryView tbl =
+ new KVBinaryViewImpl(new DummyInternalTableImpl(), new DummySchemaManagerImpl(schema), null, null);
final Tuple key = Tuple.create().set("id", 1L);
final Tuple key2 = Tuple.create().set("id", 2L);
@@ -306,8 +306,8 @@ public class KeyValueBinaryViewOperationsTest {
new Column[] {new Column("val", NativeTypes.INT64, false)}
);
- KeyValueView<Tuple, Tuple> tbl =
- new KeyValueBinaryViewImpl(new DummyInternalTableImpl(), new DummySchemaManagerImpl(schema), null, null);
+ KeyValueBinaryView tbl =
+ new KVBinaryViewImpl(new DummyInternalTableImpl(), new DummySchemaManagerImpl(schema), null, null);
final Tuple key = Tuple.create().set("id", 1L);
final Tuple key2 = Tuple.create().set("id", 2L);
diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/StrictSchemaOperationsTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/StrictSchemaOperationsTest.java
index ab5088f..bf02686 100644
--- a/modules/table/src/test/java/org/apache/ignite/internal/table/StrictSchemaOperationsTest.java
+++ b/modules/table/src/test/java/org/apache/ignite/internal/table/StrictSchemaOperationsTest.java
@@ -24,7 +24,6 @@ import org.apache.ignite.internal.schema.SchemaDescriptor;
import org.apache.ignite.internal.schema.SchemaMismatchException;
import org.apache.ignite.internal.table.impl.DummyInternalTableImpl;
import org.apache.ignite.internal.table.impl.DummySchemaManagerImpl;
-import org.apache.ignite.table.RecordView;
import org.apache.ignite.table.Table;
import org.apache.ignite.table.Tuple;
import org.junit.jupiter.api.Test;
@@ -46,9 +45,9 @@ public class StrictSchemaOperationsTest {
new Column[] {new Column("val", NativeTypes.INT64, true)}
);
- RecordView<Tuple> recView = createTableImpl(schema).recordView();
+ Table tbl = new TableImpl(new DummyInternalTableImpl(), new DummySchemaManagerImpl(schema), null, null);
- assertThrows(SchemaMismatchException.class, () -> recView.insert(Tuple.create().set("id", 0L).set("invalidCol", 0)));
+ assertThrows(SchemaMismatchException.class, () -> tbl.insert(Tuple.create().set("id", 0L).set("invalidCol", 0)));
}
/**
@@ -65,17 +64,17 @@ public class StrictSchemaOperationsTest {
new Column[] {new Column("val", NativeTypes.INT64, true)}
);
- Table tbl = createTableImpl(schema);
+ Table tbl = new TableImpl(new DummyInternalTableImpl(), new DummySchemaManagerImpl(schema), null, null);
- assertThrows(SchemaMismatchException.class, () -> tbl.recordView().get(Tuple.create().set("id", 0L).set("affId", 1L).set("val", 0L)));
- assertThrows(SchemaMismatchException.class, () -> tbl.recordView().get(Tuple.create().set("id", 0L)));
+ assertThrows(SchemaMismatchException.class, () -> tbl.get(Tuple.create().set("id", 0L).set("affId", 1L).set("val", 0L)));
+ assertThrows(SchemaMismatchException.class, () -> tbl.get(Tuple.create().set("id", 0L)));
- assertThrows(SchemaMismatchException.class, () -> tbl.keyValueView().get(Tuple.create().set("id", 0L)));
- assertThrows(SchemaMismatchException.class, () -> tbl.keyValueView().get(Tuple.create().set("id", 0L).set("affId", 1L).set("val", 0L)));
+ assertThrows(SchemaMismatchException.class, () -> tbl.kvView().get(Tuple.create().set("id", 0L)));
+ assertThrows(SchemaMismatchException.class, () -> tbl.kvView().get(Tuple.create().set("id", 0L).set("affId", 1L).set("val", 0L)));
- assertThrows(SchemaMismatchException.class, () -> tbl.keyValueView().put(Tuple.create().set("id", 0L), Tuple.create()));
- assertThrows(SchemaMismatchException.class, () -> tbl.keyValueView().put(Tuple.create().set("id", 0L).set("affId", 1L).set("val", 0L), Tuple.create()));
- assertThrows(SchemaMismatchException.class, () -> tbl.keyValueView().put(Tuple.create().set("id", 0L).set("affId", 1L),
+ assertThrows(SchemaMismatchException.class, () -> tbl.kvView().put(Tuple.create().set("id", 0L), Tuple.create()));
+ assertThrows(SchemaMismatchException.class, () -> tbl.kvView().put(Tuple.create().set("id", 0L).set("affId", 1L).set("val", 0L), Tuple.create()));
+ assertThrows(SchemaMismatchException.class, () -> tbl.kvView().put(Tuple.create().set("id", 0L).set("affId", 1L),
Tuple.create().set("id", 0L).set("val", 0L)));
}
@@ -93,7 +92,7 @@ public class StrictSchemaOperationsTest {
}
);
- RecordView<Tuple> tbl = createTableImpl(schema).recordView();
+ Table tbl = new TableImpl(new DummyInternalTableImpl(), new DummySchemaManagerImpl(schema), null, null);
// Check not-nullable column.
assertThrows(IllegalArgumentException.class, () -> tbl.insert(Tuple.create().set("id", null)));
@@ -118,7 +117,7 @@ public class StrictSchemaOperationsTest {
}
);
- RecordView<Tuple> tbl = createTableImpl(schema).recordView();
+ Table tbl = new TableImpl(new DummyInternalTableImpl(), new DummySchemaManagerImpl(schema), null, null);
Tuple tuple = Tuple.create().set("id", 1L);
@@ -145,7 +144,7 @@ public class StrictSchemaOperationsTest {
new Column("valLimited", NativeTypes.blobOf(2), true)
});
- RecordView<Tuple> tbl = createTableImpl(schema).recordView();
+ Table tbl = new TableImpl(new DummyInternalTableImpl(), new DummySchemaManagerImpl(schema), null, null);
Tuple tuple = Tuple.create().set("id", 1L);
@@ -158,8 +157,4 @@ public class StrictSchemaOperationsTest {
assertThrows(InvalidTypeException.class, () -> tbl.insert(tuple.set("valLimited", new byte[3])));
}
-
- private TableImpl createTableImpl(SchemaDescriptor schema) {
- return new TableImpl(new DummyInternalTableImpl(), new DummySchemaManagerImpl(schema), null);
- }
}
diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/RecordBinaryViewOperationsTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/TableBinaryViewOperationsTest.java
similarity index 92%
rename from modules/table/src/test/java/org/apache/ignite/internal/table/RecordBinaryViewOperationsTest.java
rename to modules/table/src/test/java/org/apache/ignite/internal/table/TableBinaryViewOperationsTest.java
index 5166a80..26db2d5 100644
--- a/modules/table/src/test/java/org/apache/ignite/internal/table/RecordBinaryViewOperationsTest.java
+++ b/modules/table/src/test/java/org/apache/ignite/internal/table/TableBinaryViewOperationsTest.java
@@ -25,9 +25,8 @@ import org.apache.ignite.internal.schema.SchemaMismatchException;
import org.apache.ignite.internal.table.impl.DummyInternalTableImpl;
import org.apache.ignite.internal.table.impl.DummySchemaManagerImpl;
import org.apache.ignite.internal.table.impl.TestTupleBuilder;
-import org.apache.ignite.table.RecordView;
+import org.apache.ignite.table.Table;
import org.apache.ignite.table.Tuple;
-import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -43,7 +42,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
* TODO: IGNITE-14486 Add tests for bulk operations.
* TODO: IGNITE-14486 Add tests for async operations.
*/
-public class RecordBinaryViewOperationsTest {
+public class TableBinaryViewOperationsTest {
/**
*
*/
@@ -55,7 +54,7 @@ public class RecordBinaryViewOperationsTest {
new Column[] {new Column("val", NativeTypes.INT64, false)}
);
- RecordView<Tuple> tbl = createTableImpl(schema).recordView();
+ Table tbl = new TableImpl(new DummyInternalTableImpl(), new DummySchemaManagerImpl(schema), null, null);
final Tuple tuple = Tuple.create().set("id", 1L).set("val", 11L);
final Tuple newTuple = Tuple.create().set("id", 1L).set("val", 22L);
@@ -87,7 +86,7 @@ public class RecordBinaryViewOperationsTest {
new Column[] {new Column("val", NativeTypes.INT64, false)}
);
- RecordView<Tuple> tbl = createTableImpl(schema).recordView();
+ Table tbl = new TableImpl(new DummyInternalTableImpl(), new DummySchemaManagerImpl(schema), null, null);
final Tuple tuple = Tuple.create().set("id", 1L).set("val", 11L);
final Tuple newTuple = Tuple.create().set("id", 1L).set("val", 22L);
@@ -119,7 +118,7 @@ public class RecordBinaryViewOperationsTest {
new Column[] {new Column("val", NativeTypes.INT64, false)}
);
- RecordView<Tuple> tbl = createTableImpl(schema).recordView();
+ Table tbl = new TableImpl(new DummyInternalTableImpl(), new DummySchemaManagerImpl(schema), null, null);
final Tuple tuple = Tuple.create().set("id", 1L).set("val", 11L);
final Tuple newTuple = Tuple.create().set("id", 1L).set("val", 22L);
@@ -148,7 +147,7 @@ public class RecordBinaryViewOperationsTest {
new Column[] {new Column("val", NativeTypes.INT64, false)}
);
- RecordView<Tuple> tbl = createTableImpl(schema).recordView();
+ Table tbl = new TableImpl(new DummyInternalTableImpl(), new DummySchemaManagerImpl(schema), null, null);
tbl.upsert(Tuple.create().set("id", 1L).set("val", 11L));
@@ -176,7 +175,7 @@ public class RecordBinaryViewOperationsTest {
new Column[] {new Column("val", NativeTypes.INT64, false)}
);
- RecordView<Tuple> tbl = createTableImpl(schema).recordView();
+ Table tbl = new TableImpl(new DummyInternalTableImpl(), new DummySchemaManagerImpl(schema), null, null);
final Tuple keyTuple = Tuple.create().set("id", 1L);
final Tuple tuple = Tuple.create().set("id", 1L).set("val", 11L);
@@ -227,7 +226,7 @@ public class RecordBinaryViewOperationsTest {
new Column[] {new Column("val", NativeTypes.INT64, false)}
);
- RecordView<Tuple> tbl = createTableImpl(schema).recordView();
+ Table tbl = new TableImpl(new DummyInternalTableImpl(), new DummySchemaManagerImpl(schema), null, null);
final Tuple keyTuple = Tuple.create().set("id", 1L);
final Tuple tuple = Tuple.create().set("id", 1L).set("val", 11L);
@@ -260,7 +259,7 @@ public class RecordBinaryViewOperationsTest {
new Column[] {new Column("val", NativeTypes.INT64, false)}
);
- RecordView<Tuple> tbl = createTableImpl(schema).recordView();
+ Table tbl = new TableImpl(new DummyInternalTableImpl(), new DummySchemaManagerImpl(schema), null, null);
final Tuple tuple = Tuple.create().set("id", 1L).set("val", 11L);
final Tuple tuple2 = Tuple.create().set("id", 1L).set("val", 22L);
@@ -298,7 +297,7 @@ public class RecordBinaryViewOperationsTest {
}
);
- RecordView<Tuple> tbl = createTableImpl(schema).recordView();
+ Table tbl = new TableImpl(new DummyInternalTableImpl(), new DummySchemaManagerImpl(schema), null, null);
final Tuple keyTuple0 = new TestTupleBuilder().set("id", 0).set("id1", 0);
final Tuple keyTuple1 = new TestTupleBuilder().set("id1", 0);
@@ -333,7 +332,7 @@ public class RecordBinaryViewOperationsTest {
}
);
- RecordView<Tuple> tbl = createTableImpl(schema).recordView();
+ Table tbl = new TableImpl(new DummyInternalTableImpl(), new DummySchemaManagerImpl(schema), null, null);
final Tuple keyTuple0 = Tuple.create().set("id", 0L);
final Tuple keyTuple1 = Tuple.create().set("id", 1L);
@@ -406,8 +405,4 @@ public class RecordBinaryViewOperationsTest {
Assertions.assertEquals(val1, val2, "Equality check failed: colIdx=" + col.schemaIndex());
}
}
-
- @NotNull private TableImpl createTableImpl(SchemaDescriptor schema) {
- return new TableImpl(new DummyInternalTableImpl(), new DummySchemaManagerImpl(schema), null);
- }
}
diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/TxTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/TxTest.java
index d42cebf..61fcda8 100644
--- a/modules/table/src/test/java/org/apache/ignite/internal/table/TxTest.java
+++ b/modules/table/src/test/java/org/apache/ignite/internal/table/TxTest.java
@@ -25,8 +25,7 @@ import org.apache.ignite.internal.schema.SchemaDescriptor;
import org.apache.ignite.internal.table.impl.DummyInternalTableImpl;
import org.apache.ignite.internal.table.impl.DummySchemaManagerImpl;
import org.apache.ignite.internal.util.Pair;
-import org.apache.ignite.table.KeyValueView;
-import org.apache.ignite.table.RecordView;
+import org.apache.ignite.table.KeyValueBinaryView;
import org.apache.ignite.table.Table;
import org.apache.ignite.table.Tuple;
import org.apache.ignite.tx.IgniteTransactions;
@@ -78,12 +77,12 @@ public class TxTest {
new Column[]{new Column("balance", NativeTypes.DOUBLE, false)}
);
- accounts = new TableImpl(new DummyInternalTableImpl(), new DummySchemaManagerImpl(schema), null);
+ accounts = new TableImpl(new DummyInternalTableImpl(), new DummySchemaManagerImpl(schema), null, null);
Tuple r1 = Tuple.create().set("accountNumber", 1L).set("balance", BALANCE_1);
Tuple r2 = Tuple.create().set("accountNumber", 2L).set("balance", BALANCE_2);
- accounts.recordView().insert(r1);
- accounts.recordView().insert(r2);
+ accounts.insert(r1);
+ accounts.insert(r2);
Mockito.doAnswer(invocation -> {
Consumer<Transaction> argument = invocation.getArgument(0);
@@ -102,7 +101,7 @@ public class TxTest {
@Test
public void testTxSync() {
igniteTransactions.runInTransaction(tx -> {
- RecordView<Tuple> txAcc = accounts.recordView().withTransaction(tx);
+ Table txAcc = accounts.withTransaction(tx);
CompletableFuture<Tuple> read1 = txAcc.getAsync(makeKey(1));
CompletableFuture<Tuple> read2 = txAcc.getAsync(makeKey(2));
@@ -115,8 +114,8 @@ public class TxTest {
Mockito.verify(tx).commit();
- assertEquals(BALANCE_1 - DELTA, accounts.recordView().get(makeKey(1)).doubleValue("balance"));
- assertEquals(BALANCE_2 + DELTA, accounts.recordView().get(makeKey(2)).doubleValue("balance"));
+ assertEquals(BALANCE_1 - DELTA, accounts.get(makeKey(1)).doubleValue("balance"));
+ assertEquals(BALANCE_2 + DELTA, accounts.get(makeKey(2)).doubleValue("balance"));
}
/**
@@ -125,7 +124,7 @@ public class TxTest {
@Test
public void testTxSyncKeyValue() {
igniteTransactions.runInTransaction(tx -> {
- KeyValueView<Tuple, Tuple> txAcc = accounts.keyValueView().withTransaction(tx);
+ KeyValueBinaryView txAcc = accounts.kvView().withTransaction(tx);
CompletableFuture<Tuple> read1 = txAcc.getAsync(makeKey(1));
CompletableFuture<Tuple> read2 = txAcc.getAsync(makeKey(2));
@@ -138,8 +137,8 @@ public class TxTest {
Mockito.verify(tx).commit();
- assertEquals(BALANCE_1 - DELTA, accounts.recordView().get(makeKey(1)).doubleValue("balance"));
- assertEquals(BALANCE_2 + DELTA, accounts.recordView().get(makeKey(2)).doubleValue("balance"));
+ assertEquals(BALANCE_1 - DELTA, accounts.get(makeKey(1)).doubleValue("balance"));
+ assertEquals(BALANCE_2 + DELTA, accounts.get(makeKey(2)).doubleValue("balance"));
}
/**
@@ -147,9 +146,9 @@ public class TxTest {
*/
@Test
public void testTxAsync() {
- igniteTransactions.beginAsync().thenApply(tx -> accounts.recordView().withTransaction(tx)).
+ igniteTransactions.beginAsync().thenApply(tx -> accounts.withTransaction(tx)).
thenCompose(txAcc -> txAcc.getAsync(makeKey(1))
- .thenCombine(txAcc.getAsync(makeKey(2)), Pair::new)
+ .thenCombine(txAcc.getAsync(makeKey(2)), (v1, v2) -> new Pair<>(v1, v2))
.thenCompose(pair -> allOf(
txAcc.upsertAsync(makeRecord(1, pair.getFirst().doubleValue("balance") - DELTA)),
txAcc.upsertAsync(makeRecord(2, pair.getSecond().doubleValue("balance") + DELTA))
@@ -160,8 +159,8 @@ public class TxTest {
Mockito.verify(tx).commitAsync();
- assertEquals(BALANCE_1 - DELTA, accounts.recordView().get(makeKey(1)).doubleValue("balance"));
- assertEquals(BALANCE_2 + DELTA, accounts.recordView().get(makeKey(2)).doubleValue("balance"));
+ assertEquals(BALANCE_1 - DELTA, accounts.get(makeKey(1)).doubleValue("balance"));
+ assertEquals(BALANCE_2 + DELTA, accounts.get(makeKey(2)).doubleValue("balance"));
}
/**
@@ -169,9 +168,9 @@ public class TxTest {
*/
@Test
public void testTxAsyncKeyValue() {
- igniteTransactions.beginAsync().thenApply(tx -> accounts.keyValueView().withTransaction(tx)).
+ igniteTransactions.beginAsync().thenApply(tx -> accounts.kvView().withTransaction(tx)).
thenCompose(txAcc -> txAcc.getAsync(makeKey(1))
- .thenCombine(txAcc.getAsync(makeKey(2)), Pair::new)
+ .thenCombine(txAcc.getAsync(makeKey(2)), (v1, v2) -> new Pair<>(v1, v2))
.thenCompose(pair -> allOf(
txAcc.putAsync(makeKey(1), makeValue(pair.getFirst().doubleValue("balance") - DELTA)),
txAcc.putAsync(makeKey(2), makeValue(pair.getSecond().doubleValue("balance") + DELTA))
@@ -182,8 +181,8 @@ public class TxTest {
Mockito.verify(tx).commitAsync();
- assertEquals(BALANCE_1 - DELTA, accounts.recordView().get(makeKey(1)).doubleValue("balance"));
- assertEquals(BALANCE_2 + DELTA, accounts.recordView().get(makeKey(2)).doubleValue("balance"));
+ assertEquals(BALANCE_1 - DELTA, accounts.get(makeKey(1)).doubleValue("balance"));
+ assertEquals(BALANCE_2 + DELTA, accounts.get(makeKey(2)).doubleValue("balance"));
}
/**