• 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 
17 #include "src/trace_processor/db/storage_overlay.h"
18 
19 #include "src/trace_processor/db/storage_variants.h"
20 
21 namespace perfetto {
22 namespace trace_processor {
23 namespace column {
24 
Filter(FilterOp op,SqlValue value,RowMap & rm) const25 void StorageOverlay::Filter(FilterOp op, SqlValue value, RowMap& rm) const {
26   if (op == FilterOp::kIsNotNull)
27     return;
28 
29   if (op == FilterOp::kIsNull) {
30     rm.Clear();
31     return;
32   }
33 
34   BitVector::Builder builder(storage_->size());
35   // Slow path: we compare <64 elements and append to get us to a word
36   // boundary.
37   uint32_t front_elements = builder.BitsUntilWordBoundaryOrFull();
38   storage_->CompareSlow(op, value, 0, front_elements, builder);
39   uint32_t cur_index = front_elements;
40 
41   // Fast path: we compare as many groups of 64 elements as we can.
42   // This should be very easy for the compiler to auto-vectorize.
43   uint32_t fast_path_elements = builder.BitsInCompleteWordsUntilFull();
44   storage_->CompareFast(op, value, cur_index, fast_path_elements, builder);
45   cur_index += fast_path_elements;
46 
47   // Slow path: we compare <64 elements and append to fill the Builder.
48   uint32_t back_elements = builder.BitsUntilFull();
49   storage_->CompareSlow(op, value, cur_index, back_elements, builder);
50 
51   BitVector bv = std::move(builder).Build();
52   rm.Intersect(RowMap(std::move(bv)));
53 }
54 
StableSort(uint32_t * rows,uint32_t rows_size) const55 void StorageOverlay::StableSort(uint32_t* rows, uint32_t rows_size) const {
56   storage_->StableSort(rows, rows_size);
57 }
58 
59 }  // namespace column
60 }  // namespace trace_processor
61 }  // namespace perfetto
62