Business request processing method, system and electronic device based on rule matching

By splitting and reorganizing rules, batch matching of business requests and determination of target rule links are realized, which solves the problem of large memory usage in rule matching and improves system performance.

CN118427409BActive Publication Date: 2024-10-01HANGZHOU PINGPONG INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410894726.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-04
Publication Date
2024-10-01
Estimated Expiration
2044-07-04

AI Technical Summary

Technical Problem

The existing technology occupies a large amount of memory space during the rule matching process, resulting in high resource overhead, and fails to effectively solve the cache occupation problem, affecting dynamic performance.

Method used

By splitting and reorganizing multiple configuration rules, the business requests are matched in batches, the sub-rules of each attribute in the corresponding rule set are determined, and the target rule is determined in the preset rule list according to the logical order between the sub-rules. link, reducing dependence on cache and memory space usage.

Benefits of technology

It realizes batch matching of multiple attributes at the same time, reduces the time and memory space occupied for finding target rules, and improves dynamic performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118427409B_ABST
    Figure CN118427409B_ABST
Patent Text Reader

Abstract

The present application relates to a business request processing method, system and electronic device based on rule matching, which receives a business request, wherein the business request carries multiple attributes; performs batch matching processing on the multiple attributes based on multiple rule sets, and determines the sub-rules that each attribute hits in the corresponding rule set; determines a target rule link in a preset rule chain table according to the multiple hit sub-rules and the logical order between the sub-rules; executes the business request according to the rule indicated by the target rule link; reduces the dependence on the cache, reduces the occupancy of memory space, and also saves the time of finding the target rule.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer applications, and in particular to a method, system and electronic device for processing business requests based on rule matching. Background Art

[0002] When a business request enters the system, it is necessary to find a rule that matches the business request to execute the business request. Usually, a business request contains multiple attributes, and a rule also contains multiple conditional expressions. Different business requests have different attribute values, and the matching rules are also different.

[0003] The traditional rule matching solution is to match multiple attributes of a business request with each rule one by one. Only when all conditional expressions of a rule are matched can the rule be considered matched. Among them, every time the system receives a business request, it needs to open a cache space for its hit result.

[0004] However, the dynamic performance of the traditional solution is poor. For this reason, the relevant technology proposes improvements. First, multiple conditional expressions of a rule are split, and multiple attributes of the business request are directly matched with multiple conditional expressions to determine the hit conditional expression, and the final rule is determined based on the hit conditional expression. Among them, each time the system receives a business request, it needs to open up a cache space for its hit result. If the hit result of the current business request is the same as the historical hit result, the cache space of the historical hit result is reused, that is, the calculated conditions are put into the cache to avoid repeated calculations, which improves the dynamic performance.

[0005] However, the cache takes up a lot of memory space and has high resource overhead. There is no effective solution to the problem that rule matching in related technologies requires a lot of memory space. Summary of the invention

[0006] In this embodiment, a method, system and electronic device for processing a business request based on rule matching are provided to solve the problem in the related art that rule matching requires occupying a large amount of memory space.

[0007] In a first aspect, a method for processing a service request based on rule matching is provided in this embodiment, including:

[0008] Receiving a service request, wherein the service request carries multiple attributes;

[0009] Perform batch matching processing on the multiple attributes based on multiple rule sets to determine the sub-rules matched by each attribute in the corresponding rule set;

[0010] Determine a target rule link in a preset rule chain table according to a plurality of hit sub-rules and a logical order between the sub-rules;

[0011] The service request is executed according to the rule indicated by the target rule link.

[0012] In some of the embodiments, batch matching processing is performed on the multiple attributes based on multiple rule sets to determine the sub-rules that each of the attributes matches in the corresponding rule sets, including:

[0013] According to the data structure type of each rule set, the attribute value of the attribute is compared with the value or value range of each sub-rule in the corresponding rule set;

[0014] If the attribute value of the attribute is the same as or falls within a value range of a sub-rule in the corresponding rule set, it is determined that the attribute hits the sub-rule in the corresponding rule set.

[0015] In some of the embodiments, comparing the attribute value of the attribute with the value or value range of each sub-rule in the corresponding rule set includes:

[0016] When the data structure type of the rule set is a set or a map, a target sub-rule that meets the conditions is determined in the corresponding rule set according to a hash algorithm; or,

[0017] When the data structure type of the rule set is a multi-mode string, determining a target sub-rule that meets the conditions in the corresponding rule set according to the multi-mode string matching algorithm; or,

[0018] When the data structure type of the rule set is a segment tree, starting from the root node of the corresponding rule set, the following steps are executed cyclically until the current search node completely contains the attribute value of the attribute:

[0019] Compare the attribute value with the interval value of the current search node;

[0020] If the attribute value is less than the minimum interval value of the current search node, the left subtree of the current search node is used as the next search node;

[0021] If the attribute value is greater than the maximum interval value of the current search node, the right subtree of the current search node is used as the next search node.

[0022] In some embodiments, according to a plurality of hit sub-rules and the logical order between the sub-rules, determining a target rule link in a preset rule chain table includes:

[0023] determining relative computational costs between the sub-rules;

[0024] Starting from the root node, the sub-rules are arranged in order based on their relative computational costs from low to high;

[0025] The arranged sub-rules are ANDed one by one to obtain the target rule link.

[0026] In some embodiments, determining the relative computational cost between the sub-rules includes:

[0027] Determine the business scenario corresponding to the business request and the primary calculation cost of each of the sub-rules;

[0028] The relative computing costs between the sub-rules are determined according to the business scenario and the primary computing costs of the sub-rules.

[0029] In some embodiments, before batch matching the multiple attributes based on multiple rule sets to determine the sub-rules matched by each attribute in the corresponding rule set, the method further includes:

[0030] Get multiple configuration rules, each configuration rule includes multiple conditional expressions;

[0031] Splitting the multiple conditional expressions to obtain multiple sub-rules;

[0032] The multiple sub-rules are classified and combined according to the field names and operators to obtain multiple rule sets of different types.

[0033] In some embodiments, the multiple conditional expressions are split to obtain multiple sub-rules, including:

[0034] Splitting the multiple conditional expressions into multiple minimum unit conditional expressions, wherein the minimum unit conditional expression includes a unique variable, a unique operator, and a unique expected value or a unique expected value interval;

[0035] The sub-rule is determined according to the minimum unit conditional expression.

[0036] In some embodiments, the multiple sub-rules are classified and combined according to the field name and the operator to obtain multiple different types of rule sets, including:

[0037] Grouping sub-rules containing the same field names and operators into the same rule set; and,

[0038] According to the type of the operator in each of the sub-rules, a data structure of the rule set is determined, wherein the data structure of the rule set includes at least one of the following: a set, a map, a multi-mode string, and a segment tree.

[0039] In some embodiments, after the plurality of sub-rules are classified and combined according to the field names and operators to obtain a plurality of rule sets of different types, the method further comprises:

[0040] Creating a rule node based on each of the sub-rules;

[0041] Connecting the rule nodes according to the logical order between the sub-rules to obtain multiple rule links;

[0042] The rule chain list is generated according to the multiple rule links.

[0043] In a second aspect, a service request processing system based on rule matching is provided in this embodiment, including:

[0044] A receiving module, used for receiving a service request, wherein the service request carries multiple attributes;

[0045] A matching module, used for performing batch matching processing on the multiple attributes based on multiple rule sets, and determining a sub-rule matched by each attribute in a corresponding rule set;

[0046] A determination module, used to determine a target rule link in a preset rule chain table according to a plurality of hit sub-rules and a logical order between the sub-rules;

[0047] An execution module is used to execute the service request according to the rule indicated by the target rule link.

[0048] According to a third aspect, an electronic device is provided in this embodiment, comprising a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the rule-matching-based business request processing method described in the first aspect above.

[0049] The above-mentioned rule-matching-based business request processing method, system and electronic device can process business requests by using a rule set obtained by splitting and reorganizing multiple configuration rules, which can play a role in batch matching multiple attributes at the same time; and when the sub-rules that each attribute hits in the corresponding rule set are determined, the target rule is found according to the logical order between the multiple hit sub-rules, which can reduce the dependence on the cache, reduce the occupancy of memory space, and also save the time of finding the target rule.

[0050] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0052] Figure 1 A schematic diagram of an application environment of a method for processing a business request based on rule matching in an embodiment;

[0053] Figure 2 A flowchart of a method for processing a business request based on rule matching in one embodiment;

[0054] Figure 3 A schematic diagram of the structure of a rule chain table in one embodiment;

[0055] Figure 4 A flowchart of a method for determining a target regular link in one embodiment;

[0056] Figure 5 A flowchart of a configuration rule loading method in one embodiment;

[0057] Figure 6 A schematic diagram of the structure of a business request processing system based on rule matching in one embodiment;

[0058] Figure 7 is a schematic structural diagram of an electronic device in one embodiment;

[0059] Figure 8 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0060] In order to more clearly understand the purpose, technical solutions and advantages of the present application, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments.

[0061] Unless otherwise defined, the technical terms or scientific terms involved in this application shall have the general meaning understood by people with general skills in the technical field to which this application belongs. The words "one", "a", "the", "these" and the like in this application do not indicate a quantitative limitation, and they may be singular or plural. The terms "include", "comprise", "have" and any variants thereof involved in this application are intended to cover non-exclusive inclusions; for example, a process, method and system, product or device comprising a series of steps or modules (units) is not limited to the listed steps or modules (units), but may include unlisted steps or modules (units), or may include other steps or modules (units) inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there may be three relationships, for example, "A and / or B" may mean: A exists alone, A and B exist at the same time, and B exists alone. Generally, the character " / " indicates that the objects associated with each other are in an "or" relationship. The terms "first", "second", "third", etc. in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.

[0062] The service request processing method based on rule matching provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Among them, the terminal 101 communicates with the server 102 through the network. The data storage system 103 can store the data that the server 102 needs to process. The data storage system 103 can be integrated on the server 102, or it can be placed on the cloud or other network servers. Among them, the terminal 101 can be but not limited to various personal computers, laptops, smart phones, tablets, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 102 can be implemented with an independent server or a server cluster consisting of multiple servers.

[0063] The rule matching scheme of related technologies needs to converge the condition set in order to give full play to its dynamic performance advantages. For example, in some business scenarios, there may be only 10 objects, so the condition set only needs to pre-embed 10 possible results. However, if there are millions of objects, the condition set needs to pre-embed millions of possible results, which will invalidate the advantages of the scheme. It is understandable that the scheme needs to cache each condition hit result. When one or some attributes of the business request itself cannot be enumerated, a large amount of memory will be occupied for caching, and the hit rate is not high, which makes it impossible to give full play to its dynamic performance advantages.

[0064] Moreover, due to the high memory usage, the system had to be deployed in an independent cluster, which made the deployment structure cumbersome. More importantly, each time a rule match was executed, the system had to communicate with the Drools cluster over the network, which was an additional network interaction link for lightweight gateway applications and would cause a large overhead.

[0065] Based on the analysis of the above problems, in one embodiment, Figure 2 As shown, a business request processing method based on rule matching (hereinafter referred to as the business request processing method) is provided, and the method is applied to Figure 1 The server in the example is used as an example to illustrate the process, including the following steps:

[0066] Step S201: receiving a service request, wherein the service request carries multiple attributes.

[0067] In this step, the server, as the executor of the business request processing method, is responsible for responding to the business request initiated by the client. When a user triggers an order, payment, or withdrawal operation on the client, the client will generate information containing the user information and the operation, which will be packaged into a request and sent to the server for processing. Different operations correspond to different business scenarios. Among them, the withdrawal operation belongs to the billing scenario. Taking the billing scenario as an example, the business request encapsulation format is as follows:

[0068] {clientId:0001

[0069] scene:withdraw

[0070] regTime:100000340000

[0071] kycName:Company A

[0072] amount:100000;

[0073] }.

[0074] In this embodiment, the business request is encapsulated in a key-value pair format, where the key represents the attribute and the value represents the attribute value. The meaning of each attribute in the above business request is: clientId represents the user ID, scene represents the business scene, regTime represents the registration time, kycName represents the company name, and amount represents the amount. Among them, the attribute value withdraw represents withdrawal.

[0075] Step S202: batch matching is performed on multiple attributes based on multiple rule sets to determine the sub-rules matched by each attribute in the corresponding rule set.

[0076] In this step, for different business requests in the same business scenario, different rules will be used to execute the business requests due to differences in their attribute values. These different rules are defined as configuration rules, and the rule set is generated by the preset configuration rules. Each configuration rule contains multiple conditional expressions, which are connected by logical operators (and, or). The configuration rules can be split into minimum unit conditional expressions, which are defined as sub-rules, and then these sub-rules constitute a rule set. In this way, each rule set contains multiple sub-rules of the same type. Among them, the minimum unit conditional expression contains a unique variable, a unique operator, and a unique expected value or a unique expected value interval.

[0077] Still taking the billing scenario as an example, there are the following three configuration rules.

[0078] Configuration rule 1:

[0079] when

[0080] clientId='00001'and scene='withdraw' and regTime>=100000000000 andregTime<=200000000000 and kycName contains 'Company A'

[0081] then

[0082] fee=amount×0.01.

[0083] Configuration rule 2:

[0084] when

[0085] clientId='00001'and scene= 'payout' and regTime>=100000000000 andregTime<=200000000000 and kycName contains 'Company A'

[0086] then

[0087] fee=amount×0.02.

[0088] Configuration rule 3:

[0089] when

[0090] clientId='00001'and scene='withdraw' and regTime>=100000000000 andregTime<=250000000000 and kycName contains 'Company B'

[0091] then

[0092] fee=amount×0.03.

[0093] In the above configuration rules, when the conditions after when are met, the operation after then is executed, that is, the fee is calculated according to a certain billing formula.

[0094] By splitting and reorganizing the above configuration rules, we can get the following rule set:

[0095] Rule set 1: clientId={00001};

[0096] Rule set 2: scene = {withdraw, payout};

[0097] Rule set 3: regTime = {(100000000000, +limit), (-limit, 200000000000), (-limit, 250000000000)};

[0098] Rule set 4: kycName contains = {'Company A', 'Company B'}.

[0099] When batch matching multiple attributes based on multiple rule sets, first find the corresponding rule set for each attribute. Since these corresponding rule sets are independent of each other, they can synchronously match the corresponding attributes and each determine the sub-rules hit by the corresponding attributes. In this way, the effect of batch matching multiple attributes using multiple rule sets is achieved.

[0100] Step S203: determining a target rule link in a preset rule chain table according to a plurality of matched sub-rules and the logical order between the sub-rules.

[0101] In this step, after determining the hit results of the business request for the sub-rules in each rule set, it is necessary to determine the target rule based on the hit sub-rules and execute the business request based on the target rule. When determining the target rule based on the hit sub-rules, it is necessary to compare the hit sub-rules with the expressions in the configuration rules one by one, and cache the comparison results. If the hit sub-rules completely contain a certain configuration rule, it can be determined that the behavior corresponding to the configuration rule needs to be executed. There are two problems here: first, when the number of configuration rules is large, the computational complexity of the comparison process itself exceeds the rule matching complexity for the business request, and this step will take a long time; second, the comparison results will take up a lot of memory for caching.

[0102] To solve this problem, this embodiment provides a preset rule chain table. Starting from the root node of the rule chain table, nodes identical to the hit sub-rules are searched according to the logical order between the sub-rules, and finally the target rule chain is determined according to the chain formed by these nodes. Taking the above three configuration rules as an example, the rule chain table is as follows: Figure 3 As shown, a node is created for each sub-rule as follows:

[0103] 1.clientId=00001;

[0104] 2.scene =withdraw;

[0105] 3.scene=payout;

[0106] 4.regTime>=100000000000;

[0107] 5.regTime<=200000000000;

[0108] 6.regTime<=250000000000;

[0109] 7.kycName contains 'Company A';

[0110] 8.kycName contains 'Company B';

[0111] 9. fee = amount × 0.01;

[0112] 10.fee=amount×0.02;

[0113] 11.fee=amount × 0.02.

[0114] A rule linked list is a storage logical representation of configuration rules. It creates a rule node (referred to as a node) for each sub-rule in the configuration rule, connects each rule node in the logical order between the sub-rules, and obtains multiple rule links. These multiple rule links constitute a rule linked list. The logical order is the expression of the order in which the nodes are arranged according to the relative computational cost, which reflects the relative computational cost between the nodes.

[0115] Determining the target rule link in the rule chain is a logical judgment process. Placing the judgment with low computational cost at the front end of the logic chain can filter out most of the unnecessary in-depth calculations at the earliest possible stage, that is, terminating unnecessary calculations in advance, reducing the reliance on the cache, and saving time for finding the target rule. For example, when processing a logical expression such as A&&B&&C, if the result of A is false, then no matter what the values ​​of B and C are, the result of the entire expression has been determined to be false, so the judgment of B and C can be skipped directly. It can be understood that the key to saving judgment costs is to first determine the computational cost of each sub-rule, and then determine the judgment order based on the computational cost. For another example, in the identity authentication scenario, when the business request has the two attributes of user login information and password, it is more efficient to first determine whether the user is logged in (low-cost operation) than to directly verify the password (high-cost operation), because users who are not logged in do not need to perform subsequent password verification.

[0116] Step S204: Execute the service request according to the rule indicated by the target rule link.

[0117] In this step, taking the above-mentioned billing scenario and service request as an example, the service request hits the sub-rules in each rule set and the sub-rule corresponding nodes are as follows:

[0118] 1.clientId=00001;

[0119] 2.scene =withdraw;

[0120] 4.regTime>=100000000000;

[0121] 5.regTime<=200000000000;

[0122] 7.kycName contains 'Company A'.

[0123] The target rule link containing the above node is link 1, then the operation 9.fee = amount × 0.01 in link 1 is activated, and the final billing result is 100000 × 0.01. In actual operation, it only takes 600 microseconds to filter out the required billing rules from the existing rule set of tens of millions for billing, and it can run on a single machine with only 4G memory.

[0124] In the above steps S201 to S204, the business request is processed by using a rule set obtained by splitting and reorganizing multiple configuration rules, which can achieve batch matching of multiple attributes at the same time; and after determining the sub-rules that each attribute hits in the corresponding rule set, the target rule is found according to the logical order between the multiple hit sub-rules, which can reduce the dependence on the cache, reduce the occupancy of memory space, and also save the time for finding the target rule.

[0125] In one embodiment, batch matching processing is performed on multiple attributes based on multiple rule sets to determine the sub-rules that each attribute hits in the corresponding rule set, including: comparing the attribute value of the attribute with the value or value range of each sub-rule in the corresponding rule set according to the data structure type of each rule set; if the attribute value of the attribute is the same as the value of a sub-rule in the corresponding rule set or falls within the value range, it is determined that the attribute hits the sub-rule in the corresponding rule set.

[0126] For example, if the attribute clientId:0001 in the business request is the same as the value 0001 in rule set 1, then the attribute is determined to match the sub-rule clientId=00001 in rule set 1. For another example, if the attribute regTime:100000340000 in the business request falls within the value range (1000000000000, +limit) and (-limit, 200000000000) in rule set 3, then the attribute is determined to match the sub-rule regTime>=100000000000 and regTime<=200000000000 in rule set 3.

[0127] In some embodiments, comparing the attribute value of an attribute with the value or value range of each sub-rule in the corresponding rule set can be achieved by the following method.

[0128] In one embodiment, when the data structure type of the rule set is a set or a map, the target sub - rule that meets the conditions is determined in the corresponding rule set according to the hash algorithm. For example, if the sub - rule has an equal operator, the hash algorithm can be used for optimization. Through mutual exclusion, the value that meets the equal condition is found, and all other results in the same batch do not meet the condition. Specifically, sub - rules such as clientId = 00001, scene = withdraw, and scene = payout can be stored in a map structure.

[0129] In one embodiment, when the data structure type of the rule set is a multi - pattern string, the target sub - rule that meets the conditions is determined in the corresponding rule set according to the multi - pattern string matching algorithm. For example, if the sub - rule has a string contains operator or an is - empty operator, the Aho - Corasick automaton can be used, and its complexity is O(1). Specifically, sub - rules such as kycName contains 'Company A' and kycName contains 'Company B' can be stored in a multi - pattern string (Aho - Corasick automaton) structure.

[0130] In one embodiment, when the data structure type of the rule set is a segment tree, starting from the root node of the corresponding rule set, the following steps are repeatedly executed until the current search node completely contains the attribute value of the attribute:

[0131] Compare the attribute value with the interval value of the current search node;

[0132] If the attribute value is less than the minimum interval value of the current search node, take the left subtree of the current search node as the next search node;

[0133] If the attribute value is greater than the maximum interval value of the current search node, take the right subtree of the current search node as the next search node.

[0134] For example, if the sub - rule has an interval judgment, the segment tree structure can be used for optimization, and its complexity is O(log(n)). The logical order is arranged after the operator with a complexity of O(1), and it degrades to O(log(N)) only when the condition list does not contain an operator with a complexity of O(1). Specifically, sub - rules such as regTime >= 100000000000, regTime <= 200000000000, and regTime <= 250000000000 can be stored in the segment tree structure. Refer to Figure 3 , nodes 4, 5, and 6 form a segment tree, 5 is the left subtree of 4, and 6 is the right subtree of 4.

[0135] In one embodiment, as Figure 4As shown, according to multiple hit sub-rules and the logical order between the sub-rules, determining the target rule link in the preset rule chain table includes the following steps:

[0136] Step S401, determining the relative computational cost between the sub-rules.

[0137] You can first determine the business scenario corresponding to the business request and the primary computational cost of each sub-rule; then determine the relative computational cost between the sub-rules based on the business scenario and the primary computational cost of each sub-rule. The primary computational complexity depends on the operator, and the computational cost of the computational operator is higher than that of string inclusion. In some business scenarios, the computational cost of string inclusion is higher than that of string equality. Therefore, if multiple sub-rules include computational operators, string inclusion operators, and string equality operators, the string inclusion operator and the string equality operator are preferentially arranged before the computational operator, and between the string inclusion operator and the string equality operator, and the order of the two is adjusted according to the computational cost caused by the two in the business scenario.

[0138] Step S402, starting from the root node, arrange the sub-rules in order based on the relative computational cost from low to high.

[0139] Step S403, AND the arranged sub-rules one by one to obtain the target rule link.

[0140] The above embodiment introduces rule matching, and the following embodiment will introduce rule loading.

[0141] In one embodiment, Figure 5 As shown, before the above step S201 or step S202, the method further includes:

[0142] Step S501: Acquire multiple configuration rules, each configuration rule including multiple conditional expressions.

[0143] Step S502: split the multiple conditional expressions to obtain multiple sub-rules.

[0144] In this step, multiple conditional expressions may be split into multiple minimum unit conditional expressions, and sub-rules may be determined according to the minimum unit conditional expressions, wherein the minimum unit conditional expressions include a unique variable, a unique operator, and a unique expected value or a unique expected value interval.

[0145] Step S503: Classify and combine the multiple sub-rules according to the field names and operators to obtain multiple rule sets of different types.

[0146] In this step, sub-rules with the same field names and operators can be grouped into the same rule set; and, according to the types of operators in each sub-rule, the data structure of the rule set is determined, where the data structure of the rule set includes at least one of the following: set, map, multi-pattern string, and segment tree.

[0147] When the data structure type of the rule set is a set or a map, the target sub-rule that meets the conditions is determined in the corresponding rule set according to the hash algorithm. For example, if the sub-rule has an equal operator, the hash algorithm can be used for optimization. Through mutual exclusion, the value that meets the equal condition is found, and all other batch results do not meet the condition. Specifically, sub-rules such as clientId = 00001, scene = withdraw, and scene = payout can be stored in a map structure.

[0148] When the data structure type of the rule set is a multi-pattern string, the target sub-rule that meets the conditions is determined in the corresponding rule set according to the multi-pattern string matching algorithm. For example, if the sub-rule has a string containment operator or an is-empty operator, the Aho-Corasick automaton can be used, and its complexity is O(1). Specifically, sub-rules such as kycName contains 'Company A' and kycName contains 'Company B' can be stored in a multi-pattern string (Aho-Corasick automaton) structure.

[0149] When the data structure type of the rule set is a segment tree, starting from the root node of the corresponding rule set, the following steps are looped until the current search node completely contains the attribute value of the attribute:

[0150] Compare the attribute value with the interval value of the current search node;

[0151] If the attribute value is less than the minimum interval value of the current search node, the left subtree of the current search node is used as the next search node;

[0152] If the attribute value is greater than the maximum interval value of the current search node, the right subtree of the current search node is used as the next search node.

[0153] For example, if the sub-rule has an interval judgment, the segment tree structure can be used for optimization, and its complexity is O(log(n)). The logical order is placed after the operator with a complexity of O(1), and it degrades to O(log(N)) only when the condition list does not contain an operator with a complexity of O(1). Specifically, sub-rules such as regTime >= 100000000000, regTime <= 200000000000, and regTime <= 250000000000 can be stored in the segment tree structure. Reference Figure 3, nodes 4, 5, and 6 form a segment tree, 5 is the left subtree of 4, and 6 is the right subtree of 4.

[0154] In one embodiment, after the above step S503, the method further includes: creating a rule node based on each sub-rule; connecting each rule node according to the logical order between each sub-rule to obtain multiple rule links; and generating a rule linked list according to the multiple rule links.

[0155] In this embodiment, the relative computational cost between each sub-rule is first determined; starting from the root node, each sub-rule is arranged in order based on the relative computational cost from low to high; each arranged sub-rule is connected to obtain multiple rule links; multiple rule links constitute a rule chain list. Regarding the relative computational cost between each sub-rule, the business scenario corresponding to the business request and the primary computational cost of each sub-rule can be determined first; then, based on the business scenario and the primary computational cost of each sub-rule, the relative computational cost between each sub-rule is determined. The primary computational complexity depends on the operator, and the computational cost of the computational operator is higher than that of string inclusion. In some business scenarios, the computational cost of string inclusion is higher than that of string equality. Therefore, if multiple sub-rules include a computational operator, a string inclusion operator, and a string equality operator, the string inclusion operator and the string equality operator are preferentially arranged in front of the computational operator, and between the string inclusion operator and the string equality operator, the order of the two is adjusted according to the computational cost caused by the two in the business scenario.

[0156] It should be noted that the steps shown in the above process or the flowchart in the attached figure can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here. For example, the service request processing method is executed according to the following steps:

[0157] Step S1, obtaining multiple configuration rules, each configuration rule including multiple conditional expressions;

[0158] Step S2, splitting the multiple conditional expressions to obtain multiple sub-rules;

[0159] Step S3, classifying and combining the multiple sub-rules according to the field names and operators to obtain multiple rule sets of different types;

[0160] Step S4, receiving a service request, wherein the service request carries multiple attributes;

[0161] Step S5, performing batch matching processing on multiple attributes based on multiple rule sets, and determining the sub-rules matched by each attribute in the corresponding rule set;

[0162] Step S6, determining a target rule link in a preset rule chain table according to the multiple hit sub-rules and the logical order between the sub-rules;

[0163] Step S7: Execute the service request according to the rule indicated by the target rule link.

[0164] In one embodiment, based on the inventive concept similar to the above-mentioned service request processing method, Figure 6 A business request processing system based on rule matching is provided, comprising: a receiving module 601 , a matching module 602 , a determining module 603 and an executing module 604 .

[0165] In summary, the receiving module 601 is used to receive a service request, wherein the service request carries multiple attributes.

[0166] The matching module 602 is used to perform batch matching processing on multiple attributes based on multiple rule sets, and determine the sub-rules that each attribute matches in the corresponding rule set.

[0167] The determination module 603 is used to determine the target rule link in the preset rule chain table according to multiple hit sub-rules and the logical order between the sub-rules.

[0168] The execution module 604 is used to execute the service request according to the rule indicated by the target rule link.

[0169] The above modules may be functional modules or program modules, and may be implemented by software or hardware. For modules implemented by hardware, the above modules may be located in the same processor; or the above modules may be located in different processors in any combination. It should be noted that the specific examples in this embodiment may refer to the examples described in the above embodiments and the optional implementation modes, and will not be described in detail in this embodiment.

[0170] In this embodiment, an electronic device is also provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any of the above-mentioned rule-matching-based service request processing method embodiments.

[0171] In one embodiment, a hardware structure block diagram of an electronic device is provided. Figure 7 As shown, the electronic device may include one or more ( Figure 7Only one is shown in the figure) processor 701 and memory 702 for storing data, wherein the processor 701 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA. The above electronic device may also include a transmission device 703 and an input and output device 704 for communication functions. It can be understood by those skilled in the art that Figure 7 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 7 More or fewer components as shown, or with Figure 1 Different configurations shown.

[0172] The memory 702 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the business request processing method based on rule matching in this embodiment. The processor 701 executes various functional applications and data processing by running the computer program stored in the memory 702, that is, to implement the above method. The memory 702 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 702 may further include a memory remotely arranged relative to the processor 701, and these remote memories may be connected to the electronic device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0173] The transmission device 703 is used to receive or send data via a network. The above network includes a wireless network provided by a communication provider of the electronic device. In one example, the transmission device 703 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 703 can be a radio frequency (Radio Frequency, referred to as RF) module, which is used to communicate with the Internet wirelessly.

[0174] In this embodiment, the processor may be configured to perform the following steps through a computer program:

[0175] receiving a service request, wherein the service request carries multiple attributes;

[0176] Perform batch matching on multiple attributes based on multiple rule sets, and determine the sub-rules that each attribute matches in the corresponding rule set;

[0177] According to the multiple hit sub-rules and the logical order between the sub-rules, determine the target rule link in the preset rule chain table;

[0178] Execute the service request according to the rule indicated by the target rule link.

[0179] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation modes, and will not be repeated in this embodiment.

[0180] In addition, in combination with the service request processing method based on rule matching provided in the above embodiments, a storage medium can also be provided in this embodiment to implement the method. The storage medium stores a computer program; when the computer program is executed by the processor, any service request processing method based on rule matching in the above embodiments is implemented.

[0181] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 8 As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store configuration rule data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a business request processing method based on rule matching is implemented.

[0182] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0183] It should be understood that the specific embodiments described above are only used to explain the relevant application, rather than to limit it. According to the embodiments provided in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the protection scope of this application.

[0184] Obviously, the drawings are only some examples or embodiments of the present application. For ordinary technicians in the field, the present application can also be applied to other similar situations based on these drawings without creative work. In addition, it is understandable that although the work done in this development process may be complicated and lengthy, for ordinary technicians in the field, certain changes in design, manufacturing or production based on the technical content disclosed in this application are only conventional technical means and should not be regarded as insufficient content disclosed in this application.

[0185] The term "embodiment" in this application refers to a specific feature, structure or characteristic described in conjunction with the embodiment that can be included in at least one embodiment of the present application. The appearance of this phrase in various locations in the specification does not necessarily mean the same embodiment, nor does it mean that it is mutually exclusive with other embodiments and is independent or optional. It is clearly or implicitly understood by those of ordinary skill in the art that the embodiments described in this application can be combined with other embodiments without conflict.

[0186] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. The acquisition, storage, use, and processing of data involved in the embodiments of this application are in compliance with the relevant provisions of national laws and regulations.

[0187] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0188] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of patent protection. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the scope of protection of the present application. Therefore, the scope of protection of the present application shall be subject to the attached claims.

Claims

1. A business request processing method based on rule matching, characterized in that: include: receiving a service request, wherein the service request carries a plurality of attributes; Perform batch matching processing on the multiple attributes based on multiple rule sets, and determine the sub-rules matched by each attribute in the corresponding rule set; Determine a target rule link in a preset rule chain table according to a plurality of hit sub-rules and a logical order between the sub-rules; Execute the service request according to the rule indicated by the target rule link; Among them, the logical order corresponds to the order in which the sub-rules are arranged from low to high according to relative computing cost; the relative computing cost is determined according to the business scenario corresponding to the business request and the primary computing cost of each sub-rule; the primary computing cost of each sub-rule depends on the operator, wherein the primary computing cost of the operation operator is higher than that of string inclusion, and the primary computing cost of string inclusion is higher than that of string equality, and the operation operator includes a range operation operator.

2. The method for processing business requests based on rule matching according to claim 1, characterized in that: Batch matching is performed on the multiple attributes based on multiple rule sets to determine the sub-rules matched by each attribute in the corresponding rule set, including: According to the data structure type of each rule set, the attribute value of the attribute is compared with the value or value range of each sub-rule in the corresponding rule set; If the attribute value of the attribute is the same as or falls within a value range of a sub-rule in the corresponding rule set, it is determined that the attribute hits the sub-rule in the corresponding rule set.

3. The method for processing business requests based on rule matching according to claim 2, characterized in that: Comparing the attribute value of the attribute with the value or value range of each sub-rule in the corresponding rule set includes: When the data structure type of the rule set is a set or a map, a target sub-rule that meets the conditions is determined in the corresponding rule set according to a hash algorithm; or, When the data structure type of the rule set is a multi-mode string, determining a target sub-rule that meets the conditions in the corresponding rule set according to the multi-mode string matching algorithm; or, When the data structure type of the rule set is a segment tree, starting from the root node of the corresponding rule set, the following steps are executed cyclically until the current search node completely contains the attribute value of the attribute: Compare the attribute value with the interval value of the current search node; If the attribute value is less than the minimum interval value of the current search node, the left subtree of the current search node is used as the next search node; If the attribute value is greater than the maximum interval value of the current search node, the right subtree of the current search node is used as the next search node.

4. The method for processing business requests based on rule matching according to claim 1, characterized in that: According to the multiple hit sub-rules and the logical order between the sub-rules, a target rule link is determined in a preset rule chain table, including: determining relative computational costs between the sub-rules; Starting from the root node, the sub-rules are arranged in order based on their relative computational costs from low to high; The arranged sub-rules are ANDed one by one to obtain the target rule link.

5. The method for processing business requests based on rule matching according to claim 4, characterized in that: Determining the relative computational costs between the sub-rules, including: Determine the business scenario corresponding to the business request and the primary calculation cost of each of the sub-rules; The relative computing costs between the sub-rules are determined according to the business scenario and the primary computing costs of the sub-rules.

6. The method for processing business requests based on rule matching according to claim 1, characterized in that: Before batch matching the multiple attributes based on multiple rule sets to determine the sub-rules matched by each attribute in the corresponding rule set, the method further includes: Get multiple configuration rules, each configuration rule includes multiple conditional expressions; Splitting the multiple conditional expressions to obtain multiple sub-rules; The multiple sub-rules are classified and combined according to the field names and operators to obtain multiple rule sets of different types.

7. The method for processing business requests based on rule matching according to claim 6, characterized in that: The multiple conditional expressions are split to obtain multiple sub-rules, including: Splitting the multiple conditional expressions into multiple minimum unit conditional expressions, wherein the minimum unit conditional expression includes a unique variable, a unique operator, and a unique expected value or a unique expected value interval; The sub-rule is determined according to the minimum unit conditional expression.

8. The method for processing business requests based on rule matching according to claim 6, characterized in that: The multiple sub-rules are classified and combined according to the field names and operators to obtain multiple different types of rule sets, including: Grouping sub-rules containing the same field names and operators into the same rule set; and, According to the type of the operator in each of the sub-rules, a data structure of the rule set is determined, wherein the data structure of the rule set includes at least one of the following: a set, a map, a multi-mode string, and a segment tree.

9. The method for processing business requests based on rule matching according to claim 6, characterized in that: After the multiple sub-rules are classified and combined according to the field names and operators to obtain multiple rule sets of different types, the method further includes: Creating a rule node based on each of the sub-rules; Connecting the rule nodes according to the logical order between the sub-rules to obtain multiple rule links; The rule chain list is generated according to the multiple rule links.

10. A business request processing system based on rule matching, characterized in that: include: A receiving module, used for receiving a service request, wherein the service request carries multiple attributes; A matching module, used for performing batch matching processing on the multiple attributes based on multiple rule sets, and determining a sub-rule matched by each attribute in a corresponding rule set; A determination module, used to determine a target rule link in a preset rule chain table according to a plurality of hit sub-rules and a logical order between the sub-rules; An execution module, configured to execute the service request according to the rule indicated by the target rule link; Among them, the logical order corresponds to the order in which the sub-rules are arranged from low to high according to relative computing cost; the relative computing cost is determined according to the business scenario corresponding to the business request and the primary computing cost of each sub-rule; the primary computing cost of each sub-rule depends on the operator, wherein the primary computing cost of the operation operator is higher than that of string inclusion, and the primary computing cost of string inclusion is higher than that of string equality, and the operation operator includes a range operation operator.

11. An electronic device comprising a memory and a processor, characterized in that: The memory stores a computer program, and the processor is configured to run the computer program to execute the service request processing method based on rule matching according to any one of claims 1 to 9.