blob: a9264472bcc75cae262240ea001c98dcd0b40fbc [file] [log] [blame]
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed 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.
*/
#ifndef SRC_TRACE_PROCESSOR_DB_STORAGE_NUMERIC_STORAGE_H_
#define SRC_TRACE_PROCESSOR_DB_STORAGE_NUMERIC_STORAGE_H_
#include <variant>
#include "src/trace_processor/db/storage/storage.h"
#include "src/trace_processor/db/storage/storage_variants.h"
namespace perfetto {
namespace trace_processor {
namespace storage {
class NumericStorage : public Storage {
public:
NumericStorage(void* data, uint32_t size, ColumnType type)
: type_(type), data_(data), size_(size) {}
void StableSort(uint32_t* rows, uint32_t rows_size) const override;
void Sort(uint32_t* rows, uint32_t rows_size) const override;
void LinearSearchAligned(FilterOp op,
SqlValue val,
uint32_t offset,
uint32_t num_elements,
BitVector::Builder& builder) const override;
void LinearSearchUnaligned(FilterOp op,
SqlValue val,
uint32_t offset,
uint32_t num_elements,
BitVector::Builder& builder) const override;
std::optional<Range> BinarySearch(FilterOp op,
SqlValue val,
Range search_range) const override;
std::optional<Range> BinarySearchWithIndex(FilterOp op,
SqlValue val,
uint32_t* order,
Range search_range) const override;
uint32_t size() const override { return size_; }
private:
// As we don't template those functions, we need to use std::visitor to type
// `start`, hence this wrapping.
uint32_t UpperBoundIndex(NumericValue val, Range search_range) const;
// As we don't template those functions, we need to use std::visitor to type
// `start`, hence this wrapping.
uint32_t LowerBoundIndex(NumericValue val, Range search_range) const;
// As we don't template those functions, we need to use std::visitor to type
// `start`, hence this wrapping.
uint32_t UpperBoundIndex(NumericValue val,
uint32_t* order,
Range search_range) const;
// As we don't template those functions, we need to use std::visitor to type
// `start`, hence this wrapping.
uint32_t LowerBoundIndex(NumericValue val,
uint32_t* order,
Range search_range) const;
const ColumnType type_;
const void* data_;
const uint32_t size_;
};
} // namespace storage
} // namespace trace_processor
} // namespace perfetto
#endif // SRC_TRACE_PROCESSOR_DB_STORAGE_NUMERIC_STORAGE_H_