split.hpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // Boost.Geometry Index
  2. //
  3. // R-tree kmeans split algorithm implementation
  4. //
  5. // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
  6. //
  7. // This file was modified by Oracle on 2021.
  8. // Modifications copyright (c) 2021 Oracle and/or its affiliates.
  9. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  10. //
  11. // Use, modification and distribution is subject to the Boost Software License,
  12. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  13. // http://www.boost.org/LICENSE_1_0.txt)
  14. #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_KMEANS_SPLIT_HPP
  15. #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_KMEANS_SPLIT_HPP
  16. #include <boost/geometry/index/detail/rtree/node/concept.hpp>
  17. #include <boost/geometry/index/detail/rtree/visitors/insert.hpp>
  18. namespace boost { namespace geometry { namespace index {
  19. namespace detail { namespace rtree {
  20. // TODO: This should be defined in options.hpp
  21. // For now it's defined here to satisfy Boost header policy
  22. struct split_kmeans_tag {};
  23. namespace kmeans {
  24. // some details
  25. } // namespace kmeans
  26. // split_kmeans_tag
  27. // OR
  28. // split_clusters_tag and redistribute_kmeans_tag - then redistribute will probably slightly different interface
  29. // or some other than "redistribute"
  30. // 1. for this algorithm one probably MUST USE NON-STATIC NODES with node_default_tag
  31. // or the algorithm must be changed somehow - to not store additional nodes in the current node
  32. // but return excessive element/elements container instead (possibly pushable_array<1> or std::vector)
  33. // this would also cause building of smaller trees since +1 element in nodes wouldn't be needed in different redistributing algorithms
  34. // 2. it is probably possible to add e.g. 2 levels of tree in one insert
  35. // Edge case is that every node split generates M + 1 children, in parent containing M nodes
  36. // result is 2M + 1 nodes in parent on this level
  37. // On next level the same, next the same and so on.
  38. // We have Depth*M+1 nodes in the root
  39. // The tree may then gain some > 1 levels in one insert
  40. // split::apply() manages this but special attention is required
  41. // which algorithm should be used to choose current node in traversing while inserting?
  42. // some of the currently used ones or some using mean values as well?
  43. // TODO
  44. // 1. Zmienic troche algorytm zeby przekazywal nadmiarowe elementy do split
  45. // i pobieral ze split nadmiarowe elementy rodzica
  46. // W zaleznosci od algorytmu w rozny sposob - l/q/r* powinny zwracac np pushable_array<1>
  47. // wtedy tez is_overerflow (z R* insert?) bedzie nieportrzebne
  48. // Dla kmeans zapewne std::vector, jednak w wezlach nadal moglaby byc pushable_array
  49. // 2. Fajnie byloby tez uproscic te wszystkie parametry root,parent,index itd. Mozliwe ze okazalyby sie zbedne
  50. // 3. Sprawdzyc czasy wykonywania i zajetosc pamieci
  51. // 4. Pamietac o parametryzacji kontenera z nadmiarowymi elementami
  52. // PS. Z R* reinsertami moze byc masakra
  53. template <typename MembersHolder>
  54. class split<MembersHolder, split_kmeans_tag>
  55. {
  56. protected:
  57. typedef typename MembersHolder::parameters_type parameters_type;
  58. typedef typename MembersHolder::box_type box_type;
  59. typedef typename MembersHolder::translator_type translator_type;
  60. typedef typename MembersHolder::allocators_type allocators_type;
  61. typedef typename MembersHolder::size_type size_type;
  62. typedef typename MembersHolder::node node;
  63. typedef typename MembersHolder::internal_node internal_node;
  64. typedef typename MembersHolder::leaf leaf;
  65. public:
  66. typedef index::detail::varray
  67. <
  68. typename rtree::elements_type<internal_node>::type::value_type,
  69. 1
  70. > nodes_container_type;
  71. template <typename Node>
  72. static inline void apply(nodes_container_type & additional_nodes,
  73. Node & n,
  74. box_type & n_box,
  75. parameters_type const& parameters,
  76. translator_type const& translator,
  77. allocators_type & allocators)
  78. {
  79. }
  80. };
  81. }} // namespace detail::rtree
  82. }}} // namespace boost::geometry::index
  83. #endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_KMEANS_SPLIT_HPP