zjw1111 commented on code in PR #447:
URL: https://github.com/apache/paimon-cpp/pull/447#discussion_r4375379570


##########
include/paimon/catalog/table.h:
##########
@@ -33,50 +33,48 @@
 
 namespace paimon {
 
-class TableScan;
+class CommitContext;
+class FileStoreCommit;
+class FileStoreWrite;
+class ReadContext;
+class ScanContext;
 class TableRead;
+class TableScan;
+class WriteContext;
 
 /// A table provides basic abstraction for table type.
+///
+/// The state a table of every kind carries - file system, root path, schema 
and identifier - lives

Review Comment:
   There are so many sentence "XXX(n.) a XXX(n.)" in this PR, I think it's 
difficult to understand



##########
src/paimon/core/table/file_store.h:
##########
@@ -0,0 +1,236 @@
+/*
+ * 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 <map>
+#include <memory>
+#include <optional>
+#include <string>
+
+#include "paimon/catalog/identifier.h"
+#include "paimon/core/core_options.h"
+#include "paimon/core/schema/schema_manager.h"
+#include "paimon/core/utils/file_store_path_factory.h"
+#include "paimon/core/utils/snapshot_manager.h"
+#include "paimon/result.h"
+#include "paimon/type_fwd.h"
+
+namespace arrow {
+class Schema;
+}  // namespace arrow
+
+namespace paimon {
+
+class BinaryRowPartitionComputer;
+class Catalog;
+class IndexFileHandler;
+class IndexManifestFile;
+class ManifestFile;
+class ManifestList;
+class TableSchema;
+
+/// The storage a managed table is served through: the file system, root path, 
schema, branch,
+/// options and the schema and snapshot managers it was loaded with - the 
state Java Paimon's
+/// `AbstractFileStore` carries, parsed once here rather than per operator. 
`FileStoreTable` hands
+/// the state it was loaded with to one of these and asks it back for the 
pieces every operator
+/// opens with.
+///
+/// The options are the ones the table was loaded with on this branch - the 
schema's own, or
+/// the ones a load merged over them - the base every operator serves: 
`NewXxx` takes no
+/// options of its own beyond them. A cache is not part of them - 
`WithCache()` arms a copy an
+/// operator makes - so the factories below take the options of the call, not 
the store's own.
+///
+/// The factory methods build a fresh instance on every call, never a cached 
one: a path factory
+/// names each file it builds, and a snapshot manager a write or a commit arms 
with a catalog
+/// loader is not one a scan should be served through afterwards.
+class FileStore {
+ public:
+    /// @param file_system The file system the caller opened the table 
through, which wins over
+    ///        the access configuration the schema's options may carry when it 
is not null. A
+    ///        null one hands the resolution to that configuration: the table 
is then served by
+    ///        the file system its options name - the way a load that only had 
a path and a
+    ///        schema to read names it - and by the default local one when 
they name none.
+    /// @param root_path Root path of the table in the file system.
+    /// @param schema The schema the table was loaded with, whose partition 
keys name the
+    ///        partitions the paths below are built for and whose options 
`options()` parses. It
+    ///        is null when the caller had no schema; the operators then 
report that none was
+    ///        found.
+    /// @param branch The branch the store serves, normalized here.
+    /// @param schema_manager A schema manager to carry instead of building 
one - the one a
+    ///        context dispatch read the schema through, whose cache the 
operators then serve.
+    /// @param snapshot_manager A snapshot manager to carry instead of 
building one.
+    /// A null manager is built over `root_path` on `branch`, so the operators 
always read
+    /// through the managers the store carries.
+    /// @param fs_scheme_map The scheme-to-identifier map the caller's 
contexts resolve custom
+    ///        schemes through. It takes part in building the store's options 
the way it took
+    ///        part in reading the schema: without it a schema naming a custom 
scheme would
+    ///        resolve to the default backend once its operators run. It is 
kept for a copy to
+    ///        hand over again, so the copy resolves as this store does.
+    ///
+    /// Building the store parses the schema's options, so it fails when they 
do not parse: the
+    /// error is the caller's to see, which is why a store is built through 
this factory rather
+    /// than the constructor.
+    static Result<std::shared_ptr<FileStore>> Create(
+        const std::shared_ptr<FileSystem>& file_system, const std::string& 
root_path,
+        const std::shared_ptr<TableSchema>& schema, const std::string& branch,
+        const std::shared_ptr<SchemaManager>& schema_manager = nullptr,
+        const std::shared_ptr<SnapshotManager>& snapshot_manager = nullptr,
+        const std::map<std::string, std::string>& fs_scheme_map = {});
+
+    /// The branch this store serves, as resolved when it was built.
+    const std::string& branch() const {
+        return branch_;
+    }
+
+    /// The schema manager the operators read through. It carries the schema 
cache of `root_path`
+    /// on `branch()`.
+    const std::shared_ptr<SchemaManager>& schema_manager() const {

Review Comment:
   why these function name is xiao_xie, not DaXie?



##########
src/paimon/core/table/file_store_table.h:
##########
@@ -0,0 +1,227 @@
+/*
+ * 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 <map>
+#include <memory>
+#include <string>
+
+#include "paimon/catalog/identifier.h"
+#include "paimon/catalog/table.h"
+#include "paimon/core/operation/commit/commit_scanner.h"
+#include "paimon/core/schema/schema_manager.h"
+#include "paimon/core/table/file_store.h"
+#include "paimon/core/utils/branch_manager.h"
+#include "paimon/core/utils/snapshot_manager.h"
+#include "paimon/result.h"
+#include "paimon/type_fwd.h"
+
+namespace paimon {
+
+class InternalReadContext;
+class IOManager;
+class ManifestFile;
+class ManifestList;
+class RealtimeContext;
+class Schema;
+class SplitGenerator;
+
+/// The managed table a catalog hands out: one with snapshots and manifests, 
which the schema under
+/// its root path describes. A format table - a directory of plain data files 
- is a `FormatTable`,
+/// the other kind of `Table`.
+///
+/// This is the flow the four operators share, Java Paimon's 
`AbstractFileStoreTable`: what the
+/// table was constructed with - the schema, file system, root path, branch 
and managers - decides
+/// what every operator serves, so it is read here once and handed down. The 
schema's primary keys
+/// decide the kind of managed table it is - `AppendOnlyFileStoreTable` or
+/// `PrimaryKeyFileStoreTable`, the `Create` factory below - and that kind 
builds the pieces the
+/// flows hand down: the write itself, the scans, the read and the split 
generator.
+///
+/// Its `NewScan`/`NewRead`/`NewWrite`/`NewCommit` build the operators here, 
from the context plus
+/// the state the table was constructed with, so they serve the table as it 
was loaded. The
+/// context-only entry points - `TableScan::Create()`, `TableRead::Create()`,
+/// `FileStoreWrite::Create()` and `FileStoreCommit::Create()` - load the 
table the context names
+/// and hand the context to that table's `NewXxx`, which is how a context 
built without a table
+/// reaches the same operators.
+class FileStoreTable : public Table {
+ public:
+    /// The managed table the schema describes, built as the kind its primary 
keys name: an
+    /// `AppendOnlyFileStoreTable` when there are none, a 
`PrimaryKeyFileStoreTable` when there
+    /// are, the way Java Paimon's `FileStoreTableFactory` does. Primary keys 
cannot be added or
+    /// dropped by a schema change, so the kind the table was built as is the 
kind every schema
+    /// its root path ever held describes.
+    /// @param schema The schema the table was loaded with, whose primary keys 
name the kind and
+    ///        whose options the operators serve. It is null when the caller 
had no schema, and
+    ///        the table is built as the append-only kind - its operators then 
report that no
+    ///        schema was found.
+    /// @param branch The branch the table serves, which the managers below 
read and write on.
+    /// @param schema_manager A schema manager to carry instead of building 
one - the one a
+    ///        context dispatch read the schema through, whose cache the 
operators then serve.
+    /// @param snapshot_manager A snapshot manager to carry instead of 
building one, the way
+    ///        `Copy` hands its table's over so both share one.
+    /// A null manager is built over `root_path` on `branch`, so the operators 
always read
+    /// through the managers the table carries.
+    /// @param fs_scheme_map The scheme-to-identifier map the caller's 
contexts resolve custom
+    ///        schemes through, which the store's options resolve through as 
well - see
+    ///        `FileStore::Create`. `Copy` hands its table's map over.
+    static Result<std::shared_ptr<FileStoreTable>> Create(
+        const std::shared_ptr<FileSystem>& file_system, const std::string& 
root_path,
+        const std::shared_ptr<Schema>& schema, const Identifier& identifier,
+        const std::string& uuid = "",
+        const std::string& branch = BranchManager::DEFAULT_MAIN_BRANCH,
+        const std::shared_ptr<SchemaManager>& schema_manager = nullptr,
+        const std::shared_ptr<SnapshotManager>& snapshot_manager = nullptr,
+        const std::map<std::string, std::string>& fs_scheme_map = {});

Review Comment:
   Do not use default values



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