zhf999 commented on code in PR #243: URL: https://github.com/apache/paimon-cpp/pull/243#discussion_r3861401327
########## src/paimon/common/reader/late_materializing_file_batch_reader.h: ########## @@ -0,0 +1,149 @@ +/* + * 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 <arrow/array/array_nested.h> +#include <arrow/c/abi.h> + +#include <cstdint> +#include <memory> +#include <utility> +#include <vector> + +#include "paimon/reader/prefetch_file_batch_reader.h" + +namespace paimon { + +class PredicateFilter; + +// For convenience, we abbreviate `Later Materializing` as `LatMat`. +// This reader is installed below the prefetch layer (see +// AbstractSplitRead::CreateFileBatchReader) and performs probe/payload two-phase reads when a +// predicate is pushed down through SetReadSchema; without a predicate it is a plain passthrough. +class LateMaterializingFileBatchReader : public PrefetchFileBatchReader { + public: + static Result<std::unique_ptr<LateMaterializingFileBatchReader>> Create( + std::unique_ptr<PrefetchFileBatchReader> inner, std::shared_ptr<MemoryPool> pool); + + Result<FileBatchReader::ReadBatch> NextBatch() override; + + std::shared_ptr<Metrics> GetReaderMetrics() const override { + return inner_->GetReaderMetrics(); + }; + + void Close() override { + inner_->Close(); + } + + Result<std::unique_ptr<::ArrowSchema>> GetFileSchema() const override { + return inner_->GetFileSchema(); + } + + Status SetReadSchema(::ArrowSchema* read_schema, const std::shared_ptr<Predicate>& predicate, + const std::optional<RoaringBitmap32>& selection_bitmap) override; + + Result<uint64_t> GetPreviousBatchFileRowId(uint64_t batch_row_id) const override; + + Result<uint64_t> GetNumberOfRows() const override { + return inner_->GetNumberOfRows(); + } + + bool SupportPreciseBitmapSelection() const override { + // When probe_schema_ or payload_schema_ is null, lat-mat does not take effect. + // Here we simply pass through the inner reader's support. + return inner_->SupportPreciseBitmapSelection(); + } + + Status SeekToRow(uint64_t row_number) override; + + uint64_t GetNextRowToRead() const override { + return inner_->GetNextRowToRead(); + } + + Result<std::vector<std::pair<uint64_t, uint64_t>>> GenReadRanges( + bool* need_prefetch) const override { + return inner_->GenReadRanges(need_prefetch); Review Comment: Remain it for future work. -- 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]
