• 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_NUMERIC_STORAGE_H_
17 #define SRC_TRACE_PROCESSOR_DB_NUMERIC_STORAGE_H_
18 
19 #include <variant>
20 #include "perfetto/ext/base/status_or.h"
21 #include "src/trace_processor/db/column.h"
22 #include "src/trace_processor/db/storage.h"
23 #include "src/trace_processor/db/storage_variants.h"
24 
25 namespace perfetto {
26 namespace trace_processor {
27 namespace column {
28 
29 class NumericStorage : public Storage {
30  public:
NumericStorage(void * data,uint32_t size,ColumnType type)31   NumericStorage(void* data, uint32_t size, ColumnType type)
32       : type_(type), data_(data), size_(size) {}
33 
34   void StableSort(uint32_t* rows, uint32_t rows_size) const override;
35 
36   void CompareFast(FilterOp op,
37                    SqlValue val,
38                    uint32_t offset,
39                    uint32_t num_elements,
40                    BitVector::Builder& builder) const override;
41 
42   void CompareSlow(FilterOp op,
43                    SqlValue val,
44                    uint32_t offset,
45                    uint32_t num_elements,
46                    BitVector::Builder& builder) const override;
47 
48   void CompareSorted(FilterOp op, SqlValue val, RowMap&) const override;
49 
50   void CompareSortedIndexes(FilterOp op,
51                             SqlValue val,
52                             uint32_t* order,
53                             RowMap&) const override;
54 
size()55   uint32_t size() const override { return size_; }
56 
57  private:
58   // As we don't template those functions, we need to use std::visitor to type
59   // `start`, hence this wrapping.
60   uint32_t UpperBoundIndex(NumericValue val) const;
61 
62   // As we don't template those functions, we need to use std::visitor to type
63   // `start`, hence this wrapping.
64   uint32_t LowerBoundIndex(NumericValue val) const;
65 
66   // As we don't template those functions, we need to use std::visitor to type
67   // `start`, hence this wrapping.
68   uint32_t UpperBoundIndex(NumericValue val, uint32_t* order) const;
69 
70   // As we don't template those functions, we need to use std::visitor to type
71   // `start`, hence this wrapping.
72   uint32_t LowerBoundIndex(NumericValue val, uint32_t* order) const;
73 
74   const ColumnType type_;
75   const void* data_;
76   const uint32_t size_;
77 };
78 
79 }  // namespace column
80 }  // namespace trace_processor
81 }  // namespace perfetto
82 #endif  // SRC_TRACE_PROCESSOR_DB_NUMERIC_STORAGE_H_
83