isapego commented on code in PR #1287:
URL: https://github.com/apache/ignite-3/pull/1287#discussion_r1010103069


##########
modules/platforms/cpp/ignite/client/detail/table/table_impl.h:
##########
@@ -41,24 +45,301 @@ class table_impl {
      *
      * @param name Name.
      * @param id ID.
+     * @param connection Connection.
      */
-    table_impl(std::string name, const uuid &id)
+    table_impl(std::string name, const uuid &id, 
std::shared_ptr<cluster_connection> connection)
         : m_name(std::move(name))
-        , m_id(id) { }
+        , m_id(id)
+        , m_connection(std::move(connection)) { }
 
     /**
-     * Get table name.
+     * Gets table name.
      *
      * @return Table name.
      */
     [[nodiscard]] const std::string &name() const { return m_name; }
 
+    /**
+     * Gets the latest schema.
+     *
+     * @param callback Callback which is going to be called with the latest 
schema.
+     */
+    void get_latest_schema_async(ignite_callback<std::shared_ptr<schema>> 
callback);
+
+    /**
+     * Gets the latest schema.
+     *
+     * @param handler Callback to call on error during retrieval of the latest 
schema.
+     */
+    template <typename T>
+    void with_latest_schema_async(ignite_callback<T> handler, 
std::function<void(const schema&, ignite_callback<T>)> callback) {
+        get_latest_schema_async(
+            [this, handler = std::move(handler), callback = 
std::move(callback)]
+                (ignite_result<std::shared_ptr<schema>>&& res) mutable {
+            if (res.has_error()) {
+                handler(ignite_error{res.error()});
+                return;
+            }
+
+            auto schema = res.value();
+            if (!schema) {
+                handler(ignite_error{"Can not get a schema for the table " + 
m_name});

Review Comment:
   Probably, but I still prefer to have a meaningful error in case we have a 
bug in server code than `nullptr` dereference. I can use assert here but I'm 
not sure this would be better.



-- 
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