FlatCityBuf C++ reader 0.8.0
Native C++17 reader for FlatCityBuf, the cloud-optimized CityJSON format
Loading...
Searching...
No Matches
stree.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <fcb/error.hpp>
4#include <fcb/header.hpp>
5#include <fcb/key.hpp>
7
8#include <cstdint>
9#include <string>
10#include <vector>
11
12namespace fcb {
13
14struct SearchResultItem;
15
17enum class Operator { Eq, Ne, Gt, Ge, Lt, Le };
18
25
26using AttrQuery = std::vector<AttrCondition>;
27
33 bool exact_index_only = false;
34};
35
38constexpr std::uint64_t kPayloadTag = 1ULL << 63;
39constexpr std::uint64_t kPayloadMask = ~kPayloadTag;
40
41inline bool is_payload_ref(std::uint64_t off) { return (off & kPayloadTag) != 0; }
42inline std::uint64_t payload_offset(std::uint64_t off) { return off & kPayloadMask; }
43
47std::uint64_t stree_num_nodes(std::uint64_t num_items, std::uint16_t branching_factor);
48
54 std::uint64_t start;
55 std::uint64_t end;
56};
57
65std::vector<StreeLevelBound> stree_level_bounds(std::uint64_t num_items,
66 std::uint16_t branching_factor);
67
69std::vector<std::uint64_t> decode_payload_entry(bytes_view b);
70
73void encode_payload_entry(std::vector<std::uint8_t>& out,
74 const std::vector<std::uint64_t>& offsets);
75
78std::vector<SearchResultItem> stree_query(RangeReader& reader, const AttrIndexInfo& index,
79 KeyKind kind, Operator op, const KeyValue& value);
80
81} // namespace fcb
A decoded index key.
Definition key.hpp:40
Synchronous byte-range source.
Minimal C++17 stand-in for std::span: a non-owning view over contiguous memory.
Definition span.hpp:13
std::size_t index
Definition geometry.cpp:70
bool is_payload_ref(std::uint64_t off)
Definition stree.hpp:41
std::uint64_t stree_num_nodes(std::uint64_t num_items, std::uint16_t branching_factor)
Total node count.
Definition stree.cpp:313
std::vector< std::uint64_t > decode_payload_entry(bytes_view b)
Decode a payload entry: u32 count then count x u64, all little-endian.
Definition stree.cpp:331
std::vector< StreeLevelBound > stree_level_bounds(std::uint64_t num_items, std::uint16_t branching_factor)
Mirrors Stree::generate_level_bounds (stree.rs:474-508).
Definition stree.cpp:20
std::uint64_t payload_offset(std::uint64_t off)
Definition stree.hpp:42
std::vector< SearchResultItem > stree_query(RangeReader &reader, const AttrIndexInfo &index, KeyKind kind, Operator op, const KeyValue &value)
Run one condition against one column's index blob, returning candidate feature offsets (relative to t...
Definition stree.cpp:360
void encode_payload_entry(std::vector< std::uint8_t > &out, const std::vector< std::uint64_t > &offsets)
Encode a payload entry: u32 count then count x u64, all little-endian (mirrors PayloadEntry::serializ...
Definition stree.cpp:350
constexpr std::uint64_t kPayloadMask
Definition stree.hpp:39
constexpr std::uint64_t kPayloadTag
The MSB of a leaf offset marks a payload reference rather than a direct feature offset (stree....
Definition stree.hpp:38
KeyKind
The concrete key types the B+tree index can hold.
Definition key.hpp:14
std::vector< AttrCondition > AttrQuery
Definition stree.hpp:26
Operator
Comparison operators the attribute index supports.
Definition stree.hpp:17
KeyKind kind
Definition stree.cpp:166
RangeReader & reader
Definition stree.cpp:162
One condition of an attribute query.
Definition stree.hpp:20
KeyValue value
Definition stree.hpp:23
std::string field
Definition stree.hpp:21
Where one column's B+tree index lives, and how it is shaped.
Definition header.hpp:35
bool exact_index_only
Return raw index candidates without verifying them against the decoded attribute.
Definition stree.hpp:33
Half-open [start, end) node index range for one tree level, in the flat node array shared by every le...
Definition stree.hpp:53
std::uint64_t start
Definition stree.hpp:54
std::uint64_t end
Definition stree.hpp:55