yiguolei commented on code in PR #69982: URL: https://github.com/apache/doris/pull/69982#discussion_r4476044682
########## be/src/storage/segment/segment_read_ahead.h: ########## @@ -0,0 +1,204 @@ +// 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 <cstddef> +#include <functional> +#include <map> +#include <memory> +#include <mutex> +#include <span> +#include <vector> + +#include "io/cache/file_range_planner.h" +#include "io/fs/file_range_read_scheduler.h" +#include "io/fs/file_reader.h" +#include "storage/segment/column_read_ahead.h" + +namespace doris { + +class ExecEnv; +class StorageReadOptions; + +namespace segment_v2 { + +class ColumnIterator; + +/// Invoked with the whole physical range at most once, when any registered page successfully +/// consumes bytes from it. +using ReadAheadRangeConsumer = std::function<void(const io::FileRangeRead&)>; +/// Creates submission-scoped state immediately before asynchronous range tasks are admitted. +using ReadAheadRangeConsumerFactory = std::function<ReadAheadRangeConsumer()>; +/// Returns true when the exact compressed data-page range is already in StoragePageCache. +using ReadAheadPageCacheProbe = std::function<bool(const io::FileRange& page_range)>; + +struct SegmentReadAheadOptions { + io::FileRangePlanOptions range_plan; + ReadAheadPageCacheProbe page_cache_probe; + /// Capture per-submission writeback state immediately before asynchronous IO starts. The + /// returned consumer is retained only by ranges accepted in that submission. + ReadAheadRangeConsumerFactory range_consumer_factory; +}; + +struct SegmentReadAheadResult { + /// Data pages newly requested by all column windows before the page-cache probe. + size_t new_pages {0}; + /// Newly requested pages already available from StoragePageCache. + size_t page_cache_hits {0}; + /// Physical ranges admitted to buffering; byte-budget skips are excluded. + size_t submitted_ranges {0}; + /// Sum of admitted range sizes, including coalescing and block-fill bytes. + size_t submitted_bytes {0}; + /// Batch-level scheduler rejection; NONE also covers plans that required no source reads. + io::FileRangeReadRejectReason reject_reason {io::FileRangeReadRejectReason::NONE}; + /// Planning or batch-submission status. Per-range execution failures surface on page reads. + Status status; + + bool accepted() const { + return reject_reason == io::FileRangeReadRejectReason::NONE && status.ok(); + } +}; + +/// FileReader view used by PageIO. Exact data-page reads reuse an asynchronous range buffer; +/// unrelated reads and failed prefetches transparently use the original reader. +class SegmentReadAheadFileReader final : public io::FileReader { +public: Review Comment: 这个file reader 为啥不在fs 这个目录下? -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
