• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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 #ifndef SRC_TRACE_PROCESSOR_DB_STORAGE_H_
17 #define SRC_TRACE_PROCESSOR_DB_STORAGE_H_
18 
19 #include <variant>
20 #include "perfetto/ext/base/status_or.h"
21 #include "src/trace_processor/db/column.h"
22 
23 namespace perfetto {
24 namespace trace_processor {
25 namespace column {
26 
27 // Most base column interpreting layer - responsible for implementing operations
28 // that require looking at the data, such as comparison or sorting.
29 class Storage {
30  public:
31   virtual ~Storage();
32 
33   // Changes the vector of indices to represent the sorted state of the column.
34   virtual void StableSort(uint32_t* rows, uint32_t rows_size) const = 0;
35 
36   // Efficiently compares series of |num_elements| of data from |data_start| to
37   // comparator value and appends results to BitVector::Builder. Should be used
38   // on as much data as possible.
39   virtual void CompareFast(FilterOp op,
40                            SqlValue value,
41                            uint32_t offset,
42                            uint32_t compare_elements_count,
43                            BitVector::Builder&) const = 0;
44 
45   // Inefficiently compares series of |num_elements| of data from |data_start|
46   // to comparator value and appends results to BitVector::Builder. Should be
47   // avoided if possible, with `FastSeriesComparison` used instead.
48   virtual void CompareSlow(FilterOp op,
49                            SqlValue value,
50                            uint32_t offset,
51                            uint32_t compare_elements_count,
52                            BitVector::Builder&) const = 0;
53 
54   // Compares sorted (asc) series data with comparator value. Should be used
55   // where possible.
56   virtual void CompareSorted(FilterOp op, SqlValue value, RowMap&) const = 0;
57 
58   // Compares sorted (asc) with `order` vector series with comparator value.
59   // Should be used where possible.
60   virtual void CompareSortedIndexes(FilterOp op,
61                                     SqlValue value,
62                                     uint32_t* order,
63                                     RowMap&) const = 0;
64 
65   // Number of elements in stored data.
66   virtual uint32_t size() const = 0;
67 };
68 
69 }  // namespace column
70 }  // namespace trace_processor
71 }  // namespace perfetto
72 #endif  // SRC_TRACE_PROCESSOR_DB_STORAGE_H_
73