isapego commented on code in PR #1704:
URL: https://github.com/apache/ignite-3/pull/1704#discussion_r1113920779
##########
modules/platforms/cpp/ignite/client/table/ignite_tuple.h:
##########
@@ -179,6 +183,28 @@ class ignite_tuple {
return std::int32_t(it->second);
}
+ /**
+ * Concatenation operator.
+ *
+ * @param left Left hand value.
+ * @param right Right hand value.
+ * @return Resulting tuple.
+ */
+ friend ignite_tuple operator+(const ignite_tuple& left, const
ignite_tuple& right) {
Review Comment:
I can do that, but that will require declaring some internal function as a
friend. Well, Ok, I'll fix that.
##########
modules/platforms/cpp/ignite/client/table/key_value_view.h:
##########
@@ -0,0 +1,500 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include "ignite/client/table/ignite_tuple.h"
+#include "ignite/client/transaction/transaction.h"
+
+#include "ignite/common/config.h"
+#include "ignite/common/ignite_result.h"
+
+#include <memory>
+#include <type_traits>
+#include <utility>
+#include <vector>
+
+namespace ignite {
+
+class table;
+
+namespace detail {
+class table_impl;
+}
+
+/**
+ * Key-Value view interface provides methods to access table records in form
of separate key and value parts.
+ */
+template<typename K, typename V>
+class key_value_view {
+public:
+ typedef typename std::decay<K>::type key_type;
+ typedef typename std::decay<V>::type value_type;
+
+ // Deleted
+ key_value_view(const key_value_view &) = delete;
+ key_value_view &operator=(const key_value_view &) = delete;
+
+ // Default
+ key_value_view() = default;
+ ~key_value_view() = default;
+ key_value_view(key_value_view &&) noexcept = default;
+ key_value_view &operator=(key_value_view &&) noexcept = default;
+};
+
+/**
+ * Key-Value view interface provides methods to access table records in form
of separate key and value parts.
+ */
+template<>
+class key_value_view<ignite_tuple, ignite_tuple> {
+ friend class table;
+
+public:
+ typedef ignite_tuple key_type;
+ typedef ignite_tuple value_type;
+
+ // Deleted
+ key_value_view(const key_value_view &) = delete;
+ key_value_view &operator=(const key_value_view &) = delete;
+
+ // Default
+ key_value_view() = default;
+ ~key_value_view() = default;
+ key_value_view(key_value_view &&) noexcept = default;
+ key_value_view &operator=(key_value_view &&) noexcept = default;
+
+ /**
+ * Gets a record by key asynchronously.
+ *
+ * @param tx Optional transaction. If nullptr implicit transaction for this
+ * single operation is used.
+ * @param key Key.
+ * @param callback Callback which is called on success with value if it
+ * exists and @c std::nullopt otherwise
+ */
+ IGNITE_API void get_async(
+ transaction *tx, const key_type &key,
ignite_callback<std::optional<value_type>> callback);
+
+ /**
+ * Gets a record by key.
+ *
+ * @param tx Optional transaction. If nullptr implicit transaction for this
+ * single operation is used.
+ * @param key Key.
+ * @return Value if exists and @c std::nullopt otherwise.
+ */
+ [[nodiscard]] IGNITE_API std::optional<value_type> get(transaction *tx,
const key_type &key) {
+ return sync<std::optional<value_type>>(
+ [this, tx, &key](auto callback) { get_async(tx, key,
std::move(callback)); });
+ }
+
+ /**
+ * Gets multiple records by keys asynchronously.
+ *
+ * @param tx Optional transaction. If nullptr implicit transaction for this
+ * single operation is used.
+ * @param keys Keys.
+ * @param callback Callback that called on operation completion. Called
with
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]