split.hpp 3.7 KB

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