MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / _removePage

Method _removePage

src/common/classes/tree.h:887–988  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

885
886template <typename Value, typename Key, typename KeyOfValue, typename Cmp>
887void BePlusTree<Value, Key, KeyOfValue, Cmp>::_removePage(const int nodeLevel, NodePtr node)
888{
889 NodeList *list;
890 // Get parent and adjust the links
891 if (nodeLevel)
892 {
893 NodeList *temp = node.nodes;
894 if (temp->prev)
895 temp->prev->next = temp->next;
896 if (temp->next)
897 temp->next->prev = temp->prev;
898 list = temp->parent;
899 }
900 else
901 {
902 ItemList *temp = node.items;
903 if (temp->prev)
904 temp->prev->next = temp->next;
905 if (temp->next)
906 temp->next->prev = temp->prev;
907 list = temp->parent;
908 }
909
910 if (list->getCount() == 1)
911 {
912 // Only one node left in the list. We cannot remove it directly
913 // because is would invalidate our tree structure
914 NodeList *temp;
915 if ((temp = list->prev) && NEED_MERGE(temp->getCount(), NODE_COUNT)) {
916 _removePage(nodeLevel + 1, list);
917 }
918 else
919 if ((temp = list->next) && NEED_MERGE(temp->getCount(), NODE_COUNT)) {
920 _removePage(nodeLevel + 1, list);
921 }
922 else
923 if ((temp = list->prev))
924 {
925 NodeList::setNodeParent(((*list)[0] = (*temp)[temp->getCount() - 1]), nodeLevel, list);
926 temp->shrink(temp->getCount() - 1);
927 }
928 else
929 if ((temp = list->next))
930 {
931 NodeList::setNodeParent(((*list)[0] = (*temp)[0]), nodeLevel, list);
932 temp->remove(0);
933 }
934 else
935 {
936 // It means the tree is broken
937 fb_assert(false);
938 }
939 }
940 else
941 {
942 FB_SIZE_T pos;
943#ifndef DEV_BUILD
944 list->find(NodeList::generate(list, node), pos);

Callers 1

fastRemoveMethod · 0.80

Calls 6

NEED_MERGEFunction · 0.85
getCountMethod · 0.45
shrinkMethod · 0.45
removeMethod · 0.45
findMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected