Query statement processing method, device, equipment and medium

By generating a sequence of computing units sorted by computing priority and executing the computing units in sequence order, the problem of low computing speed caused by recursive calls of SQL query statements is solved and the efficiency of data query is improved.

CN113157720BActive Publication Date: 2024-09-20ALIBABA GROUP HOLDING LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010076254.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-01-23
Publication Date
2024-09-20
Estimated Expiration
2040-01-23

AI Technical Summary

Technical Problem

In the existing technology, the recursive calling method of SQL query statements reduces the operation processing speed of expressions, thereby reducing the efficiency of data query.

Method used

By generating a sequence of computing units from high to low according to the operation priority, and executing the operation processing of each computing unit in sequence order, the computing units in the expression are called in a non-recursive manner to improve the calling speed and operation of the computing units. efficiency.

Benefits of technology

The operation processing speed and data query efficiency of query statements are improved. Compared with the recursive calling method, the calling speed and operation efficiency of the calculation unit in the expression are significantly improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113157720B
    Figure CN113157720B
Patent Text Reader

Abstract

The present invention discloses a method, device, equipment and medium for processing query statements. The method for processing query statements includes: obtaining a first calculation expression in the query statement; wherein the first calculation expression includes multiple first calculation units; generating a first calculation unit sequence corresponding to the multiple first calculation units according to the order of operation priority from high to low; performing the operation processing corresponding to the first calculation unit on the input data of each first calculation unit according to the sequence order of the first calculation unit sequence, and obtaining the operation processing result corresponding to the query statement. According to an embodiment of the present invention, the operation processing speed corresponding to the query statement can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of computer technology, and in particular relates to a query statement processing method, device, equipment and medium. Background Art

[0002] When a user uses a Structured Query Language (SQL) query statement to query data, when the server receives the SQL query statement, it first parses the expression in the SQL query statement into an expression tree, and then recursively calls and executes the calculation units corresponding to each node in the expression tree to obtain the operation processing result of the SQL query statement.

[0003] However, in the process of recursively calling each calculation unit in the expression, the operation processing speed of the expression will be reduced, thereby reducing the operation processing speed corresponding to the SQL query statement, and further reducing the data query efficiency. Summary of the invention

[0004] The embodiments of the present invention provide a query statement processing method, device, equipment and medium, which can improve the operation processing speed corresponding to the query statement.

[0005] In a first aspect, an embodiment of the present invention provides a method for processing a query statement, comprising:

[0006] Obtaining a first calculation expression in the query statement; wherein the first calculation expression includes a plurality of first calculation units;

[0007] Generate a first computing unit sequence corresponding to the plurality of first computing units according to the order of operation priority from high to low;

[0008] According to the sequence order of the first computing unit sequence, the operation processing corresponding to the first computing unit is performed on the input data of each first computing unit to obtain the operation processing result corresponding to the query statement.

[0009] In a second aspect, an embodiment of the present invention provides a query statement processing device, including:

[0010] A first expression acquisition module, used to acquire a first calculation expression in a query statement; wherein the first calculation expression includes a plurality of first calculation units;

[0011] A first sequence generating module, used for generating a first computing unit sequence corresponding to a plurality of first computing units according to the order of operation priority from high to low;

[0012] The operation processing module is used to perform the operation processing corresponding to each first calculation unit on the input data of each first calculation unit according to the sequence order of the first calculation unit sequence, so as to obtain the operation processing result corresponding to the query statement.

[0013] In a third aspect, an embodiment of the present invention provides a query statement processing device, the device comprising: a processor and a memory storing computer program instructions;

[0014] When the processor executes the computer program instructions, the query statement processing method as described in the first aspect is implemented.

[0015] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium having computer program instructions stored thereon. When the computer program instructions are executed by a processor, the method for processing query statements as described in the first aspect is implemented.

[0016] The query statement processing method, device, equipment and medium of the embodiment of the present invention can, after obtaining the first calculation expression in the query statement, generate a first calculation unit sequence according to the order of the operation priority of multiple first calculation units in the first calculation expression from high to low, and perform the operation processing corresponding to the first calculation unit on the input data of each first calculation unit according to the sequence order of the first calculation unit sequence to obtain the operation processing result corresponding to the query statement, thereby realizing the sequential calling of each first calculation unit in the first expression in a non-recursive manner. Compared with the method of recursively calling the calculation unit in the expression, the calling speed and operation efficiency of the calculation unit in the expression can be improved, thereby improving the operation processing speed of the query statement, and then improving the data query efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solution of the embodiment of the present invention, the following is a brief introduction to the drawings required for use in the embodiment of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0018] Figure 1 It is a flowchart of a method for processing a query statement provided by an embodiment of the present invention;

[0019] Figure 2 is a schematic diagram of an abstract structure of an expression tree provided by an embodiment of the present invention;

[0020] Figure 3 is a structural diagram of a specific example of an expression tree provided by an embodiment of the present invention;

[0021] Figure 4 yes Figure 2Schematic diagram of the traversal process of the expression tree shown;

[0022] Figure 5 yes Figure 3 Schematic diagram of the traversal result of the expression tree shown;

[0023] Figure 6 is a schematic diagram of the structure of a data slot provided by an embodiment of the present invention;

[0024] Figure 7 is a flowchart of a calculation process provided by an embodiment of the present invention;

[0025] Figure 8 is a schematic diagram of the working principle of a control data slot provided by an embodiment of the present invention;

[0026] Fig. 9 It is a schematic diagram of a multi-threaded computing process provided by an embodiment of the present invention;

[0027] Fig.10 It is a structural diagram of a query statement processing device provided by an embodiment of the present invention;

[0028] Fig.11 It is a schematic diagram of the hardware structure of a query statement processing device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0029] The features and exemplary embodiments of various aspects of the present invention will be described in detail below. In order to make the purpose, technical solutions and advantages of the present invention clearer, the present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only configured to explain the present invention and are not configured to limit the present invention. For those skilled in the art, the present invention can be implemented without the need for some of these specific details. The following description of the embodiments is only to provide a better understanding of the present invention by illustrating examples of the present invention.

[0030] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "include..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0031] When a user uses an SQL query statement to query data, after receiving the SQL query statement, the server will first parse the expression in the SQL query statement into an expression tree, and then recursively call and execute the calculation unit corresponding to each node in the expression tree, so as to obtain the operation and processing result of the SQL query statement. Specifically, the calculation unit corresponding to the root node of the expression tree is first called, and the calculation unit corresponding to the root node will call the calculation unit corresponding to its own child node, and such calls will continue to recursively go down until the calculation unit corresponding to the leaf node returns, and the calculation unit corresponding to the leaf node and the calculation units of each child node are completed. The calculation unit corresponding to the root node obtains the required data and completes the calculation to obtain the final expression operation result.

[0032] However, in the process of recursively calling each calculation unit in the expression, the operation processing speed of the expression will be reduced, thereby reducing the operation processing speed corresponding to the SQL query statement, and further reducing the data query efficiency.

[0033] In order to solve the problems in the prior art, an embodiment of the present invention provides a method, device, equipment and medium for processing a query statement. The following first introduces the method for processing a query statement provided by an embodiment of the present invention.

[0034] Figure 1 A schematic flow chart of a method for processing a query statement provided by an embodiment of the present invention is shown. Figure 1 The method shown can be performed by a server that performs data query, wherein the server can be a high-performance electronic calculator for storing and processing data.

[0035] like Figure 1 As shown, the query statement processing method may include:

[0036] S110, obtaining a first calculation expression in a query statement; wherein the first calculation expression includes a plurality of first calculation units;

[0037] S120, generating a first computing unit sequence corresponding to the plurality of first computing units according to the order of computing priority from high to low;

[0038] S130. Perform a calculation process corresponding to each first calculation unit on the input data of each first calculation unit according to the sequence order of the first calculation unit sequence, and obtain a calculation process result corresponding to the query statement.

[0039] In an embodiment of the present invention, after obtaining the first calculation expression in the query statement, a first calculation unit sequence can be generated according to the order of the operation priorities of multiple first calculation units in the first calculation expression from high to low, and the operation processing corresponding to each first calculation unit is performed on the input data of each first calculation unit according to the sequence order of the first calculation unit sequence to obtain the operation processing result corresponding to the query statement, thereby realizing the sequential calling of each first calculation unit in the first expression in a non-recursive manner. Compared with the method of recursively calling the calculation unit in the expression, the calling speed and operation efficiency of the calculation unit in the expression can be improved, thereby improving the operation processing speed of the query statement, and then improving the data query efficiency.

[0040] In some embodiments of the present invention, the server executing the data query may be a server of a database provider. After receiving the query statement sent by the data query device, the server may process the received query statement according to the query statement processing method provided in the embodiment of the present invention.

[0041] The data query device may specifically be a mobile phone, a tablet computer, a personal computer, etc.

[0042] In some embodiments of the present invention, the query statement may include an SQL query statement, an Object Query Language (OQL) query statement, etc. The type of the query statement is not limited to the above examples, and may also be other types of query statements, which will not be described in detail here.

[0043] In S110 of some embodiments of the present invention, the query statement may be parsed to obtain a first calculation expression, wherein the first calculation expression may be a separate calculation expression in the query statement that is not restricted by any conditions.

[0044] In order to simplify the calculation expression, the first calculation expression can be abstracted into multiple first calculation units, that is, in the embodiment of the present invention, the first calculation expression includes multiple first calculation units. Each complete first calculation unit includes three parts: input, operation function and output. Specifically, the calculation process of the first calculation unit is to perform operation processing corresponding to the operation function on the input to obtain the output.

[0045] In some embodiments of the present invention, the specific method of S120 may include:

[0046] Parse the first calculation expression into a first expression tree; wherein each node of the first expression tree corresponds to a first calculation unit, the root node of the first expression tree is the first calculation unit with the lowest operation priority, and the leaf node of the first expression tree is the first calculation unit with the highest operation priority;

[0047] In a post-order depth-first order, the first calculation unit corresponding to each node of the first expression tree is traversed from the root node to the leaf node to generate a first calculation unit sequence.

[0048] In these embodiments, the first calculation unit with the lowest operation priority can be used as the root node of the first expression tree, the first calculation unit with a higher operation priority than the first calculation unit corresponding to the root node and having a direct operation relationship with the root node can be used as the first calculation unit corresponding to the first-level child node of the root node, and so on, and the first calculation unit with the highest operation priority can be used as the leaf node of the first expression tree.

[0049] It can be seen that each node in the first expression tree has 0 or at least one child node, and the calculation of the first calculation unit corresponding to each node can be executed only when the calculation of all the child nodes of the node is completed.

[0050] Figure 2 FIG. 1 shows an abstract structure diagram of an expression tree provided by an embodiment of the present invention. Figure 2 As shown, in the expression tree, the operation priority increases from the root node to the leaf node. Among them, the root node in the expression tree corresponds to calculation unit 1, and there are two first-level child nodes of the root node, corresponding to calculation unit 2 and calculation unit 3 respectively. The output of calculation unit 2 and calculation unit 3 is the input of calculation unit 1, that is, calculation unit 2 and calculation unit 3 have a direct operation relationship with calculation unit 1. There are two leaf nodes of the second-level child node corresponding to calculation unit 2, corresponding to calculation unit 4 and calculation unit 5 respectively, and the output of calculation unit 4 and calculation unit 5 is the input of calculation unit 2, that is, calculation unit 4 and calculation unit 5 have a direct operation relationship with calculation unit 2, and calculation unit 4 and calculation unit 5 have an indirect operation relationship with calculation unit 1. There are two leaf nodes of the second-level child node corresponding to calculation unit 3, corresponding to calculation unit 6 and calculation unit 7 respectively, and the output of calculation unit 6 and calculation unit 7 is the input of calculation unit 3, that is, calculation unit 6 and calculation unit 7 have a direct operation relationship with calculation unit 3, and calculation unit 6 and calculation unit 7 have an indirect operation relationship with calculation unit 1.

[0051] Figure 3 FIG. 2 is a schematic diagram showing a specific example of an expression tree provided by an embodiment of the present invention. Figure 3As shown, taking the first expression tree corresponding to the first calculation unit (a + b) < d × 2 as an example, according to the operation priorities of each first calculation unit in the formula, it can be determined that: the root node of the first expression tree is the first calculation unit corresponding to "<", the first-level child nodes of the root node are respectively the first calculation units corresponding to "+" and "×", the second-level child nodes of the first-level child node "+" are respectively the first calculation units corresponding to "a" and "b", and the second-level child nodes of the first-level child node "×" are respectively the first calculation units corresponding to "d" and "2".

[0052] In these embodiments, the first calculation units corresponding to each node of the first expression tree can be traversed from the root node to the leaf nodes in the post-order depth-first order to generate a first calculation unit sequence, so as to convert the first calculation expression that needs to be recursively calculated into a non-recursively calculated first calculation unit sequence as the execution model for non-recursive calculation.

[0053] Figure 4 shows Figure 2 a schematic diagram of the traversal process of the shown expression tree. As Figure 4 shown, each node of the expression tree can be traversed in the order of sequential numbers 1 - 12, the operation priorities of the calculation units corresponding to each node are recorded, and after the traversal of the nodes of the expression tree is completed, the calculation units are pushed into the calculation unit queue in the order from high to low of the operation priorities to generate a calculation unit sequence.

[0054] If there are multiple calculation units with the same operation priority, these calculation units can be sorted in the order from the left node to the right node of the expression tree.

[0055] Figure 5 shows Figure 3 a schematic diagram of the traversal result of the shown expression tree. As Figure 5 shown, continuing to take the first expression tree corresponding to the first calculation unit (a + b) < d × 2 as an example, after traversing each first calculation unit in the first expression tree according to the Figure 4 shown traversal method, a first calculation unit sequence as shown in Figure 5 can be obtained.

[0056] Therefore, only by executing each first calculation unit from front to back in the sequence order of the first calculation unit sequence can the complete calculation process of the first expression be completed.

[0057] In some other embodiments of the present invention, the specific method of S120 may include:

[0058] Parse the first calculation expression into a first expression tree; wherein each node of the first expression tree corresponds to a first calculation unit, the root node of the first expression tree is the first calculation unit with the lowest operation priority, and the leaf node of the first expression tree is the first calculation unit with the highest operation priority;

[0059] The first calculation unit corresponding to each node of the first expression tree is recursively called from the root node to the leaf nodes to generate a first calculation unit sequence.

[0060] The method of parsing the first calculation expression into the first expression tree is the same as the method in the above embodiment, which will not be described in detail here.

[0061] After recursively calling the first calculation unit corresponding to each node of the first expression tree from the root node to the leaf node, when the calculation unit corresponding to the leaf node of the first expression tree returns, starting from the calculation unit corresponding to the leaf node, the calculation unit corresponding to each upper node of the leaf node can be pushed into the calculation unit queue in turn to generate a first calculation unit sequence.

[0062] In each first computing unit, the input and output of the first computing unit are abstracted into unified data objects, and the computing function of the first computing unit is abstracted into a computing function, so that the first computing unit can be separated into input data, output data and computing functions, and the input data, output data and computing functions are modularly managed to reduce the space occupied by the query and further improve the computing efficiency of the computing expression. Specifically, the computing function can be stored in the corresponding first computing unit in the first computing unit sequence.

[0063] Figure 6 FIG. 1 shows a schematic diagram of the structure of a data slot provided by an embodiment of the present invention. Figure 6 As shown, the data slot is used to store the input data and output data after the first computing unit abstracts. The data slot includes a control data slot and a computing data slot, that is, the control data slot and the computing data slot are respectively located in the data slot. Specifically, Figure 6 The data slot No. 0 shown is a control data slot, and the other data slots are computing data slots. The computing data slots are used to store input data and output data, and the control data slots are used to store computing unit identifiers, and the computing unit identifiers are used to indicate the first computing unit currently being executed.

[0064] Therefore, in some embodiments of the present invention, after S120, the query statement processing method may further include:

[0065] A corresponding input data slot and an output data slot are allocated to each first computing unit in the computing data slot.

[0066] In some other embodiments of the present invention, in the process of generating the first computing unit sequence corresponding to the plurality of first computing units in S120, the query statement processing method may further include:

[0067] A corresponding input data slot and an output data slot are allocated to each first computing unit in the computing data slot.

[0068] In summary, in the embodiment of the present invention, there is no restriction on the time for allocating the corresponding input data slot and output data slot to each first computing unit.

[0069] Since each computing data slot has a data slot number corresponding to it, in the process of allocating the corresponding input data slot and output data slot to the first computing unit, it is only necessary to allocate the data slot number as its input data slot and output data slot to the first computing unit, and the allocated data slot number will be stored in the first computing unit. In this way, the first computing unit can take out input data from the corresponding input data slot according to the data slot number, and output output data to the corresponding output data slot.

[0070] Furthermore, the input data slot of the first computing unit with the highest computing priority is the new computing data slot allocated to it, and the input data slot of the first computing unit with a lower computing priority is determined from the already allocated computing data slots, specifically, the input data slot is the output data slot of the first computing unit that has a direct computing relationship with it and is in a sequence position before it. In this way, the space occupied by the query can be further reduced.

[0071] In S130 of these embodiments, optionally, a specific method of performing the operation processing corresponding to each first computing unit on the input data of the first computing unit may include:

[0072] Obtaining input data of each first computing unit from an input data slot corresponding to the first computing unit;

[0073] Performing a calculation process corresponding to each first calculation unit on the input data of each first calculation unit to obtain output data of each first calculation unit;

[0074] The output data of each first computing unit is stored in the output data slot corresponding to the first computing unit.

[0075] Specifically, each first computing unit can take out input data from the computing data slot according to the data slot number of its input data slot, and then perform the operation processing corresponding to its computing function on the taken out input data, and store the output data of the computing function into the computing data slot according to the data slot number of its output data slot, so as to facilitate other first computing units to continue to perform operation processing based on their output data.

[0076] Figure 7 FIG. 1 is a flow chart showing a calculation process according to an embodiment of the present invention. Figure 7 As shown, each computing unit in the computing unit sequence is executed in sequence from left to right in the sequence position, and each computing unit takes out input data from the corresponding input data slot and stores the output data in the output data slot. Taking computing unit 2 as an example, the data slots of the input data slots of computing unit 2 are numbered 2 and 4 respectively, and the data slot number of the output data slot is 5. Computing unit 2 can take out input data from data slots 2 and 4, and store the output data in data slot 5.

[0077] Figure 8 FIG. 2 shows a schematic diagram of the working principle of a control data slot provided by an embodiment of the present invention. Figure 8 As shown, each computing unit in the computing unit sequence is executed in sequence from left to right. The currently executed computing unit is computing unit 2. The sequence position of computing unit 2 is the third bit, and its corresponding computing unit identifier is 3. At this time, the computing unit identifier stored in the control data slot, that is, data slot No. 0, is 3.

[0078] In some embodiments of the present invention, there are multiple computing data slots, and the multiple computing data slots are all located in one data slot, so that the data slot is divided into multiple groups, and the multiple groups of data slots include one computing data slot.

[0079] In these embodiments, a specific method of allocating a corresponding input data slot and an output data slot to each first computing unit in a computing data slot may include:

[0080] For each computing data slot, a corresponding input data slot and an output data slot are allocated to each first computing unit in the computing data slot.

[0081] In other embodiments of the present invention, there are multiple calculation data slots, and each calculation data slot is located in a data slot, that is, there are multiple data slots, and each data slot includes a control data difference and a calculation data slot.

[0082] In these embodiments, a specific method of allocating a corresponding input data slot and an output data slot to each first computing unit in a computing data slot may include:

[0083] For each computing data slot, a corresponding input data slot and an output data slot are allocated to each first computing unit in the computing data slot.

[0084] Specifically, when there are multiple data slots, corresponding input data slots and output data slots can be allocated to the first computing unit in each data slot, so that each data slot corresponds to an execution thread, thereby realizing multi-threaded operation processing of the first computing expression.

[0085] In these embodiments, optionally, for each first computing unit, a specific method of performing the operation processing corresponding to the first computing unit on the input data of each first computing unit may include:

[0086] Synchronously acquiring a plurality of input data of each first computing unit from a plurality of input data slots corresponding to the first computing unit;

[0087] Synchronously performing arithmetic processing corresponding to each first computing unit on multiple input data of each first computing unit to obtain multiple output data of each first computing unit;

[0088] The multiple output data of each first computing unit are synchronously stored in the multiple output data slots corresponding to the first computing unit.

[0089] In these embodiments, the first computing unit sequence can be replicated into multiple copies, and the multiple first computing units can synchronously use their corresponding data slots to implement multi-threaded synchronous operation and processing of the first computing expression, further improving execution efficiency.

[0090] In these embodiments, optionally, for each first computing unit, the specific method of performing the operation processing corresponding to the first computing unit on the input data of each first computing unit may also include:

[0091] Obtaining multiple input data of each first computing unit from multiple input data slots corresponding to the first computing unit in sequence;

[0092] Performing calculation processing corresponding to each first calculation unit on multiple input data of each first calculation unit in sequence to obtain multiple output data of each first calculation unit;

[0093] The multiple output data of each first computing unit are sequentially stored in the multiple output data slots corresponding to the first computing unit.

[0094] Fig. 9 FIG. 2 is a schematic diagram showing a multi-threaded computing process flow diagram provided by an embodiment of the present invention. Fig. 9As shown, when computing unit 4 takes out input data from data slot No. 1 of data slot 2, computing unit 5 takes out data from data slot No. 3 of data slot 1. After the two computing units take out the data, they perform calculations on the taken-out input data. Then, computing unit 4 stores the output data into data slot No. 2 of data slot 2, and computing unit 5 stores the output data into data slot No. 4 of data slot 1. Data slot 1 records the identifier 2 of the currently executed computing unit, and data slot 2 records the identifier 1 of the currently executed computing unit.

[0095] Therefore, in these embodiments, each first calculation unit and data slot will not interfere with each other, and each thread is independent of each other, which can reduce the calculation error rate during the multi-threaded execution of the first calculation expression.

[0096] Since in the query statement, there may be calculation expressions that are subject to conditions and do not exist independently, for example, a calculation expression in a jump statement, the jump statement also includes a conditional expression. If the preset conditions corresponding to the conditional expression are met, the jump is made to the calculation expression in the jump statement for operation processing.

[0097] Therefore, in some embodiments of the present invention, before S130, the following steps are further included:

[0098] Obtaining a second calculation expression in the query statement, the second calculation expression is located in a target statement of the query statement, wherein the target statement also includes a conditional expression, and the second calculation expression includes a plurality of second calculation units;

[0099] Generate a second computing unit sequence corresponding to the plurality of second computing units according to the order of operation priority from high to low;

[0100] The conditional calculation unit corresponding to the conditional expression is inserted into the first target position in the second calculation unit sequence to obtain an updated second calculation unit sequence; wherein the first target position is the first sequence position of the second calculation unit sequence.

[0101] In these embodiments, it is also necessary to obtain the second calculation expression in the target statement, wherein the target statement can be the jump statement mentioned above, or it can be other statements with conditional expressions, and the conditional expression is used to implement the jump from the first calculation expression to the second calculation expression.

[0102] It should be noted that the method for generating the second computing unit sequence is based on the same principle as the method for generating the first computing unit sequence, and will not be described in detail here.

[0103] Since the conditional expression is the condition for jumping to the second calculation expression, in order to perform calculation processing according to the second calculation unit sequence after the preset condition corresponding to the conditional expression is met, the conditional calculation unit corresponding to the conditional expression needs to be inserted into the first sequence position in the second calculation unit sequence to realize the jump function of the conditional calculation unit.

[0104] Since the conditional calculation unit jumps to the second calculation unit sequence after the operation processing result of a certain first calculation unit meets the preset condition corresponding to the conditional expression, the conditional calculation unit only includes input, conditional function and jump, but does not include output. If the operation processing result of a certain first calculation unit does not meet the preset condition corresponding to the conditional expression, the first calculation unit sequence continues to be executed. Therefore, the jump function can be realized by the conditional calculation unit.

[0105] In other embodiments of the present invention, after generating a second computing unit sequence corresponding to multiple second computing units in order of operation priority from high to low, the second computing unit sequence can also be spliced ​​after the first computing unit sequence, and the computing unit identifier of the second computing unit to be jumped to is stored in the conditional computing unit.

[0106] In some embodiments of the present invention, after inserting the conditional calculation unit corresponding to the conditional expression into the first target position in the second calculation unit sequence to obtain the updated second calculation unit sequence, the method may further include:

[0107] Insert the conditional computing unit into the second target position in the first computing unit sequence to obtain an updated first computing unit sequence; wherein the second target position is a sequence position adjacent to the target first computing unit in the first computing unit sequence, and the output data of the target first computing unit is the input data of the conditional computing unit.

[0108] Specifically, since during the process of executing the operation processing of the first calculation unit sequence, when the operation processing result of a first calculation unit meets the preset condition corresponding to the conditional expression, it should jump to the second calculation unit sequence to continue the operation processing, therefore, the conditional calculation unit corresponding to the conditional expression should also be inserted into the first calculation unit sequence. In order to reduce the data processing amount and improve the data processing efficiency, the conditional calculation unit can be directly inserted into the sequence position adjacent to the target first calculation unit of the input data of the output conditional calculation unit.

[0109] In these embodiments, optionally, the specific method of S130 may include:

[0110] According to the sequence order of the updated first computing unit sequence, the operation processing corresponding to the first computing unit is performed on the input data of each first computing unit whose sequence position is before the conditional computing unit to obtain the input data of the conditional computing unit;

[0111] Performing conditional operation processing corresponding to the conditional calculation unit on the input data of the conditional calculation unit to obtain the conditional operation result of the conditional calculation unit;

[0112] When the conditional operation result does not meet the preset condition, continue to perform the operation processing corresponding to the first calculation unit on the input data of each first calculation unit whose sequence position is after the conditional calculation unit in the sequence order to obtain the operation processing result corresponding to the first calculation unit.

[0113] Optionally, after obtaining the conditional operation result of the conditional calculation unit, the specific method of S130 may further include:

[0114] When the conditional operation result meets the preset condition, the operation processing corresponding to the second calculation unit is performed on the input data of each second calculation unit whose sequence position is after the conditional calculation unit in accordance with the sequence order of the updated second calculation unit sequence to obtain the operation processing result corresponding to the second calculation unit.

[0115] It should be noted that the method for executing the calculation processing corresponding to each second calculation unit is similar in principle to the method for executing the calculation processing corresponding to each first calculation unit, and will not be elaborated here.

[0116] Fig.10 A schematic diagram showing the structure of a query statement processing device provided by an embodiment of the present invention is shown. Fig.10 The device shown can be arranged in a server for data query, wherein the server can be a high-performance electronic calculator for storing and processing data.

[0117] like Fig.10 As shown, the query statement processing device may include:

[0118] A first expression acquisition module 210 is used to acquire a first calculation expression in a query statement; wherein the first calculation expression includes a plurality of first calculation units;

[0119] A first sequence generating module 220, configured to generate a first computing unit sequence corresponding to a plurality of first computing units according to the order of computing priority from high to low;

[0120] The operation processing module 230 is used to perform the operation processing corresponding to each first calculation unit on the input data of each first calculation unit according to the sequence order of the first calculation unit sequence, so as to obtain the operation processing result corresponding to the query statement.

[0121] In an embodiment of the present invention, after obtaining the first calculation expression in the query statement, a first calculation unit sequence can be generated according to the order of the operation priorities of multiple first calculation units in the first calculation expression from high to low, and the operation processing corresponding to each first calculation unit is performed on the input data of each first calculation unit according to the sequence order of the first calculation unit sequence to obtain the operation processing result corresponding to the query statement, thereby realizing the sequential calling of each first calculation unit in the first expression in a non-recursive manner. Compared with the method of recursively calling the calculation unit in the expression, the calling speed and operation efficiency of the calculation unit in the expression can be improved, thereby improving the operation processing speed of the query statement, and then improving the data query efficiency.

[0122] In some embodiments of the present invention, the server executing the data query may be a server of a database provider. When the query statement processing device receives the query statement sent by the data query device, it may process the received query statement. Specifically, the data query device may be a mobile phone, a tablet computer, a personal computer, etc.

[0123] In some embodiments of the present invention, the first sequence generating module 220 is specifically used to:

[0124] Parse the first calculation expression into a first expression tree; wherein each node of the first expression tree corresponds to a first calculation unit, the root node of the first expression tree is the first calculation unit with the lowest operation priority, and the leaf node of the first expression tree is the first calculation unit with the highest operation priority;

[0125] In a post-order depth-first order, the first calculation unit corresponding to each node of the first expression tree is traversed from the root node to the leaf node to generate a first calculation unit sequence.

[0126] In some embodiments of the present invention, the query statement processing device may further include:

[0127] The data slot allocation module is used to allocate a corresponding input data slot and an output data slot to each first computing unit in the computing data slot.

[0128] In these embodiments, optionally, when the operation processing module 230 performs the operation processing corresponding to each first computing unit on the input data of the first computing unit, it is specifically used to:

[0129] Obtaining input data of each first computing unit from an input data slot corresponding to the first computing unit;

[0130] Performing a calculation process corresponding to each first calculation unit on the input data of each first calculation unit to obtain output data of each first calculation unit;

[0131] The output data of each first computing unit is stored in the output data slot corresponding to the first computing unit.

[0132] In some embodiments of the present invention, the number of the calculation data slots is multiple.

[0133] In these embodiments, the data slot allocation module is specifically used to:

[0134] For each computing data slot, a corresponding input data slot and an output data slot are allocated to each first computing unit in the computing data slot.

[0135] In these embodiments, optionally, when the operation processing module 230 performs the operation processing corresponding to each first computing unit on the input data of each first computing unit, it is specifically used to:

[0136] Synchronously acquiring a plurality of input data of each first computing unit from a plurality of input data slots corresponding to the first computing unit;

[0137] Synchronously performing arithmetic processing corresponding to each first computing unit on multiple input data of each first computing unit to obtain multiple output data of each first computing unit;

[0138] The multiple output data of each first computing unit are synchronously stored in the multiple output data slots corresponding to the first computing unit.

[0139] In some embodiments of the present invention, the computing data slot is located in the data slot, and the data slot also includes a control data slot, and the control data slot is used to store a computing unit identifier, and the computing unit identifier is used to indicate the first computing unit currently being executed.

[0140] In some embodiments of the present invention, the query statement processing device may further include:

[0141] A second expression acquisition module, used to acquire a second calculation expression in the query statement, the second calculation expression is located in a target statement of the query statement, wherein the target statement also includes a conditional expression, and the second calculation expression includes a plurality of second calculation units;

[0142] A second sequence generation module, used to generate a second computing unit sequence corresponding to a plurality of second computing units according to the order of operation priority from high to low;

[0143] The second sequence updating module is used to insert the conditional calculation unit corresponding to the conditional expression into the first target position in the second calculation unit sequence to obtain an updated second calculation unit sequence; wherein the first target position is the first sequence position of the second calculation unit sequence.

[0144] In these embodiments, optionally, the query statement processing device may further include:

[0145] The first sequence updating module is used to insert the conditional computing unit into the second target position in the first computing unit sequence to obtain an updated first computing unit sequence; wherein the second target position is a sequence position adjacent to the target first computing unit in the first computing unit sequence, and the output data of the target first computing unit is the input data of the conditional computing unit.

[0146] In some embodiments of the present invention, the operation processing module 230 is specifically used for:

[0147] According to the sequence order of the updated first computing unit sequence, the operation processing corresponding to the first computing unit is performed on the input data of each first computing unit whose sequence position is before the conditional computing unit to obtain the input data of the conditional computing unit;

[0148] Performing conditional operation processing corresponding to the conditional calculation unit on the input data of the conditional calculation unit to obtain the conditional operation result of the conditional calculation unit;

[0149] When the conditional operation result does not meet the preset condition, continue to perform the operation processing corresponding to the first calculation unit on the input data of each first calculation unit whose sequence position is after the conditional calculation unit in the sequence order to obtain the operation processing result corresponding to the first calculation unit.

[0150] In these embodiments, optionally, the operation processing module 230 is further specifically configured to:

[0151] When the conditional operation result meets the preset condition, the operation processing corresponding to the second calculation unit is performed on the input data of each second calculation unit whose sequence position is after the conditional calculation unit in accordance with the sequence order of the updated second calculation unit sequence to obtain the operation processing result corresponding to the second calculation unit.

[0152] It should be noted that the query statement processing device provided in the embodiment of the present invention can achieve Figures 1 to 9 The various processes and effects in the method embodiment shown have similar principles and will not be described again here to avoid repetition.

[0153] Fig.11FIG. 1 is a schematic diagram showing the hardware structure of a query statement processing device provided in an embodiment of the present invention. The query statement processing device described in the embodiment of this specification may be a server. Fig.11 As shown, the query statement processing device 300 includes an input device 301, an input interface 302, a processor 303, a memory 304, an output interface 305, and an output device 306. The input interface 302, the processor 303, the memory 304, and the output interface 305 are connected to each other through a bus 310, and the input device 301 and the output device 306 are connected to the bus 310 through the input interface 302 and the output interface 305, respectively, and then connected to other components of the query statement processing device 300.

[0154] Specifically, the input device 301 receives input information from the outside and transmits the input information to the processor 303 through the input interface 302; the processor 303 processes the input information based on the computer executable instructions stored in the memory 304 to generate output information, temporarily or permanently stores the output information in the memory 304, and then transmits the output information to the output device 306 through the output interface 305; the output device 306 outputs the output information to the outside of the query statement processing device 300 for user use.

[0155] The processor 303 may include a central processing unit (CPU), a network processor (NPU), a tensor processing unit (TPU) tpu, a field programmable gate array (FpGA) chip or an artificial intelligence (AI) chip, etc. The figure is only for illustrative purposes and is not limited to the types of processors listed in the text. .

[0156] That is to say, Fig.11 The query statement processing device shown may also be implemented to include: a memory storing computer executable instructions; and a processor, which can implement the query statement processing method and apparatus described in the embodiments of this specification when executing the computer executable instructions.

[0157] The embodiments of the present specification also provide a computer-readable storage medium, on which computer program instructions are stored; when the computer program instructions are executed by a processor, the query statement processing method provided in the embodiments of the present specification is implemented.

[0158] The functional blocks shown in the above block diagram can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of this specification are programs or code segments that are used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link by a data signal carried in a carrier. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, etc. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.

[0159] It should also be noted that the above description is of a specific embodiment of the present specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in the order of different embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0160] The above is only a specific implementation method of this specification. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the system, module and unit described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. It should be understood that the protection scope of this specification is not limited to this. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in this specification, and these modifications or replacements should be covered within the protection scope of this specification.

Claims

1. A method for processing a query statement, comprising: Obtaining a first calculation expression in the query statement; wherein the first calculation expression includes a plurality of first calculation units; Generate a first computing unit sequence corresponding to the plurality of first computing units according to the order of operation priority from high to low; Acquire a second calculation expression in the query statement, where the second calculation expression is located in a target statement of the query statement; the second calculation expression includes a plurality of second calculation units; Generate a second computing unit sequence corresponding to the plurality of second computing units according to the order of operation priority from high to low; Inserting the conditional calculation unit corresponding to the conditional expression into the first target position in the second calculation unit sequence to obtain an updated second calculation unit sequence; wherein the first target position is the first sequence position of the second calculation unit sequence; According to the sequence order of the first computing unit sequence, the operation processing corresponding to the first computing unit is performed on the input data of each first computing unit to obtain the operation processing result corresponding to the query statement.

2. The method according to claim 1, wherein: Generating a first computing unit sequence corresponding to the plurality of first computing units according to the order of operation priority from high to low includes: Parsing the first calculation expression into a first expression tree; wherein each node of the first expression tree corresponds to a first calculation unit, the root node of the first expression tree is the first calculation unit with the lowest operation priority, and the leaf node of the first expression tree is the first calculation unit with the highest operation priority; The first calculation unit corresponding to each node of the first expression tree is traversed from the root node to the leaf node in a post-order depth-first order to generate the first calculation unit sequence.

3. The method according to claim 1, wherein: After generating the first computing unit sequence corresponding to the plurality of first computing units in descending order of operation priority, the method further includes: A corresponding input data slot and an output data slot are allocated to each of the first computing units in the computing data slot.

4. The method according to claim 3, wherein: The performing the operation processing corresponding to each first computing unit on the input data of each first computing unit includes: Obtaining input data of each first computing unit from an input data slot corresponding to the first computing unit; Performing a calculation process corresponding to each of the first calculation units on the input data of each of the first calculation units to obtain output data of each of the first calculation units; The output data of each of the first computing units is stored in the output data slot corresponding to the first computing unit.

5. The method according to claim 3, wherein: The number of the computing data slots is multiple; The allocating a corresponding input data slot and an output data slot to each of the first computing units in the computing data slot includes: For each of the computing data slots, a corresponding input data slot and an output data slot are allocated to each of the first computing units in the computing data slot.

6. The method according to claim 5, wherein: For each of the first computing units, performing a calculation process corresponding to the first computing unit on the input data of each of the first computing units includes: Synchronously acquiring a plurality of input data of the first computing unit from a plurality of input data slots corresponding to each of the first computing units; Synchronously performing arithmetic processing corresponding to each of the first computing units on a plurality of input data of each of the first computing units to obtain a plurality of output data of each of the first computing units; The multiple output data of each of the first computing units are synchronously stored in the multiple output data slots corresponding to the first computing unit.

7. The method according to any one of claims 3 to 6, wherein: The computing data slot is located in the data slot, and the data slot also includes a control data slot, and the control data slot is used to store a computing unit identifier, and the computing unit identifier is used to indicate a first computing unit currently being executed.

8. The method according to claim 1, wherein: The target statement also includes a conditional expression.

9. The method according to claim 8, wherein: After inserting the conditional calculation unit corresponding to the conditional expression into the first target position in the second calculation unit sequence to obtain an updated second calculation unit sequence, the method further includes: Insert the conditional computing unit into the second target position in the first computing unit sequence to obtain an updated first computing unit sequence; wherein the second target position is a sequence position adjacent to the target first computing unit in the first computing unit sequence, and the output data of the target first computing unit is the input data of the conditional computing unit.

10. The method according to claim 9, wherein: The step of performing the operation processing corresponding to each first computing unit on the input data of each first computing unit according to the sequence order of the first computing unit sequence to obtain the operation processing result corresponding to the query statement includes: According to the sequence order of the updated first computing unit sequence, the operation processing corresponding to the first computing unit is performed on the input data of each first computing unit whose sequence position is before the conditional computing unit to obtain the input data of the conditional computing unit; Performing conditional calculation processing corresponding to the conditional calculation unit on the input data of the conditional calculation unit to obtain the conditional calculation result of the conditional calculation unit; When the conditional operation result does not meet the preset condition, continue to perform the operation processing corresponding to the first calculation unit on the input data of each first calculation unit whose sequence position is after the conditional calculation unit in the sequence order of the first calculation unit sequence to obtain the operation processing result corresponding to the first calculation unit.

11. The method according to claim 10, wherein: After obtaining the conditional operation result of the conditional calculation unit, the method further includes: When the conditional operation result meets the preset condition, the operation processing corresponding to the second calculation unit is performed on the input data of each second calculation unit whose sequence position is after the conditional calculation unit in accordance with the sequence order of the updated second calculation unit sequence to obtain the operation processing result corresponding to the second calculation unit.

12. A query statement processing device, characterized in that: include: A first expression acquisition module, used to acquire a first calculation expression in the query statement; wherein the first calculation expression includes a plurality of first calculation units; A first sequence generating module, configured to generate a first computing unit sequence corresponding to the plurality of first computing units according to a descending order of computing priority; A second expression acquisition module is used to acquire a second calculation expression in the query statement, where the second calculation expression is located in the target statement of the query statement; the second calculation expression includes a plurality of second calculation units; A second sequence generating module, used for generating a second computing unit sequence corresponding to a plurality of second computing units according to the order of operation priority from high to low; A second sequence updating module, used for inserting the conditional calculation unit corresponding to the conditional expression into the first target position in the second calculation unit sequence to obtain an updated second calculation unit sequence; wherein the first target position is the first sequence position of the second calculation unit sequence; An operation processing module is used to perform operation processing corresponding to the first computing unit on the input data of each first computing unit according to the sequence order of the first computing unit sequence, so as to obtain the operation processing result corresponding to the query statement.

13. A query statement processing device, characterized in that: The device comprises: a processor and a memory storing computer program instructions; When the processor executes the computer program instructions, the query statement processing method according to any one of claims 1 to 11 is implemented.

14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by a processor, the method for processing a query statement according to any one of claims 1 to 11 is implemented.