1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef SRC_TRACE_PROCESSOR_DB_COLUMN_RANGE_OVERLAY_H_ 18 #define SRC_TRACE_PROCESSOR_DB_COLUMN_RANGE_OVERLAY_H_ 19 20 #include <cstdint> 21 #include <memory> 22 #include <optional> 23 #include <string> 24 25 #include "perfetto/trace_processor/basic_types.h" 26 #include "src/trace_processor/db/column/data_layer.h" 27 #include "src/trace_processor/db/column/types.h" 28 29 namespace perfetto::trace_processor::column { 30 31 class RangeOverlay final : public DataLayer { 32 public: 33 explicit RangeOverlay(const Range*); 34 ~RangeOverlay() override; 35 36 std::unique_ptr<DataLayerChain> MakeChain( 37 std::unique_ptr<DataLayerChain>, 38 ChainCreationArgs = ChainCreationArgs()); 39 40 private: 41 class ChainImpl : public DataLayerChain { 42 public: 43 ChainImpl(std::unique_ptr<DataLayerChain>, const Range*); 44 45 SingleSearchResult SingleSearch(FilterOp, 46 SqlValue, 47 uint32_t) const override; 48 49 SearchValidationResult ValidateSearchConstraints(FilterOp, 50 SqlValue) const override; 51 52 RangeOrBitVector SearchValidated(FilterOp, SqlValue, Range) const override; 53 54 void IndexSearchValidated(FilterOp p, SqlValue, Indices&) const override; 55 56 void StableSort(SortToken* start, 57 SortToken* end, 58 SortDirection) const override; 59 60 void Distinct(Indices&) const override; 61 62 std::optional<Token> MaxElement(Indices&) const override; 63 64 std::optional<Token> MinElement(Indices&) const override; 65 66 SqlValue Get_AvoidUsingBecauseSlow(uint32_t index) const override; 67 68 void Serialize(StorageProto*) const override; 69 size()70 uint32_t size() const override { return range_->size(); } 71 DebugString()72 std::string DebugString() const override { return "RangeOverlay"; } 73 74 private: 75 std::unique_ptr<DataLayerChain> inner_; 76 const Range* range_; 77 }; 78 79 const Range* range_; 80 }; 81 82 } // namespace perfetto::trace_processor::column 83 84 #endif // SRC_TRACE_PROCESSOR_DB_COLUMN_RANGE_OVERLAY_H_ 85