CN115129324A - Rule matching method, device, electronic equipment and medium - Google Patents

Rule matching method, device, electronic equipment and medium Download PDF

Info

Publication number
CN115129324A
CN115129324A CN202210901406.1A CN202210901406A CN115129324A CN 115129324 A CN115129324 A CN 115129324A CN 202210901406 A CN202210901406 A CN 202210901406A CN 115129324 A CN115129324 A CN 115129324A
Authority
CN
China
Prior art keywords
rule
register
index
target
event
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202210901406.1A
Other languages
Chinese (zh)
Other versions
CN115129324B (en
Inventor
龙安
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Topsec Technology Co Ltd
Beijing Topsec Network Security Technology Co Ltd
Beijing Topsec Software Co Ltd
Original Assignee
Beijing Topsec Technology Co Ltd
Beijing Topsec Network Security Technology Co Ltd
Beijing Topsec Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Topsec Technology Co Ltd, Beijing Topsec Network Security Technology Co Ltd, Beijing Topsec Software Co Ltd filed Critical Beijing Topsec Technology Co Ltd
Priority to CN202210901406.1A priority Critical patent/CN115129324B/en
Publication of CN115129324A publication Critical patent/CN115129324A/en
Application granted granted Critical
Publication of CN115129324B publication Critical patent/CN115129324B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/441Register allocation; Assignment of physical memory space to logical memory space

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present disclosure relates to the field of data matching technologies, and in particular, to a rule matching method, apparatus, electronic device, and medium, in which a corresponding target event status register is determined according to at least one attribute value of an event to be matched; aiming at a target event state register, judging whether a first rule register matched with the target event state register exists in at least one rule register, wherein each rule register corresponds to a preset rule one by one, and the preset rule is composed of at least one index item value supported by a rule engine; if yes, determining the first rule register as a target rule register of the event to be matched; and determining a target rule corresponding to the event to be matched based on the target rule register. By adopting the method, the efficiency of matching the rules is improved.

Description

Rule matching method, device, electronic equipment and medium
Technical Field
The present disclosure relates to the field of data matching technologies, and in particular, to a rule matching method, an apparatus, an electronic device, and a medium.
Background
The rule engine is developed according to the inference engine, is a component embedded in an application program, and can separate a business decision from the application program and write the business decision by using a predefined semantic module, and specifically, when a developer uses the rule engine in the program, the developer creates a rule engine object, loads or replaces a plurality of rules into the rule engine, and sends an event to be processed by the plurality of rules to the rule engine so as to trigger and execute corresponding operations.
In the prior art, after all attribute values of an event are received simultaneously, matching is performed among a plurality of index items included in a plurality of rules, and when an index item matching with a certain attribute value of the event exists, a rule corresponding to the index item is determined as a rule that is possibly used for executing the received event, so as to obtain a plurality of initial preset rules, and then the plurality of initial preset rules are matched with the attribute values of the event, so as to determine a rule that is finally used for executing the event.
However, in the prior art, since all attribute values of an event need to be received simultaneously, and after a plurality of initial preset rules are determined, the plurality of initial preset rules are further matched with the attribute values of the event, so that there may be a plurality of repetitions of matching the same attribute value, thereby reducing the efficiency of matching the rules.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a rule matching method, apparatus, electronic device and medium for solving the above technical problems.
In a first aspect of the embodiments of the present disclosure, a rule matching method is provided, where the method includes:
determining a corresponding target event state register according to at least one attribute value of an event to be matched;
aiming at the target event state register, judging whether a first rule register matched with the target event state register exists in at least one rule register, wherein each rule register corresponds to a preset rule one by one, and the preset rule is composed of at least one index item value supported by a rule engine;
if so, determining the first rule register as a target rule register of the event to be matched;
and determining a target rule corresponding to the event to be matched based on the target rule register.
In one embodiment, the determining a corresponding target event status register according to at least one attribute value of an event to be matched includes:
for each index item value in all index item values included in at least one preset rule, establishing a corresponding index table according to the index item corresponding to the index item value included in each preset rule, wherein the index item corresponding to each index table is associated with the preset rule containing the index item value corresponding to the index item;
and determining a target event state register according to the time sequence of receiving at least one attribute value and according to each attribute value corresponding to the event to be matched and at least one index table in sequence.
In an embodiment, the determining a target event status register according to the time sequence of receiving at least one attribute value and according to each attribute value corresponding to the event to be matched and at least one index table in sequence includes:
sequentially acquiring each attribute value corresponding to the event to be matched according to the time sequence;
for each attribute value, determining a target index table in at least one index table;
determining at least one initial preset rule corresponding to the attribute value according to the target index table;
when the attribute value is determined to be a main index item of any initial preset rule in at least one initial preset rule, establishing an event state sub-register corresponding to the attribute value, and marking;
and determining the target event state register according to the event state sub-registers corresponding to all the attribute values of the event to be matched.
In one embodiment, the determining, for the target event status register, whether there is a first rule register matching the target event status register in the at least one rule register further includes:
acquiring all the preset rules;
and determining a corresponding rule register according to each preset rule.
In one embodiment, the determining, for each of the preset rules, a corresponding rule register includes:
sorting all index items corresponding to all index item values included in each preset rule, and setting priority;
after setting the priority, determining the logical relationship among the index item values according to a preset logical condition, wherein the logical relationship is an OR relationship or an AND relationship;
after the logical relationship among the index item values is determined, at least one main index item is determined in each index item corresponding to each index item value included in the preset rule, and a corresponding rule register is created for the preset rule according to a preset marking condition.
In an embodiment, the sorting the index items corresponding to the index item values included in each preset rule and setting the priority includes:
according to preset sorting conditions, sorting all index items corresponding to all index item values included in each preset rule;
after the sorting of the index items is completed, determining the priority of the index items according to the sorting order of the index items.
In one embodiment, the determining the logical relationship between the index entry values according to a preset logical condition includes:
obtaining at least one index item value corresponding to each index item, and when at least two index item values belong to the same index item, determining that the logical relationship between the at least two index item values belonging to the same index item is an OR relationship;
when at least two index item values corresponding to different index items belong to the same preset group, determining that the logical relationship between the at least two index item values belonging to the same preset group is an OR relationship; or
And if the logical relationship between the index item values corresponding to the index items is not determined to be the AND relationship, determining that the logical relationship between at least two index item values is the AND relationship.
In a second aspect of the embodiments of the present disclosure, there is provided a rule matching apparatus, including:
the target event state register determining module is used for determining a corresponding target event state register according to at least one attribute value of the event to be matched;
the judging module is used for judging whether a first rule register matched with the target event state register exists in at least one rule register aiming at the target event state register, wherein each rule register corresponds to a preset rule one by one, and the preset rule is composed of at least one index item value supported by a rule engine;
a target rule register determining module, configured to determine, if yes, the first rule register as a target rule register of the event to be matched;
and the target rule determining module is used for determining a target rule corresponding to the event to be matched based on the target rule register.
In a third aspect of the embodiments of the present disclosure, there is provided an electronic device, including:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement a method as in any one of the first aspects.
In a fourth aspect, the embodiments of the present disclosure provide a computer-readable storage medium, on which a computer program is stored, which when executed by a processor, implements the method according to any one of the first aspect.
Compared with the prior art, the technical scheme provided by the embodiment of the disclosure has the following advantages:
the present disclosure provides a rule matching method, apparatus, electronic device and medium, determining a corresponding target event status register according to at least one attribute value of an event to be matched; aiming at a target event state register, judging whether a first rule register matched with the target event state register exists in at least one rule register, wherein each rule register corresponds to a preset rule one by one, and the preset rule is composed of at least one index item value supported by a rule engine; if yes, determining the first rule register as a target rule register of the event to be matched; and determining a target rule corresponding to the event to be matched based on the target rule register. Therefore, the target event state register corresponding to the event to be matched is matched with the rule register corresponding to one or more preset rules at one time, so that the target rule register matched with the target event state register is determined, and the target rule matched with the target event state register is obtained according to the target rule register, so that the problem that in the prior art, a plurality of initial preset rules are matched with the attribute value of the event, the same attribute value needs to be matched repeatedly for many times is solved, and the efficiency of the matching rule is improved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the disclosure.
In order to more clearly illustrate the embodiments or technical solutions in the prior art of the present disclosure, the drawings used in the embodiments or technical solutions in the prior art description will be briefly described below, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without inventive labor.
Fig. 1 is a schematic flow chart of a rule matching method according to an embodiment of the present disclosure;
fig. 2 is a schematic flow chart of another rule matching method provided in the embodiment of the present disclosure;
fig. 3 is a schematic structural diagram of a rule matching apparatus according to an embodiment of the present disclosure;
fig. 4 is an internal structure diagram of an electronic device provided in an embodiment of the present disclosure.
Detailed Description
In order that the above objects, features and advantages of the present disclosure may be more clearly understood, aspects of the present disclosure will be further described below. It should be noted that, in the case of no conflict, the embodiments and features in the embodiments of the present disclosure may be combined with each other.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present disclosure, but the present disclosure may be practiced in other ways than those described herein; it is to be understood that the embodiments disclosed in the specification are only a few embodiments of the present disclosure, and not all embodiments.
The terms first, second and the like in the description and in the claims of the present disclosure are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It will be appreciated that the data so used may be interchanged under appropriate circumstances such that embodiments of the disclosure may be practiced other than those illustrated or described herein, and that the objects identified as "first," "second," etc. are generally a class of objects and do not limit the number of objects, e.g., a first object may be one or more. In addition, "and/or" in the specification and claims means at least one of connected objects, a character "/", and generally means that the former and latter related objects are in an "or" relationship.
The rule engine is developed according to an inference engine, is a component embedded in an application program, and can separate a business decision from the application program and write the business decision by using a predefined semantic module.
In the prior art, after all attribute values of an event are received simultaneously, matching is performed in a plurality of index items included in a plurality of rules, when an index item matching with a certain attribute value of the event exists, a rule corresponding to the index item is determined to be possibly used for executing the received event, so as to obtain a plurality of initial preset rules, and then the plurality of initial preset rules are matched with the attribute values of the event, so as to determine a rule finally used for executing the event.
However, in the prior art, since all attribute values of an event need to be received simultaneously, and after a plurality of initial preset rules are determined, the plurality of initial preset rules are further matched with the attribute values of the event, so that there may be a plurality of repetitions of matching the same attribute value, thereby reducing the efficiency of matching the rules.
Based on this, the present disclosure provides a rule matching method, apparatus, electronic device and medium, determining a corresponding target event status register according to at least one attribute value of an event to be matched; aiming at a target event state register, judging whether a first rule register matched with the target event state register exists in at least one rule register, wherein each rule register corresponds to a preset rule one by one, and the preset rule is composed of at least one index item value supported by a rule engine; if yes, determining the first rule register as a target rule register of the event to be matched; and determining a target rule corresponding to the event to be matched based on the target rule register. Therefore, the target event state register corresponding to the event to be matched is matched with the rule register corresponding to one or more preset rules at one time, so that the target rule register matched with the target event state register is determined, and the target rule matched with the target event state register is obtained according to the target rule register, so that the problem that in the prior art, a plurality of initial preset rules are matched with the attribute value of the event, the same attribute value needs to be matched repeatedly for many times is solved, and the efficiency of the matching rule is improved.
In an embodiment, as shown in fig. 1, fig. 1 is a schematic flow chart of a rule matching method provided in an embodiment of the present disclosure, which specifically includes the following steps:
s11: and determining a corresponding target event state register according to at least one attribute value of the event to be matched.
The attribute value refers to information describing features and attributes of events to be matched, one or more attribute values exist for each event to be matched, and the event to be matched is exemplarily "lie XX17 years old, and is a high school student. "wherein," lie XX, age 17, and high school student "are attribute values of the event to be matched, respectively, but not limited thereto, and the disclosure is not particularly limited, and may be set by a person skilled in the art according to the actual situation.
The target event status register is determined according to one or more attribute values of the event to be matched, the target rule corresponding to the event to be matched can be determined more quickly and directly by using the target event status register, and the target event status registers corresponding to the events to be matched are stored in the same event status storage module.
Specifically, after an event to be matched is received, one or more attribute values of the event to be matched are obtained, and a target event state register corresponding to the event to be matched is determined according to the one or more attribute values.
Optionally, on the basis of the above embodiments, in some embodiments of the present disclosure, one executable manner of S11 is:
and S11-A, establishing a corresponding index table according to the index item corresponding to the index item value included by each preset rule for each index item value in all the index item values included by at least one preset rule.
The index entry corresponding to each index table is associated with a preset rule containing the index entry value corresponding to the index entry, that is, each index table can be associated with a plurality of preset rules at the same time. Illustratively, for preset rule 1: "li X19 years old", preset rule 2: "20 years", wherein a preset rule 1 includes an index value of "19 years", and a preset rule 2 includes an index value of "20 years", and the index values corresponding to the index values of "19 years" and "20 years" are all "ages", then the preset rule 1 and the preset rule 2 are respectively associated with an index table corresponding to the index value of "age", but not limited thereto, and the disclosure is not particularly limited, and can be set by a person skilled in the art according to practical situations.
For example, for each index entry value in all index entry values included in one or more preset rules, it may be determined whether the index entry value exists in the index entry value included in each preset rule, so as to establish the index table, and for the manner of establishing the index table, reference may be made to the prior art, such as an array, a tree, or a hash table, and details are not repeated here.
And S11-B, determining a target event state register according to the time sequence of receiving at least one attribute value and each attribute value corresponding to the event to be matched and at least one index table in sequence.
Optionally, on the basis of the above embodiments, in some embodiments of the present disclosure, one executable manner of S11-B is:
S11-B1: and sequentially acquiring each attribute value corresponding to the event to be matched according to the time sequence.
S11-B2: for each attribute value, a target index table is determined in at least one index table.
In an exemplary embodiment, the target index table is an index table corresponding to an index entry corresponding to each attribute value, and when the attribute value is "19 years old", the corresponding index entry is "age", and the target index table is an index table corresponding to the index entry "age", but the disclosure is not limited thereto, and a person skilled in the art may set the target index table according to actual situations.
S11-B3: and determining at least one initial preset rule corresponding to the attribute value according to the target index table.
The initial preset rule refers to a preset rule which can be matched with an event to be matched.
S11-B4: and when the attribute value is determined to be the main index item of any initial preset rule in at least one initial preset rule, establishing an event state sub-register corresponding to the attribute value, and marking.
S11-B5: and determining a target event state register according to the event state sub-registers corresponding to all attribute values of the event to be matched.
Specifically, according to the time sequence of receiving the attribute values of the events to be matched, each attribute value corresponding to the events to be matched is sequentially obtained, according to each attribute value, a target index table corresponding to the attribute value is determined in a plurality of established index tables, one or more preset rules associated with the target index table are determined as one or more initial preset rules corresponding to the attribute value by using the target index table, when the current attribute value is determined as the main index item of any one of the one or more initial preset rules, a corresponding event state sub-register is established for the attribute value at the moment, marking is carried out, a flag bit is added to the event state sub-register corresponding to the attribute value, then after the current attribute value is determined, one or more initial preset rules corresponding to the next attribute value are determined, and whether the one or more initial preset rules are the main index items of the one or more initial preset rules is judged, and establishing or updating the corresponding event state sub-register until all the attribute values corresponding to the event to be matched determine the corresponding event state sub-register, thereby obtaining the target event state register.
For example, the event status sub-register corresponding to the attribute value may add a flag bit by adding a1 flag bit, but the disclosure is not limited thereto, and a person skilled in the art may set the flag bit according to actual situations.
After all the attribute values corresponding to the event to be matched determine the corresponding event state sub-registers, the obtaining of the target event state register may be performed by updating flag bits of registers corresponding to other attribute values in the event state sub-register corresponding to the first attribute value when it is determined that the other attribute values are also the main index items of the same initial preset rule after the event state sub-register corresponding to the first attribute value is established for the first attribute value, so as to obtain the target event state register.
It should be noted that, in some embodiments of the present disclosure, each attribute value corresponding to an event to be matched may also be sequentially obtained according to a sequence supported by the rule engine to sort the plurality of index items, for example, a logical sequence of event attributes corresponding to the index items, and after obtaining the attribute values, the S11-B2 to S11-B5 are executed, and a specific execution process is described with reference to the above embodiments, and is not described herein again.
In this way, in the embodiment, by establishing the target event status register corresponding to the event to be matched, the target rule matched with the event to be matched can be determined at one time through the target event status register, so that the event to be matched or one or more attribute values corresponding to the event to be matched are prevented from being used for matching the corresponding target rule, and the efficiency of matching the rule is improved.
S12: and aiming at the target event state register, judging whether a first rule register matched with the target event state register exists in at least one rule register.
Each rule register corresponds to a preset rule one by one, and the preset rule is composed of at least one index entry value supported by a rule engine.
Specifically, when a target event state register corresponding to an event to be matched is determined, the target event state register is matched with one or more rule registers corresponding to one or more preset rules, and whether a first rule register consistent with the target event state register exists is judged.
For example, it is possible to determine whether each flag bit corresponding to the matching target event status register and the rule register is consistent, but the disclosure is not limited thereto, and a person skilled in the art may set the flag bits according to the actual situation.
Optionally, on the basis of the above embodiment, in some embodiments of the present disclosure, as shown in fig. 2, before performing S12, the method further includes:
s21: and acquiring all preset rules.
S22: for each preset rule, a corresponding rule register is determined.
Specifically, after all the preset rules are acquired, a rule register corresponding to each preset rule is determined for each preset rule.
Optionally, on the basis of the foregoing embodiments, in some embodiments of the present disclosure, an execution manner of S22 may be:
and S22-A, sorting the index items corresponding to the index item values included in each preset rule and setting the priority.
Specifically, each index item corresponding to each index item value included in each preset rule is determined, the determined index items are sorted, and after the index items are sorted, priority is set for each index item.
Optionally, on the basis of the foregoing embodiments, in some embodiments of the present disclosure, one implementation manner of S22-a may be:
S22-A1: and according to a preset sorting condition, sorting the index items corresponding to the index item values included in each preset rule.
S22-A2: after the ordering of the index items is completed, the priority of each index item is determined according to the ordering order of each index item.
The preset ordering condition may be an ordering order of the index items supported by the rule engine on the logic, and the ordering order may be, for example, an established fact, an axiom, or a human limitation; or counting the number of rules with the same value of the index items in the index items, and sorting the index items according to the number from few to many; the resource size to be consumed may also be sorted in the order from small to large when verifying the index entry and the event attribute value to be matched, or sorted in the order from small to large according to the size of the value range included in each index entry, but is not limited thereto, and the present disclosure is not particularly limited, and may be set by those skilled in the art according to the actual situation.
In the case of a plurality of index items having the same priority, the order of the plurality of index items may be set manually.
Specifically, according to a preset sorting condition, sorting the index items corresponding to the index item values included in each preset rule, and after sorting, setting the index items arranged at the previous preset position to have higher priority according to the sorting order of the index items, and for the value of the preset position, the disclosure is not particularly limited, and those skilled in the art can set the value according to actual conditions.
For example, if each index entry corresponding to each index entry value of the preset rule is "index entry a, index entry B, index entry C, and index entry D", and is "index entry C, index entry a, index entry B, and index entry D" after being sorted according to the preset sorting condition, the index entry C, index entry a, index entry B, and index entry D "with the highest priority is set to be arranged at the preset position in front of the index entry C > index entry a > index entry B > index entry D, and so on, the priority order is set to be index entry C > index entry a > index entry B > index entry D.
And S22-B, determining the logic relation among the index item values according to the preset logic condition after setting the priority.
Wherein the logical relationship is an or relationship or an and relationship.
Optionally, on the basis of the foregoing embodiments, in some embodiments of the present disclosure, one implementation manner of S22-B may be:
S22-B1: and obtaining at least one index item value corresponding to each index item, and determining that the logical relationship between the at least two index item values belonging to the same index item is an OR relationship when the at least two index item values belong to the same index item.
Specifically, one or more index item values corresponding to each index item are obtained, and when it is determined that a plurality of index item values belong to the same index item, the logical relationship between the plurality of index item values belonging to the same index item is determined to be an or relationship.
For example, if the index a has an index value 1, an index value 2, and an index value 3, the logical relationship between the index value 1, the index value 2, and the index value 3 belonging to the index a may be determined to be an or relationship, but is not limited thereto, and the disclosure is not limited thereto, and may be set by those skilled in the art according to the actual situation.
Optionally, on the basis of the foregoing embodiments, in some embodiments of the present disclosure, another execution manner of S22-B may be:
S22-B2: when at least two index item values corresponding to different index items belong to the same preset group, determining that the logical relationship between the at least two index item values belonging to the same preset group is an OR relationship.
The preset group is set to aim at different index items, and index item values corresponding to a plurality of different index items are set to belong to the same group, so that one efficiency in the matching rule is improved.
Specifically, one or more index item values corresponding to each index item are obtained, and when it is determined that a plurality of index item values corresponding to different index items belong to the same preset group, the logical relationship between the plurality of index item values belonging to the same preset group is determined to be an or relationship.
For example, the index a has an index value of 1, the index B has an index value of 2, and when the index value 1 and the index value 2 belong to the same preset group, the logical relationship between the index value 1 and the index value 2 may be determined to be an or relationship, but the disclosure is not limited thereto, and a person skilled in the art may set the logical relationship according to actual situations.
Optionally, on the basis of the foregoing embodiments, in some embodiments of the present disclosure, another execution manner of S22-B may be:
S22-B3: and if the logical relationship between the index item values corresponding to the index items is not determined to be the AND relationship, determining that the logical relationship between at least two index item values is the AND relationship.
Specifically, if it is determined that the logical relationship between the index values corresponding to the index items is not an exclusive-nor relationship, that is, there is no case where a plurality of index item values belong to the same index item, or a plurality of index item values corresponding to different index items belong to the same preset group, it is determined that the logical relationship between the index values corresponding to the index items is an exclusive-nor relationship.
And S22-C, after the logic relation among the index item values is determined, at least one main index item is determined in each index item corresponding to each index item value included in the preset rule, and a corresponding rule register is created for the preset rule according to the preset marking condition.
The preset flag condition is used to determine a register flag bit of an index entry corresponding to an index entry value, and for example, the preset flag condition includes: when the index entry has a corresponding index value, the index entry value corresponding to the index entry does not belong to the preset group, or the index entry value corresponding to the index entry belongs to the first index value of the preset group, the register flag bit corresponding to the index entry value may be 1, but is not limited thereto.
Specifically, after determining the logical relationship between the index entry values, one or more corresponding main index entries are determined in the index entries corresponding to the index entry values included in the preset rule, and when a preset marking condition is met, a flag bit of a register corresponding to the index entry value is marked, so that a rule register corresponding to the preset rule is created.
Therefore, the rule register corresponding to the preset rule is created, when the event to be matched is matched with the target rule, the rule register can be used for matching, and the efficiency of matching the rule is improved in the mode.
S13: and if the first rule register matched with the target event state register is judged to exist in the at least one rule register, determining the first rule register as the target rule register of the event to be matched.
S14: and determining a target rule corresponding to the event to be matched based on the target rule register.
Specifically, one or more rule registers corresponding to one or more preset rules are matched with a target event state register, when it is determined that a first rule register consistent with the target event state register exists in the one or more rule registers, the first rule register is determined as a target rule register of an event to be matched, and a target rule corresponding to the event to be matched is matched according to the target rule register.
For example, the rule having the same identification information as the target rule may be determined to be the target rule by identification information corresponding to the target rule register, such as RID, but is not limited thereto.
It should be noted that, the target event status register and the target rule register corresponding to the event to be matched have the same storage mode, and may be uncompressed registers, or compressed registers, that is, all flag bits of 0 in the registers are removed, and the compressed registers are utilized, so as to improve the matching efficiency.
Thus, the embodiment of the disclosure determines the corresponding target event status register according to at least one attribute value of the event to be matched; aiming at a target event state register, judging whether a first rule register matched with the target event state register exists in at least one rule register, wherein each rule register corresponds to a preset rule one by one, and the preset rule is composed of at least one index item value supported by a rule engine; if yes, determining the first rule register as a target rule register of the event to be matched; and determining a target rule corresponding to the event to be matched based on the target rule register. Therefore, the target event state register corresponding to the event to be matched is matched with the rule register corresponding to one or more preset rules at one time, so that the target rule register matched with the target event state register is determined, and the target rule matched with the target event state register is obtained according to the target rule register, so that the problem that in the prior art, a plurality of initial preset rules are matched with the attribute value of the event, the same attribute value needs to be matched repeatedly for many times is solved, and the efficiency of the matching rule is improved.
The embodiment of the disclosure further provides a rule matching device, which is used for executing any one of the rule matching methods provided by the embodiments, and has the corresponding beneficial effects of the rule matching method.
Fig. 3 is a rule matching apparatus provided in an embodiment of the present disclosure, including: and the target event state register determining module 11 is configured to determine a corresponding target event state register according to at least one attribute value of the event to be matched.
The determining module 12 is configured to determine, for the target event status register, whether a first rule register matching the target event status register exists in at least one rule register, where each rule register corresponds to a preset rule one to one, and the preset rule is composed of at least one index entry value supported by the rule engine.
And a target rule register determining module 13, configured to determine, if yes, the first rule register as a target rule register of the event to be matched.
And the target rule determining module 14 is configured to determine a target rule corresponding to the event to be matched based on the target rule register.
In the above embodiment, the target event status register determining module 11 is specifically configured to, for each index entry value in all index entry values included in at least one preset rule, establish a corresponding index table according to an index entry corresponding to the index entry value included in each preset rule, where the index entry corresponding to each index table is associated with the preset rule including the index entry corresponding to the index entry. And according to the time sequence of receiving at least one attribute value, determining a target event state register according to each attribute value corresponding to the event to be matched and at least one index table in sequence.
In the above embodiment, the target event status register determining module 11 is further specifically configured to sequentially obtain each attribute value corresponding to an event to be matched according to a time sequence; for each attribute value, a target index table is determined in at least one index table. And determining at least one initial preset rule corresponding to the attribute value according to the target index table. And when the attribute value is determined to be the main index item of any initial preset rule in at least one initial preset rule, establishing an event state sub-register corresponding to the attribute value, and marking. And determining a target event state register according to the event state sub-registers corresponding to all the attribute values of the event to be matched.
In the above embodiment, the apparatus further includes: the rule register determining module is used for acquiring all preset rules; for each preset rule, a corresponding rule register is determined.
In the foregoing embodiment, the rule register determining module is specifically configured to sort the index items corresponding to the index item values included in each preset rule, and set a priority. After setting the priority, determining the logical relationship between the index item values according to a preset logical condition, wherein the logical relationship is an OR relationship or an AND relationship. After the logical relationship among the index item values is determined, at least one main index item is determined in each index item corresponding to each index item value included in the preset rule, and a corresponding rule register is created for the preset rule according to the preset marking condition.
In the above embodiment, the rule register determining module is further specifically configured to sort, according to a preset sorting condition, each index item corresponding to each index item value included in each preset rule; after the ordering of the index items is completed, determining the priority of the index items according to the ordering sequence of the index items.
In the foregoing embodiment, the rule register determining module is specifically further configured to obtain at least one index entry value corresponding to each index entry, and when at least two index entry values belong to the same index entry, determine that a logical relationship between the at least two index entry values belonging to the same index entry is an or relationship. When at least two index item values corresponding to different index items belong to the same preset group, determining that the logical relationship between the at least two index item values belonging to the same preset group is an OR relationship; or if the logical relationship between the index item values corresponding to the index items is not determined to be the AND relationship, determining that the logical relationship between the at least two index item values is the AND relationship.
Thus, the target event status register determining module 11 is used for determining a corresponding target event status register according to at least one attribute value of the event to be matched; the judging module 12 is configured to judge, for the target event status register, whether a first rule register matching the target event status register exists in at least one rule register, where each rule register corresponds to a preset rule one to one, and the preset rule is composed of at least one index entry value supported by a rule engine; the target rule register determining module 13 is configured to determine, if yes, the first rule register as a target rule register of the event to be matched; the target rule determining module 14 is configured to determine, based on the target rule register, a target rule corresponding to the event to be matched. Therefore, the target event state register corresponding to the event to be matched is matched with the rule register corresponding to one or more preset rules at one time, so that the target rule register matched with the target event state register is determined, and the target rule matched with the target event state register is obtained according to the target rule register, so that the problem that in the prior art, a plurality of initial preset rules are matched with the attribute value of the event, the same attribute value needs to be matched repeatedly for many times is solved, and the efficiency of the matching rule is improved.
Fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure, as shown in fig. 4, the electronic device includes a processor 410, a memory 420, an input device 430, and an output device 440; the number of the processors 410 in the computer device may be one or more, and one processor 410 is taken as an example in fig. 4; the processor 410, the memory 420, the input device 430 and the output device 440 in the electronic apparatus may be connected by a bus or other means, and the connection by the bus is exemplified in fig. 4.
Memory 420 serves as a computer-readable storage medium that may be used to store software programs, computer-executable programs, and modules, such as program instructions/modules corresponding to the methods of embodiments of the present invention. The processor 410 executes software programs, instructions and modules stored in the memory 420 to execute various functional applications of the computer device and data processing, namely, to implement the method provided by the embodiment of the present invention.
The memory 420 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the terminal, and the like. Further, the memory 420 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some examples, memory 420 may further include memory located remotely from processor 410, which may be connected to a computer device through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input device 430 may be used to receive input numeric or character information and generate key signal inputs related to user settings and function control of the electronic apparatus, and may include a keyboard, a mouse, and the like. The output device 440 may include a display device such as a display screen.
The disclosed embodiments also provide a storage medium containing computer-executable instructions, which when executed by a computer processor are used to implement the method provided by the embodiments of the present invention, the method comprising:
determining a corresponding target event state register according to at least one attribute value of an event to be matched;
aiming at a target event state register, judging whether a first rule register matched with the target event state register exists in at least one rule register, wherein each rule register corresponds to a preset rule one by one, and the preset rule is composed of at least one index item value supported by a rule engine;
if yes, determining the first rule register as a target rule register of the event to be matched;
and determining a target rule corresponding to the event to be matched based on the target rule register.
Of course, the storage medium provided by the embodiment of the present invention contains computer-executable instructions, and the computer-executable instructions are not limited to the method operations described above, and may also execute the relevant operations in the method provided by any embodiment of the present invention.
From the above description of the embodiments, it is obvious for those skilled in the art that the present invention can be implemented by software and necessary general hardware, and certainly can be implemented by hardware, but the former is a better embodiment in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which can be stored in a computer-readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a FLASH Memory (FLASH), a hard disk or an optical disk of a computer, and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device) to execute the methods according to the embodiments of the present invention.
It is noted that, in this document, relational terms such as "first" and "second," and the like, may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The previous description is only for the purpose of describing particular embodiments of the present disclosure, so as to enable those skilled in the art to understand or implement the present disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the disclosure. Thus, the present disclosure is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A method of rule matching, the method comprising:
determining a corresponding target event state register according to at least one attribute value of an event to be matched;
aiming at the target event state register, judging whether a first rule register matched with the target event state register exists in at least one rule register, wherein each rule register corresponds to a preset rule one by one, and the preset rule is composed of at least one index item value supported by a rule engine;
if so, determining the first rule register as a target rule register of the event to be matched;
and determining a target rule corresponding to the event to be matched based on the target rule register.
2. The method according to claim 1, wherein determining a corresponding target event status register according to at least one attribute value of an event to be matched comprises:
for each index item value in all index item values included in at least one preset rule, establishing a corresponding index table according to the index item corresponding to the index item value included in each preset rule, wherein the index item corresponding to each index table is associated with the preset rule containing the index item value corresponding to the index item;
and determining a target event state register according to the time sequence of receiving at least one attribute value and according to each attribute value corresponding to the event to be matched and at least one index table in sequence.
3. The method according to claim 2, wherein said determining a target event status register according to each attribute value corresponding to the event to be matched and at least one index table in sequence according to the time sequence of receiving at least one of the attribute values comprises:
sequentially acquiring each attribute value corresponding to the event to be matched according to the time sequence;
for each attribute value, determining a target index table in at least one index table;
determining at least one initial preset rule corresponding to the attribute value according to the target index table;
when the attribute value is determined to be a main index item of any initial preset rule in at least one initial preset rule, establishing an event state sub-register corresponding to the attribute value, and marking;
and determining the target event state register according to the event state sub-registers corresponding to all the attribute values of the event to be matched.
4. The method of claim 1, wherein before determining, for the target event status register, whether there is a first rule register matching the target event status register in the at least one rule register, further comprising:
acquiring all the preset rules;
and determining a corresponding rule register according to each preset rule.
5. The method of claim 4, wherein determining, for each of the preset rules, a corresponding rule register comprises:
sorting all index items corresponding to all index item values included in each preset rule, and setting priority;
after setting the priority, determining the logical relationship among the index item values according to a preset logical condition, wherein the logical relationship is an OR relationship or an AND relationship;
after the logical relationship among the index item values is determined, at least one main index item is determined in each index item corresponding to each index item value included in the preset rule, and a corresponding rule register is created for the preset rule according to a preset marking condition.
6. The method according to claim 5, wherein the sorting and setting the priority of the respective indexing items corresponding to the respective indexing item values included in each of the preset rules comprises:
according to a preset sorting condition, sorting all index items corresponding to all index item values included in each preset rule;
after the sorting of the index items is completed, determining the priority of the index items according to the sorting order of the index items.
7. The method according to claim 5, wherein the determining the logical relationship between the index entry values according to the preset logical condition comprises:
obtaining at least one index item value corresponding to each index item, and when at least two index item values belong to the same index item, determining that the logical relationship between the at least two index item values belonging to the same index item is an OR relationship;
when at least two index item values corresponding to different index items belong to the same preset group, determining that the logical relationship between the at least two index item values belonging to the same preset group is an OR relationship; or
And if the logical relationship between the index item values corresponding to the index items is not determined to be the AND relationship, determining that the logical relationship between at least two index item values is the AND relationship.
8. An apparatus for rule matching, the apparatus comprising:
the target event state register determining module is used for determining a corresponding target event state register according to at least one attribute value of the event to be matched;
the judging module is used for judging whether a first rule register matched with the target event state register exists in at least one rule register aiming at the target event state register, wherein each rule register corresponds to a preset rule one by one, and the preset rule is composed of at least one index item value supported by a rule engine;
the target rule register determining module is used for determining the first rule register as the target rule register of the event to be matched if the first rule register is the target rule register of the event to be matched;
and the target rule determining module is used for determining a target rule corresponding to the event to be matched based on the target rule register.
9. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the steps of the rule matching method of any one of claims 1-7.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the rule matching method according to one of claims 1 to 7.
CN202210901406.1A 2022-07-28 2022-07-28 Rule matching method, device, electronic equipment and medium Active CN115129324B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210901406.1A CN115129324B (en) 2022-07-28 2022-07-28 Rule matching method, device, electronic equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210901406.1A CN115129324B (en) 2022-07-28 2022-07-28 Rule matching method, device, electronic equipment and medium

Publications (2)

Publication Number Publication Date
CN115129324A true CN115129324A (en) 2022-09-30
CN115129324B CN115129324B (en) 2023-03-24

Family

ID=83386198

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210901406.1A Active CN115129324B (en) 2022-07-28 2022-07-28 Rule matching method, device, electronic equipment and medium

Country Status (1)

Country Link
CN (1) CN115129324B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115617400A (en) * 2022-12-20 2023-01-17 杭州加速科技有限公司 Register matching method and device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7162703B1 (en) * 2003-06-19 2007-01-09 Altera Corporation Electrical design rule checking expert traverser system
CN102968309A (en) * 2012-11-30 2013-03-13 亚信联创科技(中国)有限公司 Method and device for realizing rule matching based on rule engine
CN108733425A (en) * 2017-04-20 2018-11-02 北京京东尚科信息技术有限公司 Business change method for sending information, device, electronic equipment and storage medium
CN112527838A (en) * 2020-12-10 2021-03-19 联通(浙江)产业互联网有限公司 Business decision method, device, equipment and storage medium based on rule engine
CN113641708A (en) * 2021-08-11 2021-11-12 华院计算技术(上海)股份有限公司 Rule engine optimization method, data matching method and device, storage medium and terminal

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7162703B1 (en) * 2003-06-19 2007-01-09 Altera Corporation Electrical design rule checking expert traverser system
CN102968309A (en) * 2012-11-30 2013-03-13 亚信联创科技(中国)有限公司 Method and device for realizing rule matching based on rule engine
CN108733425A (en) * 2017-04-20 2018-11-02 北京京东尚科信息技术有限公司 Business change method for sending information, device, electronic equipment and storage medium
CN112527838A (en) * 2020-12-10 2021-03-19 联通(浙江)产业互联网有限公司 Business decision method, device, equipment and storage medium based on rule engine
CN113641708A (en) * 2021-08-11 2021-11-12 华院计算技术(上海)股份有限公司 Rule engine optimization method, data matching method and device, storage medium and terminal

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
刘金龙: "drools规则引擎模式匹配效率优化研究及实现", 《中国优秀硕士学位论文全文数据库(电子期刊)》 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115617400A (en) * 2022-12-20 2023-01-17 杭州加速科技有限公司 Register matching method and device

Also Published As

Publication number Publication date
CN115129324B (en) 2023-03-24

Similar Documents

Publication Publication Date Title
Yao et al. FD/spl I. bar/Mine: discovering functional dependencies in a database using equivalences
US9390176B2 (en) System and method for recursively traversing the internet and other sources to identify, gather, curate, adjudicate, and qualify business identity and related data
CN110474900B (en) Game protocol testing method and device
CN101398820A (en) Large scale key word matching method
CN115129324B (en) Rule matching method, device, electronic equipment and medium
CN113282630B (en) Data query method and device based on interface switching
CN111026765A (en) Dynamic processing method, equipment, storage medium and device for strictly balanced binary tree
CN114139161A (en) Method, device, electronic equipment and medium for batch vulnerability detection
CN110990350A (en) Log analysis method and device
CN111078671A (en) Method, device, equipment and medium for modifying data table field
CN112181964A (en) Business notification duplicate removal method, device, server and storage medium
CN109101630B (en) Method, device and equipment for generating search result of application program
CN111382189A (en) Heterogeneous data collision analysis method, terminal device and storage medium
CN111008873A (en) User determination method and device, electronic equipment and storage medium
US9201982B2 (en) Priority search trees
CN116560984A (en) Test case clustering grouping method based on call dependency graph
CN110888876A (en) Method and device for generating database script, storage medium and computer equipment
CN113342647A (en) Test data generation method and device
Eyal-Salman et al. Identifying traceability links between product variants and their features
CN114780589A (en) Multi-table connection query method, device, equipment and storage medium
US10318523B2 (en) Apparatus and method for aligning token sequences with block permutations
CN113935034A (en) Malicious code family classification method and device based on graph neural network and storage medium
CN111858366A (en) Test case generation method, device, equipment and storage medium
CN112291241A (en) Firewall wall opening method, firewall wall opening device and terminal equipment
CN116051018B (en) Election processing method, election processing device, electronic equipment and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant