lidavidm commented on code in PR #111:
URL: https://github.com/apache/iceberg-cpp/pull/111#discussion_r2110592864


##########
src/iceberg/table.h:
##########
@@ -108,4 +109,85 @@ class ICEBERG_EXPORT Table {
   virtual std::unique_ptr<LocationProvider> location_provider() const = 0;
 };
 
+class ICEBERG_EXPORT BaseTable : public Table {
+ public:
+  ~BaseTable() override = default;
+  BaseTable(std::string name, std::shared_ptr<TableMetadata> metadata);
+
+  const std::string& name() const override { return name_; }
+
+  const std::string& uuid() const override;
+
+  const std::shared_ptr<Schema>& schema() const override;
+
+  const std::unordered_map<int32_t, std::shared_ptr<Schema>>& schemas() const 
override;
+
+  const std::shared_ptr<PartitionSpec>& spec() const override;
+
+  const std::unordered_map<int32_t, std::shared_ptr<PartitionSpec>>& specs()
+      const override;
+
+  const std::shared_ptr<SortOrder>& sort_order() const override;
+
+  const std::unordered_map<int32_t, std::shared_ptr<SortOrder>>& sort_orders()
+      const override;
+
+  const std::unordered_map<std::string, std::string>& properties() const 
override;
+
+  const std::string& location() const override;
+
+  const std::shared_ptr<Snapshot>& current_snapshot() const override;
+
+  Result<std::shared_ptr<Snapshot>> snapshot(int64_t snapshot_id) const 
override;
+
+  const std::vector<std::shared_ptr<Snapshot>>& snapshots() const override;
+
+  const std::vector<std::shared_ptr<HistoryEntry>>& history() const override;
+
+ private:
+  void InitSchema() const;
+  void InitPartitionSpec() const;
+  void InitSortOrder() const;
+  void InitSnapshot() const;
+
+  const std::string name_;
+
+  mutable std::shared_ptr<Schema> schema_;
+  mutable std::unordered_map<int32_t, std::shared_ptr<Schema>> schemas_map_;
+
+  mutable std::shared_ptr<PartitionSpec> partition_spec_;
+  mutable std::unordered_map<int32_t, std::shared_ptr<PartitionSpec>> 
partition_spec_map_;
+
+  mutable std::shared_ptr<SortOrder> sort_order_;
+  mutable std::unordered_map<int32_t, std::shared_ptr<SortOrder>> 
sort_orders_map_;
+
+  mutable std::shared_ptr<Snapshot> current_snapshot_;
+  mutable std::unordered_map<int64_t, std::shared_ptr<Snapshot>> 
snapshots_map_;
+
+  std::shared_ptr<TableMetadata> metadata_;
+
+  // once_flags
+  mutable std::once_flag init_schema_once_;
+  mutable std::once_flag init_partition_spec_once_;
+  mutable std::once_flag init_sort_order_once_;
+  mutable std::once_flag init_snapshot_once_;
+};
+
+class ICEBERG_EXPORT StaticTable : public BaseTable {

Review Comment:
   Add docstring?



##########
test/table_test.cc:
##########
@@ -0,0 +1,110 @@
+/*
+ * 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.
+ */
+
+#include "iceberg/table.h"
+
+#include <filesystem>
+#include <fstream>
+#include <optional>
+#include <sstream>
+#include <string>
+
+#include <gtest/gtest.h>
+#include <nlohmann/json.hpp>
+
+#include "iceberg/partition_spec.h"
+#include "iceberg/schema.h"
+#include "iceberg/snapshot.h"
+#include "iceberg/table_metadata.h"
+#include "table_test_helper.h"
+
+namespace iceberg {
+
+namespace {
+
+class TableTest : public ::testing::Test {
+ protected:
+  void SetUp() override {}
+};
+
+}  // namespace

Review Comment:
   You don't need all of this. You can just declare tests as `TEST(TableTest, 
FooTest)` instead of declaring this.



-- 
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: issues-unsubscr...@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to