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



##########
File path: 
modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTable.java
##########
@@ -0,0 +1,439 @@
+/*
+ * 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 org.apache.ignite.client.ClientMessageUnpacker;
+import org.apache.ignite.client.ClientOp;
+import org.apache.ignite.client.IgniteClientException;
+import org.apache.ignite.internal.client.PayloadInputChannel;
+import org.apache.ignite.internal.client.PayloadOutputChannel;
+import org.apache.ignite.internal.client.ReliableChannel;
+import org.apache.ignite.internal.tostring.IgniteToStringBuilder;
+import org.apache.ignite.lang.IgniteBiTuple;
+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;
+import org.apache.ignite.table.Tuple;
+import org.apache.ignite.table.TupleBuilder;
+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;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionException;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Client table API implementation.
+ */
+public class ClientTable implements Table {
+    /** */
+    private final UUID id;
+
+    /** */
+    private final String name;
+
+    /** */
+    private final ReliableChannel ch;
+
+    /** */
+    private final ConcurrentHashMap<Integer, ClientSchema> schemas = new 
ConcurrentHashMap<>();
+
+    /** */
+    private volatile int latestSchemaVer = -1;
+
+    /** */
+    private final Object latestSchemaLock = new Object();
+
+    /**
+     * Constructor.
+     *
+     * @param ch Channel.
+     * @param id Table id.
+     * @param name Table name.
+     */
+    public ClientTable(ReliableChannel ch, UUID id, String name) {
+        assert ch != null;
+        assert id != null;
+        assert name != null && !name.isEmpty();
+
+        this.ch = ch;
+        this.id = id;
+        this.name = name;
+    }
+
+    /**
+     * Gets the table id.
+     *
+     * @return Table id.
+     */
+    public UUID tableId() {
+        return id;
+    }
+
+    /** {@inheritDoc} */
+    @Override public @NotNull String tableName() {
+        return name;
+    }
+
+    /** {@inheritDoc} */
+    @Override public <R> RecordView<R> recordView(RecordMapper<R> recMapper) {
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    @Override public <K, V> KeyValueView<K, V> kvView(KeyMapper<K> keyMapper, 
ValueMapper<V> valMapper) {
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    @Override public KeyValueBinaryView kvView() {
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Table withTransaction(Transaction tx) {
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    @Override public TupleBuilder tupleBuilder() {
+        return new ClientTupleBuilder();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Tuple get(@NotNull Tuple keyRec) {
+        return getAsync(keyRec).join();
+    }
+
+    /** {@inheritDoc} */
+    @Override public @NotNull CompletableFuture<Tuple> getAsync(@NotNull Tuple 
keyRec) {
+        return getLatestSchema().thenCompose(schema ->
+                ch.serviceAsync(ClientOp.TUPLE_GET, w -> writeTuple(keyRec, 
schema, w, true), r -> {
+                    if (r.in().getNextFormat() == MessageFormat.NIL)
+                        return null;
+
+                    var schemaVer = r.in().unpackInt();
+
+                    return new IgniteBiTuple<>(r, schemaVer);
+                })).thenCompose(biTuple -> {
+            if (biTuple == null)
+                return CompletableFuture.completedFuture(null);
+
+            assert biTuple.getKey() != null;
+            assert biTuple.getValue() != null;
+
+            return getSchema(biTuple.getValue()).thenApply(schema -> 
readTuple(schema, biTuple.getKey()));
+        });
+    }
+
+    /** {@inheritDoc} */
+    @Override public Collection<Tuple> getAll(@NotNull Collection<Tuple> 
keyRecs) {
+        return null;

Review comment:
       Fixed.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to