List matching method and device, electronic equipment and computer program product
Through the layer-by-layer matching method of the preset list hash tree structure, the problem of inefficiency of multi-attribute black and white list matching is solved, and efficient multi-attribute list matching is achieved, which is suitable for high-concurrency scenarios such as advertising targeted delivery and abnormal traffic filtering.
Patent Information
- Application Number
- CN202510512598.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-22
- Publication Date
- 2025-08-15
AI Technical Summary
The existing black and white list matching scheme is inefficient in multi-attribute scenarios, especially when the number of rules is huge, it cannot meet the high concurrency needs.
The preset list hash tree structure is used to determine whether the data to be matched complies with the rules in the preset list through layer-by-layer matching, avoiding rule-by-line matching, and using the preset list hash tree to match multiple attribute values.
It improves the matching efficiency of multi-attribute black and white lists, and can achieve matching performance of tens of millions of times/second in a single thread in a million-level rule scenario, which is suitable for high-concurrency application scenarios.
Smart Images

Figure CN120498722A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing, and in particular to a list matching method, device, electronic device and computer program product. Background Art
[0002] Blacklists and whitelists are common Internet applications and can be used for abnormal traffic filtering, fraud prevention, targeted advertising, and A / B experiments.
[0003] However, common blacklist and whitelist configurations only support a single attribute. The following is an example of an IP whitelist configuration:
[0004] "123.121.12.3 134.131.1.2 134.131.1.3 . . . 234.112.1.2
[0011] 234.112.1.3”.
[0012] If the IP address is in the whitelist, such as "234.112.1.3," the result is a match; if it is not in the list, such as "10.1.1.3," the result is a mismatch. In other words, IP addresses in the whitelist are allowed to proceed to the next step, while IP addresses not in the whitelist are not allowed to proceed to the next step.
[0013] The blacklist is the reverse operation of the whitelist. The next operation is prohibited for those in the list, while the next operation is allowed for those not in the list.
[0014] However, actual requirements are often more complex and require a combination of multiple attributes, such as:
[0015] "ip=123.121.12.3&os=android
[0016] ip=134.131.1.2&os=android
[0017] ip=134.131.1.3 . . .
[0021] ip=234.112.1.2&brand=huawei
[0022] ip=234.112.1.3".
[0023] In the above blacklist-based multi-attribute matching example, each row is called a rule, and a match is considered as long as the entire table matches one rule.
[0024] However, the difference between matching multiple attributes and matching a single attribute is that in the blacklist example above, some IP addresses must be Android devices to match, while others must be Huawei devices to match. Therefore, during the matching process, all attributes in a rule corresponding to the same row must match for the rule to be considered a match.
[0025] Currently, the mainstream blacklist and whitelist solutions are:
[0026] 1) Only single attributes are supported, typically implemented using HashSet, which allows for efficient matching with a time commitment of O(1) and a matching QPS exceeding 10 million. However, single-attribute hash matching, with a QPS >= 10 million, is highly efficient but limited in supported scenarios, supporting only single-attribute and / or operations on multiple lists.
[0027] 2) Supports multi-attribute matching, sequentially determining whether each rule matches, and exiting only when a match is found. The time complexity is O(n), where n is the number of rules. However, multi-attribute matching is only suitable for scenarios with a small number of rules. For example, when the number of rules is <= 1000, it can support over 200,000 QPS. However, when the number of rules is large, the efficiency is low. For example, when the number of rules is >= 1 million, it can only support 200 QPS, making it unsuitable for high-concurrency scenarios such as advertising.
[0028] Currently, no effective solution has been proposed to the above-mentioned problem of poor matching efficiency for multi-attribute blacklists and whitelists. Summary of the Invention
[0029] Embodiments of the present invention provide a list matching method, apparatus, electronic device, and computer program product to at least solve the technical problem of poor matching efficiency for multi-attribute blacklists and whitelists.
[0030] According to one aspect of an embodiment of the present invention, a list matching method is provided, comprising: obtaining data to be matched, wherein the data to be matched comprises: attribute values to be matched corresponding to a plurality of attribute items; matching the plurality of attribute values to be matched layer by layer in a plurality of matching layers of a preset list hash tree to obtain a matching result, wherein the matching layers in the preset list hash tree are: a root layer, a plurality of intermediate layers, and a tail layer, each of the intermediate layers comprises a plurality of attribute nodes of the same attribute item, each of the attribute nodes has a preconfigured key-value pair, the key in the key-value pair is a preset attribute value for matching the attribute value to be matched, and the value in the key-value pair is a pointer to a node to be matched in the next intermediate layer, The node to be matched is at least one attribute node used to match the attribute value to be matched, and the matching result is used to indicate whether there is a path in the preset list hash tree, and the path indicates that multiple attribute values to be matched in the data to be matched start from the root layer and are matched with the attribute nodes in each intermediate layer in sequence until the tail layer is reached; when the matching result indicates that there is the path in the preset list hash tree, it is determined that the data to be matched meets the rules recorded in the preset list, wherein the preset list is used to establish the preset list hash tree, and the preset list includes: multiple rules, and each rule includes: the preset attribute values corresponding to multiple attribute items respectively.
[0031] Optionally, after obtaining the data to be matched, the method further includes: identifying the attribute item corresponding to each of the intermediate layers in the preset list hash tree; and extracting the attribute value to be matched corresponding to each of the attribute items from the data to be matched.
[0032] Optionally, before matching the multiple attribute values to be matched layer by layer in the multiple matching layers of the preset list hash tree to obtain the matching results, the method further includes: obtaining the preset list, wherein the preset list is a blacklist or a whitelist; identifying the multiple attribute items of each rule in the preset list, and the preset attribute value corresponding to each attribute item; setting multiple matching layers in the preset list hash tree according to the multiple attribute items in the preset list, wherein the matching layers include: the root layer as the starting point of matching, the intermediate layers corresponding to different attribute items, and the tail layer as the end point of matching; setting the attribute node in each intermediate layer according to the multiple attribute items in each rule and the preset attribute value corresponding to each attribute item, wherein a corresponding attribute node is set for each preset attribute value in the intermediate layer corresponding to the attribute item, and the pointer is set for the attribute node according to the multiple preset attribute values of the same rule.
[0033] Optionally, according to the multiple attribute items in the preset list, setting multiple matching layers in the preset list hash tree includes: identifying the number of different attribute items in the preset list; setting the number of layers of the middle layer in the preset list hash tree according to the number of items, wherein the number of items is the same as the number of layers; setting the root layer as the starting point of matching before the middle layer, and setting the tail layer as the end point of matching after the middle layer.
[0034] Optionally, according to the multiple attribute items in each rule and the preset attribute value corresponding to each attribute item, the attribute node set in each intermediate layer includes: in each intermediate layer, setting the corresponding node to be configured for the same rule; according to the multiple attribute items in the same rule and the preset attribute value corresponding to each attribute item, configuring the key-value pair of the node to be configured to obtain the attribute node.
[0035] Optionally, according to multiple attribute items in the same rule and the preset attribute value corresponding to each attribute item, the key-value pair is configured for the node to be configured to obtain the attribute node, including: pairing each intermediate layer with the attribute item in each rule in sequence from the root layer to the tail layer to obtain a pairing result, wherein the pairing result is used to indicate whether the attribute item corresponding to the intermediate layer exists in the rule; according to the pairing result, the preset attribute value is configured for each node to be configured; according to the order from the root layer to the tail layer, the pointer is configured for the node to be configured in each intermediate layer for the same rule, wherein the pointer points to the node to be configured in the next intermediate layer; according to the preset attribute value and the pointer of the same node to be configured, the key-value pair is configured to obtain the attribute node, wherein the key in the key-value pair is the preset attribute value, and the value in the key-value pair is the pointer.
[0036] Optionally, according to the pairing result, configuring the preset attribute value for each node to be configured includes: when the pairing result indicates that the attribute item corresponding to the intermediate layer exists in the rule, configuring the preset attribute value corresponding to the attribute item for the node to be configured in the intermediate layer; when the pairing result indicates that the attribute item corresponding to the intermediate layer does not exist in the rule, configuring the target attribute value for the node to be configured in the intermediate layer, wherein the target attribute value is the preset attribute value that can match any of the attribute values to be matched.
[0037] According to another aspect of an embodiment of the present invention, a list matching device is also provided, including: an acquisition module for acquiring data to be matched, wherein the data to be matched includes: attribute values to be matched corresponding to multiple attribute items; a matching module for matching the multiple attribute values to be matched layer by layer in multiple matching layers of a preset list hash tree to obtain a matching result, wherein the matching layers in the preset list hash tree are: a root layer, multiple intermediate layers, and a tail layer, each of the intermediate layers includes multiple attribute nodes of the same attribute item, each of the attribute nodes has a pre-configured key-value pair, the key in the key-value pair is a preset attribute value for matching the attribute value to be matched, and the value in the key-value pair is a pointer to a node to be matched in the next intermediate layer. , the node to be matched is at least one attribute node for matching with the attribute value to be matched, the matching result is used to indicate whether there is a path in the preset list hash tree, and the path indicates that multiple attribute values to be matched in the data to be matched start from the root layer and are matched with the attribute nodes in each of the intermediate layers in sequence until the tail layer is reached; a determination module is used to determine whether the data to be matched complies with the rules recorded in the preset list when the matching result indicates that there is the path in the preset list hash tree, wherein the preset list is used to establish the preset list hash tree, and the preset list includes: multiple rules, and each rule includes: the preset attribute values corresponding to multiple attribute items.
[0038] According to another aspect of an embodiment of the present invention, an electronic device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to execute the list matching method through the computer program.
[0039] According to another aspect of an embodiment of the present invention, a computer program product is provided, comprising computer instructions, which implement the steps of the list matching method when executed by a processor.
[0040] In an embodiment of the present invention, a preset list hash tree is established in advance based on the preset list, and then multiple to-be-matched attribute values in the to-be-matched data are matched layer by layer in multiple matching layers of the preset list hash tree. When there are paths in the preset list hash tree that match the multiple to-be-matched attribute values in the to-be-matched data one by one, it is determined that the to-be-matched data matches the preset list. Therefore, by utilizing the preset list hash tree, there is no need to match the to-be-matched data with the multiple preset rules in the preset list one by one, and there is no need to repeatedly match the to-be-matched attribute values in the to-be-matched data with the preset attribute values in different preset rules. This achieves the technical effect of improving the matching efficiency between the to-be-matched data and the preset list, and solves the technical problem of poor matching efficiency for multi-attribute black and white lists. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0042] Figure 1 is a flow chart of a list matching method according to an embodiment of the present invention;
[0043] Figure 2 is a schematic diagram of a memory structure of a list according to an embodiment of the present invention;
[0044] Figure 3 is a schematic diagram of a list matching device according to an embodiment of the present invention;
[0045] Figure 4 It is a structural block diagram of a computer terminal according to an embodiment of the present invention. DETAILED DESCRIPTION
[0046] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.
[0047] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0048] First, some nouns or terms that appear in the description of the embodiments of the present application are subject to the following interpretations:
[0049] A whitelist is a list of rules that combines a single attribute or multiple attributes (such as IP address, device ID, phone number, user tag, city, geographic location, etc.). Users on the whitelist are allowed to perform subsequent operations. A blacklist is the reverse of the whitelist. Users on the blacklist are not allowed to perform subsequent operations.
[0050] QPS, or queries per second, is an important metric for measuring system processing power. It is often used to evaluate database, cache, and server performance.
[0051] According to an embodiment of the present invention, an embodiment of a list matching method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0052] Figure 1 is a flow chart of a list matching method according to an embodiment of the present invention. Figure 1 As shown, the method includes the following steps:
[0053] Step S102: obtaining data to be matched, wherein the data to be matched includes: attribute values to be matched corresponding to a plurality of attribute items;
[0054] Step S104: Match the multiple attribute values to be matched layer by layer in the multiple matching layers of the preset list hash tree to obtain a matching result. The matching layers in the preset list hash tree are: a root layer, multiple intermediate layers, and a tail layer. Each intermediate layer includes multiple attribute nodes of the same attribute item. Each attribute node has a pre-configured key-value pair. The key in the key-value pair is a preset attribute value for matching the attribute value to be matched. The value in the key-value pair is a pointer to a node to be matched in the next intermediate layer. The node to be matched is at least one attribute node for matching the attribute value to be matched. The matching result is used to indicate whether there is a path in the preset list hash tree. The path indicates that the multiple attribute values to be matched in the data to be matched start from the root layer and match the attribute nodes in each intermediate layer in sequence until the tail layer is reached.
[0055] Step S106, when the matching result indicates that there is a path in the preset list hash tree, determines whether the data to be matched meets the rules recorded in the preset list, wherein the preset list is used to establish the preset list hash tree, and the preset list includes: multiple rules, each rule includes: preset attribute values corresponding to multiple attribute items.
[0056] In an embodiment of the present invention, a preset list hash tree is established in advance based on the preset list, and then multiple to-be-matched attribute values in the to-be-matched data are matched layer by layer in multiple matching layers of the preset list hash tree. When there are paths in the preset list hash tree that match the multiple to-be-matched attribute values in the to-be-matched data one by one, it is determined that the to-be-matched data matches the preset list. Therefore, by utilizing the preset list hash tree, there is no need to match the to-be-matched data with the multiple preset rules in the preset list one by one, and there is no need to repeatedly match the to-be-matched attribute values in the to-be-matched data with the preset attribute values in different preset rules. This achieves the technical effect of improving the matching efficiency between the to-be-matched data and the preset list, and solves the technical problem of poor matching efficiency for multi-attribute black and white lists.
[0057] In the above step S102, the data to be matched includes: multiple attribute items, each attribute item has a corresponding attribute value to be matched. During the matching process, the attribute items can be used to lock the object for matching, such as determining a preset attribute value for matching with the attribute value to be matched, and then matching the attribute value to be matched with the corresponding preset attribute value.
[0058] In the above step S104 , the preset list hash tree may be established according to the preset list.
[0059] Optionally, the preset list may be a blacklist or a whitelist.
[0060] Optionally, the preset list includes: multiple rules, each rule records multiple attribute items, and preset attribute values corresponding to each attribute item.
[0061] Optionally, the attribute items in each rule correspond one-to-one to the attribute items in the data to be matched, but the preset attribute value corresponding to the same attribute item in the rule and the attribute value to be matched corresponding to the data to be matched may be the same or different. When the preset attribute value corresponding to the same attribute item is the same as the attribute value to be matched, it means that the data to be matched matches the rule for the attribute item, and the attribute item is the matching attribute item. When every attribute item in the same rule matches the data to be matched, it means that the data to be matched matches the rule, and the rule is the matching rule.
[0062] In the above step S104, the preset list hash tree includes at least: a root layer, multiple intermediate layers, and a tail layer. The root layer serves as the starting point of the match, and the tail layer serves as the end point of the match. Each intermediate layer includes multiple attribute nodes of the same attribute item. The preset list hash tree matches the attribute values to be matched in the data to be matched through the attribute nodes. Each attribute node uses a key-value pair to record the preset attribute value corresponding to the attribute item, and a pointer to the next attribute node to be matched after the match is successful.
[0063] Optionally, the middle layer may include multiple layers, and the number of the middle layers may be determined according to the number of attribute items in the same rule (or the same data to be matched).
[0064] Optionally, the same layer of the intermediate layer may include: multiple preset attribute values for the same attribute item in multiple rules, and different preset attribute values may be set in different attribute nodes.
[0065] Optionally, the data to be matched is matched one by one with multiple attribute nodes in each intermediate layer in the preset list hash tree. If the match with a certain attribute node fails, it is matched with the next attribute node in the same intermediate layer until the match is successful. If all attribute nodes in the same intermediate layer fail to match, it means that the data to be matched fails to match the preset list used to construct the preset list hash tree.
[0066] Optionally, when the data to be matched successfully matches an attribute node in a certain intermediate layer, matching is performed with multiple attribute nodes in the next intermediate layer according to the pointer of the key-value pair in the attribute node.
[0067] In the above step S104 , the node to be matched may be at least one attribute node belonging to the same attribute item.
[0068] Optionally, if there is the same preset attribute value for the same attribute item in multiple rules, the preset attribute value can be used as the key of the preset key-value pair in the attribute node corresponding to the attribute item, and the node to be matched can be the value of the preset key-value pair in the attribute node. The node to be matched can be at least one attribute node corresponding to the next attribute item.
[0069] As an optional embodiment, after obtaining the data to be matched, the method further includes: identifying the attribute item corresponding to each intermediate layer in the preset list hash tree; and extracting the attribute value to be matched corresponding to each attribute item from the data to be matched.
[0070] In the above embodiment of the present application, the data to be matched is matched with the preset list hash tree based on the attribute items. During the matching process, the attribute values to be matched corresponding to each attribute item can be extracted one by one in the data to be matched according to the order of the intermediate layers corresponding to each attribute item in the preset list hash tree, and then the attribute values to be matched are matched with the preset attribute values pre-configured in the attribute nodes in the intermediate layer, thereby achieving a technical effect of matching the attribute values to be matched in the data to be matched based on the attribute items.
[0071] As an optional embodiment, before matching multiple attribute values to be matched layer by layer in multiple matching layers of a preset list hash tree to obtain a matching result, the method also includes: obtaining a preset list, wherein the preset list is a blacklist or a whitelist; identifying multiple attribute items of each rule in the preset list, and the preset attribute values corresponding to each attribute item; setting multiple matching layers in the preset list hash tree according to the multiple attribute items in the preset list, wherein the matching layers include: a root layer as the starting point of matching, intermediate layers corresponding to different attribute items, and a tail layer as the end point of matching; attribute nodes are set in each intermediate layer according to the multiple attribute items in each rule and the preset attribute values corresponding to each attribute item, wherein a corresponding attribute node is set for each preset attribute value in the intermediate layer corresponding to the attribute item, and pointers are set for the attribute nodes according to the multiple preset attribute values of the same rule.
[0072] In the above embodiment of the present application, the preset list hash tree is constructed based on the preset list, which includes multiple rules, each rule includes multiple attribute items, and each attribute item has a corresponding preset attribute value. In the process of constructing the preset list hash tree, a matching layer including a root layer, multiple middle layers and a tail layer can be set, and an attribute node corresponding to each preset attribute value can be set in the middle layer corresponding to each attribute item, and based on multiple preset attribute values of the same rule, pointers between attribute nodes are set, so that the preset list hash tree can achieve the same function as the rules in the preset list.
[0073] As an optional embodiment, according to multiple attribute items in the preset list, setting multiple matching layers in the preset list hash tree includes: identifying the number of different attribute items in the preset list; setting the number of intermediate layers in the preset list hash tree according to the number of items, wherein the number of items is the same as the number of layers; setting a root layer as the starting point of matching before the intermediate layer, and setting a tail layer as the end point of matching after the intermediate layer.
[0074] In the above embodiment of the present application, in the preset list hash tree, the number of intermediate layers is the same as the number of different attribute items in the preset list, that is, each different attribute item has a corresponding intermediate layer, and then a root layer and a tail layer are added at both ends of the multiple intermediate layers as the matching starting point and matching end point.
[0075] As an optional embodiment, based on multiple attribute items in each rule and the preset attribute values corresponding to each attribute item, the attribute nodes set in each intermediate layer include: in each intermediate layer, setting the corresponding node to be configured for the same rule; based on multiple attribute items in the same rule and the preset attribute values corresponding to each attribute item, configuring the node to be configured with key-value pairs to obtain the attribute node.
[0076] In the above-mentioned embodiment of the present application, the preset attribute values of multiple attribute items in the same rule can be set in different intermediate layers of the preset list hash tree, and each intermediate layer corresponds to different attribute items of the same rule. Then, attribute nodes are configured in each intermediate layer, and the attribute nodes match the attribute values to be matched of the same attribute item with the preset attribute values.
[0077] As an optional embodiment, according to multiple attribute items in the same rule and the preset attribute value corresponding to each attribute item, the node to be configured is configured with a key-value pair to obtain the attribute node, including: pairing each intermediate layer with the attribute item in each rule in sequence from the root layer to the last layer to obtain a pairing result, wherein the pairing result is used to indicate whether there is an attribute item corresponding to the intermediate layer in the rule; according to the pairing result, configuring the preset attribute value for each node to be configured; according to the order from the root layer to the last layer, configuring a pointer to the node to be configured in each intermediate layer for the same rule, wherein the pointer points to the node to be configured in the next intermediate layer; configuring the key-value pair according to the preset attribute value and the pointer of the same node to be configured to obtain the attribute node, wherein the key in the key-value pair is the preset attribute value, and the value in the key-value pair is the pointer.
[0078] In the above embodiment of the present application, the preset attribute values of multiple attribute items in the same rule can be set in different intermediate layers of the preset list hash tree, each intermediate layer corresponds to different attribute items of the same rule, and then attribute nodes are configured in each intermediate layer. The multiple attribute items in the same rule can be used to determine the value of the key-value pair in each attribute node, and the preset attribute values corresponding to the attribute items in the same rule can be used to determine the key of the key-value pair in each attribute node, so that the same rule can be represented in the preset list hash tree as a path connected by multiple attribute nodes, and the connection relationship between each attribute node is indicated by the key of the key-value pair in the attribute node.
[0079] As an optional embodiment, according to the pairing result, configuring a preset attribute value for each node to be configured includes: when there is an attribute item corresponding to the middle layer in the pairing result representation rule, configuring the preset attribute value corresponding to the attribute item for the node to be configured in the middle layer; when there is no attribute item corresponding to the middle layer in the pairing result representation rule, configuring a target attribute value for the node to be configured in the middle layer, wherein the target attribute value is a preset attribute value that can match any attribute value to be matched.
[0080] In the above embodiments of the present application, the requirements for attribute items are also different in different rules. If there is no preset attribute value for a certain attribute item in a certain rule, it means that this rule does not require this attribute item. Then, in the preset list hash tree, in the middle layer corresponding to this attribute item, the target attribute value is used to configure the attribute node. Since the target attribute value is a preset attribute value that can match any待匹配属性值 (to be matched attribute value), the attribute node configured with the target attribute value can make the configured preset list hash tree meet the requirements of this rule for this attribute item.
[0081] The present invention also provides an optional embodiment, which provides a high-performance memory structure and matching method, provided in the form of source code or binary library, and can greatly improve the matching performance of multi-attribute black and white lists.
[0082] For example, assuming the number of rules is n and the number of attributes (IP, device ID, etc.) is m, the matching complexity is O(m), which is only related to the number of attributes and has nothing to do with the number of rules. In the scenario of less than 10 attribute numbers and 1 million rules, it is still possible to achieve a matching performance of tens of millions of times per second in a single thread.
[0083] As an optional example, the white list is as follows:
[0084] “city = Beijing & os = android & tag = t0001
[0085] city = Beijing & os = android & tag = t0002
[0086] city = Beijing & os = android & tag = t0003
[0087] city = Beijing & os = ios
[0088] city = Shanghai & os = ios & tag = t0002
[0089] city = Shanghai & tag = t0003
[0090] tag = t0004
[0091] tag = t0005”.
[0092] Figure 2 It is a schematic diagram of the memory structure of a list according to an embodiment of the present invention. As Figure 2 shown, the above white list is constructed into a multi-level nested hash tree structure. The construction process includes:
[0093] Step S201, determine the number of layers. Among them, each attribute corresponds to one layer. As configured above with city, os, tag attributes, plus the root layer (<root>) and the tail layer ( <eof>), with a total of 5 layers.
[0094] Step S202, define the nodes corresponding to each layer (such as the middle layer) (such as attribute nodes). Among them, the upper-layer nodes point to the corresponding subtrees in the lower layer. Each layer of nodes can include two types, as Figure 2 shown, blue nodes, which have definite values (i.e., preset attribute values), adopt the HashMap structure, where the Key is the attribute value and the Value is a pointer pointing to the corresponding lower-layer subtree; green nodes, which have no definite values (i.e., any value is acceptable, that is, the target attribute value).
[0095] For example:
[0096] The rule "-city = Beijing, os = android, tag = t0001" includes three layers: city, os, and tag, and each layer has a definite value. Therefore, each layer is a blue node.
[0097] The rule "-city = Beijing, os = ios", the city and os layers have definite values and are blue nodes; the tag layer has no definite value and is a green node.
[0098] The rule "-tag = t0004", the city and os layers have no definite values and are green nodes; the tag layer has a definite value and is a blue node.
[0099] Step S203, place the nodes corresponding to each attribute row by row in the appropriate positions of each layer. The lower layer must be under the subtree pointed to by the value of the upper-layer node. Finally, each row forms a self <root>Layer through each layer to reach <eof>Layer pathways.
[0100] As an optional example, during the matching process, <root>Starting from the layer, go to the nodes corresponding to the values in the next layer. If there is a node that can be reached <eof>If there is a path, it is a match; if there is no path, it is a mismatch. The specific matching process includes:
[0101] Step S301: The pointer is positioned at <root>The next level;
[0102] Step S302: If there is a green node, recurse to the lower subtree until all subtrees are matched, then the whole tree is matched and exit.
[0103] Step S303: If a blue node exists, the hash is used to locate the corresponding subtree in the lower layer. If it exists, the subtree is recursively searched until all subtrees are matched. If so, the whole tree is matched and the process is exited.
[0104] Step S304: Other situations are not matched.
[0105] The technical solution provided by this application solves the problem of low efficiency of previous multi-attribute matching. It improves the rule-by-rule matching to multi-layer hash matching, making the matching performance independent of the number of rules. In a scenario with millions of rules, the performance is improved by tens of thousands of times compared with rule-by-rule matching, reaching a single-thread matching performance of tens of millions of times per second. It can be applied to high-concurrency application scenarios such as targeted advertising and abnormal traffic filtering.
[0106] The technical solution provided in this application performs a matching test on 10 attributes with millions of rules when a mainstream notebook uses the 13th generation Core i7 13700H CPU. The result of the matching test is: single-core matching QPS>=10 million.
[0107] According to an embodiment of the present invention, an embodiment of a list matching device is also provided. It should be noted that the list matching device can be used to execute the list matching method in the embodiment of the present invention, and the list matching method in the embodiment of the present invention can be executed in the list matching device.
[0108] Figure 3 is a schematic diagram of a list matching device according to an embodiment of the present invention, such as Figure 3 As shown, the device may include: an acquisition module 32, for acquiring data to be matched, wherein the data to be matched includes: attribute values to be matched corresponding to multiple attribute items; a matching module 34, for matching the multiple attribute values to be matched layer by layer in multiple matching layers of a preset list hash tree to obtain a matching result, wherein the matching layers in the preset list hash tree are: a root layer, multiple middle layers, and a tail layer, each middle layer includes multiple attribute nodes of the same attribute item, each attribute node has a pre-configured key-value pair, the key in the key-value pair is a preset attribute value for matching the attribute value to be matched, and the value in the key-value pair is a pointer to the attribute value to be matched in the next middle layer. The pointer to the matching node is a node to be matched, and the node to be matched is at least one attribute node used to match the attribute value to be matched. The matching result is used to indicate whether there is a path in the preset list hash tree. The path indicates that multiple attribute values to be matched in the data to be matched start from the root layer and are matched with the attribute nodes in each intermediate layer in turn until the tail layer is reached; the determination module 36 is used to determine whether the data to be matched meets the rules recorded in the preset list when the matching result indicates that there is a path in the preset list hash tree, wherein the preset list is used to establish the preset list hash tree, and the preset list includes: multiple rules, and each rule includes: preset attribute values corresponding to multiple attribute items.
[0109] It should be noted that the acquisition module 32 in this embodiment can be used to execute step S102 in the embodiment of the present application, the matching module 34 in this embodiment can be used to execute step S104 in the embodiment of the present application, and the determination module 36 in this embodiment can be used to execute step S106 in the embodiment of the present application. The examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the contents disclosed in the above embodiments.
[0110] In an embodiment of the present invention, a preset list hash tree is established in advance based on the preset list, and then multiple to-be-matched attribute values in the to-be-matched data are matched layer by layer in multiple matching layers of the preset list hash tree. When there are paths in the preset list hash tree that match the multiple to-be-matched attribute values in the to-be-matched data one by one, it is determined that the to-be-matched data matches the preset list. Therefore, by utilizing the preset list hash tree, there is no need to match the to-be-matched data with the multiple preset rules in the preset list one by one, and there is no need to repeatedly match the to-be-matched attribute values in the to-be-matched data with the preset attribute values in different preset rules. This achieves the technical effect of improving the matching efficiency between the to-be-matched data and the preset list, and solves the technical problem of poor matching efficiency for multi-attribute black and white lists.
[0111] As an optional embodiment, the device also includes: a first identification submodule, which is used to identify the attribute items corresponding to each intermediate layer in the preset list hash tree after obtaining the data to be matched; and an extraction submodule, which is used to extract the attribute value to be matched corresponding to each attribute item from the data to be matched.
[0112] As an optional embodiment, the device also includes: an acquisition submodule, which is used to obtain a preset list before matching multiple attribute values to be matched layer by layer in multiple matching layers of the preset list hash tree to obtain a matching result, wherein the preset list is a blacklist or a whitelist; a second identification submodule, which is used to identify multiple attribute items of each rule in the preset list and the preset attribute values corresponding to each attribute item; a first setting submodule, which is used to set multiple matching layers in the preset list hash tree according to the multiple attribute items in the preset list, wherein the matching layer includes: a root layer as the starting point of the matching, intermediate layers corresponding to different attribute items, and a tail layer as the end point of the matching; a second setting submodule, which is used to set attribute nodes in each intermediate layer according to the multiple attribute items in each rule and the preset attribute values corresponding to each attribute item, wherein a corresponding attribute node is set for each preset attribute value in the intermediate layer corresponding to the attribute item, and a pointer is set for the attribute node according to the multiple preset attribute values of the same rule.
[0113] As an optional embodiment, the first setting submodule includes: an identification unit for identifying the number of different attribute items in a preset list; a first setting unit for setting the number of intermediate layers in the preset list hash tree according to the number of items, wherein the number of items is the same as the number of layers; a second setting unit for setting a root layer as a starting point for matching before the intermediate layer, and a tail layer as an end point for matching after the intermediate layer.
[0114] As an optional embodiment, the second setting submodule includes: a third setting unit, used to set the corresponding node to be configured for the same rule in each intermediate layer; a configuration unit, used to configure the node to be configured in key-value pairs according to multiple attribute items in the same rule and the preset attribute values corresponding to each attribute item to obtain an attribute node.
[0115] As an optional embodiment, the configuration unit includes: a pairing subunit, which pairs each intermediate layer with the attribute item in each rule in order from the root layer to the tail layer to obtain a pairing result, wherein the pairing result is used to indicate whether there is an attribute item corresponding to the intermediate layer in the rule; a first configuration subunit, which is used to configure a preset attribute value for each node to be configured according to the pairing result; a second configuration subunit, which is used to configure a pointer to the node to be configured in each intermediate layer for the same rule in the order from the root layer to the tail layer, wherein the pointer points to the node to be configured in the next intermediate layer; a third configuration subunit, which is used to configure a key-value pair according to the preset attribute value and pointer of the same node to be configured to obtain an attribute node, wherein the key in the key-value pair is the preset attribute value, and the value in the key-value pair is the pointer.
[0116] As an optional embodiment, the first configuration subunit includes: a fourth configuration subunit, which is used to configure a preset attribute value corresponding to the attribute item for the node to be configured in the middle layer when there is an attribute item corresponding to the middle layer in the pairing result representation rule; and a fifth configuration subunit, which is used to configure a target attribute value for the node to be configured in the middle layer when there is no attribute item corresponding to the middle layer in the pairing result representation rule, wherein the target attribute value is a preset attribute value that can match any attribute value to be matched.
[0117] An embodiment of the present invention may provide an electronic device, which may be a computer terminal, and the computer terminal may be any computer terminal device in a computer terminal group. Optionally, in this embodiment, the computer terminal may also be replaced by a terminal device such as a mobile terminal.
[0118] Optionally, in this embodiment, the computer terminal may be located in at least one network device among a plurality of network devices of a computer network.
[0119] In this embodiment, the computer terminal can execute the program code of the following steps in the list matching method: obtaining data to be matched, wherein the data to be matched includes: attribute values to be matched corresponding to multiple attribute items; matching the multiple attribute values to be matched layer by layer in multiple matching layers of a preset list hash tree to obtain matching results, wherein the matching layers in the preset list hash tree are: a root layer, multiple middle layers, and a tail layer, each middle layer includes multiple attribute nodes of the same attribute item, each attribute node has a pre-configured key-value pair, the key in the key-value pair is a preset attribute value for matching the attribute value to be matched, and the value in the key-value pair is a pointer to A pointer to a node to be matched in the next intermediate layer, where the node to be matched is at least one attribute node used to match the attribute value to be matched. The matching result is used to indicate whether there is a path in the preset list hash tree, where the path indicates that multiple attribute values to be matched in the data to be matched start from the root layer and are matched with the attribute nodes in each intermediate layer in sequence until the tail layer is reached. When the matching result indicates that there is a path in the preset list hash tree, it is determined that the data to be matched meets the rules recorded in the preset list, wherein the preset list is used to establish the preset list hash tree, and the preset list includes: multiple rules, and each rule includes: preset attribute values corresponding to multiple attribute items.
[0120] Figure 4 is a structural block diagram of a computer terminal according to an embodiment of the present invention, such as Figure 4 As shown, the computer terminal 40 may include: one or more (only one is shown in the figure) processors 42 and a memory 44.
[0121] The memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the list matching method and device in the embodiments of the present invention. The processor executes the software programs and modules stored in the memory to perform various functional applications and data processing, thereby implementing the above-mentioned list matching method. The memory can include high-speed random access memory and can also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory can further include memory remotely located relative to the processor, and these remote memories can be connected to the terminal 40 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0122] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: obtaining data to be matched, wherein the data to be matched includes: attribute values to be matched corresponding to multiple attribute items; matching the multiple attribute values to be matched layer by layer in multiple matching layers of the preset list hash tree to obtain matching results, wherein the matching layers in the preset list hash tree are: root layer, multiple middle layers, and tail layer, each middle layer includes multiple attribute nodes of the same attribute item, each attribute node has a pre-configured key-value pair, the key in the key-value pair is a preset attribute value for matching the attribute value to be matched, and the value in the key-value pair is a pointer to A pointer to a node to be matched in the next intermediate layer, where the node to be matched is at least one attribute node used to match the attribute value to be matched. The matching result is used to indicate whether there is a path in the preset list hash tree, where the path indicates that multiple attribute values to be matched in the data to be matched start from the root layer and are matched with the attribute nodes in each intermediate layer in sequence until the tail layer is reached. When the matching result indicates that there is a path in the preset list hash tree, it is determined that the data to be matched meets the rules recorded in the preset list, wherein the preset list is used to establish the preset list hash tree, and the preset list includes: multiple rules, and each rule includes: preset attribute values corresponding to multiple attribute items.
[0123] Optionally, the processor may further execute program code of the following steps: identifying the attribute item corresponding to each intermediate layer in the preset list hash tree; and extracting the attribute value to be matched corresponding to each attribute item from the data to be matched.
[0124] Optionally, the processor may also execute the following program code: obtaining a preset list, wherein the preset list is a blacklist or a whitelist; identifying multiple attribute items of each rule in the preset list, and the preset attribute value corresponding to each attribute item; setting multiple matching layers in the preset list hash tree according to the multiple attribute items in the preset list, wherein the matching layer includes: a root layer as the starting point of the match, intermediate layers corresponding to different attribute items, and a tail layer as the end point of the match; setting attribute nodes in each intermediate layer according to the multiple attribute items in each rule and the preset attribute value corresponding to each attribute item, wherein a corresponding attribute node is set for each preset attribute value in the intermediate layer corresponding to the attribute item, and a pointer is set for the attribute node according to the multiple preset attribute values of the same rule.
[0125] Optionally, the processor may also execute the following program code steps: identifying the number of different attribute items in a preset list; setting the number of intermediate layers in the hash tree of the preset list according to the number of items, where the number of items is the same as the number of layers; setting a root layer as the starting point of matching before the intermediate layer, and setting a tail layer as the end point of matching after the intermediate layer.
[0126] Optionally, the above-mentioned processor can also execute the program code of the following steps: in each intermediate layer, set the corresponding node to be configured for the same rule; according to multiple attribute items in the same rule and the preset attribute values corresponding to each attribute item, configure the key-value pairs of the node to be configured to obtain the attribute node.
[0127] Optionally, the processor may also execute the program code of the following steps: pairing each intermediate layer with the attribute item in each rule in sequence from the root layer to the tail layer to obtain a pairing result, wherein the pairing result is used to indicate whether there is an attribute item corresponding to the intermediate layer in the rule; configuring a preset attribute value for each node to be configured according to the pairing result; configuring a pointer to the node to be configured in each intermediate layer for the same rule in the sequence from the root layer to the tail layer, wherein the pointer points to the node to be configured in the next intermediate layer; configuring a key-value pair according to the preset attribute value and pointer of the same node to be configured to obtain an attribute node, wherein the key in the key-value pair is the preset attribute value, and the value in the key-value pair is the pointer.
[0128] Optionally, the above-mentioned processor can also execute the program code of the following steps: when there is an attribute item corresponding to the middle layer in the pairing result representation rule, configure the preset attribute value corresponding to the attribute item for the node to be configured in the middle layer; when there is no attribute item corresponding to the middle layer in the pairing result representation rule, configure the target attribute value for the node to be configured in the middle layer, wherein the target attribute value is a preset attribute value that can match any attribute value to be matched.
[0129] In an embodiment of the present invention, a preset list hash tree is established in advance based on the preset list, and then multiple to-be-matched attribute values in the to-be-matched data are matched layer by layer in multiple matching layers of the preset list hash tree. When there are paths in the preset list hash tree that match the multiple to-be-matched attribute values in the to-be-matched data one by one, it is determined that the to-be-matched data matches the preset list. Therefore, by utilizing the preset list hash tree, there is no need to match the to-be-matched data with the multiple preset rules in the preset list one by one, and there is no need to repeatedly match the to-be-matched attribute values in the to-be-matched data with the preset attribute values in different preset rules. This achieves the technical effect of improving the matching efficiency between the to-be-matched data and the preset list, and solves the technical problem of poor matching efficiency for multi-attribute black and white lists.
[0130] It can be understood by those skilled in the art that Figure 4 The structure shown is for illustration only, and the computer terminal may also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a handheld computer, a mobile Internet device (MID), a PAD, or other terminal devices. Figure 4 It does not limit the structure of the above electronic device. For example, the computer terminal 40 may also include Figure 4 More or fewer components (such as network interfaces, display devices, etc.) shown in, or with Figure 4 Different configurations shown.
[0131] A person skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a computer program. The computer program can be stored in a non-volatile medium. The non-volatile storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0132] The embodiment of the present invention further provides a non-volatile storage medium. Optionally, in this embodiment, the non-volatile storage medium can be used to store the program code executed by the list matching method provided in the above embodiment.
[0133] Optionally, in this embodiment, the non-volatile storage medium may be located in any computer terminal in a computer terminal group in a computer network, or in any mobile terminal in a mobile terminal group.
[0134] Optionally, in this embodiment, the non-volatile storage medium is configured to store program codes for executing the following steps: obtaining data to be matched, wherein the data to be matched includes: attribute values to be matched corresponding to a plurality of attribute items; matching the plurality of attribute values to be matched layer by layer in a plurality of matching layers of a preset list hash tree to obtain matching results, wherein the matching layers in the preset list hash tree are: a root layer, a plurality of intermediate layers, and a tail layer, each intermediate layer includes a plurality of attribute nodes of the same attribute item, each attribute node has a pre-configured key-value pair, the key in the key-value pair is a preset attribute value for matching the attribute value to be matched, and the value in the key-value pair is A pointer to a node to be matched in the next intermediate layer, where the node to be matched is at least one attribute node used to match the attribute value to be matched. The matching result is used to indicate whether there is a path in the preset list hash tree. The path indicates that multiple attribute values to be matched in the data to be matched start from the root layer and are matched with the attribute nodes in each intermediate layer in turn until the tail layer is reached. When the matching result indicates that there is a path in the preset list hash tree, it is determined that the data to be matched meets the rules recorded in the preset list, wherein the preset list is used to establish the preset list hash tree, and the preset list includes: multiple rules, and each rule includes: preset attribute values corresponding to multiple attribute items.
[0135] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for executing the following steps: identifying the attribute item corresponding to each intermediate layer in the preset list hash tree; and extracting the attribute value to be matched corresponding to each attribute item from the data to be matched.
[0136] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for executing the following steps: obtaining a preset list, wherein the preset list is a blacklist or a whitelist; identifying multiple attribute items of each rule in the preset list, and preset attribute values corresponding to each attribute item; setting multiple matching layers in the preset list hash tree based on the multiple attribute items in the preset list, wherein the matching layer includes: a root layer as the starting point of the match, intermediate layers corresponding to different attribute items, and a tail layer as the end point of the match; setting attribute nodes in each intermediate layer based on the multiple attribute items in each rule and the preset attribute values corresponding to each attribute item, wherein a corresponding attribute node is set for each preset attribute value in the intermediate layer corresponding to the attribute item, and a pointer is set for the attribute node based on the multiple preset attribute values of the same rule.
[0137] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for performing the following steps: identifying the number of different attribute items in a preset list; setting the number of intermediate layers in the preset list hash tree according to the number of items, where the number of items is the same as the number of layers; setting a root layer as the starting point of matching before the intermediate layer, and setting a tail layer as the end point of matching after the intermediate layer.
[0138] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for executing the following steps: in each intermediate layer, setting a corresponding node to be configured for the same rule; configuring the node to be configured in key-value pairs according to multiple attribute items in the same rule and the preset attribute values corresponding to each attribute item to obtain an attribute node.
[0139] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for executing the following steps: pairing each intermediate layer with the attribute item in each rule in sequence from the root layer to the last layer to obtain a pairing result, wherein the pairing result is used to indicate whether there is an attribute item corresponding to the intermediate layer in the rule; configuring a preset attribute value for each node to be configured according to the pairing result; configuring a pointer to the node to be configured in each intermediate layer for the same rule in the sequence from the root layer to the last layer, wherein the pointer points to the node to be configured in the next intermediate layer; configuring a key-value pair according to the preset attribute value and pointer of the same node to be configured to obtain an attribute node, wherein the key in the key-value pair is the preset attribute value, and the value in the key-value pair is the pointer.
[0140] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for executing the following steps: when there is an attribute item corresponding to the intermediate layer in the pairing result representation rule, configuring a preset attribute value corresponding to the attribute item for the node to be configured in the intermediate layer; when there is no attribute item corresponding to the intermediate layer in the pairing result representation rule, configuring a target attribute value for the node to be configured in the intermediate layer, wherein the target attribute value is a preset attribute value that can match any attribute value to be matched.
[0141] An embodiment of the present invention further provides a computer program product, including a computer program. Optionally, in this embodiment, when the computer program is executed by a processor, the steps of the list matching method provided in the above embodiment are implemented.
[0142] The serial numbers of the above embodiments of the present invention are for description only and do not represent the advantages or disadvantages of the embodiments.
[0143] In the above embodiments of the present invention, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0144] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only exemplary. For example, the division of the units can be a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0145] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0146] In addition, the functional units in the various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0147] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a non-volatile storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a non-volatile storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present invention. The aforementioned non-volatile storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program code.
[0148] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as within the scope of protection of the present invention.< / root> < / eof> < / root> < / eof> < / root> < / eof> < / root>
Claims
1. A list matching method, characterized in that: include: Acquire data to be matched, wherein the data to be matched includes: attribute values to be matched corresponding to a plurality of attribute items; Matching the plurality of attribute values to be matched layer by layer in the plurality of matching layers of the preset list hash tree to obtain a matching result, wherein the matching layers in the preset list hash tree are: a root layer, a plurality of intermediate layers, and a tail layer, each of the intermediate layers includes a plurality of attribute nodes of the same attribute item, each of the attribute nodes has a pre-configured key-value pair, the key in the key-value pair is a preset attribute value for matching the attribute value to be matched, the value in the key-value pair is a pointer to a node to be matched in the next intermediate layer, the node to be matched is at least one attribute node for matching the attribute value to be matched, and the matching result is used to indicate whether there is a path in the preset list hash tree, the path indicating that the plurality of attribute values to be matched in the data to be matched start from the root layer and match the attribute nodes in each intermediate layer in sequence until the tail layer is reached; When the matching result indicates that the path exists in the preset list hash tree, it is determined that the data to be matched meets the rules recorded in the preset list, wherein the preset list is used to establish the preset list hash tree, and the preset list includes: multiple rules, each rule includes: multiple preset attribute values corresponding to the attribute items.
2. The method according to claim 1, characterized in that After obtaining the data to be matched, the method further includes: Identify the attribute item corresponding to each intermediate layer in the preset list hash tree; The attribute value to be matched corresponding to each attribute item is extracted from the data to be matched.
3. The method according to claim 1, characterized in that Before matching the plurality of attribute values to be matched layer by layer in the plurality of matching layers of the preset list hash tree to obtain a matching result, the method further includes: Obtaining the preset list, wherein the preset list is a blacklist or a whitelist; Identifying a plurality of attribute items of each rule in the preset list, and the preset attribute value corresponding to each attribute item; According to the plurality of attribute items in the preset list, a plurality of matching layers are set in the preset list hash tree, wherein the matching layers include: the root layer as a matching starting point, the middle layers corresponding to different attribute items, and the tail layer as a matching end point; According to the multiple attribute items in each rule and the preset attribute value corresponding to each attribute item, the attribute node is set in each intermediate layer, wherein a corresponding attribute node is set for each preset attribute value in the intermediate layer corresponding to the attribute item, and the pointer is set for the attribute node based on the multiple preset attribute values of the same rule.
4. The method according to claim 3, characterized in that According to the plurality of attribute items in the preset list, setting a plurality of matching layers in the preset list hash tree comprises: Identifying the number of different attribute items in the preset list; According to the number of items, setting the number of layers of the intermediate layer in the preset list hash tree, wherein the number of items is the same as the number of layers; The root layer as a matching start point is set before the middle layer, and the tail layer as a matching end point is set after the middle layer.
5. The method according to claim 3, characterized in that According to the plurality of attribute items in each rule and the preset attribute value corresponding to each attribute item, the attribute node set in each intermediate layer includes: In each of the intermediate layers, a corresponding node to be configured is set for the same rule; According to the multiple attribute items in the same rule and the preset attribute value corresponding to each attribute item, the key-value pair is configured on the node to be configured to obtain the attribute node.
6. The method according to claim 5, characterized in that According to the multiple attribute items in the same rule and the preset attribute value corresponding to each attribute item, configuring the key-value pair for the node to be configured to obtain the attribute node includes: In order from the root layer to the last layer, each intermediate layer is paired with the attribute item in each rule to obtain a pairing result, wherein the pairing result is used to indicate whether the attribute item corresponding to the intermediate layer exists in the rule; According to the pairing result, configuring the preset attribute value for each node to be configured; In order from the root layer to the tail layer, for the same rule, the pointer is configured for the node to be configured in each intermediate layer, wherein the pointer points to the node to be configured in the next intermediate layer; The key-value pair is configured according to the preset attribute value and the pointer of the same node to be configured to obtain the attribute node, wherein the key in the key-value pair is the preset attribute value, and the value in the key-value pair is the pointer.
7. The method according to claim 6, characterized in that Configuring the preset attribute value for each node to be configured according to the pairing result includes: If the pairing result indicates that the attribute item corresponding to the intermediate layer exists in the rule, configuring the preset attribute value corresponding to the attribute item for the node to be configured in the intermediate layer; When the pairing result indicates that the attribute item corresponding to the intermediate layer does not exist in the rule, a target attribute value is configured for the node to be configured in the intermediate layer, wherein the target attribute value is the preset attribute value that can match any of the attribute values to be matched.
8. A list matching device, characterized in that: include: An acquisition module is used to acquire data to be matched, wherein the data to be matched includes: attribute values to be matched corresponding to a plurality of attribute items; a matching module, configured to match the plurality of attribute values to be matched layer by layer in the plurality of matching layers of the preset list hash tree to obtain a matching result, wherein the matching layers in the preset list hash tree are, in order: a root layer, a plurality of intermediate layers, and a tail layer, each of the intermediate layers including a plurality of attribute nodes for the same attribute item, each of the attribute nodes having a preconfigured key-value pair, the key in the key-value pair being a preset attribute value for matching the attribute value to be matched, the value in the key-value pair being a pointer to a node to be matched in the next intermediate layer, the node to be matched being at least one attribute node for matching the attribute value to be matched, and the matching result being used to indicate whether a path exists in the preset list hash tree, the path indicating that the plurality of attribute values to be matched in the data to be matched are matched with the attribute nodes in each intermediate layer in sequence, starting from the root layer, until the tail layer is reached; A determination module is used to determine whether the data to be matched meets the rules recorded in the preset list when the matching result indicates that the path exists in the preset list hash tree, wherein the preset list is used to establish the preset list hash tree, and the preset list includes: multiple rules, each rule includes: multiple preset attribute values corresponding to each of the attribute items.
9. An electronic device comprising a memory and a processor, characterized in that: The memory stores a computer program, and the processor is configured to execute the list matching method according to any one of claims 1 to 7 through the computer program.
10. A computer program product comprising computer instructions, characterized in that When the computer instructions are executed by a processor, the steps of the list matching method according to any one of claims 1 to 7 are implemented.