Request processing method, electronic device, and program product

By obtaining the short-circuit characteristics of expressions and optimizing the target evaluation order, the Boolean value calculation order is optimized, which solves the resource waste and speed reduction problems caused by a fixed calculation order and achieves more efficient expression calculation.

CN119557557BActive Publication Date: 2025-10-21KE COM (BEIJING) TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411686949.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-22
Publication Date
2025-10-21
Estimated Expiration
2044-11-22

AI Technical Summary

Technical Problem

In the prior art, a fixed calculation sequence ignores the short-circuit characteristic, leading to unnecessary calculations, wasting resources and reducing the calculation speed.

Method used

By obtaining the short-circuit characteristics of expressions and the target evaluation order of multiple main Boolean factors, the short-circuit characteristics are combined to obtain Boolean values ​​and optimize the calculation order to reduce unnecessary calculations.

Benefits of technology

It improves the efficiency and success rate of expression calculation, reduces the number of exception retries, and saves computing resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119557557B_ABST
    Figure CN119557557B_ABST
Patent Text Reader

Abstract

The present disclosure provides a request processing method, an electronic device and a program product. The request processing method of the present disclosure comprises: receiving a call request of a to-be-processed expression; in response to the call request, obtaining a short-circuit characteristic of the to-be-processed expression and a target evaluation order of a plurality of main Boolean factors of the to-be-processed expression, the target evaluation order being determined from different evaluation orders of the plurality of main Boolean factors according to the size of the plurality of expression normal termination probabilities corresponding to the different evaluation orders; obtaining the Boolean values of the plurality of main Boolean factors according to the target evaluation order combined with the short-circuit characteristic; performing expression calculation according to the Boolean values of the plurality of main Boolean factors to obtain the value of the to-be-processed expression; and processing the value of the to-be-processed expression according to the processing mode corresponding to the call request.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of computers and the like, and in particular to a request processing method, an electronic device, and a program product. Background Art

[0002] When processing some call requests, it's necessary to evaluate the expressions associated with them. Expressions are a fundamental concept in computer science, encompassing programming, algorithm design, data processing, and other aspects. Expressions typically consist of variables and operators, describing relationships between data and computational processes. In application scenarios such as conditional judgments and loop control, evaluating expressions is necessary to ensure the program's logical correctness and functional integrity.

[0003] In the prior art, the calculation order of variables in an expression is generally fixed. When calculating the final value of the expression, the calculated values ​​of the variables are obtained in sequence based on the fixed calculation order and then calculated.

[0004] However, a fixed calculation order generally ignores the short-circuit characteristics, leading to unnecessary calculations, wasting computing resources, and reducing computing speed. Summary of the Invention

[0005] The present disclosure provides a request processing method, an electronic device, and a program product.

[0006] According to one aspect of the present disclosure, a request processing method is provided, comprising:

[0007] Receive a call request for an expression to be processed;

[0008] In response to the call request, obtaining a short-circuit characteristic of the expression to be processed and a target evaluation order of a plurality of main Boolean factors of the expression to be processed, wherein the target evaluation order is determined from different evaluation orders of the plurality of main Boolean factors according to normal termination probabilities of the plurality of expressions corresponding to the different evaluation orders;

[0009] Obtaining Boolean values ​​of the plurality of main Boolean factors according to the target evaluation order in combination with the short-circuit characteristic;

[0010] Perform expression calculation according to the Boolean values ​​of the plurality of main Boolean factors to obtain the value of the expression to be processed;

[0011] The value of the expression to be processed is processed according to the processing method corresponding to the call request.

[0012] According to the request processing method of at least one embodiment of the present disclosure, obtaining the short-circuit characteristic of the expression to be processed and the target evaluation order of multiple main Boolean factors of the expression to be processed includes:

[0013] Obtaining the target evaluation order of the plurality of main Boolean factors from the expression-evaluation order mapping; or,

[0014] The target evaluation order of the plurality of main Boolean factors is obtained from the different evaluation orders of the plurality of main Boolean factors according to the normal termination probabilities of the plurality of expressions corresponding to the different evaluation orders.

[0015] According to at least one embodiment of the request processing method of the present disclosure, obtaining a target evaluation order of the multiple main Boolean factors from different evaluation orders of the multiple main Boolean factors according to normal termination probabilities of multiple expressions corresponding to the different evaluation orders includes:

[0016] Obtaining different evaluation orders of the plurality of main Boolean factors;

[0017] Obtain normal termination probabilities of multiple expressions corresponding to the different evaluation orders;

[0018] The target evaluation order is obtained from the different evaluation orders according to the magnitudes of the normal termination probabilities of the multiple expressions.

[0019] According to the request processing method of at least one embodiment of the present disclosure, for any evaluation order, obtaining normal termination probabilities of multiple expressions corresponding to the different evaluation orders includes:

[0020] The main Boolean factors are repeatedly calculated in sequence according to the evaluation order and the number of calculations, and the calculation success rate of each main Boolean factor and the Boolean value obtained when the calculation is successful each time are obtained;

[0021] Performing statistical operations based on the calculation success rate of each main Boolean factor and the Boolean value obtained when the calculation is successful each time, to obtain a result probability distribution of each main Boolean factor;

[0022] Get the termination probability calculation method corresponding to the evaluation order and operator;

[0023] Substituting the result probability distribution of each main Boolean factor into the termination probability calculation method to obtain the normal termination probability of the expression corresponding to the evaluation order;

[0024] The operator is an operator between the multiple main Boolean factors in the expression to be processed.

[0025] According to at least one embodiment of the request processing method of the present disclosure, for any main Boolean factor, performing statistical operations based on the calculation success rate of each main Boolean factor and the Boolean value obtained when the calculation is successful each time, includes:

[0026] According to the Boolean value obtained each time the main Boolean factor is successfully calculated, the number of occurrences of different Boolean values ​​is counted to obtain the true value count and the false value count;

[0027] Multiplying the calculation success rate of the main Boolean factor by the true value count and the false value count respectively to obtain the true value expectation and the false value expectation;

[0028] Dividing the true value expectation and the false value expectation by the number of iterations of the main Boolean factor respectively;

[0029] The number of iterations is the sum of the number of calculations and the number of retries when the calculation fails.

[0030] According to at least one embodiment of the request processing method of the present disclosure, for the first main Boolean factor corresponding to the evaluation order, repeatedly calculating the main Boolean factors in sequence according to the evaluation order and the number of calculations to obtain a calculation success rate of each main Boolean factor and a Boolean value obtained when the calculation is successful each time, includes:

[0031] Repeatedly calculating the first main Boolean factor according to the number of calculations to obtain a first execution state of each calculation;

[0032] When the first execution state of any calculation is calculation failure, retries are performed until the deadline condition is met, and the first number of retries is obtained;

[0033] Obtaining the first iteration number of the first main Boolean factor according to the sum of the number of calculations and the total number of first retries when the calculation fails;

[0034] The calculation success rate of the first main Boolean factor is obtained according to the quotient of the number of states in which calculation is successfully completed in the first execution state and the first number of iterations.

[0035] According to at least one embodiment of the request processing method of the present disclosure, for any second main Boolean factor other than the first main Boolean factor corresponding to the evaluation order, repeatedly calculating the main Boolean factors in sequence according to the evaluation order and the number of calculations to obtain a calculation success rate of each main Boolean factor and a Boolean value obtained upon each successful calculation, includes:

[0036] Obtaining the number of short-circuit triggering times of the second main Boolean factor being short-circuited according to the calculation status of the main Boolean factor before the second main Boolean factor in the evaluation order;

[0037] Obtaining the execution count of the second main Boolean factor according to the difference between the calculation count and the short circuit trigger count;

[0038] Repeatedly calculating the second main Boolean factor according to the number of executions to obtain a second execution state of each calculation;

[0039] When the second execution state of any calculation is calculation failure, retry until the deadline is reached, and obtain the second retry number;

[0040] Obtaining the second iteration number of the second main Boolean factor according to the sum of the number of calculations and the total number of second retries when the calculation fails;

[0041] The calculation success rate of the second main Boolean factor is obtained according to the quotient of the number of states in which calculation is successfully completed in the second execution state and the second number of iterations.

[0042] According to another aspect of the present disclosure, an electronic device is provided, comprising: a memory storing execution instructions; and a processor executing the execution instructions stored in the memory, so that the processor executes the request processing method of any embodiment of the present disclosure.

[0043] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the request processing method according to any one of the embodiments of the present disclosure is implemented. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] The accompanying drawings illustrate exemplary embodiments of the present disclosure and together with the description serve to explain the principles of the present disclosure. These drawings are included to provide a further understanding of the present disclosure and are incorporated in and constitute a part of this specification.

[0045] Figure 1 is a flowchart of a request processing method according to an embodiment of the present disclosure.

[0046] Figure 2 yes Figure 1 The flowchart of the target evaluation order acquisition method in the request processing method shown.

[0047] Figure 3 yes Figure 2 The flowchart of the normal probability acquisition method in the target evaluation order acquisition method is shown.

[0048] Figure 4 yes Figure 3 The flowchart of the probability distribution acquisition method in the normal probability acquisition method shown is shown.

[0049] Figure 5 yes Figure 3 The process of calculating the success rate acquisition method in the normal probability acquisition method shown Figure 1 .

[0050] Figure 6 yes Figure 3 The process of calculating the success rate acquisition method in the normal probability acquisition method shown Figure 2 .

[0051] Figure 7 yes Figure 1 The flowchart of the expression evaluation method in the request processing method is shown.

[0052] Figure 8 It is a schematic flowchart of a request processing method according to an embodiment of the present disclosure.

[0053] Figure 9 This is a schematic block diagram of the structure of a request processing device according to another embodiment of the present disclosure.

[0054] Figure 10 It is a schematic block diagram of the structure of an electronic device equipped with a request processing device according to another embodiment of the present disclosure. DETAILED DESCRIPTION

[0055] The present disclosure is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific examples described herein are intended only to illustrate the relevant content and are not intended to limit the present disclosure. It should also be noted that, for ease of description, only the portions relevant to the present disclosure are shown in the accompanying drawings.

[0056] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in the present disclosure can be combined with each other. The technical solution of the present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0057] Boolean expressions are expressions consisting of Boolean values ​​(true and false) and are used to express logical relationships and conditional judgments. For example, in the expression "a || b," a fixed calculation order typically requires calculating the Boolean value of one Boolean factor first, then the Boolean value of the other Boolean factor, with the final value of the Boolean expression being calculated using the Boolean values ​​of both factors. However, because "||" indicates that the final value of the expression is true only if at least one Boolean factor is true, calculating the Boolean value of the other Boolean factor when the first Boolean factor is true wastes resources.

[0058] To this end, this disclosure proposes a request processing method, electronic device, and program product. In response to a call request, the method sequentially obtains the Boolean value of each primary Boolean variable based on the target evaluation order and short-circuit characteristics, then calculates and processes the value of the expression to be processed, thereby implementing request processing. This disclosure can be used in electronic devices such as mobile phones, tablets, computers, and servers.

[0059] To facilitate description and make the technical solutions of the specific embodiments of the present disclosure easier to understand, before describing the request processing method implemented by the present disclosure, the technical terms involved in the specific embodiments of the present disclosure are explained as follows:

[0060] The short-circuit feature means that during the evaluation of a logical expression, if the final value of the entire expression can be determined based on the currently calculated Boolean value, the evaluation of subsequent Boolean factors will be skipped.

[0061] The main Boolean factors refer to the factors that directly participate in the highest-level logical operations.

[0062] The normal termination probability of an expression refers to the possibility that the expression successfully calculates the final result during the evaluation process.

[0063] Figure 1 FIG. 1 shows a schematic diagram of the overall process of a request processing method M100 according to an embodiment of the present disclosure. Figure 1 The method shown includes steps S110 to S150, which can be executed by electronic devices such as mobile phones, tablet computers, computers, and servers.

[0064] Specifically, Figure 1 The methods shown include:

[0065] Step S110: receiving a call request for an expression to be processed.

[0066] In some embodiments of the present disclosure, the triggering entity of the call request in step S110 may be a database or a Web service, etc., and the triggering condition of the call request may be a specific keyword, phrase, intention, or user behavior pattern, etc.

[0067] Step S120 , in response to the call request, obtaining the short-circuit characteristic of the expression to be processed and the target evaluation order of the multiple main Boolean factors of the expression to be processed.

[0068] In some embodiments of the present disclosure, the process of obtaining the short-circuit characteristic through step S120 may include: first obtaining the operator of the highest-level logical operation in the expression to be processed; and then determining the short-circuit characteristic based on the operator of the highest-level logical operation. If the expression to be processed contains && (logical AND), when the Boolean value of the first calculated main Boolean factor is "false", the final result of the entire expression to be processed must be "false", and there is no need to continue calculating the subsequent main Boolean factors; if the expression to be processed contains || (logical OR), when the Boolean value of the first calculated main Boolean factor is "true", the final result of the entire expression to be processed must be "true", and there is no need to continue calculating the subsequent main Boolean factors.

[0069] The highest-level logical operators in the expression to be processed can be obtained by analyzing the elements of the expression to be processed; the elements of the expression to be processed refer to the basic components of the expression to be processed. Elements of the expression to be processed can include primary Boolean factors and logical operators for the highest-level logical operations (such as &&, ||, etc.). In addition to the above, elements of the expression to be processed can also include one or more of: sub-Boolean factors, logical operators for lower-level logical operations, or non-logical operators (such as addition (+), subtraction (-), multiplication (*), and division ( / )).

[0070] The target evaluation order obtained in step S120 is determined based on the normal termination probabilities of the multiple expressions corresponding to the different evaluation orders of the multiple main Boolean factors. For example, the evaluation order corresponding to the larger normal termination probability of the multiple expressions is used as the target evaluation order, or the evaluation order corresponding to the largest normal termination probability of the multiple expressions is used as the target evaluation order.

[0071] The main Boolean factor in step S120 can be in various forms, including but not limited to a simple Boolean variable (a variable that can only take two possible values, which usually represent true or false), a Boolean expression (an expression consisting of a Boolean variable, a Boolean constant (such as a constant that can only take one of two fixed values, which are one of true and false), a logical operator (such as &&, ||, NOT!), and possible parentheses; the final result of the expression is always a Boolean value), a function call (referring to the process of executing a function by specifying the function name and providing the required parameters (if any) during program execution, and the function returns a Boolean value), etc.

[0072] Step S130 , obtaining Boolean values ​​of a plurality of main Boolean factors according to the target evaluation order and the short-circuit characteristic.

[0073] In some embodiments of the present disclosure, the process of obtaining the Boolean values ​​of multiple main Boolean factors according to the target evaluation order combined with the short-circuit characteristic through step S130 may include: first obtaining the Boolean value of the first main Boolean factor in the target evaluation order; judging whether the final value of the entire expression to be processed can be determined based on the Boolean value of the first main Boolean factor; if the final value of the entire expression to be processed can be determined based on the Boolean value of the first main Boolean factor, the Boolean values ​​of other main Boolean factors other than the first main Boolean factor in the target evaluation order are no longer calculated; if the final value of the entire expression to be processed cannot be determined based on the Boolean value of the first main Boolean factor, obtaining the target The Boolean value of the next main Boolean factor in the target evaluation order is determined; it is determined whether the final value of the entire expression to be processed can be determined based on all the Boolean values ​​currently obtained; if the final value of the entire expression to be processed can be determined based on all the Boolean values ​​currently obtained, the Boolean values ​​of other main Boolean factors other than the main Boolean factors whose Boolean values ​​have been obtained in the target evaluation order are no longer calculated; if the final value of the entire expression to be processed cannot be determined based on all the Boolean values ​​currently obtained, the above-mentioned process of obtaining the Boolean value of the next main Boolean factor is repeated until the final value of the entire expression to be processed can be determined based on all the Boolean values ​​currently obtained or the Boolean values ​​of all main Boolean factors are obtained.

[0074] When a main Boolean factor takes the form of a simple Boolean variable, its Boolean value can be obtained locally or from an external device via a Remote Procedure Call (RPC) interface. When a main Boolean factor takes the form of a complex Boolean expression, each Boolean variable in the Boolean expression can be obtained separately before performing the operation. The Boolean expression can be a simple Boolean expression (i.e., an expression consisting only of basic Boolean factors (such as Boolean variables or Boolean constants) and logical operators (such as &&, ||, or !)) or a nested Boolean expression (i.e., a Boolean expression that contains other Boolean expressions as its components).

[0075] Step S140 , performing expression calculation according to the Boolean values ​​of the plurality of main Boolean factors to obtain the value of the expression to be processed.

[0076] In some embodiments of the present disclosure, step S140 may substitute the Boolean values ​​of the plurality of main Boolean factors into the corresponding highest-level logical operation operators to obtain the value of the expression to be processed.

[0077] Step S150: Process the value of the expression to be processed according to the processing method corresponding to the call request.

[0078] In some embodiments of the present disclosure, the processing method corresponding to the call request in step S150 can be determined based on the specific requirements of the call request. The processing method determines how the value of the expression to be processed is effectively applied to the program's logical flow after the value is calculated. It can include directly returning the result, executing conditional branches, loop control, exception handling, caching, asynchronous processing, or event triggering.

[0079] The request processing method provided by the present disclosure is capable of improving the probability of completing the calculation of the expression to be processed, reducing the number of abnormal retries, and improving the calculation efficiency when calculating based on the target evaluation order, because the target evaluation order is determined from the different evaluation orders of multiple main Boolean factors according to the size of the normal termination probability of multiple expressions corresponding to the different evaluation orders, thereby improving the efficiency of request processing. When calculating the Boolean values ​​of multiple main Boolean factors, the short-circuit characteristics of the expression to be processed are combined, and the evaluation operation of subsequent main Boolean factors can be skipped when the short-circuit characteristics are met, thereby saving resources. This method solves the problem in the prior art that a fixed calculation order generally ignores the short-circuit characteristics, resulting in unnecessary calculations and wasting resources.

[0080] In some embodiments of the present disclosure, taking the expression to be processed A&&(B||C) as an example, the main Boolean factors may include: the main Boolean factor "A" and the main Boolean factor "(B||C)"; the short-circuit characteristic obtained by step S120 may be "when the Boolean value of the main Boolean factor "A" is calculated first, if the Boolean value of the main Boolean factor "A" is "true", then there is no need to calculate the Boolean value of the main Boolean factor "(B||C)"; when the Boolean value of the main Boolean factor "(B||C)" is calculated first, if the Boolean value of the main Boolean factor "(B||C)" is "true", then there is no need to calculate the Boolean value of the main Boolean factor "A"".

[0081] Assuming that the target evaluation order obtained through step S120 is to first calculate the Boolean value of the main Boolean factor "(B||C)" and then calculate the Boolean value of the main Boolean factor "A", the method of obtaining the Boolean value through step S130 may include: first obtaining the Boolean value of the main Boolean factor "(B||C)"; then judging whether the Boolean value of the main Boolean factor "(B||C)" is "true"; if the Boolean value of the main Boolean factor "(B||C)" is "true", the Boolean value of the main Boolean factor "A" is no longer calculated; if the Boolean value of the main Boolean factor "(B||C)" is "false", the Boolean value of the main Boolean factor "A" needs to be calculated.

[0082] Assuming that the Boolean value of the main Boolean factor "(B||C)" is "false" and the Boolean value of the main Boolean factor "A" is "true", step S140 substitutes these two Boolean values ​​into both sides of the "&&" operator to obtain the value of the expression to be processed "false".

[0083] In some embodiments of the present disclosure, the process of obtaining the target evaluation order of multiple main Boolean factors in step S120 can be specifically as follows: obtaining the target evaluation order of multiple main Boolean factors from the different evaluation orders of the multiple main Boolean factors according to the normal termination probabilities of multiple expressions corresponding to the different evaluation orders; in particular, in order to reduce computing overhead, improve request processing efficiency and improve maintainability, the process can also be specifically as follows: obtaining the target evaluation order of multiple main Boolean factors from the expression-evaluation order mapping. The expression-evaluation order mapping can significantly improve system performance and user experience by calculating and storing the mapping relationship in advance; the mapping relationship stored in the expression-evaluation order mapping can be fixed, or can be updated periodically, or can be updated when related content (such as the expression to be processed, the operating environment, etc.) changes, etc.

[0084] Regarding step S120, the process of obtaining the target evaluation order of the plurality of main Boolean factors is specifically to obtain the target evaluation order of the plurality of main Boolean factors from the different evaluation orders of the plurality of main Boolean factors according to the magnitude of the normal termination probabilities of the plurality of expressions corresponding to the different evaluation orders. In some embodiments of the present disclosure, it may include the following: Figure 2 Steps S121 to S123 are shown.

[0085] Step S121 , obtaining different evaluation orders of multiple main Boolean factors.

[0086] In some embodiments of the present disclosure, step S121 can use a recursive method to obtain different evaluation orders of multiple main Boolean factors. The specific process is: fix one of the multiple main Boolean factors, recursively generate the permutations of the remaining main Boolean factors except the fixed main Boolean factor in the multiple main Boolean factors, and insert the fixed main Boolean factor into each position of the permutation in these permutations; then fix the next main Boolean factor, repeat the recursive generation of the permutation and insertion operations, and so on until the generation of the permutation and insertion operations of the last main Boolean factor in the multiple main Boolean factors are completed.

[0087] Alternatively, a full permutation method is used to obtain different evaluation orders of multiple principal Boolean factors. The specific process is: select one principal Boolean factor from the multiple principal Boolean factors and fix it at the first position of the permutation, and perform full permutation on the remaining principal Boolean factors except the selected principal Boolean factor from the multiple principal Boolean factors; select the next principal Boolean factor from the multiple principal Boolean factors and fix it at the first position of the permutation, repeat the full permutation operation, and so on until the last principal Boolean factor from the multiple principal Boolean factors is fixed at the first position of the permutation and the full permutation operation is completed.

[0088] Alternatively, a dynamic programming method can be used to obtain different evaluation orders for multiple principal Boolean factors. The specific process is as follows: starting with an empty permutation, one principal Boolean factor from the multiple principal Boolean factors is inserted into the empty permutation, resulting in 1! full permutation; based on the 1! full permutation, the next principal Boolean factor from the multiple principal Boolean factors is inserted into each position in the full permutation, resulting in 2! full permutations; for any subsequent principal Boolean factor, this principal Boolean factor is inserted into each position in the permutation of the previous n-1 principal Boolean factors, resulting in n! full permutations, where n-1 is the number of principal Boolean factors currently inserted.

[0089] Step S122: Obtain normal termination probabilities of multiple expressions corresponding to different evaluation orders.

[0090] In some embodiments of the present disclosure, the normal termination probability of the expression corresponding to each evaluation order in different evaluation orders can be obtained respectively through step S122.

[0091] Step S123 , obtaining a target evaluation order from different evaluation orders according to the normal termination probabilities of the multiple expressions.

[0092] In some embodiments of the present disclosure, step S123 may select the evaluation order corresponding to the largest expression termination probability from multiple expression termination probabilities corresponding to different evaluation orders as the target evaluation order, so that the expression to be processed can reach its maximum completion degree.

[0093] By determining the target evaluation order based on the normal termination probabilities of multiple expressions in different evaluation orders through steps S121 to S123, the calculation flexibility of the expressions to be processed and the probability of normal completion of the calculation can be improved, thereby improving the performance and reliability of the calculation of the expressions to be processed.

[0094] For any evaluation order in different evaluation orders, regarding step S122, in some embodiments of the present disclosure, it may include the following: Figure 3 Steps S1221 to S1224 are shown.

[0095] Step S1221 , repeatedly calculating the main Boolean factors in sequence according to the evaluation order and the number of calculations, to obtain the calculation success rate of each main Boolean factor and the Boolean value obtained when the calculation is successful each time.

[0096] In some embodiments of the present disclosure, the number of calculations in step S1221 is the initial number of repetitive calculations for each variable. This number of calculations can be preset and adjusted as needed. The success rate of calculating a particular Boolean factor in step 1221 is the probability of successful calculation of the principal Boolean factor when the principal Boolean factor is repeatedly calculated based on the number of calculations. When a principal Boolean factor is successfully calculated, its Boolean value can be either "true" or "false."

[0097] Step S1222 , performing statistical operations based on the calculation success rate of each main Boolean factor and the Boolean value obtained when the calculation is successful each time, to obtain a result probability distribution of each main Boolean factor.

[0098] In some embodiments of the present disclosure, for any main Boolean factor, the result probability distribution in step S1222 is the Boolean value obtained each time the main Boolean factor is successfully calculated, the probability of the true value corresponding to the Boolean value "true" and the probability of the false value corresponding to the Boolean value "false".

[0099] Step S1223, obtaining the termination probability calculation method corresponding to the evaluation order and the operator.

[0100] In some embodiments of the present disclosure, the operator may cause the result probability distribution of multiple main Boolean factors to have different effects on the normal termination probability of the expression, that is, the termination probability calculation method for the normal termination of the expression is different. Therefore, before calculating the normal termination probability of the expression, the termination probability calculation method may be obtained through step S1223. The termination probability calculation method corresponding to different expressions may be pre-set, or the termination probability calculation method may be obtained based on the evaluation order and the operator. The operator in step S1223 may be an operator for the highest-level logical operation between multiple main Boolean factors in the expression to be processed. When one or several main Boolean factors are in the form of expressions, the operator may also include operators for low-level logical operations within the main Boolean factors.

[0101] Step S1224 , substitute the result probability distribution of each main Boolean factor into the termination probability calculation method to obtain the normal termination probability of the expression corresponding to the evaluation order.

[0102] With two main Boolean factors and For example, the main Boolean factor The calculation success rate is recorded as , the main Boolean factor The calculation success rate is recorded as , the main Boolean factor The true value probability of , the main Boolean factor The true value probability of .

[0103] Two main Boolean factors and When the operator between them is "and (&& or and)", the main Boolean factor is calculated first. Then calculate the main Boolean factor The expression for the normal termination probability is ; Calculate the main Boolean factors first Then calculate the main Boolean factor The expression for the normal termination probability is .

[0104] Two main Boolean factors and When the operator between them is "or (|| or or)", the main Boolean factor is calculated first. Then calculate the main Boolean factor The expression for the normal termination probability is ; Calculate the main Boolean factors first Then calculate the main Boolean factor The expression for the normal termination probability is .

[0105] When not is used in conjunction with other logical operators, such as , will calculate The expression of the normal termination probability formula and exchange; The calculation method is similar.

[0106] NAND negates the result of AND, and NOR negates the result of OR.

[0107] When the expression to be processed contains a combination of multiple operators, the termination probability calculation method can be a combination of the above calculation methods; when a main Boolean factor includes multiple sub-Boolean factors, the calculation success rate and truth value probability of the sub-Boolean factors can be calculated first, and then the normal termination probability of the sub-expression composed of these sub-Boolean factors can be used as the calculation success rate of the main Boolean factor, and the truth value probability of the sub-expression calculated by the truth value probabilities of the sub-Boolean factors can be used as the truth value probability of the main Boolean factor.

[0108] By calculating the normal termination probability of the expression corresponding to the evaluation order through steps S1221 to S1224, it is possible to determine in which evaluation order the probability of successfully calculating the final result of the expression to be processed is the highest.

[0109] For any main Boolean factor, regarding step S1222, in some embodiments of the present disclosure, as Figure 4 As shown, it can be replaced by the following steps:

[0110] According to the Boolean value obtained each time the main Boolean factor is successfully calculated, the number of occurrences of different Boolean values ​​is counted to obtain the true value count and the false value count;

[0111] Multiply the calculation success rate of the main Boolean factor by the true value count and the false value count respectively to obtain the true value expectation and the false value expectation;

[0112] Divide the expected true value and the expected false value by the number of iterations of the main Boolean factor respectively;

[0113] The number of iterations is the sum of the number of calculations and the number of retries when the calculation fails.

[0114] In some embodiments of the present disclosure, two counters can be set for the main Boolean factor, one for recording the number of times the Boolean value is "true" and the other for recording the number of times the Boolean value is "false"; each time the calculation is successful, the result of the Boolean value is checked, if it is "true", the "true" counter is increased by 1; if it is "false", the "false" counter is increased by 1; after the statistics of all successful calculations are completed, the count value of the "true" counter is the true value count, and the count value of the "false" counter is the false value count.

[0115] Multiplying the success rate of the main Boolean factor by the true value count yields the expected true value; multiplying the success rate of the main Boolean factor by the false value count yields the expected false value. Dividing the expected true value by the number of iterations of the main Boolean factor yields the probability of true values ​​in the resulting probability distribution; dividing the expected false value by the number of iterations of the main Boolean factor yields the probability of false values ​​in the resulting probability distribution.

[0116] For the first main Boolean factor corresponding to the evaluation order, regarding step S1221, in some embodiments of the present disclosure, such as Figure 5 As shown, it can be replaced by the following steps:

[0117] Repeatedly calculate the first main Boolean factor according to the number of calculations to obtain the first execution state of each calculation;

[0118] When the first execution state of any calculation is calculation failure, retries are performed until the deadline condition is met, and the first number of retries is obtained;

[0119] Obtain the first iteration number of the first main Boolean factor according to the sum of the number of calculations and the total number of first retries when the calculation fails;

[0120] The calculation success rate of the first main Boolean factor is obtained according to the quotient of the number of states in which calculations are successfully performed in the first execution state and the first number of iterations.

[0121] In some embodiments of the present disclosure, after calculating the first main Boolean factor any time and obtaining the first execution state, it can be determined whether the first execution state is a calculation failure; if the first execution state is a calculation failure, retry until the cutoff condition is met; if the first execution state is a calculation success, repeat the next calculation of the first main Boolean factor until the number of repetitions reaches the number of calculations.

[0122] The first execution state of each calculation can include calculation failure and calculation success. The retry process for any calculation failure is to recalculate the first main Boolean factor upon calculation failure. The total number of first retries upon calculation failure is the sum of the number of first retries upon each calculation failure. The cutoff condition can be that the number of retries exceeds a retry threshold or the calculation is successful.

[0123] For any second main Boolean factor other than the first main Boolean factor corresponding to the evaluation order, regarding step S1221, in some embodiments of the present disclosure, such as Figure 6 As shown, it can be replaced by the following steps:

[0124] Obtaining the number of short-circuit triggering times of the second main Boolean factor being short-circuited according to the calculation status of the main Boolean factor before the second main Boolean factor in the evaluation order;

[0125] Obtaining the execution times of the second main Boolean factor according to the difference between the calculation times and the short-circuit triggering times;

[0126] Repeatedly calculate the second main Boolean factor according to the number of executions to obtain a second execution state of each calculation;

[0127] When the second execution state of any calculation is calculation failure, retry until the deadline is reached, and obtain the second retry number;

[0128] Obtain the second iteration number of the second main Boolean factor according to the sum of the number of calculations and the total number of second retries when the calculation fails;

[0129] The calculation success rate of the second main Boolean factor is obtained according to the quotient of the number of states in which calculations are successfully performed in the second execution state and the second number of iterations.

[0130] In some embodiments of the present disclosure, the method for obtaining the number of short circuit triggering times can be to first determine whether the main Boolean factors that can trigger a short circuit among the main Boolean factors calculated before the second main Boolean factor are one (group) or multiple (groups); if it is one (group), the number of times the main Boolean factor triggers a short circuit can be directly used as the number of short circuit triggering times; if it is multiple (groups), the number of times each (group) of main Boolean factors triggers a short circuit can be obtained separately; then the number of times multiple (groups) of short circuits are triggered is comprehensively processed to obtain the number of short circuit triggering times (such as taking the maximum, minimum or average number of times multiple (groups) of short circuits are triggered as the number of short circuit triggering times).

[0131] The second execution state of each calculation can include calculation failure and calculation success. The retry process for any calculation failure is to recalculate the second main Boolean factor upon calculation failure. The total number of second retries upon calculation failure is the sum of the number of second retries upon each calculation failure. The cutoff condition can be that the number of retries exceeds a retry threshold or the calculation is successful.

[0132] Regarding step S140, in some embodiments of the present disclosure, it may include the following: Figure 7 Steps S141 to S142 are shown.

[0133] Step S141: Obtain operators between multiple main Boolean factors in the expression to be processed.

[0134] In some embodiments of the present disclosure, the operators acquired in step S141 may include one or more of: AND &&, OR ||, NOT !, XOR ^, etc.

[0135] Step S142 : performing operations on the Boolean values ​​of the plurality of main Boolean factors according to the operator.

[0136] Taking A&&B as an example, assuming that the calculation success rate of the main Boolean factor A is , the calculation success rate of the main Boolean factor B is , the false value probability of the main Boolean factor A is , the false value probability of the main Boolean factor B A&&B corresponds to two evaluation orders. Evaluation order 1 is to calculate the main Boolean factor A first and then calculate the main Boolean factor B. Then the normal termination probability of the expression corresponding to this evaluation order is

[0137] ; Evaluation order 2 is to calculate the main Boolean factor B first and then the main Boolean factor A. The probability of normal termination of the expression corresponding to this evaluation order is Since the probability of normal termination of expressions in evaluation order 1 is greater than the probability of normal termination of expressions in evaluation order 2, evaluation order 1 can be used as the target evaluation order.

[0138] Figure 8 A schematic flow chart illustrating the implementation of the request processing method disclosed herein is shown.

[0139] exist Figure 8 In the request processing method shown, the request processing process may include:

[0140] 1. Receive a call request for an expression to be processed.

[0141] 2. In response to a call request, obtain the short-circuit characteristics of the expression to be processed and the different evaluation orders of multiple main Boolean factors.

[0142] 3. Obtain the normal termination probability of the expression corresponding to each evaluation order.

[0143] 4. Obtain the target evaluation order with the highest probability of normal termination of the expression from different evaluation orders.

[0144] 5. Obtain the Boolean values ​​of multiple main Boolean factors according to the target evaluation order combined with the short-circuit characteristic.

[0145] 6. Calculate the expression based on the Boolean values ​​of multiple main Boolean factors to obtain the value of the expression to be processed.

[0146] 7. Process the value of the expression to be processed according to the processing method corresponding to the call request.

[0147] In some embodiments of the present disclosure, this step can store the value in a variable for subsequent use, use the value for conditional judgment to determine the next operation of the program, or use the value as input for further calculation or processing.

[0148] Based on any of the above implementations, the present disclosure also provides a request processing device.

[0149] Figure 9 It is a schematic block diagram of the structure of a request processing device according to an embodiment of the present disclosure.

[0150] like Figure 9 As shown, the request processing device includes:

[0151] The request receiving module 110 is used to receive a call request for an expression to be processed.

[0152] The sequence acquisition module 120 is used to obtain the short-circuit characteristics of the expression to be processed and the target evaluation order of multiple main Boolean factors of the expression to be processed in response to a call request. The target evaluation order is determined from the different evaluation orders of the multiple main Boolean factors according to the size of the normal termination probability of multiple expressions corresponding to different evaluation orders.

[0153] The Boolean value calculation module 130 is configured to obtain Boolean values ​​of a plurality of main Boolean factors according to a target evaluation order combined with a short-circuit characteristic.

[0154] The final value calculation module 140 is used to calculate an expression according to the Boolean values ​​of the plurality of main Boolean factors to obtain a value of the expression to be processed.

[0155] The expression processing module 150 is used to process the value of the expression to be processed according to the processing method corresponding to the call request.

[0156] Each of the above modules can be implemented through computer program modules. Figure 9 The request processing device shown can be implemented based on a computer program module architecture.

[0157] The implementation process of the functions and effects of each module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, and will not be repeated here.

[0158] The execution subject of the request processing method in the specific implementation of the present disclosure can be an electronic device such as a mobile phone, a tablet computer, or a server.

[0159] Therefore, based on any of the above embodiments, the present disclosure further provides an electronic device, which can execute the request processing method of any of the above embodiments of the present disclosure, and the request processing device of any of the above embodiments can be configured on the electronic device.

[0160] Figure 10 FIG. 1 is a schematic block diagram of the structure of an electronic device 1000 equipped with a request processing device according to an embodiment of the present disclosure.

[0161] The hardware structure of the electronic device 1000 can be implemented using a bus architecture. The bus architecture can include any number of interconnecting buses and bridges, depending on the specific application and overall design constraints of the hardware. The bus 1100 connects various circuits including one or more processors 1200, memory 1300, and / or hardware modules. The bus 1100 can also connect various other circuits 1400 such as peripheral devices, voltage regulators, power management circuits, external antennas, etc.

[0162] Bus 1100 may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Component Architecture (EISA) bus. Buses can be classified as address buses, data buses, control buses, and the like. For ease of illustration, this figure shows only one connecting line, but this does not imply that there is only one bus or only one type of bus.

[0163] The present disclosure also provides a readable storage medium having a computer program stored therein, which is used to implement the above-mentioned method when the computer program is executed by a processor. "Readable storage medium" can be any device that can contain, store, communicate, propagate or transmit a program for use in an instruction execution system, device or equipment or in combination with these instruction execution systems, devices or equipment. More specific examples of readable storage media include the following: an electrical connection portion with one or more wirings (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and editable read-only memory (EPROM or flash memory), an optical fiber device, and a portable read-only memory (CDROM), etc.

[0164] The present disclosure also provides a computer program product. The method of the present disclosure can be implemented in whole or in part using software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instructions are loaded and executed, the process or function of the present disclosure is performed in whole or in part.

[0165] A computer program or instruction can be stored in a readable storage medium or transferred from one readable storage medium to another. For example, the computer program or instruction can be transferred from one website, computer, server, or data center to another website, computer, server, or data center via wired or wireless means. The readable storage medium can be any accessible medium or a data storage device such as a server or data center that integrates one or more accessible media. The accessible medium can be a magnetic medium such as a floppy disk, hard disk, or magnetic tape; an optical medium such as a digital video disk; or a semiconductor medium such as a solid-state drive. The computer-readable storage medium can be a volatile or non-volatile storage medium, or can include both volatile and non-volatile types of storage media.

[0166] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0167] The present disclosure is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present disclosure. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0168] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0169] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 The steps for the function specified in one or more boxes.

[0170] In the description of this specification, the description with reference to the terms "one embodiment / method", "some embodiments / methods", "example", "specific example", or "some examples" means that the specific features, structures, or characteristics described in conjunction with the embodiment / method or example are included in at least one embodiment / method or example of the present disclosure. In this specification, the schematic expressions of the above terms do not necessarily refer to the same embodiment / method or example. Moreover, the specific features, structures, or characteristics described may be combined in a suitable manner in any one or more embodiments / methods or examples. In addition, those skilled in the art may combine and combine different embodiments / methods or examples described in this specification and the features of different embodiments / methods or examples, unless they are contradictory.

[0171] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features being referred to. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. Throughout the present disclosure, "plurality" means at least two, such as two, three, etc., unless otherwise specifically defined.

[0172] Those skilled in the art will appreciate that the above embodiments are merely intended to clearly illustrate the present disclosure and are not intended to limit the scope of the present disclosure. Other changes or modifications may be made based on the above disclosure, and such changes or modifications are still within the scope of the present disclosure.

Claims

1. A request processing method, characterized in that: include: Receive a call request for an expression to be processed; In response to the call request, obtaining the short-circuit characteristic of the expression to be processed and the target evaluation order of multiple main Boolean factors of the expression to be processed, including: obtaining the target evaluation order of the multiple main Boolean factors from an expression-evaluation order mapping; or obtaining the target evaluation order of the multiple main Boolean factors from different evaluation orders of the multiple main Boolean factors according to the magnitude of normal termination probabilities of multiple expressions corresponding to the different evaluation orders; Obtaining Boolean values ​​of the plurality of main Boolean factors according to the target evaluation order in combination with the short-circuit characteristic; Perform expression calculation according to the Boolean values ​​of the plurality of main Boolean factors to obtain the value of the expression to be processed; and Processing the value of the expression to be processed according to the processing method corresponding to the call request; The step of obtaining the target evaluation order of the plurality of main Boolean factors from the different evaluation orders of the plurality of main Boolean factors according to the normal termination probabilities of the plurality of expressions corresponding to the different evaluation orders includes: Obtain different evaluation orders of the multiple main Boolean factors; obtain normal termination probabilities of multiple expressions corresponding to the different evaluation orders; and obtain the target evaluation order from the different evaluation orders according to the sizes of the normal termination probabilities of the multiple expressions.

2. The request processing method according to claim 1, wherein: The obtaining of different evaluation orders of the plurality of main Boolean factors includes: Using a recursive method to obtain different evaluation orders of the plurality of main Boolean factors; or, Use a full permutation method to obtain different evaluation orders of the plurality of principal Boolean factors; or, A dynamic programming method is used to obtain different evaluation orders of the plurality of main Boolean factors.

3. The request processing method according to claim 1 or 2, characterized in that: For any evaluation order, obtaining normal termination probabilities of multiple expressions corresponding to the different evaluation orders includes: The main Boolean factors are repeatedly calculated in sequence according to the evaluation order and the number of calculations, and the calculation success rate of each main Boolean factor and the Boolean value obtained when the calculation is successful each time are obtained; Performing statistical operations based on the calculation success rate of each main Boolean factor and the Boolean value obtained when the calculation is successful each time, to obtain a result probability distribution of each main Boolean factor; Obtain the termination probability calculation method corresponding to the evaluation order and operator; and Substituting the result probability distribution of each main Boolean factor into the termination probability calculation method to obtain the normal termination probability of the expression corresponding to the evaluation order; The operator is an operator between the multiple main Boolean factors in the expression to be processed.

4. The request processing method according to claim 3, wherein: For any main Boolean factor, performing statistical operations based on the calculation success rate of each main Boolean factor and the Boolean value obtained when the calculation is successful each time includes: According to the Boolean value obtained each time the main Boolean factor is successfully calculated, the number of occurrences of different Boolean values ​​is counted to obtain the true value count and the false value count; Multiplying the calculation success rate of the main Boolean factor by the true value count and the false value count respectively to obtain the true value expectation and the false value expectation; and Dividing the true value expectation and the false value expectation by the number of iterations of the main Boolean factor respectively; The number of iterations is the sum of the number of calculations and the number of retries when the calculation fails.

5. The request processing method according to claim 3, wherein: For the first main Boolean factor corresponding to the evaluation order, repeatedly calculating the main Boolean factors in sequence according to the evaluation order and the number of calculations to obtain a calculation success rate of each main Boolean factor and a Boolean value obtained when the calculation is successful each time, including: Repeatedly calculating the first main Boolean factor according to the number of calculations to obtain a first execution state of each calculation; When the first execution state of any calculation is calculation failure, retries are performed until the deadline condition is met, and the first number of retries is obtained; Obtaining the first iteration number of the first main Boolean factor according to the sum of the number of calculations and the total number of first retries when the calculation fails; and The calculation success rate of the first main Boolean factor is obtained according to the quotient of the number of states in which calculation is successfully completed in the first execution state and the first number of iterations.

6. The request processing method according to claim 3, wherein: For any second main Boolean factor other than the first main Boolean factor corresponding to the evaluation order, the main Boolean factors are repeatedly calculated in sequence according to the evaluation order and the number of calculations to obtain a calculation success rate of each main Boolean factor and a Boolean value obtained when the calculation is successful each time, including: Obtaining the number of short-circuit triggering times of the second main Boolean factor being short-circuited according to the calculation status of the main Boolean factor before the second main Boolean factor in the evaluation order; Obtaining the execution count of the second main Boolean factor according to the difference between the calculation count and the short circuit trigger count; Repeatedly calculating the second main Boolean factor according to the number of executions to obtain a second execution state of each calculation; When the second execution state of any calculation is calculation failure, retry until the deadline is reached, and obtain the second retry number; Obtaining a second iteration number of the second main Boolean factor according to the sum of the number of calculations and the total number of second retries when the calculation fails; and The calculation success rate of the second main Boolean factor is obtained according to the quotient of the number of states in which calculation is successfully completed in the second execution state and the second number of iterations.

7. The request processing method according to claim 6, characterized in that: The cut-off conditions include: The number of retries is greater than the retry threshold or the calculation succeeds.

8. The request processing method according to claim 1 or 2, characterized in that: The performing expression calculation according to the Boolean values ​​of the plurality of main Boolean factors includes: Obtaining an operator between a plurality of main Boolean factors in the expression to be processed; and The Boolean values ​​of the plurality of main Boolean factors are operated according to the operator.

9. An electronic device, characterized in that: include: a memory storing execution instructions; as well as A processor, wherein the processor executes the execution instruction stored in the memory, so that the processor executes the request processing method according to any one of claims 1 to 8.

10. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the request processing method according to any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Data processing method, electronic device, storage medium and program product

    CN118051650A

  • Method and apparatus for optimizing boolean expression evaluation

    US20070174830A1