Data sorting method, storage medium and equipment
By building a data structure containing heap structure and linked list, and determining whether the elements to be sorted are added to the linked list based on the first sort key, the non-essential sort key extraction and comparison operations in the existing top-N heap sort algorithm are solved, improving the sorting efficiency and improving database performance.
Patent Information
- Application Number
- CN202510292383.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-12
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2045-03-12
AI Technical Summary
When the existing top-N heap sorting algorithm executes order by + limit statements, there are non-essential extraction and comparison operations for non-first sorting keys, as well as repeated replacement operations for data in the heap, resulting in wasted CPU execution time and reducing overall sorting efficiency.
A data sorting method is proposed. By pre-constructing a data structure including a heap structure and a linked list with a heap node in the heap structure as a linked list node, it determines whether the conditions for joining the linked list are met based on the first sorting key of the element to be sorted, and adds it to the linked list to avoid directly replacing the nodes in the heap structure.
It reduces node replacement and comparison operations during the heap sorting process, improves overall sorting execution efficiency, and improves the performance of the database system.
Smart Images

Figure CN119782289A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to database technology, and in particular to a data sorting method, storage medium and device. Background Art
[0002] When the database executes the order by + limit statement, if the memory size is set to be sufficient, the top-N heap sort algorithm in the sort node will be triggered, and the first N tuples that meet the conditions will be obtained from the data set to be processed. The general operation of the sorting node of the database executor is as follows: when it is determined that top-N sorting is required, in order to ensure the correct comparison order of tuples for building a max-top heap (or a min-top heap), the overall sorting direction is reversed first; a tuple data is read from the lower node each time (if it is a column storage database, a row of data will be read from a batch of data); initially, the new tuples are put into the end of the heap in sequence and then rotated to build a heap of size N; once the number of tuples in the heap reaches N, the newly introduced tuple is subsequently compared with the sorting key of the top tuple of the heap in sequence to determine whether the newly introduced tuple can replace the top tuple of the heap; when it cannot be replaced, the newly introduced tuple is directly released; when replacement is required, the top tuple of the heap is released, the new tuple is put into the top of the heap, and then the heap is sorted; after all subsequent data is read, the top tuple of the final heap memory is exchanged with the end tuple in sequence to reduce the heap length and reorganize the heap until the heap length is zero to complete the sorting; the sorted tuples are returned to the upper node in sequence to finally obtain the execution result of the order by + limit statement. In the general algorithm, once a sort key needs to be compared, the program will read the actual value from the memory for comparison (if it is a complex sort key, the actual value will be found from the memory and copied, which is a more time-consuming process).
[0003] However, in the above process of comparing the sorting keys of the newly introduced tuples and the top tuples of the heap in sequence, the comparison operation is meaningless in some cases. For example, the data that needs to be put into the heap is judged by comparing the non-first sorting keys in the early stage, and is released by judging the first sorting key in the later stage. Therefore, the existing top-N heap sorting algorithm has invalid operations such as unnecessary extraction and comparison operations on non-first sorting key data, and repeated replacement operations on data in the heap. In the case of large data volumes, there is a problem of wasting CPU execution time due to excessive execution of invalid operations, and then there is a problem of reducing the execution efficiency of the overall sorting process. Summary of the invention
[0004] In view of the above problems, a data sorting method, storage medium and device are proposed to overcome the above problems or at least partially solve the above problems.
[0005] An object of the present invention is to provide a data sorting method to reduce node replacement operations in a heap sorting process, thereby improving the overall sorting execution efficiency.
[0006] A further object of the present invention is to optimize the data structure and improve the sorting accuracy.
[0007] Another further object of the present invention is to reduce the comparison operations in the heap sorting process to further improve the overall sorting execution efficiency.
[0008] In particular, the present invention provides a data sorting method, comprising: Obtaining elements to be sorted and a pre-constructed data structure, wherein the data structure includes a heap structure and a linked list using heap nodes in the heap structure as linked list nodes; Based on the first sort key of the element to be sorted, determine whether the element to be sorted meets the conditions for joining the linked list; If so, add the element to be sorted to the linked list.
[0009] Further, different heap nodes in the heap structure are used to store elements with different first sort keys, and different linked list nodes in each linked list are used to store elements with the same first sort key; and Based on the first sort key of the element to be sorted, the steps of determining whether the element to be sorted meets the condition of being added to the linked list include: Determine whether the first sort key of the element to be sorted is the same as the first sort key of the element stored in any heap node in the heap structure; If they are the same, confirm that the element to be sorted meets the conditions for adding to the linked list; If they are not the same, it is confirmed that the element to be sorted does not meet the conditions for joining the linked list.
[0010] Further, each node in the data structure is used to store an element; and After the step of adding the elements to be sorted into the linked list, the data sorting method further includes: The number of elements stored in nodes other than the top-of-heap linked list in the data structure is taken as the number of non-top-of-heap elements, wherein the top-of-heap linked list is a linked list with the top node of the heap structure as the linked list node; Determine whether the number of non-top elements of the heap reaches a set boundary value, where the boundary value is the target number of target elements to be obtained from the data set to be processed; If so, release all elements of the top linked list.
[0011] Furthermore, the step of obtaining the elements to be sorted includes: Determine whether there is a to-be-processed element, wherein the to-be-processed element is an element in the to-be-processed data set that has not been added to the data structure and has not been released; If it exists, get the element to be processed; Determine whether the number of elements stored in the data structure has reached the boundary value; If it is not reached, the obtained elements to be processed will be used as the elements to be sorted; If it is reached, based on the first sort key of the element to be processed, determine whether the element to be processed meets the conditions for adding to the data structure; If satisfied, the obtained elements to be processed will be used as the elements to be sorted.
[0012] Furthermore, after the step of determining whether there are elements to be processed, the data sorting method further includes: In the absence of elements to be processed, the elements stored in the data structure are sorted based on non-first sort keys of the elements stored in the data structure until the number of elements stored in the data structure is the same as the boundary value to obtain all target elements.
[0013] Furthermore, based on the first sort key of the element to be processed, the step of determining whether the element to be processed meets the condition of being added to the data structure includes: In the case where the type of the heap structure is a mini-heap, determine whether the first sort key of the element to be processed is not less than the first sort key of the element stored in the top node of the heap. If so, confirm that the element to be processed meets the conditions for adding to the data structure. If so, confirm that the element to be processed does not meet the conditions for adding to the data structure. Or When the heap structure type is a max-heap, determine whether the first sort key of the element to be processed is not greater than the first sort key of the element stored in the top node of the heap. If not, confirm that the element to be processed meets the conditions for adding to the data structure. If greater, confirm that the element to be processed does not meet the conditions for adding to the data structure.
[0014] Furthermore, after the step of determining whether the element to be processed meets the condition of being added to the data structure based on the first sorting key of the element to be processed, the data sorting method further includes: When the element to be processed does not meet the conditions for being added to the data structure, the element to be processed is released.
[0015] Further, the data structure is constructed by the following steps: An index array structure is constructed based on the first sorting keys of all elements to be processed in the data set to be processed, wherein the index array structure includes multiple arrays, the multiple arrays correspond to all elements to be processed one by one, and each array includes the first sorting key, row index and next hop index of the corresponding element to be processed, the row index is used to indicate the memory location of the element to be processed, and the next hop index is used to point to the location of another element to be processed whose first sorting key is the same as the first sorting key of the element to be processed in the index array structure, so as to simulate a linked list; Head pointers and tail pointers are set to point to multiple arrays in the index array structure respectively. The head pointer is used to indicate that the to-be-processed element corresponding to the array pointed to is the top of the heap structure, and the tail pointer is used to indicate that the array pointed to is the tail of the heap structure, so as to simulate the heap structure.
[0016] According to another aspect of the present invention, a machine-readable storage medium is provided, on which a machine executable program is stored. When the machine executable program is executed by a processor, the steps of any of the above-mentioned data sorting methods are implemented.
[0017] According to another aspect of the present invention, a computer device is provided, comprising a memory, a processor, and a machine executable program stored in the memory and running on the processor, and the processor implements the steps of any of the above-mentioned data sorting methods when executing the machine executable program.
[0018] The data sorting method of the present invention optimizes the data storage structure for heap sorting by pre-constructing a data structure including a heap structure and a linked list with heap nodes in the heap structure as linked list nodes, and after obtaining the elements to be sorted and the pre-constructed data structure, judging whether the elements to be sorted meet the conditions for adding to the linked list based on the first sorting key of the elements to be sorted, and adding the elements to be sorted to the linked list when the elements to be sorted meet the conditions for adding to the linked list, thereby avoiding directly replacing the nodes in the heap structure when the elements to be sorted meet the conditions for adding to the data structure, and reducing the node replacement operation in the heap sorting process. Therefore, the data sorting method of the present invention can temporarily store the elements to be sorted that meet the conditions in the linked list with the heap nodes in the heap structure as linked list nodes based on the first sorting key of the elements to be sorted, avoiding the problem of low execution efficiency caused by repeatedly replacing the top nodes of the heap during the heap sorting process, reducing the replacement operation in the heap sorting process, thereby improving the overall sorting execution efficiency, and further improving the performance of the database system.
[0019] Furthermore, the data sorting method of the present invention optimizes the data structure by making different heap nodes in the heap structure used to store elements with different first sorting keys, and different linked list nodes in each linked list used to store elements with the same first sorting key. In addition, the data sorting method of the present invention also determines whether the first sorting key of the element to be sorted is the same as the first sorting key of the element stored in any heap node in the heap structure, and only confirms that the element to be sorted meets the condition of adding to the linked list when the first sorting key is the same as the first sorting key of the element stored in any heap node in the heap structure, thereby realizing the judgment of whether the element to be sorted meets the condition of adding to the linked list based on the first sorting key of the element to be sorted, ensuring that the first sorting keys of the elements stored in each linked list are the same, thereby improving the sorting accuracy.
[0020] Furthermore, the data sorting method of the present invention releases all elements of the top linked list when the number of non-top elements reaches a set boundary value, thereby avoiding comparison operations on non-first sorting keys of all elements of the top linked list, reducing waste caused by invalid operations, and effectively limiting the storage capacity of elements in the heap structure, thereby further improving the overall sorting execution efficiency and further improving the performance of the database system.
[0021] Based on the following detailed description of specific embodiments of the present invention in conjunction with the accompanying drawings, those skilled in the art will become more aware of the above and other objects, advantages and features of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Hereinafter, some specific embodiments of the present invention will be described in detail in an exemplary and non-limiting manner with reference to the accompanying drawings. The same reference numerals in the accompanying drawings indicate the same or similar components or parts. It should be understood by those skilled in the art that these drawings are not necessarily drawn to scale. In the accompanying drawings: Figure 1 It is a schematic diagram of a top-N heap sorting algorithm execution scheme in the prior art; Figure 2 is a schematic diagram of a data sorting method according to an embodiment of the present invention; Figure 3 is a schematic diagram of an application scenario of a data sorting method according to an embodiment of the present invention; Figure 4 is a schematic diagram of a data structure in an initial state in a data sorting method according to an embodiment of the present invention; Figure 5 is a schematic diagram of a data structure in a data sorting method according to an embodiment of the present invention when the N=bound condition is not satisfied; Figure 6 is a schematic diagram of a data structure in a data sorting method according to an embodiment of the present invention when the N=bound condition is satisfied; Figure 7 is a schematic diagram of a data structure in a data sorting method according to an embodiment of the present invention after releasing a top element of a heap; Figure 8 is a schematic diagram of a data structure in a data sorting method according to an embodiment of the present invention after adding elements to be sorted into a top linked list of a heap; Fig. 9 is a schematic diagram of a data structure in a data sorting method according to an embodiment of the present invention after releasing elements to be processed; Fig.10 is a schematic diagram of a data structure in a data sorting method according to an embodiment of the present invention after releasing a top element of a heap; Fig.11is a schematic diagram of a data structure in a data sorting method according to an embodiment of the present invention in a constructed state; Fig.12 is a schematic diagram of a head-cutting operation in a data sorting method according to an embodiment of the present invention; Fig.13 is a flow chart of a data sorting method according to an embodiment of the present invention; Fig.14 is a control flow chart of a data sorting method according to an embodiment of the present invention; Fig.15 is a schematic diagram of the structure of a machine-readable storage medium according to an embodiment of the present invention; and Fig.16 is a schematic diagram of the structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0023] Exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present disclosure and to enable the scope of the present invention to be fully communicated to those skilled in the art.
[0024] Figure 1 It is a schematic diagram of a top-N heap sorting algorithm execution scheme in the prior art. First of all, it should be explained that top-N heap sorting is an algorithm for quickly finding the first N largest elements or smallest elements in a set of data. The basic idea is to maintain a small top heap (for finding the smallest N elements) or a large top heap (for finding the largest N elements) of size N. In addition, in the existing top-N heap sorting algorithm execution scheme, once a certain sorting key needs to be compared, the program will read the actual value from the memory for comparison (if it is a complex sorting key, the actual value will be searched from the memory for copying, and this process is more time-consuming), but in some cases the comparison operation is meaningless. For example, Figure 1 As shown, in the top-N algorithm, there may be data that needs to be put into the heap by comparing non-first sort keys in the early stage, and is released by judging the first sort key in the later stage. The comparison operation on the non-first sort key of this data is a meaningless and invalid operation. At the same time, the replacement operation of this data with the top data of the heap is also a meaningless and invalid operation.
[0025] Using the above method, multiple sorting keys of the data are extracted in the early comparison. Therefore, the execution process of the top-N heap sort algorithm has invalid operations such as unnecessary extraction and comparison operations on non-first sorting key data and repeated replacement operations on data in the heap. In the case of large amounts of data, there is a problem of wasting CPU execution time due to excessive invalid operations, which in turn reduces the execution efficiency of the overall sorting process.
[0026] To solve the above problems, an embodiment of the present invention proposes a data sorting method to improve and optimize the overall algorithm. Figure 2 FIG. 1 is a schematic diagram of a data sorting method according to an embodiment of the present invention. Figure 2 As shown, the data sorting method of this embodiment may generally include: Step S202, obtaining the elements to be sorted and the pre-constructed data structure, wherein the data structure includes a heap structure and a linked list with heap nodes in the heap structure as linked list nodes. It should be noted that the heap structure is a complete binary tree structure, and the internal container of the heap structure can be an array. In addition, in the present embodiment, the linked list can be composed of heap nodes in the heap structure as linked list nodes.
[0027] Step S204, based on the first sort key of the element to be sorted, determine whether the element to be sorted meets the conditions for adding to the linked list, if so, execute step S206.
[0028] Step S206, adding the elements to be sorted into the linked list. That is, when the elements to be sorted meet the conditions for being added into the linked list, the non-first sorting key is not extracted, but the elements to be sorted are temporarily stored in the data structure.
[0029] It should be noted that the data sorting method of the present invention can be used in a top-N heap sorting algorithm to obtain the first N target elements from the data set to be processed, and the target number of target elements obtained from the data set to be processed can be called a boundary value (which can be recorded as bound). Accordingly, the upper limit of the number of heap nodes in the heap structure in the data structure can be set as the boundary value, so that after the entire sorting process is completed, the elements in the heap structure are read as the first N target elements obtained from the data set to be processed.
[0030] In addition, in this embodiment, the data sorting method of the present invention uses a data structure that combines a binary tree and a linked list to construct a linked heap, and uses the construction logic of a standard heap sorting algorithm for the data in the heap structure, and stores the data that meets the conditions for adding to the linked list in the linked list, thereby increasing the upper limit of the number of elements stored in the data structure.
[0031] The data sorting method of the present invention optimizes the data storage structure used for heap sorting by pre-constructing a data structure including a heap structure and a linked list with heap nodes in the heap structure as linked list nodes, and after obtaining the elements to be sorted and the pre-constructed data structure, judging whether the elements to be sorted meet the conditions for adding to the linked list based on the first sorting key of the elements to be sorted, and adding the elements to be sorted to the linked list when the elements to be sorted meet the conditions for adding to the linked list, thereby avoiding directly replacing the nodes in the heap structure when the elements to be sorted meet the conditions for adding to the data structure, and reducing the node replacement operation in the heap sorting process.
[0032] Therefore, the data sorting method of the present invention can temporarily store the elements to be sorted that meet the conditions in a linked list with the heap nodes in the heap structure as the linked list nodes based on the first sorting key of the elements to be sorted, so as to improve and optimize the overall algorithm, avoid the problem of low execution efficiency caused by repeated replacement operations on the top nodes of the heap during the heap sorting process, reduce the replacement operations in the heap sorting process, and reduce the waste caused by invalid operations, thereby further improving the overall sorting execution efficiency and further improving the performance of the database system.
[0033] In some embodiments, in the above step S202, each node in the data structure is used to store an element. In addition, different heap nodes in the heap structure in the data structure are used to store elements with different first sorting keys, and different linked list nodes in each linked list are used to store elements with the same first sorting key. In other words, elements with different first sorting keys are stored in different heap nodes in the heap structure, and elements with the same first sorting key are stored in the linked list. As a result, the data sorting method of the present invention optimizes the data structure and improves the sorting accuracy.
[0034] In some embodiments, the elements to be sorted are elements to be added to the data structure obtained from the data set to be processed. Accordingly, the step of obtaining the elements to be sorted in the above step S202 may include the following steps: determine whether there are elements to be processed; if so, obtain the elements to be processed; determine whether the number of elements stored in the data structure reaches the boundary value; if not, use the obtained elements to be processed as the elements to be sorted; if so, determine whether the elements to be processed meet the conditions for adding to the data structure based on the first sorting key of the elements to be processed; if so, use the obtained elements to be processed as the elements to be sorted; if not, sort the elements stored in the data structure based on the non-first sorting keys of the elements stored in the data structure until the number of elements stored in the data structure is the same as the boundary value to obtain all target elements. It should be noted that the elements to be processed are elements in the data set to be processed that have not been added to the data structure and have not been released.
[0035] For example, for the execution statement 'SELECT * FROM table ORDER BY a DESC, b DESC LIMIT3;', the data set to be processed is the data set consisting of columns a and b in table table, the elements to be processed are the data in columns a and b that are not added to the data structure for sorting and are not directly released, and the elements to be sorted are the data in columns a and b that meet the conditions for adding to the data structure.
[0036] Specifically, the above-mentioned step of judging whether the element to be processed meets the conditions for adding to the data structure based on the first sort key of the element to be processed may include the following steps: when the type of the heap structure is a mini-heap, judging whether the first sort key of the element to be processed is not less than the first sort key of the element stored in the top node of the heap; if not, confirming that the element to be processed meets the conditions for adding to the data structure; if less, confirming that the element to be processed does not meet the conditions for adding to the data structure; or when the type of the heap structure is a max-heap, judging whether the first sort key of the element to be processed is not greater than the first sort key of the element stored in the top node of the heap; if not, confirming that the element to be processed meets the conditions for adding to the data structure; if greater, confirming that the element to be processed does not meet the conditions for adding to the data structure.
[0037] In this embodiment, the type of heap structure may include a small top heap and a big top heap. In the case where the type of the heap structure is a small top heap, the element stored in the top node of the heap (which may be called the top element of the heap) is the smallest element in the heap structure, and can be used to obtain the first N largest target elements from the data set to be processed by using the top-N heap sorting algorithm. At this time, the top element of the heap is the minimum value of the first N largest target elements. In the case where the type of the heap structure is a big top heap, the top element of the heap is the largest element in the heap structure, and can be used to obtain the first N smallest target elements from the data set to be processed by using the top-N heap sorting algorithm. At this time, the top element of the heap is the maximum value of the first N smallest target elements.
[0038] Therefore, when the type of the heap structure is a small top heap, if the first sort key of the element to be processed is not less than the first sort key of the top element of the heap, it means that the element to be processed belongs to the first N largest target elements among the elements currently obtained, thereby confirming that the element to be processed meets the conditions for adding to the data structure. When the type of the heap structure is a big top heap, if the first sort key of the element to be processed is not greater than the first sort key of the top element of the heap, it means that the element to be processed belongs to the first N smallest target elements among the elements currently obtained, thereby confirming that the element to be processed meets the conditions for adding to the data structure.
[0039] In addition, the above-mentioned step of sorting the elements stored in the data structure based on the non-first sorting key of the elements stored in the data structure can be called a head-cut operation (which can be recorded as a head-cut operation). When performing a head-cut operation, it is necessary to sort the next sorting key. Specifically, different sorting methods can be selected for sorting the next sorting key according to the amount of data to be sorted and the data type. For example, the data structure is reconstructed based on the non-first sorting key of the elements stored in the data structure, and the first several target elements are obtained. Therefore, in the final sorting, after extracting the next sorting key from the linked list sequence, a quick sort may achieve higher efficiency in the best and average cases.
[0040] In some embodiments, the above step S204 may include the following steps: determine whether the first sorting key of the element to be sorted is the same as the first sorting key of the element stored in any heap node in the heap structure; if the same, confirm that the element to be sorted meets the conditions for adding to the linked list; if not the same, confirm that the element to be sorted does not meet the conditions for adding to the linked list. It should be noted that the elements stored in the heap node can be referred to as heap elements. Accordingly, the above step of determining whether the first sorting key of the element to be sorted is the same as the first sorting key of the element stored in any heap node in the heap structure can be executed as the following steps: determine whether there is a heap element in the heap structure whose first sorting key is the same as the first sorting key of the element to be sorted; if so, confirm that the first sorting key of the element to be sorted is the same as the first sorting key of the element stored in any heap node in the heap structure; if not, confirm that the first sorting key of the element to be sorted is not the same as the first sorting key of the element stored in any heap node in the heap structure.
[0041] Therefore, the data sorting method of the present invention also determines whether the first sorting key of the element to be sorted is the same as the first sorting key of the element stored in any heap node in the heap structure, and only confirms that the element to be sorted meets the condition for adding to the linked list when the first sorting key is the same as the first sorting key of the element stored in any heap node in the heap structure. This realizes the judgment of whether the element to be sorted meets the condition for adding to the linked list based on the first sorting key of the element to be sorted, ensures that the first sorting keys of the elements stored in each linked list are the same, and thus improves the sorting accuracy.
[0042] In some embodiments, after the above step of judging whether the element to be processed meets the condition of being added to the data structure based on the first sorting key of the element to be processed, the data sorting method of the present invention may further include the following step: if the element to be processed does not meet the condition of being added to the data structure, releasing the element to be processed. Thus, the data structure always stores the first N target elements among the currently acquired elements, thereby improving the sorting accuracy.
[0043] In addition, in some embodiments, the above step S206 may include the following steps: adding the element to be sorted to the linked list of the elements in the heap whose first sorting key is the same as the first sorting key of the element to be sorted. Thus, the elements in the heap that are the same as the first sorting key of the element to be sorted are temporarily stored in the data structure, and the comparison and replacement operations of non-first sorting keys are not directly continued, thereby avoiding the problem of low execution efficiency caused by repeated replacement operations on the top node of the heap during the heap sorting process, reducing the replacement operations during the heap sorting process, and improving the sorting efficiency.
[0044] In some embodiments, after the above-mentioned step S206, the data sorting method of the present invention may further include the following steps: using the number of elements stored in nodes other than the top linked list in the data structure as the number of non-top elements, wherein the top linked list is a linked list with the top node of the heap structure as the linked list node; determining whether the number of non-top elements reaches a set boundary value, wherein the boundary value is the target number of target elements to be obtained from the data set to be processed; if so, releasing all elements of the top linked list.
[0045] Therefore, the data sorting method of the present invention releases all elements of the top of the heap list after the number of non-top elements reaches the set boundary value, avoiding comparison operations on non-first sorting keys of all elements of the top of the heap list, reducing the waste caused by invalid operations, and effectively limiting the storage capacity of elements in the heap structure, thereby further improving the overall sorting execution efficiency and further improving the performance of the database system.
[0046] Figure 3 Schematic diagram of an application scenario of a data sorting method according to an embodiment of the present invention. Figure 3 , the application scenario of the data sorting method of the present invention is explained.
[0047] like Figure 3 As shown, the data sorting method of the present invention uses a data structure combining a binary tree and a linked list to construct a heap, uses the construction logic of a standard heap sorting algorithm for data with different key values, and stores data with the same key value in a linked list. Therefore, the data sorting method of the present invention can be referred to as Linked-heap Sort, and the data structure of the present invention can be referred to as Linked-heap Sort.
[0048] In addition, if Figure 3As shown, the linked list can use the heap node in the heap structure as the head node. That is to say, the head node of each linked list is the heap node in the heap structure. Specifically, the linked list with the top node of the heap structure as the linked list node can be called the top-of-heap linked list, the number of elements stored in all nodes except the top-of-heap linked list in the data structure can be called the number of non-top-of-heap elements (which can be recorded as subN), and the number of elements stored in the data structure can be called the total number of elements (which can be recorded as N).
[0049] In a specific embodiment, after a new node is inserted into a chain stack, if the number of non-top elements in the chain stack is equal to the boundary value, all elements in the top chain list (including the top element) are released to reduce the total number of elements in the chain stack to within the boundary value. After the chain stack is constructed, if the total number of elements is greater than the boundary value, the first top chain list needs to be sorted based on the non-first sort key and then truncated, and the excess elements are released until the sorting is completed. Thus, after the entire sorting process is completed, the data sorting method of the present invention can obtain the first N target elements from the data set to be processed.
[0050] Using the above method, such as Figure 3 As shown, each time the judgment process for a new element is performed, only the first sort key is compared once, and the values with the same first sort key are placed in the same linked list. When the linked list needs to be released, it is directly released in batches. There is no need to compare the data in the linked list again to obtain the correct result. After the heap is built, the data in the linked list that is determined to have data to be retained is sorted for subsequent sort keys, thereby avoiding unnecessary comparison processes for non-first sort keys.
[0051] Figure 4 It is a schematic diagram of a data structure in an initial state in a data sorting method according to an embodiment of the present invention. Figure 5 It is a schematic diagram of a data structure in a data sorting method according to an embodiment of the present invention when the N=bound condition is not satisfied. Figure 6 It is a schematic diagram of a data structure in a data sorting method according to an embodiment of the present invention when the N=bound condition is satisfied. Figure 7 It is a schematic diagram of a data structure in a data sorting method according to an embodiment of the present invention after releasing the top element of the heap. Figure 8 It is a schematic diagram of the data structure in the data sorting method according to an embodiment of the present invention after adding the elements to be sorted into the top linked list of the heap. Fig. 9 It is a schematic diagram of a data structure in a data sorting method according to an embodiment of the present invention after releasing elements to be processed. Fig.10 It is a schematic diagram of a data structure in a data sorting method according to an embodiment of the present invention after releasing the top element of the heap. Fig.11 It is a schematic diagram of a data structure in a data sorting method according to an embodiment of the present invention in a constructed state. Fig.12 Schematic diagram of the head-cutting operation in the data sorting method according to one embodiment of the present invention. Figure 4 to Figure 12 , the multi-key sorting execution operation details of the data sorting method of the present invention are explained.
[0052] In some embodiments, Figure 4 As shown, the data structure in the data sorting method of the present invention can be constructed by the following steps: constructing an index array structure based on the first sorting key of all elements to be processed in the data set to be processed, wherein the index array structure includes multiple arrays, the multiple arrays correspond one-to-one to all elements to be processed, and each array includes the first sorting key, row index and next hop index of the corresponding element to be processed, the row index is used to indicate the memory position of the element to be processed, and the next hop index is used to point to the position of another element to be processed whose first sorting key is the same as the first sorting key of the element to be processed in the index array structure, so as to simulate a linked list; setting a head pointer and a tail pointer pointing to multiple arrays in the index array structure respectively, the head pointer is used to indicate that the element to be processed corresponding to the array pointed to is the top of the heap structure, and the tail pointer is used to indicate that the array pointed to is the tail of the heap structure, so as to simulate the heap structure.
[0053] Specifically, Figure 4 As shown, it is assumed that 4 columns and 8 rows of data have been stored in the memory, of which there are two sorting keys. Initially, the required index array results have been constructed to perform the actual top-N sorting operation. Each array of the index array structure consists of three pieces of information: sorting key, row index, and next hop index. The row index represents the corresponding position relationship of the element in the actual memory. The sorting key can be the actual data of a key extracted from the memory. Initially, it is the actual value of the first sorting key. The next hop index points to the position of the element with the same value in the data structure, which simulates the linked list in sequence. In a specific embodiment, the next hop index is set to 0 to indicate that the element is at the end of the linked list, and the next hop index is set to -1 to indicate that the element is not in the link stack and needs to be released.
[0054] Furthermore, the head pointer (which can be recorded as head) is set to point to the top of the heap structure, the tail pointer (which can be recorded as tail) is set to indicate the tail of the heap structure (which also indicates the length of the heap structure), and the insertion pointer (which can be recorded as temp) is set to point to the next element to be inserted into the heap. In addition, bound is set to indicate the boundary size, N indicates the total number of elements in the current linked heap (including all elements in the linked list), and subN indicates the total number of elements excluding the top linked list elements. For example, when executing the statement 'SELECT* FROM table ORDER BY a DESC, b DESC LIMIT 3;', bound is equal to 3. It should be noted that when subN is equal to bound, it means that the entire top linked list can be released. The "swap pointer" operation described later means exchanging all the contents of the arrays pointed to by the two pointers (including row indexes, sort keys, and next hop indexes).
[0055] In some embodiments, Figure 4 to Figure 12 When executing the statement 'SELECT * FROM table ORDER BY aDESC, b DESC LIMIT 3;', the multi-key sorting execution process of the data sorting method of the present invention may include the following steps: 1. First, construct a heap of N=3, such as Figure 4 As shown in the figure, when inserting an element into a linked heap, you need to first determine whether it can be added to the linked list. If necessary, add it directly to the linked list and move temp; otherwise, swap temp and tail, sort the heap, and move tail backward. Specifically, the step of determining whether it can be added to the linked list can be specifically performed by determining whether the temp key value is the same as the head key value. If not, swap temp and tail, sort the heap, and move tail backward. The linked heap becomes Figure 5 The structure shown.
[0056] 2. At this time, N < bound, and temp cannot be added to the chain, so temp and tail are swapped, the heap is sorted, and tail is moved back. The chain heap becomes Figure 6 The structure shown.
[0057] 3. At this time, the N = bound condition is met, so the subsequent operations need to determine whether temp can be inserted into the link stack. Figure 6 As shown in the figure, the temp key value is greater than the head value and cannot be inserted into the linked list, so the top of the heap needs to be replaced. In actual operation, first mark the head as needing to be released (set the next hop index to -1), swap temp and head, sort the heap, and move temp forward. The linked heap becomes Figure 7 The structure shown.
[0058] 4. At this time, the temp key value is the same as the head key value, so temp can be added to the head's linked list, and the head's next hop index is set to temp (the index number in the array, not the row index), indicating that the temp position is added to the head's linked list, and then temp is moved forward, and the chain stack becomes Figure 8 The structure shown.
[0059] 5. At this time, temp is compared with head and does not meet the conditions for insertion into the link stack. Temp is directly marked as to be released and temp is moved forward. The link stack becomes Fig. 9 The structure shown.
[0060] 6. At this time, temp is compared with head and meets the conditions for insertion into the linked list. And the inserted linked list is not the top of the heap. Therefore, the following operations are required: ① Add temp to the corresponding chain and then move temp forward; ② Since subN = bound at this time, the top of the heap needs to be released and all the top linked lists are marked as to be released; ③ Since the top of the heap is released, the heap structure becomes shorter, so move tail forward, swap head and tail, sort the heap, swap tail and temp again, and move temp forward. The linked heap becomes Fig.10 Thus, the data sorting method of the present invention can optimize the algorithm. Compared with the standard algorithm, all elements in the released linked list are not compared with other sorting keys, which reduces the number of comparisons and improves the sorting execution efficiency.
[0061] 7. Now we scan the last element and find that it can be inserted into the linked heap, but not into the linked list. After insertion, subN < bound, so there is no need to release the top element of the heap. Therefore, we swap temp and tail, sort the heap, and then move tail back. At this point, temp < tail, and the construction of the linked heap is complete. The memory format after completion is Fig.11 shown.
[0062] 8. After building the linked heap, it is found that N > bound, so it is necessary to perform a head-cut operation to trim N-bound elements from the top linked list of the heap. In other words, the top linked list of the heap is sorted by the subsequent sorting keys in turn, and the whole is placed at the end of the result array until the sorting is completed. Specifically, if Fig.12 As shown, the top linked list of the heap is transferred to a temporary array, the next sort key value of the corresponding row is read, and the linked heap is sorted again with bound=bound-subN. After sorting, the data in the temporary array is stored back to the original linked list position in sequence to complete the head cutting operation.
[0063] At this point, the entire chain stack is built, and the element stored in the chain stack is the target element. When memory needs to be released, it is released from the memory in sequence according to the row number marked with the index (the row number corresponding to the element with the next hop index set to -1).
[0064] Therefore, in actual operation, the chain-heap sort only uses an array to simulate the structure of a binary tree plus a linked list, which can effectively utilize memory space, and through the chain-heap sort, effectively avoids a large number of invalid reading and comparison operations on actual information that is not the first sort key, thereby improving the overall top-N sorting execution efficiency. Therefore, the data sorting method of the present invention can improve and optimize the overall algorithm, avoid the problem of low execution efficiency caused by repeated replacement and comparison operations on the top node of the heap during the heap sorting process, reduce invalid operations such as replacement operations and comparison operations during the heap sorting process, and achieve the reduction of waste caused by invalid operations, thereby further improving the overall sorting execution efficiency, and then improving the performance of the database system.
[0065] Fig.13 1 is a flow chart of a data sorting method according to an embodiment of the present invention. Fig.13 The process steps of this embodiment are described in detail.
[0066] Step S1302, initialize the top element of the heap and the boundary value. It should be noted that the step of initializing the top element of the heap can be specifically performed as initializing the top node of the heap structure in the pre-constructed data structure. Specifically, the heap structure of type big top heap is used to find the top-N heap sort of the first N smallest elements in the data set, and the top element of the heap is the element with the largest sorting key value stored in the heap structure; the heap structure of type small top heap is used to find the top-N heap sort of the first N largest elements in the data set, and the top element of the heap is the element with the smallest sorting key value stored in the heap structure. In addition, the boundary value is the target number of obtaining the first N target elements from the data set to be processed when executing the top-N heap sorting task, which can be recorded as bound.
[0067] Step S1304, determine whether there is a new element, if so, execute step S1306, if not, execute step S1324.
[0068] Step S1306, obtaining a new element.
[0069] Step S1308, determine whether the number of elements stored in the data structure reaches a limit value, if so, execute step S1320, if not, execute step S1310. It should be noted that the number of elements stored in the data structure can be recorded as N.
[0070] Step S1310, determine whether the new element is the same as the element in the heap, if so, execute step S1312, if not, execute step S1314. It should be noted that the element in the heap refers to the element stored in the heap structure. In addition, this step can be specifically executed as determining whether the first sort key of the new element is the same as the first sort key of any element in the heap structure.
[0071] Step S1312, adding the new element to the corresponding linked list, and executing step S1316. It should be noted that the first sort key of each element in the corresponding linked list is the same as the first sort key of the new element.
[0072] Step S1314, adding the new element to the heap structure, and executing step S1316. It should be noted that the first sort key of each element in the heap structure is different.
[0073] Step S1316, determine whether the number of non-top elements has reached the boundary value, if so, execute step S1318, if not, return to step S1304. It should be noted that the number of non-top elements refers to the number of elements stored in the nodes other than the top linked list in the data structure, and the top linked list is a linked list with the top node of the heap structure as the linked list node.
[0074] Step S1318, release all elements of the top linked list of the heap to reconstruct the heap structure, and return to step S1304.
[0075] Step S1320, determine whether the new element meets the conditions for adding to the data structure, if so, execute step S1310, if not, execute step S1322.
[0076] Step S1322, release the new element and return to step S1304.
[0077] Step S1324, sorting the elements in the top linked list of the heap based on the non-first sorting keys of the elements stored in the data structure.
[0078] Step S1326, determine whether the number of elements stored in the data structure is greater than the boundary value, if so, execute step S1328, if not, execute step S1330.
[0079] Step S1328, truncate and release the redundant elements in the top linked list of the heap so that the number of elements stored in the data structure is the same as the boundary value, and execute step S1330.
[0080] Step S1330, obtaining the elements stored in the data structure as all target elements. At this point, the execution process of the top-N heap sorting task is completed, and this process ends.
[0081] Therefore, the data sorting method of the present invention realizes a heap sorting optimization scheme applied to multi-key top-N sorting, reduces the number of element comparisons in execution logic compared to the standard heap sorting algorithm, and performs data comparison only when comparison is necessary, which can improve the sorting efficiency as a whole.
[0082] Fig.14 The following is a control flow chart of a data sorting method according to an embodiment of the present invention. The following takes the top-N sorting task in a database with a column storage structure as an example, and the execution statement is 'SELECT * FROM table ORDERBY a DESC, b DESC LIMIT 3;', combined with Fig.14 The control flow of this embodiment is described in detail.
[0083] Step S1402: Create an index array for the memory data. It should be noted that the memory data refers to all the data in columns a and b in the table table.
[0084] Step S1404, initialize the pointers head, tail and temp and the variables N and sudN. It should be noted that head points to the top of the heap structure, tail indicates the tail of the heap structure (also indicates the length of the heap structure), temp points to the next element to be inserted into the data structure or released, N indicates the total number of elements in the current data structure, subN indicates the total number of elements excluding the top linked list elements, and when subN is equal to bound, it indicates that the top linked list can be released as a whole. The "swap pointer" operation described later indicates exchanging all the contents of the arrays pointed to by the two pointers (including row index, sort key value and next hop index).
[0085] Step S1406, determine whether temp<tail, if so, execute step S1430, if not, execute step S1408. It should be noted that temp<tail indicates that there is a new element to be inserted into the data structure or released.
[0086] Step S1408, determine whether N<bound, if so, execute step S1410, if not, execute step S1416. It should be noted that bound represents a boundary value, and in this embodiment, bound is equal to 3.
[0087] Step S1410, determine whether temp has the same value as the heap node, if so, execute step S1412, if not, execute step S1414. It should be noted that temp has the same value as the heap node means that the first sort key of the element corresponding to the array pointed to by temp is the same as the first sort key of any element in the heap structure.
[0088] Step S1412, add temp to the corresponding linked list, update N and subN, move temp forward, and return to step S1406. It should be noted that if temp is added to the top linked list, the N+1 operation is performed, that is, N+1; if temp is added to the non-top linked list, the subN++ operation is performed, that is, subN+1.
[0089] Step S1414, temp is exchanged with tail and the heap is reconstructed, N and subN are updated, tail is moved backward, and the process returns to step S1406. It should be noted that the first sort key of each element in the heap structure is different.
[0090] Step S1416, compare temp with head to determine whether temp can be put into the data structure, if so, execute step S1418, if not, execute step S1428. It should be noted that for a max-heap, if the first sort key of the element corresponding to the array pointed to by temp is less than the first sort key of the top element of the heap, it is confirmed that temp can be put into the data structure; for a min-heap, if the first sort key of the element corresponding to the array pointed to by temp is greater than the first sort key of the top element of the heap, it is confirmed that temp can be put into the data structure.
[0091] Step S1418, determine whether temp has the same value as the heap node, if so, execute step S1420, if not, execute step S1426.
[0092] Step S1420, add temp to the corresponding linked list, update N and subN, move temp forward, and execute step S1422.
[0093] Step S1422, determine whether subN is equal to bound, if so, execute step S1424, if not, return to step S1406.
[0094] Step S1424, release the head and all elements in the top linked list, move tail forward, swap head and tail, reconstruct the heap, update N and subN, swap tail and temp, move temp forward, and return to step S1406. It should be noted that updating N and subN includes recording N=bound and recalculating subN. Specifically, the step of releasing the head and all elements in the top linked list can be specifically executed by setting the next hop index in the array corresponding to all elements in the head and the top linked list to -1 to indicate that they need to be released in the end.
[0095] Step S1426, release head and all elements in the top linked list of the heap, exchange head with temp, reconstruct the heap, update subN, move temp forward, and return to step S1406.
[0096] Step S1428, mark temp as to be released, move temp forward, and return to step S1406. Specifically, this step can be specifically performed by setting the next hop index in the array pointed to by temp to -1 to indicate that it needs to be released in the end.
[0097] Step S1430, sort the top linked list, and cut off and release the redundant elements in the top linked list, so that the number of elements stored in the data structure is the same as the boundary value, and execute step S1432.
[0098] Step S1432, obtain the elements stored in the data structure as all target elements. At this point, the execution process of the top-N heap sorting task is completed, and this process ends.
[0099] Therefore, the data sorting method of the present invention can be used for heap sorting of multi-key top-N sorting. Compared with the standard heap sorting algorithm, the execution logic reduces the number of element comparisons and only performs data comparison when it is necessary, thereby improving the sorting efficiency as a whole.
[0100] Furthermore, the data sorting method of the present invention can be applied to the sorting nodes of the column storage database. Due to the reduction in the number of comparisons, the number of execution times of extracting actual values from the memory is effectively reduced, especially the operation consumption of locating and copying actual data from the memory for complex sorting keys is reduced, thereby improving the overall sorting execution efficiency of the node.
[0101] This embodiment also provides a machine-readable storage medium and a computer device. Fig.15 is a schematic diagram of the structure of a machine-readable storage medium 10 according to an embodiment of the present invention, Fig.16 is a schematic diagram of the structure of a computer device 20 according to an embodiment of the present invention.
[0102] The machine-readable storage medium 10 stores a machine-executable program 11 , and when the machine-executable program 11 is executed by a processor, the data sorting method of any of the above embodiments can be implemented.
[0103] The computer device 20 may include a memory 220, a processor 210, and a machine executable program 11 stored in the memory 220 and running on the processor 210, and the processor 210 implements the data sorting method of any of the above embodiments when executing the machine executable program 11.
[0104] It should be noted that the logic and / or steps represented in the flowchart or described in other ways herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be specifically implemented in any machine-readable storage medium for use by an instruction execution system, device or equipment (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or equipment and execute instructions), or used in combination with these instruction execution systems, devices or equipment.
[0105] For the purpose of the description of this embodiment, the machine-readable storage medium 10 can be any device that can contain, store, communicate, propagate or transmit a program for use with an instruction execution system, device or equipment or in conjunction with these instruction execution systems, devices or equipment. More specific examples (a non-exhaustive list) of the machine-readable storage medium 10 include the following: an electrical connection portion (electronic device) with one or more wirings, a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and editable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the machine-readable storage medium 10 can even be paper or other suitable media on which the program can be printed, because the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting or processing in other suitable ways as necessary, and then stored in a computer memory.
[0106] It should be understood that each part of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system.
[0107] The computer device 20 may be, for example, a server, a desktop computer, a notebook computer, a tablet computer, or a smart phone. In some examples, the computer device 20 may be a cloud computing node. The computer device 20 may be described in the general context of computer system executable instructions (such as program modules) executed by a computer system. Typically, a program module may include routines, programs, object programs, components, logic, data structures, etc. that perform specific tasks or implement specific abstract data types. The computer device 20 may be implemented in a distributed cloud computing environment where remote processing devices linked through a communication network perform tasks. In a distributed cloud computing environment, program modules may be located on a local or remote computing system storage medium including a storage device.
[0108] The computer device 20 may include a processor 210 adapted to execute stored instructions, and a memory 220 providing temporary storage space for the operation of the instructions during operation. The processor 210 may be a single-core processor, a multi-core processor, a computing cluster, or any number of other configurations. The memory 220 may include a random access memory (RAM), a read-only memory, a flash memory, or any other suitable storage system.
[0109] The flow chart provided by the present embodiment is not intended to indicate that the operation of the method will be performed in any particular order, or that all operations of the method are included in all every case. In addition, the method may include additional operations. Within the scope of the technical thinking provided by the present embodiment method, additional changes may be made to the above method.
[0110] At this point, those skilled in the art should recognize that, although multiple exemplary embodiments of the present invention have been shown and described in detail herein, many other variations or modifications that conform to the principles of the present invention can still be directly determined or derived based on the content disclosed in the present invention without departing from the spirit and scope of the present invention. Therefore, the scope of the present invention should be understood and recognized as covering all these other variations or modifications.
Claims
1. A data sorting method, comprising: Obtaining elements to be sorted and a pre-constructed data structure, wherein the data structure includes a heap structure and a linked list using heap nodes in the heap structure as linked list nodes; Based on the first sorting key of the element to be sorted, determining whether the element to be sorted meets the condition of being added to the linked list; If so, the element to be sorted is added to the linked list.
2. The data sorting method according to claim 1, wherein: Different heap nodes in the heap structure are used to store elements with different first sorting keys, and different linked list nodes in each linked list are used to store elements with the same first sorting key; and The step of judging whether the element to be sorted satisfies the condition of being added to the linked list based on the first sort key of the element to be sorted comprises: Determine whether the first sort key of the element to be sorted is the same as the first sort key of the element stored in any of the heap nodes in the heap structure; If they are the same, confirm that the element to be sorted meets the conditions for being added to the linked list; If they are not the same, it is confirmed that the element to be sorted does not meet the condition for being added to the linked list.
3. The data sorting method according to claim 2, wherein: Each node in the data structure is used to store an element; and After the step of adding the elements to be sorted into the linked list, the data sorting method further includes: The number of elements stored in the nodes other than the top linked list in the data structure is used as the number of non-top elements, wherein the top linked list is a linked list with the top node of the heap structure as a linked list node; Determine whether the number of non-top elements has reached a set boundary value, wherein the boundary value is a target number of target elements to be obtained from the data set to be processed; If so, all elements of the top linked list are released.
4. The data sorting method according to claim 3, wherein: The step of obtaining the elements to be sorted comprises: Determine whether there is an element to be processed, wherein the element to be processed is an element in the data set to be processed that has not been added to the data structure and has not been released; If it exists, obtain the element to be processed; Determining whether the number of elements stored in the data structure reaches the boundary value; If not reached, the acquired elements to be processed are used as the elements to be sorted; If so, judging whether the element to be processed satisfies the condition of being added to the data structure based on the first sort key of the element to be processed; If so, the obtained elements to be processed are used as the elements to be sorted.
5. The data sorting method according to claim 4, wherein: After the step of determining whether there are elements to be processed, the data sorting method further includes: In the absence of the element to be processed, the elements stored in the data structure are sorted based on the non-first sorting keys of the elements stored in the data structure until the number of elements stored in the data structure is the same as the boundary value, so as to obtain all the target elements.
6. The data sorting method according to claim 4, wherein: The step of judging whether the element to be processed satisfies the condition of being added to the data structure based on the first sort key of the element to be processed comprises: In the case where the type of the heap structure is a mini-heap, determining whether the first sort key of the element to be processed is not less than the first sort key of the element stored in the heap top node; if so, confirming that the element to be processed meets the conditions for being added to the data structure; if so, confirming that the element to be processed does not meet the conditions for being added to the data structure; or In the case where the type of the heap structure is a max-heap, determine whether the first sort key of the element to be processed is not greater than the first sort key of the element stored in the top node of the heap. If not, confirm that the element to be processed meets the conditions for adding to the data structure. If greater, confirm that the element to be processed does not meet the conditions for adding to the data structure.
7. The data sorting method according to claim 4, wherein: After the step of judging whether the element to be processed satisfies the condition of being added to the data structure based on the first sorting key of the element to be processed, the data sorting method further comprises: When the element to be processed does not satisfy the condition for being added to the data structure, the element to be processed is released.
8. The data sorting method according to claim 2, wherein: The data structure is constructed by the following steps: An index array structure is constructed based on the first sorting key of all the elements to be processed in the data set to be processed, wherein the index array structure includes a plurality of arrays, the plurality of arrays correspond one-to-one to all the elements to be processed, and each of the arrays includes the first sorting key, row index and next hop index of the element to be processed corresponding thereto, the row index is used to indicate the memory position of the element to be processed, and the next hop index is used to point to the position of another element to be processed whose first sorting key is the same as the first sorting key of the element to be processed in the index array structure, so as to simulate the linked list; A head pointer and a tail pointer are set to point to the multiple arrays in the index array structure respectively, the head pointer is used to indicate that the to-be-processed element corresponding to the array pointed to is the top of the heap structure, and the tail pointer is used to indicate that the array pointed to is the tail of the heap structure, so as to simulate the heap structure.
9. A machine-readable storage medium having a machine executable program stored thereon, wherein the machine executable program, when executed by a processor, implements the data sorting method according to any one of claims 1 to 8.
10. A computer device comprising a memory, a processor, and a machine executable program stored in the memory and running on the processor, wherein the processor implements the data sorting method according to any one of claims 1 to 8 when executing the machine executable program.
Citation Information
Patent Citations
Information screening method and device and computer equipment
CN111737263A
Data structure construction method and device, equipment and storage medium
CN117632950A
Stacking system and method based on FPGA (Field Programmable Gate Array)
CN118642680A
Sorted linked list with a midpoint binary tree
US20180095719A1
Cited By
Data sorting method and device, terminal and storage medium
CN120470046A
A data sorting method and device, a terminal and a storage medium
CN120470046B