In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "what is the principle of PostgreSQL database implementation". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the principle of PostgreSQL database implementation".
The FSM file of PostgreSQL, whose data structure is based on the maximum heap binary tree, can be found in the code notes for the related code of construction / deletion / insertion.
# include "heap.h" static int heap [Max _ ELEMENTS]; static int counter = 0 for for / exchange data static void swap (int * ireint * j) {int tmp = * j; * j = * I; * I = tmp;} / / print heap information / / n: number of elements void print_max_heap () {for (int I = 1i heap [icord 2]) ) {/ / if the inserted value is larger than its parent node, interact the value of the parent node with the current node heap [I] = heap [ibank 2]; / / here is similar to the recursive operation, that is, to find the parent node} / / the value of the parent node is larger than the current value or has reached the root node, set the value of the current position to the value to be inserted heap [I] = item } / / Delete elements in the maximum heap / / * n: number of heap elements void delete_max_heap () {/ / delete the maximum heap, always delete the root node of the largest heap if (HEAP_EMPTY (counter)) {return;} / / algorithm idea: take the last element as the root node, and then find the appropriate location of the node in the tree int lastone = heap [--counter] / / parent node, initialized to 1 int parent = 1; for (int son=parent*2;son heap [son]) {break;// is already larger than son. Exit} / / move the child node to the parent node / / parent is the location where lastone moves to heap [parent] = Heapson; / / Recursive, to the next subtree parent = son } / / the location of parent is the location of the last element heap [parent] = the actual location of lastone;//lastone has been found, assignment} / / build maximum heap / / n: number of elements / / heap is the initialized but unbuilt array void build_max_heap () {for (int I = counter;i > 1) IMub -) {/ / traverse the array if (heap [I] > heap [ibank 2]) {/ / the child node is larger than the parent node, swap the parent-child node swap (& (Heap [I / 2]), & (Heap [I])); for (int junities2dexj)
< counter;j=j*2) { //递归处理子节点 if (j >Counter) {break;} if (j
< counter && heap[j+1] >Heap [j]) {/ / switch to the right child node jobless;} if (heap [j] > heap [jbank 2]) {/ / if the child node is larger than the parent node, swap swap (& (heap [j / 2]), & (heap [j]) }} / / end for#2} / / end if} / / end for#1} void build_max_heap_new () {for (int I = counter/2;i > 1 parent -) {/ / start processing from the upper layer of the child node / / the parent node is I int parent=i; / / the value of the node int temp=heap [parent]; for (int child=parent*2 Child heap [child]) / / the parent node is larger than the child node. Exit the tree loop formed by the parent node break; else {/ / put the value of the child node into the parent node heap [parent] = heap [child];} / / enter the child node and recursively process parent = child } / / have found the appropriate location of the parent node, assign heap [parent] = temp;} / / end for#1} Thank you for your reading, the above is the content of "what is the principle of PostgreSQL database implementation". After the study of this article, I believe you have a deeper understanding of what the principle of PostgreSQL database implementation is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.