Skip to content

Commit

Permalink
basic_rtree -> cista::raw::rtree + cista::offset::rtree
Browse files Browse the repository at this point in the history
  • Loading branch information
felixguendling committed Nov 4, 2024
1 parent 0c210f2 commit 950f96f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 14 deletions.
35 changes: 25 additions & 10 deletions include/cista/containers/rtree.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ template <typename Ctx, typename T>
void serialize(Ctx& c, T const* origin, offset_t const pos);

template <typename DataType, //
std::uint32_t Dims = 2U, //
typename NumType = float, //
std::uint32_t MaxItems = 64U, //
typename SizeType = std::uint32_t, //
template <typename, typename...> typename VectorType =
offset::vector_map>
struct rtree {
template <typename, typename...> typename VectorType, //
std::uint32_t Dims, //
typename NumType, //
std::uint32_t MaxItems, //
typename SizeType>
struct basic_rtree {
static constexpr auto const kInfinity = std::numeric_limits<NumType>::max();

static constexpr auto const kSplitMinItemsPercentage = 10U;
Expand Down Expand Up @@ -631,9 +630,25 @@ struct rtree {
VectorType<node_idx_t, node> nodes_;
};

template <typename DataType, std::uint32_t Dims = 2U, typename NumType = float,
template <typename T, std::uint32_t Dims = 2U, typename NumType = float,
std::uint32_t MaxItems = 64U, typename SizeType = std::uint32_t>
using mm_rtree = cista::rtree<DataType, Dims, NumType, MaxItems, SizeType,
cista::mmap_vec_map>;
using mm_rtree = cista::basic_rtree<T, cista::mmap_vec_map, Dims, NumType,
MaxItems, SizeType>;

namespace raw {

template <typename T, std::uint32_t Dims = 2U, typename NumType = float,
std::uint32_t MaxItems = 64U, typename SizeType = std::uint32_t>
using rtree = basic_rtree<T, vector_map, Dims, NumType, MaxItems, SizeType>;

}

namespace offset {

template <typename T, std::uint32_t Dims = 2U, typename NumType = float,
std::uint32_t MaxItems = 64U, typename SizeType = std::uint32_t>
using rtree = basic_rtree<T, vector_map, Dims, NumType, MaxItems, SizeType>;

}

} // namespace cista
11 changes: 7 additions & 4 deletions include/cista/type_hash/static_type_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,15 @@ template <typename T, std::size_t NMaxTypes = 128U>
constexpr hash_t static_type_hash() noexcept {
return static_type_hash(null<T>(), hash_data<NMaxTypes>{}).h_;
}
template <typename DataType, unsigned Dims, typename NumType, unsigned MaxItems,
typename SizeType, std::size_t NMaxTypes>
template <typename DataType, std::uint32_t Dims, typename NumType,
unsigned MaxItems, typename SizeType, std::size_t NMaxTypes,
template <typename, typename...> typename VectorType>
constexpr auto static_type_hash(
typename rtree<DataType, Dims, NumType, MaxItems, SizeType>::node const*,
typename basic_rtree<DataType, VectorType, Dims, NumType, MaxItems,
SizeType>::node const*,
hash_data<NMaxTypes> h) noexcept {
using rtree_t = rtree<DataType, Dims, NumType, MaxItems, SizeType>;
using rtree_t =
basic_rtree<DataType, VectorType, Dims, NumType, MaxItems, SizeType>;
h = h.combine(hash("rtree"));
h = h.combine(MaxItems);
h = static_type_hash(null<rtree_t::node_idx_t>(), h);
Expand Down

0 comments on commit 950f96f

Please sign in to comment.