Sensor Value Matching Method, Device, Medium and Program Product

By constructing a collection of node structures and dichotomous method to locate the target node structure, the problem of low matching efficiency of numerical sensor data is solved, efficient matching of numerical data and rules is achieved, and the real-time and reliability of the Internet of Things system is improved.

CN119598216BActive Publication Date: 2025-08-01BEIJING TOPSEC NETWORK SECURITY TECH +2
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411671880.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-21
Publication Date
2025-08-01
Estimated Expiration
2044-11-21

AI Technical Summary

Technical Problem

The lack of efficient matching algorithms for numerical sensor data in the prior art has resulted in high cost of computing resources and low matching efficiency in the Internet of Things scenario, which cannot meet real-time requirements.

Method used

By building a collection of node structures, including a numerical range and a linked list of rules, quickly match numerical data and rules, avoid traversing all rules, use dichotomy to locate the target node structure, and update the node structure in time when the rules are updated.

Benefits of technology

It greatly improves numerical matching efficiency, reduces computing resource consumption, improves the real-time response capability and reliability of IoT systems, and supports real-time processing of massive data streams.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119598216B_ABST
    Figure CN119598216B_ABST
Patent Text Reader

Abstract

An embodiment of the present application provides a method, device, medium, and program product for sensor value matching, which relates to the technical field of rule matching. The method includes: in response to a rule matching request for a value to be matched, obtaining a target node structure corresponding to the value to be matched from a pre-constructed set of node structures; determining a target value range of the value to be matched relative to the target node structure, obtaining a rule linked list corresponding to the target value range from the target node structure, and determining a rule matching result corresponding to the value to be matched based on the rule linked list. By constructing node structures corresponding to each numerical node, the embodiment of the present application first matches the node structure corresponding to the value to be matched when matching values, and then obtains the corresponding rule linked list from the structure as the matching result according to the numerical size relationship between the value to be matched and the node structure, so that it is not necessary to traverse and match all rules, greatly improving the efficiency of value matching.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of rule matching. Specifically, it relates to a method, device, medium, and program product for sensor value matching. Background Art

[0002] In the Internet of Things scenario, it is usually necessary to perform real-time analysis and processing on a large amount of sensor data. By performing rule matching and value monitoring on these data, functions such as event response and anomaly warning can be achieved.

[0003] Sensor data is mainly divided into string-type data and numerical data. For string-type data, traditional multi-pattern matching algorithms can be used to process it. However, for sensor data in the form of numerical values such as temperature, humidity, and pressure, there is currently no dedicated multi-pattern matching algorithm for this numerical type.

[0004] Currently, during the process of matching numerical data, it is necessary to traverse and match the numerical value to be matched with each preset rule one by one. In the case of needing to process a large amount of sensor data or having a large number of preset rules, using the above traditional matching scheme not only consumes a large amount of computing resources, but also has low matching efficiency and cannot meet the real-time requirements of Internet of Things data processing. Summary of the Invention

[0005] The purpose of the embodiments of this application is to provide a method, device, medium, and program product for sensor value matching to improve the matching efficiency between numerical data and rules.

[0006] In a first aspect, the embodiments of this application provide a method for sensor value matching, including:

[0007] In response to a rule matching request for a numerical value to be matched, obtain a target node structure corresponding to the numerical value to be matched from a pre-constructed set of node structures; wherein, the set of node structures contains node structures corresponding to all numerical nodes of a set of rules to be matched, and each node structure contains several numerical ranges and rule linked lists corresponding to each numerical range;

[0008] Determine the target numerical range of the numerical value to be matched relative to the target node structure, obtain the rule linked list corresponding to the target numerical range from the target node structure, and determine the rule matching result corresponding to the numerical value to be matched based on the rule linked list.

[0009] In the embodiments of the present application, by constructing a structure corresponding to each numerical node based on a matching rule, when matching a numerical value, first the structure corresponding to the numerical value is matched, and then the corresponding rule linked list is obtained from the structure according to the relationship between the numerical value and the structure, so that it is not necessary to traverse and match all rules, greatly improving the efficiency of numerical value matching.

[0010] In some possible embodiments, the method for obtaining the node structure includes:

[0011] Obtain all to-be-matched rules that need to be matched currently, and determine all numerical nodes corresponding to each of the to-be-matched rules;

[0012] Determine several numerical ranges corresponding to each numerical node, and based on the matching situation between each to-be-matched rule and each numerical range, determine the rule linked list of each numerical range;

[0013] Generate a node structure corresponding to the numerical node based on several numerical ranges corresponding to each numerical node and the rule linked list corresponding to each numerical range.

[0014] In the embodiments of the present application, by obtaining the numerical nodes of all to-be-matched rules and determining the corresponding rule linked list according to the matching situation between the to-be-matched rules and the numerical ranges, the node structure corresponding to each numerical node is constructed, thereby effectively improving the efficiency of numerical value matching.

[0015] In some possible embodiments, the determining of several numerical ranges corresponding to each numerical node includes:

[0016] Arrange all numerical nodes corresponding to the set of to-be-matched rules in ascending order of node values;

[0017] For the first numerical node with the smallest node value, the several numerical ranges corresponding to it include the following three items: the value equal to the node value itself, the value greater than this node value and less than the next node value, and the value less than this node value;

[0018] For the third numerical node with the largest node value, the several numerical ranges corresponding to it include the following three items: the value equal to the node value itself, the value less than this node value and greater than the previous node value, and the value greater than this node value;

[0019] For the second numerical node other than the first numerical node and the third numerical node, the several numerical ranges corresponding to it include the following three items: the value equal to the node value itself, the value less than this node value and greater than the previous node value, and the value greater than this node value and less than the next node value.

[0020] In the embodiments of the present application, different numerical range types are respectively constructed for the minimum, maximum node values and the node values between them, thereby reducing the rule matching calculation amount in the process of constructing the node structure, and further improving the efficiency of constructing the rule structure.

[0021] In some possible embodiments, the obtaining of the target node structure corresponding to the value to be matched from the pre-constructed set of node structures in response to a rule matching request for the value to be matched includes:

[0022] In response to a rule matching request for the value to be matched, determining whether the rule matching request meets a preset quick matching condition;

[0023] If so, obtaining the target node structure corresponding to the value to be matched from the pre-constructed set of node structures;

[0024] If not, matching the value to be matched one by one based on all the rules to be matched that need to be matched currently, so as to obtain a rule matching result corresponding to the value to be matched.

[0025] In the embodiments of the present application, by respectively adopting different rule matching strategies according to whether the current numerical value matching meets the quick matching condition, the flexibility of numerical value matching is further improved.

[0026] In some possible embodiments, the determining whether the rule matching request meets a preset quick matching condition includes at least one of the following:

[0027] When the number of values to be matched that need to be processed currently exceeds a preset first threshold, determining that the rule matching request meets the preset quick matching condition;

[0028] When the number of rules to be matched that need to be matched currently exceeds a preset second threshold, determining that the rule matching request meets the preset quick matching condition.

[0029] In the embodiments of the present application, by judging whether the quick matching condition is met according to the data volume of the value to be matched or the number of rules to be matched, the flexibility of numerical value matching is further improved.

[0030] In some possible embodiments, the obtaining of the target node structure corresponding to the value to be matched from the pre-constructed set of node structures includes:

[0031] Arranging all the numerical nodes corresponding to the set of rules to be matched in ascending order of node value, and constructing a sequence of values to be matched based on the arranged numerical nodes;

[0032] The sequence position of the to-be-matched value relative to the to-be-matched value sequence is determined by the dichotomy method, and one of the value nodes corresponding to the sequence position in the to-be-matched value sequence is used as the target value node;

[0033] The node structure corresponding to the target value node is obtained from the pre-constructed set of node structures as the target node structure corresponding to the to-be-matched value.

[0034] In the embodiment of the present application, by using the dichotomy method to quickly locate and obtain the target node structure corresponding to the currently to-be-matched value, the efficiency of value matching is further improved.

[0035] In some possible embodiments, the sensor value matching method further includes:

[0036] When it is monitored that an update event occurs in the to-be-matched rule set, the set of node structures is updated based on the updated to-be-matched rule set.

[0037] In the embodiment of the present application, by monitoring the update event of the to-be-matched rule and timely updating the node structure when the rule changes, the timeliness and reliability of value matching are further improved.

[0038] In a second aspect, an embodiment of the present application provides a sensor value matching device, including:

[0039] A structure acquisition module, configured to, in response to a rule matching request for a to-be-matched value, obtain a target node structure corresponding to the to-be-matched value from a pre-constructed set of node structures; wherein, the set of node structures contains node structures corresponding to all value nodes of the to-be-matched rule set, and each node structure contains several value ranges and rule linked lists corresponding to each value range;

[0040] A rule matching module, configured to determine a target value range of the to-be-matched value relative to the target node structure, obtain a rule linked list corresponding to the target value range from the target node structure, and determine a rule matching result corresponding to the to-be-matched value based on the rule linked list.

[0041] In a third aspect, an embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein when the processor executes the program, the method described in any embodiment of the first aspect can be implemented.

[0042] Fourthly, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is run by a processor, the method described in any embodiment of the first aspect can be implemented.

[0043] Fifthly, an embodiment of the present application provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the method described in any embodiment of the first aspect can be implemented. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings required to be used in the embodiments of the present application. It should be understood that the following drawings only show some embodiments of the present application, and therefore should not be regarded as limiting the scope. For those of ordinary skill in the art, without creative efforts, other relevant drawings can also be obtained based on these drawings.

[0045] Figure 1 It is a schematic flowchart of a sensor value matching method provided by an embodiment of the present application;

[0046] Figure 2 It is a schematic structural diagram of a sensor value matching device provided by an embodiment of the present application;

[0047] Figure 3 It is a schematic structural diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0048] The following will describe the technical solutions in the embodiments of the present application with reference to the drawings in the embodiments of the present application.

[0049] It should be noted that: similar reference numerals and letters indicate similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of the present application, the terms "first", "second", etc. are only used for distinguishing descriptions and cannot be understood as indicating or implying relative importance.

[0050] It should be noted that in the rule matching technology, existing multi-mode matching algorithms mainly process string-type data. However, in scenarios such as the Internet of Things, there is a large amount of sensor data, which usually exists in the form of numerical types. Since existing multi-mode matching algorithms are not applicable to processing numerical data, it is often necessary to traverse and match the numerical value to be matched with all rules, resulting in low matching efficiency. Especially when dealing with a large amount of numerical data, frequent type conversion and comparison operations not only increase the additional computational overhead, but also, as the number of Internet of Things devices increases, the number of rules grows exponentially, and the existing matching strategies are difficult to meet the real-time processing requirements of large-scale data streams.

[0051] In view of the problems existing in the above-mentioned prior art, the embodiments of the present application provide a sensor numerical value matching method. By changing the traditional form of traversing and matching the numerical value with all rules to the form of screening the corresponding node structure according to the numerical value and obtaining the rule linked list therefrom, it is possible to avoid traversing all rules and greatly improve the efficiency of numerical value matching.

[0052] As Figure 1 shown, the embodiments of the present application provide a sensor numerical value matching method, which may include the steps:

[0053] S1. In response to a rule matching request for a numerical value to be matched, obtain a target node structure corresponding to the numerical value to be matched from a pre-constructed set of node structures; wherein, the set of node structures contains node structures corresponding to all numerical nodes of the rule set to be matched, and each node structure contains several numerical ranges and the rule linked lists corresponding to each numerical range.

[0054] Further, the method for obtaining the node structure may include:

[0055] S101. Obtain all the rules to be matched currently and determine all the numerical nodes corresponding to each rule to be matched;

[0056] S102. Determine several numerical ranges corresponding to each numerical node, and based on the matching situation between each rule to be matched and each numerical range, determine the rule linked list of each numerical range;

[0057] S103. Generate a node structure corresponding to the numerical node based on the several numerical ranges corresponding to each numerical node and the rule linked lists corresponding to each numerical range.

[0058] It should be noted that before performing numerical value matching, a set of node structures may be constructed first according to the rule set to be matched.

[0059] Specifically, the set of rules to be matched is a set of several rules to be matched that need to be matched currently. Exemplarily, multiple sets of node structures can be stored in the system, and each set of node structures corresponds to a set of rules to be matched; according to the sensor type of the value to be matched that needs to be matched currently, the set of node structures corresponding to the sensor type can be obtained.

[0060] The set of rules to be matched is the set of all rules to be matched that the value to be matched currently needs to match. It can be understood that each rule to be matched contains at least one numerical node. For example, for the rule to be matched a: "a value greater than 2", its numerical node is 2; for the rule to be matched b: "a value greater than 1 and less than 2.5", its numerical nodes are 1 and 2.5. For all numerical nodes corresponding to all rules to be matched in the set of rules to be matched, a corresponding node structure can be formed. For example, the above two rules to be matched can include the following three node structures: the node structure corresponding to numerical node 1, the node structure corresponding to numerical node 2, and the node structure corresponding to numerical node 2.5.

[0061] Exemplarily, each node structure can be a data body in the form of a table, and the table includes at least two field types: numerical range and rule linked list (or rule set); and the content of the numerical range field corresponds one-to-one with the content of the rule linked list field. Among them, the content of the numerical range field is used to represent the numerical range corresponding to the entry, and the content of the rule linked list field represents the linked list of rule IDs to be matched that match the corresponding data range. Exemplarily, the rule to be matched that matches the data range means that the numerical range has an inclusion or being included relationship with the numerical range indicated by the rule to be matched. For example, when the content of the numerical range field is "greater than 2 and less than 2.5", since this numerical range has an inclusion relationship with the above rule to be matched b "a value greater than 1 and less than 2.5", b is added to the rule linked list corresponding to the content of this numerical range field.

[0062] Exemplarily, the node structure for numerical node s can be as shown in Table 1 below:

[0063] Table 1, Node Structure of Numerical Node N

[0064]

[0065] After constructing the set of node structures, the set of node structures can be used to perform numerical matching on sensor data. It can be understood that in Internet of Things scenarios such as smart home systems, it is often necessary to perform rule matching based on the values collected by sensors and trigger corresponding processing strategies according to different matched rules, such as abnormal alarms or multi-device linkage operations, etc.

[0066] After each sensor value is collected, different matching strategies can be selected to execute on the sensor value (value to be matched): 1. In the traditional form, traverse and match the value to be matched with all rules one by one; 2. Adopt the matching strategy of the embodiment of the present application to match the corresponding node structure and obtain the corresponding rule matching result.

[0067] When the second matching strategy above is selected, the system can obtain the target node structure corresponding to the value to be matched from the pre-constructed set of node structures in response to the rule matching request for the value to be matched. Specifically, it can traverse the value nodes corresponding to all node structures and compare them with the value to be matched, and use the node structure corresponding to the value node with the smallest difference between the two as the target node structure corresponding to the value to be matched. Exemplarily, assume that the current value to be matched is "2.1", and the set of node structures contains four node structures with value nodes 1, 2, 2.5, and 3 respectively. Then, by traversing and comparing the differences between "2.1" and the four value nodes, the node structure corresponding to the smallest difference value of "2" is used as the target node structure corresponding to the value to be matched.

[0068] S2. Determine the target value range of the value to be matched relative to the target node structure, obtain the rule linked list corresponding to the target value range from the target node structure, and determine the rule matching result corresponding to the value to be matched based on the rule linked list.

[0069] Specifically, after obtaining the target node structure, first compare the content of all value range fields in the target node structure with the value to be matched to determine the target value range that matches the value to be matched. Exemplarily, assume that the set of node structures contains four node structures with value nodes 1, 2, 2.5, and 3 respectively. For the node structure corresponding to the value node "2", since the current value node to be matched is "2.1", it can be determined that the value range of "greater than this node value and less than the next node value", that is, "(2, 2.5)", in this node structure matches "2.1". Therefore, the value range of "greater than this node value and less than the next node value" is determined as the target value range of the value to be matched relative to the target node structure.

[0070] Then, obtain the rule linked list corresponding to the target value range from the target node structure, and use the rule ID corresponding to the rule linked list as the rule matching result corresponding to the value to be matched. Exemplarily, in the node structure corresponding to the value node "2", the rule linked list corresponding to the value range "(2, 2.5)" is "a-c-d". Therefore, it can be determined that the rule matching result corresponding to the value to be matched is a, c, and d, that is, the three rules to be matched with IDs a, c, and d are the rules that match the value to be matched.

[0071] Based on this, there is no need to traverse and match the value to be matched with all rules. It only needs to match the node structure corresponding to the value to be matched, and then according to the relationship between the value to be matched and the value range of the node structure, obtain the rule linked list corresponding to the value range from the node structure to obtain the matching result, thereby improving the efficiency of value matching. Especially when the number of rules to be matched is large, the embodiments of the present application can greatly save the computing resources required for value matching and improve the real-time performance of value matching.

[0072] In some possible embodiments, in step S102, determining a plurality of value ranges corresponding to each numerical node includes:

[0073] Arrange all the numerical nodes corresponding to the rule set to be matched in ascending order of node values;

[0074] For the first numerical node with the smallest node value, determining the corresponding plurality of value ranges includes the following three items: the value equal to the node value itself, the value greater than this node value and less than the next node value, and the value less than this node value;

[0075] For the third numerical node with the largest node value, determining the corresponding plurality of value ranges includes the following three items: the value equal to the node value itself, the value less than this node value and greater than the previous node value, and the value greater than this node value;

[0076] For the second numerical node other than the first numerical node and the third numerical node, determining the corresponding plurality of value ranges includes the following three items: the value equal to the node value itself, the value less than this node value and greater than the previous node value, and the value greater than this node value and less than the next node value.

[0077] It should be noted that before constructing the node structure, first extract all the numerical nodes according to all the rules to be matched, and then arrange these numerical nodes in ascending order. It should be noted that in order to avoid duplication, after extracting all the numerical nodes, they can be de-duplicated first. For example, assume that the rule set to be matched includes rule a "value greater than 2" and rule b "value less than 2", then after extracting two numerical nodes with the value of "2", they can be de-duplicated first, and finally only construct a node structure with a numerical node of "2".

[0078] During the process of constructing the node structure, for the first numerical node with the smallest node value, since there is no numerical node smaller than the first numerical node, the node structure of this numerical node does not have the numerical range of "values less than this node value and greater than the value of the previous node", and the numerical range of "values greater than this node value" overlaps with the node structures of other numerical nodes. Therefore, based on Table 1 above, the two numerical ranges of "values less than this node value and greater than the value of the previous node" and "values greater than this node value" and their corresponding rule linked lists can be omitted to obtain the simplified node structure corresponding to the first numerical node, as shown in Table 2 below:

[0079] Table 2, Node Structure of the First Numerical Node

[0080]

[0081] For the third numerical node with the largest node value, since there is no numerical node larger than the third numerical node, the node structure of this numerical node does not have the numerical range of "values greater than this node value and less than the value of the next node", and the numerical range of "values less than this node value" overlaps with the node structures of other numerical nodes. Therefore, based on Table 1 above, the two numerical ranges of "values greater than this node value and less than the value of the next node" and "values less than this node value" and their corresponding rule linked lists can be omitted to obtain the simplified node structure corresponding to the third numerical node, as shown in Table 3 below:

[0082] Table 3, Node Structure of the Third Numerical Node

[0083]

[0084] For the second numerical nodes other than the first numerical node and the third numerical node, that is, other numerical nodes except for the maximum and minimum values, since the two numerical ranges of "values less than this node value" and "values greater than this node value" of these numerical nodes both overlap with the node structures of other numerical nodes, based on Table 1 above, the two numerical ranges of "values less than this node value" and "values greater than this node value" and their corresponding rule linked lists can be omitted to obtain the simplified node structure corresponding to the second numerical node, as shown in Table 4 below:

[0085] Table 4, Node Structure of the Second Numerical Node

[0086]

[0087] Based on this, by constructing different node structures for the minimum, maximum node values and the node values between them respectively, it is possible to avoid rule matching for the repeated numerical ranges between different node structures, thereby reducing the computational amount in the process of constructing node structures and further improving the efficiency of constructing rule structures.

[0088] In some possible embodiments, step S1, in response to a rule matching request for a value to be matched, obtaining a target node structure corresponding to the value to be matched from a pre-constructed set of node structures may include:

[0089] S111. In response to a rule matching request for a value to be matched, determine whether the rule matching request meets a preset quick matching condition;

[0090] S112. If so, obtain a target node structure corresponding to the value to be matched from a pre-constructed set of node structures;

[0091] S113. If not, match the value to be matched one by one based on all the rules to be matched currently to obtain a rule matching result corresponding to the value to be matched.

[0092] It should be noted that when responding to a rule matching request for a value to be matched, it is possible to first determine whether the current rule matching request meets a preset quick matching condition. If it meets the condition, a quick matching method based on node structures is adopted. If it does not meet the condition, a traditional method of traversing and matching based on all the rules to be matched is adopted.

[0093] By setting a quick matching condition and adopting different matching methods according to whether the condition is met, it is possible to flexibly adopt an appropriate rule matching method, thereby further improving the efficiency of numerical matching.

[0094] In some possible embodiments, in S111, determining whether the rule matching request meets a preset quick matching condition may include at least one of the following:

[0095] When the number of values to be matched to be processed currently exceeds a preset first threshold, determine that the rule matching request meets the preset quick matching condition;

[0096] When the number of rules to be matched currently exceeds a preset second threshold, determine that the rule matching request meets the preset quick matching condition.

[0097] Specifically, determining whether a rule matching request meets a preset quick matching condition may include the following two cases: 1. Whether the number of numerical values to be matched currently is large enough; 2. Whether the number of rules to be matched currently is large enough. It can be understood that when a large amount of numerical values to be matched need to be processed or when matching with a large number of rules to be matched, using the matching method based on the node structure can significantly improve the matching efficiency; otherwise, when the number of numerical values to be matched is small, or only a small number of rules to be matched need to be matched, using the matching method based on the node structure cannot significantly improve the matching efficiency. In this case, the traditional method of traversing all rules can be preferentially selected to further improve the flexibility of numerical value matching.

[0098] In some possible embodiments, in step S1, obtaining the target node structure corresponding to the numerical value to be matched from the pre-constructed set of node structures may include:

[0099] S121. Arrange all the numerical nodes corresponding to the set of rules to be matched in ascending order of node values, and construct a numerical value sequence to be matched based on the arranged numerical nodes;

[0100] S122. Use the binary search method to determine the sequence position of the numerical value to be matched relative to the numerical value sequence to be matched, and take one of the numerical nodes corresponding to the sequence position in the numerical value sequence to be matched as the target numerical node;

[0101] S123. Obtain the node structure corresponding to the target numerical node from the pre-constructed set of node structures as the target node structure corresponding to the numerical value to be matched.

[0102] It should be noted that after obtaining the numerical value to be matched, the target node structure corresponding to the numerical value to be matched can be quickly determined and screened out based on the binary search method.

[0103] Specifically, first arrange all the numerical nodes in ascending order of node values to obtain an array composed of all the numerical nodes (in ascending order) (which can be called the numerical value sequence to be matched); then, the binary search method can be used to quickly determine which position (sequence position) in the array the numerical value to be matched is in. Exemplarily, first obtain the middle element in the array (the middle ranking in the array or near this ranking. For example, for an array with 5 elements, its middle element is the 3rd element; for an array with 4 elements, its middle element is the 2nd or 3rd element), compare the size relationship between the numerical value to be matched and the middle element. If the numerical value to be matched is greater than the middle element, then re-obtain the middle element based on the middle element and the maximum value in the array, and so on, until there are no other numerical node elements between the last two elements found.

[0104] It should be noted that after determining the sequence position of the value to be matched relative to the sequence of values to be matched, there may be two numerical nodes or only one numerical node based on this sequence position: when the sequence position of the value to be matched is between two numerical node elements, this sequence position corresponds to two numerical nodes; when the sequence position of the value to be matched is greater than all numerical nodes or less than all numerical nodes, this sequence position corresponds to one numerical node.

[0105] Exemplarily, when the value to be matched is greater than (or less than) all numerical nodes in the sequence of values to be matched, the largest (or smallest) numerical node can be directly obtained as the target numerical node corresponding to the value to be matched.

[0106] Exemplarily, when the sequence position of the value to be matched is between two numerical node elements, any one of the two numerical nodes corresponding to this sequence position can be obtained as the target numerical node corresponding to the value to be matched.

[0107] Then, the node structure corresponding to the target numerical node is obtained from the pre-constructed set of node structures as the target node structure corresponding to the value to be matched.

[0108] It can be understood that when the sequence position of the value to be matched is between two numerical node elements, the numerical range of "values less than this node value and greater than the previous node value" in the node structure of the larger numerical node is the same as the numerical range of "values greater than this node value and less than the next node value" in the node structure of the smaller numerical node. The corresponding rule linked lists are consistent, and specific examples can be referred to in the following for details.

[0109] In some possible embodiments, the sensor value matching method may further include the steps of:

[0110] S3. When it is monitored that an update event occurs in the set of rules to be matched, the set of node structures is updated based on the updated set of rules to be matched.

[0111] It should be noted that when the rules in the set of rules to be matched change, such as adding rules, deleting rules, and changes in the numerical values or symbols in the rules, the set of node structures needs to be updated again based on the updated set of rules to be matched.

[0112] Based on this, by monitoring the update event of the rules to be matched and updating the node structure in a timely manner when the rules change, the timeliness and reliability of value matching can be improved.

[0113] The following lists specific examples to elaborate in detail on the sensor value matching method of the present application:

[0114] Suppose the Internet of Things system needs to perform rule matching on the values collected by a certain sensor and execute corresponding configured policies according to the matched rules. Among them, since there are a large number of rule values to be matched for the values of this sensor type, in order to avoid traversing all rules, a matching method based on a node structure is adopted to obtain the result of rule matching (the rule ID that matches the value to be matched).

[0115] I. Construct a node structure:

[0116] The rules to be matched by the current sensor include the following 4 rules (the number of rules in actual applications is usually much larger than this number. In this example, only 4 rules are used for illustration for convenience):

[0117] Rule a: Values greater than 2

[0118] Rule b: Values greater than 3

[0119] Rule c: Values greater than 1 and less than 2.5

[0120] Rule d: Values less than or equal to 3

[0121] Obtain all the values included in all the above rules to be matched: 2, 3, 1, 2.5, 3. Remove duplicates from these values and sort them in ascending order. The obtained value nodes are: 1, 2, 2.5, 3.

[0122] According to the pre-defined node structure format (such as shown in Table 1), construct a node structure set containing 4 node structures, where these 4 node structures respectively correspond to the above four value nodes. For convenience of description, the 4 node structures are respectively represented as: the node structure with a node value of 1, the node structure with a node value of 2, the node structure with a node value of 2.5, and the node structure with a node value of 3.

[0123] Specifically, for the node structure with a node value of 1, since "1" is the smallest among all the value nodes and there is no "previous node value" smaller than 1, in this node structure, the rule linked list corresponding to the value range of "values less than this node value and greater than the previous node value" is marked as NULL (not assigned); at the same time, since the value range of "values greater than this node value" overlaps with the value ranges of other value nodes, the rule linked list corresponding to the value range of "values greater than this node value" is marked as NULL. In other embodiments, the above two value ranges and their corresponding rule linked list items can also be directly omitted.

[0124] Then, traverse and analyze all the rules to be matched, and add the rules that match each numerical range to the corresponding rule linked list. Specifically, for the numerical range of "the value equal to the node value itself", since there is no rule related to "equal to 1" in all the rules, it is marked as NULL; for the numerical range of "the value greater than this node value and less than the next node value", that is, "1 < x < 2", since among all the rules, it is judged that both rule c and rule d contain this numerical range, the rule linked list corresponding to this numerical range is "c - d". For the numerical range of "the value less than this node value", that is, "x < 1", since only rule d contains this numerical range, the rule linked list corresponding to this numerical range is "d". Based on this, the node structure corresponding to the node value of 1 is obtained, as shown in Table 4:

[0125] Table 5, Node Structure with Node Value of 1

[0126]

[0127]

[0128] In the same way, by analogy, rule linked list matching is performed for each node structure to obtain the node structures corresponding to each numerical node, as shown in Tables 6 to 8 below:

[0129] Table 6, Node Structure with Node Value of 2

[0130]

[0131] Table 7, Node Structure with Node Value of 2.5

[0132]

[0133]

[0134] Table 8, Node Structure with Node Value of 3

[0135]

[0136] II. Perform Rule Matching on the Numerical Values to be Matched:

[0137] Collect sensor data in real time, and perform rule matching on each collected value (numerical value to be matched). Specifically, assume that the currently collected sensor value is 2.1. First, use the binary search method to quickly find the position of this value in the array {1, 2, 2.5, 3} composed of numerical nodes. It can be understood that if the number of numerical nodes is small, the traditional method of comparing the numerical value to be matched with each numerical node value one by one can also be used. Through position matching, it can be determined that 2.1 is between the two elements "2" and "2.5" in the array.

[0138] Then, one of the numerical nodes "2" and "2.5" is selected as the target numerical node corresponding to the numerical value to be matched, and the corresponding node structure is obtained from the node structure set. For example, the node structure with a node value of 2 can be obtained, and the size relationship between 2.1 and 2 can be compared. Since "2<2.1<2.5", it can be determined that the numerical range of 2.1 relative to the node structure with a node value of 2 is "a value greater than this node value and less than the next node value". The rule linked list corresponding to this numerical range is found in the node structure as "acd", so it can be determined that the rule matching results that match the numerical value 2.1 to be matched are three rules with IDs a, c and d respectively.

[0139] Compared with the prior art, since there is no need to traverse and match the value to be matched with all rules, the matching efficiency can be greatly improved when the number of rules to be matched is large. In terms of real-time monitoring and data processing, the matching method of the embodiment of the present application can quickly locate the rule set that meets the conditions, greatly reducing computing overhead and resource waste, and effectively improving the real-time response capability and reliability of the system. Especially when deploying IoT devices on a large scale, the matching method of the embodiment of the present application can effectively support the real-time processing of massive data streams, significantly reduce operating costs, and improve the performance and stability of the overall system.

[0140] Please refer to Figure 2 , Figure 2 The following is a block diagram showing the composition of the sensor value matching device provided by some embodiments of the present application. It should be understood that the sensor value matching device is similar to the above-mentioned Figure 1 Corresponding to the method embodiment, the various steps involved in the above method embodiment can be executed. The specific functions of the sensor value matching device can be found in the description above. To avoid repetition, the detailed description is appropriately omitted here.

[0141] Figure 2 The sensor value matching device includes at least one software function module that can be stored in a memory in the form of software or firmware or fixed in the sensor value matching device, and the sensor value matching device includes:

[0142] The structure acquisition module 210 is configured to, in response to a rule matching request for a value to be matched, acquire a target node structure corresponding to the value to be matched from a pre-built node structure set; wherein the node structure set includes node structures corresponding to all value nodes of the rule set to be matched, and each node structure includes a plurality of value ranges and a rule linked list corresponding to each value range;

[0143] A rule matching module 220 is configured to determine a target numerical range of a numerical value to be matched relative to a target node structure, obtain a rule linked list corresponding to the target numerical range from the target node structure, and determine a rule matching result corresponding to the numerical value to be matched based on the rule linked list.

[0144] It can be understood that the above device item embodiments correspond to the method item embodiments of the present invention. A sensor numerical value matching device provided by the embodiments of the present invention can implement the sensor numerical value matching method provided by any one of the method item embodiments of the present invention.

[0145] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working process of the above-described device can refer to the corresponding process in the foregoing method, and will not be elaborated herein.

[0146] As Figure 3 shown, some embodiments of the present application provide an electronic device 300, which includes: a memory 310, a processor 320, and a computer program stored on the memory 310 and executable on the processor 320. Among them, when the processor 320 reads the program from the memory 310 through the bus 330 and executes the program, it can implement the method of any embodiment included in the above sensor numerical value matching method.

[0147] The processor 320 can process digital signals and can include various computing architectures. For example, a complex instruction set computer architecture, a reduced instruction set computer architecture, or an architecture that implements a combination of multiple instruction sets. In some examples, the processor 320 can be a microprocessor.

[0148] The memory 310 can be used to store instructions executed by the processor 320 or data related to the instruction execution process. These instructions and / or data can include code for implementing some or all of the functions of one or more modules described in the embodiments of the present application. The processor 320 of the embodiments of the present disclosure can be used to execute the instructions in the memory 310 to implement the method shown above. The memory 310 includes a dynamic random access memory, a static random access memory, a flash memory, an optical memory, or other memories well known to those skilled in the art.

[0149] Some embodiments of the present application further provide a computer-readable storage medium, on which a computer program is stored, and when the computer program is run by a processor, it executes the method described in the method embodiments.

[0150] Some embodiments of the present application further provide a computer program product, when the computer program product runs on a computer, it causes the computer to execute the method described in the method embodiments.

[0151] It should be noted that the various embodiments in this specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. For the similarities between the various embodiments, reference can be made to each other. For device embodiments, since they are basically similar to method embodiments, they are described relatively simply. For the relevant parts, reference can be made to the corresponding descriptions in the method embodiments.

[0152] In several embodiments provided by the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architectures, functions, and operations of devices, methods, and computer program products according to multiple embodiments of the present application. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code, and the module, program segment, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than marked in the accompanying drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and the combination of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.

[0153] In addition, in each embodiment of the present application, the various functional modules may be integrated together to form an independent part, or each module may exist alone, or two or more modules may be integrated to form an independent part.

[0154] If the above functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disks, or optical discs that can store program codes.

[0155] The above are only embodiments of the present application and are not intended to limit the protection scope of the present application. For those skilled in the art, the present application can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the protection scope of the present application. It should be noted that similar reference numerals and letters indicate similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings.

[0156] As described above, the above is only the specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art can easily think of changes or replacements within the technical scope disclosed by the present application, and all should be covered within the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claimed rights.

[0157] It should be noted that in this text, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "including one..." does not exclude the existence of additional identical elements in the process, method, article or device including the said element.

Claims

1. A method for matching sensor values, characterized in that, Including: In response to a rule matching request for a value to be matched, obtaining a target node structure corresponding to the value to be matched from a pre-constructed set of node structures; wherein, the set of node structures contains node structures corresponding to all numerical nodes of a set of rules to be matched, and each of the node structures contains a number of numerical ranges and a rule linked list corresponding to each numerical range; Determining a target numerical range of the value to be matched relative to the target node structure, obtaining a rule linked list corresponding to the target numerical range from the target node structure, and determining a rule matching result corresponding to the value to be matched based on the rule linked list; The obtaining a target node structure corresponding to the value to be matched from a pre-constructed set of node structures includes: Arranging all numerical nodes corresponding to the set of rules to be matched in ascending order of node values, and constructing a sequence of values to be matched based on the arranged numerical nodes; Using the binary search method to determine the sequence position of the value to be matched relative to the sequence of values to be matched, and taking one of the numerical nodes corresponding to the sequence position in the sequence of values to be matched as the target numerical node; Obtaining a node structure corresponding to the target numerical node from a pre-constructed set of node structures as the target node structure corresponding to the value to be matched.

2. The sensor value matching method according to claim 1, wherein The method for obtaining the node structure includes: Obtaining all rules to be matched that need to be matched currently, and determining all numerical nodes corresponding to each of the rules to be matched; Determining a number of numerical ranges corresponding to each of the numerical nodes, and determining a rule linked list for each numerical range based on the matching situation between each of the rules to be matched and each of the numerical ranges; Generating a node structure corresponding to the numerical node based on the number of numerical ranges corresponding to each numerical node and the rule linked list corresponding to each numerical range.

3. The sensor value matching method according to claim 2, wherein The determining a number of numerical ranges corresponding to each of the numerical nodes includes: Arranging all numerical nodes corresponding to the set of rules to be matched in ascending order of node values; For the first numerical node with the smallest node value, determining its corresponding number of numerical ranges includes the following three items: the value equal to the node value itself, the value greater than this node value and less than the next node value, and the value less than this node value; For the third numerical node with the largest node value, determining its corresponding number of numerical ranges includes the following three items: the value equal to the node value itself, the value less than this node value and greater than the previous node value, and the value greater than this node value; For the second numerical node other than the first numerical node and the third numerical node, determining its corresponding number of numerical ranges includes the following three items: the value equal to the node value itself, the value less than this node value and greater than the previous node value, and the value greater than this node value and less than the next node value.

4. The sensor value matching method according to claim 1, wherein The obtaining a target node structure corresponding to the value to be matched from a pre-constructed set of node structures in response to a rule matching request for the value to be matched includes: In response to a rule matching request for a value to be matched, determining whether the rule matching request meets a preset fast matching condition; If so, obtain the target node structure corresponding to the value to be matched from the pre-constructed set of node structures; If not, match the value to be matched one by one based on all the rules to be matched that need to be matched currently, so as to obtain the rule matching result corresponding to the value to be matched.

5. The sensor value matching method according to claim 4, characterized in that, The judging whether the rule matching request meets the preset quick matching condition includes at least one of the following: When the number of values to be matched that need to be processed currently exceeds a preset first threshold, determine that the rule matching request meets the preset quick matching condition; When the number of rules to be matched that need to be matched currently exceeds a preset second threshold, determine that the rule matching request meets the preset quick matching condition.

6. The sensor value matching method according to any one of claims 1 to 5, characterized in that It further includes: When it is monitored that an update event occurs in the set of rules to be matched, update the set of node structures based on the updated set of rules to be matched.

7. An electronic device, characterized in that, It includes a memory, a processor, and a computer program stored on the memory and executable on the processor. Wherein, when the processor executes the program, the sensor value matching method according to any one of claims 1-6 can be implemented.

8. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, and when the computer program is run by a processor, it executes the sensor value matching method according to any one of claims 1-6.

9. A computer program product, characterized in that, The computer program product includes a computer program, and when the computer program is executed by a processor, the sensor value matching method according to any one of claims 1-6 is implemented.

Citation Information

Patent Citations

  • High-efficiency filtering method for data packets

    CN103338155A

  • Security event association analysis method and device

    CN109255237A