iceberg-cpp
Loading...
Searching...
No Matches
roaring_position_bitmap.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#pragma once
21
24
25#include <cstdint>
26#include <functional>
27#include <memory>
28#include <string>
29#include <string_view>
30
31#include "iceberg/iceberg_data_export.h"
32#include "iceberg/result.h"
33
34namespace iceberg {
35
44
48class ICEBERG_DATA_EXPORT RoaringPositionBitmap {
49 public:
51 static constexpr int64_t kMaxPosition = 0x7FFFFFFE80000000LL;
52
55
57 RoaringPositionBitmap& operator=(RoaringPositionBitmap&& other) noexcept;
58
60 RoaringPositionBitmap& operator=(const RoaringPositionBitmap& other);
61
65 void Add(int64_t pos);
66
73 void AddRange(int64_t pos_start, int64_t pos_end);
74
78 bool Contains(int64_t pos) const;
79
81 bool IsEmpty() const;
82
84 size_t Cardinality() const;
85
88 void Or(const RoaringPositionBitmap& other);
89
94 bool Optimize();
95
97 void ForEach(const std::function<void(int64_t)>& fn) const;
98
100 size_t SerializedSizeInBytes() const;
101
103 Result<std::string> Serialize() const;
104
106 static Result<RoaringPositionBitmap> Deserialize(std::string_view bytes);
107
108 private:
109 struct Impl;
110 std::unique_ptr<Impl> impl_;
111
112 explicit RoaringPositionBitmap(std::unique_ptr<Impl> impl);
113};
114
115} // namespace iceberg
An Expression that represents a logical OR operation between two expressions.
Definition expression.h:215
A bitmap that supports positive 64-bit positions, optimized for cases where most positions fit in 32 ...
Definition roaring_position_bitmap.h:48
Definition roaring_position_bitmap.cc:62