Condition query method, device and electronic device

By analyzing conditional query formulas, optimizing nodes, and extracting operators, fast and accurate data query in database tables is realized, solving the problems of low query efficiency and high cost in the existing technology.

CN114741407BActive Publication Date: 2024-10-29BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210442496.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-25
Publication Date
2024-10-29
Estimated Expiration
2042-04-25

AI Technical Summary

Technical Problem

When the number of fields and records in existing database tables increases, the query efficiency is low and the traversal cost is high. In particular, the rules when different field types participate in formula calculation are inconsistent, resulting in increased query complexity.

Method used

By detecting the conditional query formula, it parses it into a tree structure, determines the target node, optimizes the node and extracts operators, and uses these operators to query in the table to achieve fast and accurate data query.

Benefits of technology

It improves the speed and accuracy of conditional queries in database tables, reduces query costs, and adapts to calculation rules of different field types.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114741407B_ABST
    Figure CN114741407B_ABST
Patent Text Reader

Abstract

The embodiment of the present application discloses a conditional query method, device and electronic device. A specific implementation of the method includes: in response to detecting a conditional query in a table, parsing the conditional query formula to obtain a tree structure corresponding to the conditional query formula; based on the node information in the tree structure, determining the target node in the tree structure, and processing the target node; according to a preset data description structure, extracting an operator from the processed target node to obtain at least one operator; using the at least one operator, querying and presenting results that meet the query conditions in the table. This implementation can query data in a table more quickly and accurately.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present disclosure relate to the field of computer technology, and in particular to a conditional query method, device, and electronic device. Background Art

[0002] Database tables usually support formula field queries. As the amount of data in database tables continues to grow and become more complex, it is usually necessary to query data faster and more accurately. When the number of fields and records in existing database tables reaches a certain level, a heavy traversal cost is required. In addition, database tables have many different field types, and different field types have different rules for participating in formula calculations. Summary of the invention

[0003] This disclosure section is provided to introduce concepts in a brief form, which will be described in detail in the detailed description section below. This disclosure section is not intended to identify key features or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.

[0004] In a first aspect, an embodiment of the present disclosure provides a conditional query method, including: in response to detecting a conditional query in a table, parsing the conditional query formula to obtain a tree structure corresponding to the conditional query formula; based on the node information in the tree structure, determining the target node in the tree structure, and processing the target node; according to a preset data description structure, extracting operators from the processed target node to obtain at least one operator; using at least one operator, querying and presenting results that meet the query conditions in the table.

[0005] In the second aspect, an embodiment of the present disclosure provides a conditional query device, including: a parsing unit, for parsing the conditional query formula in response to detecting a conditional query in a table, and obtaining a tree structure corresponding to the conditional query formula; a processing unit, for determining a target node in the tree structure based on the node information in the tree structure, and processing the target node; an extraction unit, for extracting operators from the processed target nodes according to a preset data description structure, and obtaining at least one operator; a query unit, for using at least one operator to query and present results that meet the query conditions in the table.

[0006] In a third aspect, an embodiment of the present disclosure provides an electronic device, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the conditional query method as described in the first aspect.

[0007] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the conditional query method as described in the first aspect.

[0008] The conditional query method, device and electronic device provided by the embodiment of the present disclosure detect that a conditional query is performed in a table, parse the conditional query formula, and obtain a tree structure corresponding to the conditional query formula; then, based on the node information in the tree structure, determine the target node in the tree structure, and process the target node; then, according to the preset data description structure, extract operators from the processed target node to obtain at least one operator; finally, use the at least one operator to query and present results that meet the query conditions in the table. By optimizing the conditional query formula and extracting the operator in the formula, data can be queried in the table more quickly and accurately. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.

[0010] Figure 1 is a flow chart of an embodiment of a conditional query method according to the present disclosure;

[0011] Figure 2 is a schematic diagram of a tree structure corresponding to a conditional query formula according to the conditional query method disclosed in the present invention;

[0012] Figure 3 is a flow chart of another embodiment of the conditional query method according to the present disclosure;

[0013] Figure 4 is a flow chart of another embodiment of the conditional query method according to the present disclosure;

[0014] Figure 5 is a flow chart of another embodiment of the conditional query method according to the present disclosure;

[0015] Figure 6 is a structural schematic diagram of an embodiment of a conditional query device according to the present disclosure;

[0016] Figure 7 is an exemplary system architecture diagram in which various embodiments of the present disclosure may be applied;

[0017] Figure 8 It is a schematic diagram of the structure of a computer system suitable for implementing the electronic device of the embodiment of the present disclosure. DETAILED DESCRIPTION

[0018] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0019] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.

[0020] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.

[0021] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0022] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0023] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0024] Figure 1 A process 100 of an embodiment of a conditional query method according to the present disclosure is shown. The conditional query method comprises the following steps:

[0025] Step 101, in response to detecting that a conditional query is performed in a table, the conditional query formula is parsed to obtain a tree structure corresponding to the conditional query formula.

[0026] In this embodiment, the execution subject of the conditional query method can detect whether the user performs a conditional query in the table. Here, the user can implement the conditional query by entering a conditional query formula in the formula field of the table.

[0027] If a conditional query is detected in the above table, the above execution subject can parse the conditional query formula to obtain a tree structure corresponding to the conditional query formula. The above execution subject can parse the conditional query formula according to the grammatical definition of the conditional query formula. The tree structure is usually a grammatical structure expressed in a tree form.

[0028] A tree structure can also be called a tree structure, which is a hierarchical nested structure. The outer and inner layers of a tree structure have similar structures, so this structure can often be represented recursively. In a tree structure, a tree can be simply represented as a root, a left subtree, and a right subtree. The left subtree and the right subtree have their own subtrees. In a tree structure, the root node has no predecessor node, and each of the remaining nodes has one and only one predecessor node. Leaf nodes have no successor nodes, and the number of successor nodes for each of the remaining nodes can be one or more.

[0029] like Figure 2 As shown, Figure 2 A schematic diagram of a tree structure corresponding to a conditional query formula of the conditional query method according to the present disclosure is shown.

[0030] exist Figure 2 In the example shown in icon 201, the conditional query formula is: Table1.FILTER(CurrentValue.Score>90).Name, that is, the names of people with scores greater than 90 are queried. After parsing the conditional query formula 201, the following can be obtained: Figure 2 Here, icon 202 shows the target node in this tree structure, i.e., the important node.

[0031] Step 102: determine a target node in the tree structure based on the node information in the tree structure, and process the target node.

[0032] In this embodiment, the above-mentioned execution subject can determine the target node in the above-mentioned tree structure based on the node information in the above-mentioned tree structure. The above-mentioned target node is usually an important node or a main node in the conditional query formula. The above-mentioned conditional query formula contains a conditional query function, and the above-mentioned execution subject can store an important conditional query function table, which is used to store the conditional query function that needs to be analyzed in detail. The above-mentioned execution subject can use the above-mentioned important conditional query function table to search for a node containing the conditional query function in the above-mentioned important conditional query function table in the remaining nodes in the above-mentioned tree structure except the root node, and determine the node as the target node.

[0033] Afterwards, the execution subject may process the target node. The purpose of processing the target node is to optimize the node. Here, the execution subject may process the target node by using relational algebra transformation, query cost optimization and other processing methods.

[0034] Step 103: extract operators from the processed target node according to the preset data description structure to obtain at least one operator.

[0035] In this embodiment, the execution subject can extract operators from the processed target node according to a preset data description structure to obtain at least one operator. Here, an operator usually refers to a mapping relationship in mathematics. When the mapping function is to map a function into a function, or to map a function into a number, this mapping is often called an operator. The data description structure may include a left node, a right node, and an operator. The left node may be used to represent the query field name, the right node may be used to represent the searched value, and the operator may include but is not limited to: an equal sign (=), a greater than sign (>), and a less than sign (<).

[0036] Here, the execution subject may extract the query field name as the left node, the searched value as the right node, and the operator from each expression in the optimized target node.

[0037] As an example, if the optimized target node is "height>170", the extracted operators are: left node: {height} field, right node: {170}, operator: {>}.

[0038] It should be noted that if at least two operators can be extracted from the optimized target node, it is usually necessary to sort the extracted at least two operators according to the positions of the expressions corresponding to the operators in the above optimized target node.

[0039] Step 104: Query and present results that meet the query conditions in the table using at least one operator.

[0040] In this embodiment, the execution entity may use the at least one operator extracted in step 103 to search and present results that meet the query conditions in the table.

[0041] As an example, if the extracted operator is: left node: {height} field, right node: {170}, operator: {>}, the above execution entity can query users whose height is greater than 170 in the above table and obtain user names: Zhang A, Li B, then the query result {Zhang A, Li B} can be presented in the cell presenting the query result.

[0042] The method provided by the above embodiment of the present disclosure detects that a conditional query is performed in a table, parses the conditional query formula, and obtains a tree structure corresponding to the conditional query formula; then, based on the node information in the tree structure, determines the target node in the tree structure, and processes the target node; then, according to the preset data description structure, extracts an operator from the processed target node to obtain at least one operator; finally, using the at least one operator, queries and presents results that meet the query conditions in the table. By optimizing the conditional query formula and extracting the operator in the formula, data can be queried in the table more quickly and accurately.

[0043] In some optional implementations, the execution subject may process the target node by at least one of the following:

[0044] The above-mentioned execution subject can determine the expression in the above-mentioned target node, and determine the expression that does not conform to the preset rules from the above-mentioned expressions, and identify the expression that does not conform to the preset rules. These identified expressions do not participate in subsequent query processing. Expressions that do not conform to the preset rules can also be understood as wrong expressions. Here, the above-mentioned execution subject can store a preset conditional relationship library, which is used to characterize the data values ​​that fields and fields may correspond to. The above-mentioned execution subject can determine whether the correspondence between the fields of the expression in the above-mentioned target node and the corresponding data values ​​exists in the above-mentioned conditional relationship library. If not, the expression can be determined as an expression that does not conform to the preset rules. As an example, if the expression "Gender = Asia" exists in the above-mentioned target node, it can be identified.

[0045] The execution subject may adjust the position of the expression in the target node using the query cost corresponding to the different execution orders of the at least two expressions in the target node. The execution subject may optimize the query cost and determine the execution order of the at least two expressions by the data density and value range corresponding to the fields of different expressions. Here, the query cost may be determined using a histogram method or a sampling method. The execution subject may adjust the position of the expression in the target node according to the execution order expressed when the query cost is minimized.

[0046] As an example, if the above-mentioned target node includes the expression "height>170" and the expression "weight>100", and the expression "height>170" is before the expression "weight>100" in the above-mentioned target node, if it is determined that the query cost is the lowest when executing the expression "weight>100" first and then the expression "height>170", then the above-mentioned execution body can adjust the positions of the expression "height>170" and the expression "weight>100" in the above-mentioned target node so that the expression "weight>100" is located before the expression "height>170", so that in subsequent queries, the condition "weight>100" is queried first, and then the condition "height>170" is queried.

[0047] The execution subject may perform a pre-merge operation on the expression in the target node to simplify the expression in the target node. For example, if the expression in the target node is "height+2>170-10", the expression may be pre-merged using the commutative law to obtain a simplified expression "height>158".

[0048] It should be noted that the execution subject may process the target node by using one of the above three optimization methods or a combination of any two or all three methods to achieve the purpose of optimizing the target node.

[0049] Through these optimization methods, the subsequent query costs can be reduced.

[0050] In some optional implementations, the execution subject may parse the conditional query formula in the following manner to obtain a tree structure corresponding to the conditional query formula: the execution subject may input the conditional query formula into a preset parser to obtain a tree structure corresponding to the conditional query formula. The parser may be used to characterize the correspondence between the query formula and the tree structure corresponding to the query formula.

[0051] Further references Figure 3 , which shows a process 300 of another embodiment of a conditional query method. The process 300 of the conditional query method includes the following steps:

[0052] Step 301, in response to detecting that a conditional query is performed in a table, the conditional query formula is parsed to obtain a tree structure corresponding to the conditional query formula.

[0053] Step 302: Determine a target node in the tree structure based on the node information in the tree structure.

[0054] In this embodiment, steps 301 - 302 may be performed in a manner similar to steps 101 - 102 , and will not be described in detail herein.

[0055] Step 303, determine the expressions in the target node, and identify the expressions that do not meet the preset rules.

[0056] In this embodiment, the execution subject of the conditional query method can determine the expression in the above-mentioned target node, and determine the expression that does not conform to the preset rules from the above-mentioned expression, and identify the expression that does not conform to the preset rules. These identified expressions do not participate in subsequent query processing. Expressions that do not conform to the preset rules can also be understood as wrong expressions.

[0057] Here, the execution subject may store a preset conditional relationship library, which is used to represent fields and data values ​​that may correspond to the fields.

[0058] The execution subject may determine whether the correspondence between the field of the expression in the target node and the corresponding data value exists in the conditional relationship library. If not, the expression may be determined as an expression that does not comply with the preset rules.

[0059] As an example, if the expression "Gender = Asia" exists in the above target node, it can be identified.

[0060] Step 304: adjust the positions of at least two expressions in the target node by using the query costs corresponding to different execution orders of at least two expressions in the target node.

[0061] In this embodiment, the execution subject may adjust the position of the expression in the target node by using the query costs corresponding to different execution orders of the at least two expressions in the target node. The execution subject may optimize the query cost and determine the execution order of the at least two expressions by the data density and value range corresponding to the fields of different expressions.

[0062] Here, the query cost may be determined by using a histogram method or a sampling method. The execution subject may adjust the position of the expression in the target node according to the execution order of the expression when the query cost is minimum.

[0063] As an example, if the above-mentioned target node includes the expression "height>170" and the expression "weight>100", and the expression "height>170" is before the expression "weight>100" in the above-mentioned target node, if it is determined that the query cost is the lowest when executing the expression "weight>100" first and then the expression "height>170", then the above-mentioned execution body can adjust the positions of the expression "height>170" and the expression "weight>100" in the above-mentioned target node so that the expression "weight>100" is located before the expression "height>170", so that in subsequent queries, the condition "weight>100" is queried first, and then the condition "height>170" is queried.

[0064] Step 305: perform a pre-merge operation on the expression in the target node.

[0065] In this embodiment, the execution entity may perform a pre-merge operation on the expression in the target node so as to minimize the expression in the target node.

[0066] As an example, if the expression in the above target node is "height+2>170-10", the expression can be pre-merged using the commutative law to obtain a simplified expression "height>158".

[0067] Step 306: extract operators from the processed target node according to the preset data description structure to obtain at least one operator.

[0068] Step 307: Use at least one operator to search and present results that meet the query conditions in the table.

[0069] In this embodiment, steps 306-307 may be performed in a manner similar to steps 103-104, and will not be described in detail herein.

[0070] from Figure 3 It can be seen that Figure 1 Compared with the corresponding embodiment, the process 300 of the conditional query method in this embodiment embodies the steps of optimizing the target node. Therefore, the solution described in this embodiment can reduce the subsequent query cost.

[0071] Further references Figure 4 , which shows a process 400 of another embodiment of a conditional query method. The process 400 of the conditional query method includes the following steps:

[0072] Step 401, in response to detecting that a conditional query is performed in a table, the conditional query formula is parsed to obtain a tree structure corresponding to the conditional query formula.

[0073] Step 402: determine a target node in the tree structure based on the node information in the tree structure, and process the target node.

[0074] In this embodiment, steps 401 - 402 may be performed in a manner similar to steps 101 - 102 , and will not be described in detail herein.

[0075] Step 403, searching for a logical operator from the processed target node, and extracting an expression in the processed target node based on the logical operator.

[0076] In this embodiment, the execution subject of the conditional query method can search for logical operators from the above-processed target node. The above-mentioned logical operators may include but are not limited to: logical AND operation (&&) and logical OR operation (||). Afterwards, the expression in the processed target node can be extracted based on the above-mentioned logical operators.

[0077] Step 404, determining whether the expression complies with a preset data description structure.

[0078] In this embodiment, the execution subject may determine whether the expression complies with a preset data description structure. If it is determined that the expression complies with the data description structure, step 405 may be executed.

[0079] It should be noted that the above data description structure may also include logical operators.

[0080] It should also be noted that the above data description structure can be set according to requirements.

[0081] Step 405: If the expression conforms to the data description structure, at least one expression conforming to the data description structure is parsed to obtain at least one operator.

[0082] In this embodiment, if it is determined in step 404 that the above expression conforms to the above data description structure, the above execution entity may parse at least one expression conforming to the above data description structure to obtain at least one operator.

[0083] Step 406: Query and present results that meet the query conditions in the table using at least one operator.

[0084] In this embodiment, step 406 may be performed in a manner similar to step 104 , and will not be described in detail herein.

[0085] from Figure 4 It can be seen that Figure 1Compared with the corresponding embodiment, the process 400 of the conditional query method in this embodiment embodies the step of extracting operators from the processed target node. Therefore, the scheme described in this embodiment can extract operators more comprehensively, thereby improving the accuracy of subsequent conditional queries.

[0086] In some optional implementations, the above-mentioned execution body can be further used to extract the expression in the above-mentioned processed target node based on the above-mentioned logical operator in the following manner: the above-mentioned execution body can perform the following extraction steps: first, the adjacent nodes of the logical operator can be found, that is, the left node and the right node; then, the extracted adjacent nodes can be recursively analyzed to determine whether the adjacent nodes contain the logical operator; if the adjacent nodes do not contain the logical operator, the extracted nodes can be determined as at least one expression in the above-mentioned processed target node for arrangement.

[0087] If the adjacent node contains a logical operator, the execution subject may continue to execute the extraction step, thereby extracting all expressions in the target node after the processing.

[0088] In some optional implementations, the data description structure may include a left node, a right node, and an operator. The left node may be used to represent the query field name, the right node may be used to represent the searched value, and the operator may include but is not limited to: an equal sign (=), a greater than sign (>), and a less than sign (<). The execution subject may be further used to determine whether the expression conforms to the preset data description structure in the following manner: the execution subject may determine whether the expression contains the query field name, the searched value, and the operator; if so, it may be determined that the expression conforms to the data description structure.

[0089] In some optional implementations, the execution subject can be further used to parse at least one expression that conforms to the data description structure to obtain at least one operator in the following manner: for each expression in the at least one expression that conforms to the data description structure, the execution subject can extract the query field name from the expression as the left node, extract the searched value from the expression as the right node, extract the operator from the expression, and combine the extracted left node, right node and operator to obtain the operator. As an example, if the processed target node is "height>170", the extracted operator is: left node: {height} field, right node: {170}, operator: {>}.

[0090] It should be noted that if at least two operators can be extracted from the processed target node, it is usually necessary to sort the extracted at least two operators according to the positions of the expressions corresponding to the operators in the processed target node.

[0091] Continue to refer Figure 5 , which shows a process 500 of another embodiment of a conditional query method. The process 500 of the conditional query method includes the following steps:

[0092] Step 501, in response to detecting that a conditional query is performed in a table, the conditional query formula is parsed to obtain a tree structure corresponding to the conditional query formula.

[0093] In this embodiment, step 501 may be performed in a manner similar to step 101 , and will not be described in detail herein.

[0094] Step 502: determine the field queried by the conditional query formula as the target field.

[0095] In this embodiment, the execution subject of the conditional query method may determine the field queried by the above conditional query formula as the target field.

[0096] Step 503: Create an index table of the target field using the relevant information of the target field in the table.

[0097] In this embodiment, the execution subject can use the relevant information of the target field in the table to establish an index table of the target field. Here, the relevant information of the target field is determined by the content stored in the table.

[0098] As an example, if the table records the correspondence between height and student names, and if the conditional query formula is "height>170", the above execution entity can determine the field "height" as the target field, and then establish a correspondence table between height and student names as an index table. For example, students with a height of 170 correspond to Zhang A and Li B, and students with a height of 190 correspond to Wang C and Wang D.

[0099] Step 504: determine the target node in the tree structure based on the node information in the tree structure, and process the target node.

[0100] Step 505: extract operators from the processed target node according to the preset data description structure to obtain at least one operator.

[0101] Step 506: Query and present results that meet the query conditions in the table using at least one operator.

[0102] In this embodiment, steps 504-506 may be performed in a manner similar to steps 102-104, and will not be described in detail herein.

[0103] Step 507 , in response to detecting that a conditional query is performed again on the target field in the table, a query is performed using the index table of the target field.

[0104] In this embodiment, the execution entity may detect whether to perform conditional query again for the target field in the table, that is, determine whether the conditional query formula this time contains the target field. If so, it indicates that conditional query is performed again for the target field.

[0105] If it is detected that a conditional query is performed again on the target field in the table, the execution subject may perform the query using the index table of the target field.

[0106] As an example, if the conditional query formula "height = 190" is entered in the above table, and it is detected that the user performs a conditional query on the "height" field again, the pre-established index table between height and student name can be used for query. At this time, it is found that the students with a height of 190 correspond to Wang C and Wang D.

[0107] As another example, if the conditional query formula "height>180" is entered in the above table, and it is detected that the user performs a conditional query on the "height" field again, the names of students whose height is greater than 180 can be extracted using the pre-established index table between height and student names.

[0108] from Figure 5 It can be seen that Figure 1 Compared with the corresponding embodiment, the process 500 of the conditional query method in this embodiment embodies the steps of establishing an index table of the target field, and using the index table to query when it is detected that the target field is queried again. Therefore, the scheme described in this embodiment can use the index table to perform conditional query more quickly.

[0109] Further references Figure 6 As an implementation of the methods shown in the above figures, the present application provides an embodiment of a conditional query device, which is similar to Figure 1 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0110] like Figure 6As shown, the conditional query device 600 of this embodiment includes: a parsing unit 601, a processing unit 602, an extraction unit 603 and a query unit 604. The parsing unit 601 is used to parse the conditional query formula in response to detecting that a conditional query is performed in a table, and obtain a tree structure corresponding to the conditional query formula; the processing unit 602 is used to determine the target node in the tree structure based on the node information in the tree structure, and process the target node; the extraction unit 603 is used to extract an operator from the processed target node according to a preset data description structure to obtain at least one operator; the query unit 604 is used to use at least one operator to query and present results that meet the query condition in the table.

[0111] In this embodiment, the specific processing of the parsing unit 601, the processing unit 602, the extraction unit 603 and the query unit 604 of the condition query device 600 can be referred to. Figure 1 This corresponds to step 101, step 102, step 103 and step 104 in the embodiment.

[0112] In some optional implementations, the processing unit 602 can be further used to process the target node through at least one of the following: determining the expression in the target node, identifying the expression that does not comply with the preset rule from the expression; adjusting the positions of at least two expressions in the target node using the query costs corresponding to the different execution orders of at least two expressions in the target node; and performing a pre-merge operation on the expression in the target node.

[0113] In some optional implementations, the extraction unit 603 can be further used to extract operators from the processed target node according to a preset data description structure to obtain at least one operator in the following manner: the extraction unit 603 can search for logical operators from the processed target node, and based on the logical operators, extract expressions in the processed target node; determine whether the expressions conform to the preset data description structure; if so, parse at least one expression that conforms to the data description structure to obtain at least one operator.

[0114] In some optional implementations, the extraction unit 603 can be further used to extract the expression in the processed target node based on the logical operator in the following manner: the extraction unit 603 can perform the following extraction steps: searching for adjacent nodes of the logical operator; determining whether the adjacent nodes contain the logical operator; if the adjacent nodes do not contain the logical operator, determining the extracted node as at least one expression in the processed target node; if the adjacent nodes contain the logical operator, continuing to perform the extraction steps.

[0115] In some optional implementations, the data description structure includes a left node, a right node and an operator, the left node is used to represent the query field name, and the right node is used to represent the searched value; and the extraction unit 603 can be further used to determine whether the expression conforms to the preset data description structure in the following manner: the extraction unit 603 can determine whether the expression contains the query field name, the searched value and the operator; if so, it is determined that the expression conforms to the data description structure.

[0116] In some optional implementations, the extraction unit 603 may be further used to parse at least one expression that conforms to the data description structure to obtain at least one operator in the following manner: for each expression in the at least one expression that conforms to the data description structure, the extraction unit 603 may extract the query field name from the expression as a left node, extract the searched value from the expression as a right node, extract the operator from the expression, and combine the extracted left node, right node and operator to obtain the operator.

[0117] In some optional implementations, the conditional query device 600 may further include a determination unit (not shown in the figure) and an establishment unit (not shown in the figure). The determination unit may be used to determine the field queried by the conditional query formula as the target field; the establishment unit may be used to establish an index table of the target field using the relevant information of the target field in the table.

[0118] In some optional implementations, the conditional query device 600 may further include a second query unit (not shown). The second query unit may be configured to query using the index table of the target field in response to detecting that a conditional query is performed again on the target field in the table.

[0119] In some optional implementations, the above-mentioned parsing unit 601 can be further used to parse the conditional query formula in the following manner to obtain a tree structure corresponding to the above-mentioned conditional query formula: the above-mentioned parsing unit 601 can input the above-mentioned conditional query formula into a preset parser to obtain a tree structure corresponding to the above-mentioned conditional query formula.

[0120] Please refer to Figure 7 , Figure 7 An exemplary system architecture is shown in which the conditional query method according to an embodiment of the present disclosure can be applied.

[0121] like Figure 7As shown, the system architecture may include terminal devices 701, 702, 703, a network 704, and a server 705. The network 704 is used to provide a medium for communication links between the terminal devices 701, 702, 703 and the server 705. The network 704 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0122] Terminal devices 701, 702, 703 can interact with server 705 through network 704 to receive or send messages, etc. Various client applications can be installed on terminal devices 701, 702, 703, such as document editing applications and instant messaging software. If terminal devices 701, 702, 703 detect that a conditional query is performed in a table, the conditional query formula is parsed to obtain a tree structure corresponding to the conditional query formula; then, based on the node information in the tree structure, the target node in the tree structure can be determined and the target node can be processed; then, according to the preset data description structure, an operator can be extracted from the processed target node to obtain at least one operator; finally, the at least one operator can be used to query and present the results that meet the query conditions in the table.

[0123] Terminal devices 701, 702, and 703 can be hardware or software. When terminal devices 701, 702, and 703 are hardware, they can be various electronic devices with display screens and supporting table queries, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III, Moving Picture Experts Group Audio Layer 3), MP4 (Moving Picture Experts Group Audio Layer IV, Moving Picture Experts Group Audio Layer 4) players, laptop computers, and desktop computers, etc. When terminal devices 701, 702, and 703 are software, they can be installed in the electronic devices listed above. It can be implemented as multiple software or software modules (for example, software or software modules used to provide distributed services), or it can be implemented as a single software or software module. No specific limitation is made here.

[0124] The server 705 may be a server that provides various services, such as sending a preset parser to the terminal devices 701 , 702 , and 703 .

[0125] It should be noted that the condition query method provided in the embodiment of the present disclosure is usually executed by the terminal devices 701 , 702 , 703 , and accordingly, the condition query device is usually set in the terminal devices 701 , 702 , 703 .

[0126] It should be noted that if the terminal devices 701, 702, and 703 have a parser stored locally, the network 704 and the server 705 may not exist in the above system architecture.

[0127] It should be understood that Figure 7 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0128] Reference below Figure 8 , which shows an electronic device (eg, Figure 1 The terminal device in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 8 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0129] like Figure 8 As shown, the electronic device 800 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage device 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the electronic device 800 are also stored. The processing device 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.

[0130] Typically, the following devices may be connected to the I / O interface 805: input devices 806 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; output devices 807 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; and communication devices 809. The communication devices 809 may allow the electronic device 800 to communicate with other devices wirelessly or by wire to exchange data. Figure 8 The electronic device 800 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead. Figure 8 Each block shown in the figure may represent one device, or may represent multiple devices as required.

[0131] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 809, or installed from a storage device 808, or installed from a ROM 802. When the computer program is executed by the processing device 801, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.

[0132] It should be noted that the computer-readable medium described in the embodiments of the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the embodiments of the present disclosure, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, device or device. In the embodiments of the present disclosure, the computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0133] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0134] The computer-readable medium may be included in the electronic device, or may exist independently without being installed in the electronic device.

[0135] The above-mentioned computer-readable medium carries one or more programs. When the above-mentioned one or more programs are executed by the electronic device, the electronic device: in response to detecting a conditional query in a table, parses the conditional query formula to obtain a tree structure corresponding to the conditional query formula; based on the node information in the tree structure, determines the target node in the tree structure, and processes the target node; according to a preset data description structure, extracts operators from the processed target node to obtain at least one operator; uses at least one operator to query and present results that meet the query conditions in the table.

[0136] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages ​​or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0137] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0138] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware. The name of a unit does not limit the unit itself in some cases. For example, a query unit may also be described as "a unit that uses at least one operator to query and present results that meet the query conditions in a table."

[0139] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0140] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0141] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.

[0142] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.

[0143] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.

Claims

1. A conditional query method, characterized in that: include: In response to detecting that a conditional query is performed in the table, parsing the conditional query formula to obtain a tree structure corresponding to the conditional query formula; Based on the node information in the tree structure, determine the target node in the tree structure, and process the target node; Extracting an operator from the processed target node according to a preset data description structure to obtain at least one operator, including: searching for a logical operator from the processed target node, and extracting an expression in the processed target node based on the logical operator; determining whether the expression conforms to the preset data description structure; if so, parsing at least one expression conforming to the data description structure to obtain at least one operator; The at least one operator is used to search and present results that meet the query conditions in the table.

2. The method according to claim 1, characterized in that The processing of the target node includes at least one of the following: Determine the expressions in the target node, and identify the expressions that do not meet the preset rules from the expressions; Adjusting the positions of at least two expressions in the target node by using query costs corresponding to different execution orders of at least two expressions in the target node; A pre-merge operation is performed on the expression in the target node.

3. The method according to claim 1, characterized in that The step of extracting the expression in the processed target node based on the logical operator comprises: The following extraction steps are performed: searching for adjacent nodes of the logical operator; determining whether the adjacent nodes contain the logical operator; if the adjacent nodes do not contain the logical operator, determining the extracted nodes as at least one expression in the processed target node; If the adjacent node contains a logical operator, the extraction step continues.

4. The method according to claim 1, characterized in that: The data description structure includes a left node, a right node and an operator, the left node is used to represent the query field name, and the right node is used to represent the searched value; as well as The step of determining whether the expression conforms to a preset data description structure includes: Determine whether the expression contains the query field name, the search value and the operator; If so, it is determined that the expression conforms to the data description structure.

5. The method according to claim 4, characterized in that The step of parsing at least one expression conforming to the data description structure to obtain at least one operator includes: For each expression in at least one expression that conforms to the data description structure, a query field name is extracted from the expression as a left node, a searched value is extracted from the expression as a right node, an operator is extracted from the expression, and the extracted left node, right node and operator are combined to obtain an operator.

6. The method according to claim 1, characterized in that The method further comprises: Determine the field queried by the conditional query formula as the target field; An index table of the target field is established using the relevant information of the target field in the table.

7. The method according to claim 6, characterized in that The method further comprises: In response to detecting that a conditional query is performed again on the target field in the table, a query is performed using an index table of the target field.

8. The method according to claim 1, characterized in that The conditional query formula is parsed to obtain a tree structure corresponding to the conditional query formula, including: The conditional query formula is input into a preset parser to obtain a tree structure corresponding to the conditional query formula.

9. A conditional query device, characterized in that: include: A parsing unit, configured to parse the conditional query formula in response to detecting that a conditional query is performed in the table, and obtain a tree structure corresponding to the conditional query formula; A processing unit, configured to determine a target node in the tree structure based on the node information in the tree structure, and process the target node; The extraction unit is used to extract operators from the processed target node according to the preset data description structure to obtain at least one operator, including: searching for a logical operator from the processed target node, and extracting an expression in the processed target node based on the logical operator; determining whether the expression conforms to the preset data description structure; if so, parsing at least one expression conforming to the data description structure to obtain at least one operator; The query unit is used to use the at least one operator to query and present results that meet the query conditions in the table.

10. An electronic device, characterized in that: include: one or more processors; a storage device having one or more programs stored thereon, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 8.

11. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Data query method and device, equipment and storage medium

    CN113420044A