SteNicholas commented on code in PR #222:
URL: https://github.com/apache/paimon-cpp/pull/222#discussion_r3843971905


##########
src/paimon/core/table/format/format_table_read.h:
##########
@@ -0,0 +1,109 @@
+/*
+ * 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 <memory>
+#include <optional>
+#include <string>
+#include <vector>
+
+#include "paimon/memory/memory_pool.h"
+#include "paimon/reader/batch_reader.h"
+#include "paimon/result.h"
+#include "paimon/table/format/format_table.h"
+#include "paimon/table/source/split.h"
+#include "paimon/table/source/table_read.h"
+#include "paimon/visibility.h"
+
+namespace paimon {
+
+class Predicate;
+
+/// Reads the splits a `FormatTableScan` produced.
+///
+/// The batches hold the table's own columns only, with no leading 
`_VALUE_KIND` field: a directory
+/// of plain data files records no row kind and every row in it is an insert. 
Partition columns are
+/// rebuilt from the split's partition values, since the data files do not 
carry them.
+///
+/// A batch borrows memory from the reader that produced it, so every batch 
must be released before
+/// that reader is destroyed.
+///
+/// Building a reader leaves the read as it was, so one may be shared between 
threads; the
+/// `BatchReader`s it hands out may not be, as `TableRead` says.
+///
+/// `CreateCountReader()` is not implemented and falls through to 
`TableRead`'s default, which
+/// refuses: counting a format table's rows means reading them.
+class PAIMON_EXPORT FormatTableRead : public TableRead {
+ public:
+    /// @param table Table the splits belong to.
+    /// @param projection Names of the columns to read, in the order they 
should appear. When
+    ///        absent, every column of the table is read. A column named twice 
is rejected.
+    /// @param limit Upper bound on the rows to return across all splits of 
one reader. When
+    ///        absent, every row is returned.
+    /// @param pool Memory pool the batches are allocated from.
+    /// @param predicate Rows the caller is interested in, as a filter over 
the table's columns.
+    ///        It is pushed into the file readers so the format skips what its 
own statistics let
+    ///        it skip; on its own that is a best effort and rows the 
predicate rejects can still
+    ///        come back. Every field it names must be a column of the table, 
of the type the
+    ///        conjunct declares, with literals of that same type and none of 
them null. The field
+    ///        index a conjunct carries is not read - a field is resolved by 
name - so a predicate
+    ///        built against the table stays valid under any projection.
+    /// @param enable_predicate_filter Whether the returned reader applies 
`predicate` exactly to
+    ///        the rows it returns. Off by default, as everywhere else in 
paimon-cpp. With it on,
+    ///        `predicate` may only name columns the projection keeps, since a 
column the reader
+    ///        does not produce cannot be tested.
+    static Result<std::unique_ptr<FormatTableRead>> Create(
+        const std::shared_ptr<FormatTable>& table,
+        const std::optional<std::vector<std::string>>& projection = 
std::nullopt,
+        const std::optional<int32_t>& limit = std::nullopt,
+        const std::shared_ptr<MemoryPool>& pool = nullptr,
+        const std::shared_ptr<Predicate>& predicate = nullptr,
+        bool enable_predicate_filter = false);

Review Comment:
   The move happened, so the defaults are gone too. 
`FormatTableRead::Create()`, `FormatTableWrite::Create()`, 
`FormatTableScan::Create()` and `FormatTableCommit::Create()` now take every 
argument explicitly, and the 111 call sites pass them with `/*param=*/` 
comments.
   
   The only `=` left in those headers is on `FormatDataFileListingOptions`' 
members, which are struct member initialisers rather than function defaults.
   
   `Catalog::GetFormatTable()` keeps its shape, and 
`SchemaValidation::ValidateFormatTableSchema()` had its file-system default 
removed earlier in the same spirit.



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