You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2021/12/21 15:30:35 UTC

[GitHub] [ignite-3] ptupitsyn commented on a change in pull request #517: IGNITE-16121 Thin client: Implement KeyValueView

ptupitsyn commented on a change in pull request #517:
URL: https://github.com/apache/ignite-3/pull/517#discussion_r773233156



##########
File path: modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientKeyValueView.java
##########
@@ -0,0 +1,412 @@
+/*
+ * 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.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Objects;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.client.IgniteClientException;
+import org.apache.ignite.internal.client.proto.ClientMessagePacker;
+import org.apache.ignite.internal.client.proto.ClientMessageUnpacker;
+import org.apache.ignite.internal.client.proto.ClientOp;
+import org.apache.ignite.internal.client.proto.TuplePart;
+import org.apache.ignite.internal.marshaller.ClientMarshallerReader;
+import org.apache.ignite.internal.marshaller.Marshaller;
+import org.apache.ignite.internal.marshaller.MarshallerException;
+import org.apache.ignite.table.InvokeProcessor;
+import org.apache.ignite.table.KeyValueView;
+import org.apache.ignite.table.mapper.Mapper;
+import org.apache.ignite.tx.Transaction;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Client key-value view implementation.
+ */
+public class ClientKeyValueView<K, V> implements KeyValueView<K, V> {
+    /** Underlying table. */
+    private final ClientTable tbl;
+
+    /** Key serializer.  */
+    private final ClientRecordSerializer<K> keySer;
+
+    /** Value serializer.  */
+    private final ClientRecordSerializer<V> valSer;
+
+    /**
+     * Constructor.
+     *
+     * @param tbl Underlying table.
+     * @param keyMapper Key mapper.
+     * @param valMapper value mapper.
+     */
+    public ClientKeyValueView(ClientTable tbl, Mapper<K> keyMapper, Mapper<V> valMapper) {
+        assert tbl != null;
+        assert keyMapper != null;
+        assert valMapper != null;
+
+        this.tbl = tbl;
+
+        keySer = new ClientRecordSerializer<>(tbl.tableId(), keyMapper);
+        valSer = new ClientRecordSerializer<>(tbl.tableId(), valMapper);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public V get(@Nullable Transaction tx, @NotNull K key) {
+        return getAsync(tx, key).join();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public @NotNull CompletableFuture<V> getAsync(@Nullable Transaction tx, @NotNull K key) {

Review comment:
       Done.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org