A method and device for information merging
By backing up information in the hash node and unlocking and merging it with backup information, the deadlock risk and lock time problems caused by hash bucket locking under multiple threads are solved, and the information merging efficiency is improved.
Patent Information
- Application Number
- CN202111139405.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-26
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2041-09-26
AI Technical Summary
In the multi-threading situation, the prior art requires a long time to lock multiple hash buckets during the information merging process, which increases the risk of deadlocking and increases the locking time of other threads.
By receiving and extracting the feature values of the input information, calculating the hash value, locking the hash bucket corresponding to the hash value, creating a hash node, and saving the input information and feature values in the hash node, and after backuping the information, Unlock immediately, use backup information to merge information, and lock only one party to avoid nesting and deadlocking of locks.
It reduces the waiting lock time for other threads, reduces the risk of deadlock, improves the efficiency of information merging, and reduces the number of additional and subtracts locks.
Smart Images

Figure CN113849318B_ABST
Abstract
Description
Technical Field
[0001] The technical solution disclosed herein relates to the field of network technology, and in particular to a method and device for information merging. Background Art
[0002] A hash table is a data structure that is accessed directly based on a characteristic value. In other words, it maps the characteristic value to a location in the table for access, so that the computer does not need to traverse all the data, thereby speeding up the search. A hash table contains multiple hash buckets, and a hash bucket contains multiple pointers to hash nodes.
[0003] In practical applications, a common requirement is: given multiple input information with the same feature value, the input information is merged so that the merged result can provide further services.
[0004] In order to achieve the above requirements, the implementation scheme of the prior art is: obtain the characteristic value (attr1, attr2) contained in the input information, and calculate the hash value (hash1, hash2) based on the characteristic value; then lock the two hash buckets corresponding to the hash value (hash1, hash2), and create two hash nodes, wherein there is a pointer to one of the hash nodes in each of the two hash buckets, and then allocate memory space to the hash nodes to save the input information; after the input information is saved in the two hash nodes respectively, the information saved in the storage space corresponding to one of the hash nodes is merged into the storage space corresponding to the other hash node, and finally the two hash buckets are unlocked.
[0005] Although the above method can merge multiple information with the same characteristic value, in the case of multi-threading, since multiple hash buckets need to be locked for a long time when merging multiple hash node information, the nesting problem of locks will increase, the risk of deadlock will increase, and at the same time, the waiting time for other threads will increase. Summary of the invention
[0006] In order to solve the above technical problems, the embodiments of the present disclosure provide a method and device for information merging.
[0007] Specifically, the embodiments of the present disclosure are implemented through the following technical solutions:
[0008] According to a first aspect of the present application, a method for information merging is proposed, the method comprising:
[0009] Receive and extract the characteristic value of the input information, and calculate the hash value corresponding to the characteristic value;
[0010] Locking the hash bucket corresponding to the hash value, creating a corresponding hash node in the hash bucket according to the characteristic value and the corresponding hash value, wherein the hash node includes: a hash node information area and a hash node association area;
[0011] Adding the input information to the hash node information area, and adding the characteristic value and the corresponding hash value contained in the input information to the hash node association area, wherein the characteristic value and the corresponding hash value are used as the first node identifier corresponding to the hash node in the hash node association area, and the hash node association area also includes at least one second node identifier for identifying other hash nodes;
[0012] Backing up the information in the hash node information area to obtain backup information, and unlocking the hash bucket;
[0013] The backup information is added to the hash node information area of at least one other hash node corresponding to the second node identifier, thereby completing the merging of information between the hash node and at least one other hash node corresponding to the second node identifier.
[0014] According to a second aspect of the present disclosure, a device for information merging is provided, the device comprising:
[0015] A first calculation module, used to receive and extract a characteristic value of input information, and calculate a hash value corresponding to the characteristic value;
[0016] A creation module, used for locking the hash bucket corresponding to the hash value, and creating a corresponding hash node in the hash bucket according to the characteristic value and the corresponding hash value, wherein the hash node includes: a hash node information area and a hash node association area;
[0017] An adding module, used for adding the input information to the hash node information area, and adding the characteristic value and the corresponding hash value contained in the input information to the hash node association area, wherein the characteristic value and the corresponding hash value are used as the first node identifier corresponding to the hash node in the hash node association area, and the hash node association area also includes at least one second node identifier for identifying other hash nodes;
[0018] A backup module, used for backing up the information in the hash node information area to obtain backup information, and unlocking the hash bucket;
[0019] A merging module is used to add the backup information to the hash node information area of at least one other hash node corresponding to the second node identifier, and complete the merging of information between the hash node and at least one other hash node corresponding to the second node identifier.
[0020] According to a third aspect of the present disclosure, a computer-readable storage medium is provided, wherein the machine-readable storage medium stores machine-readable instructions, and when the machine-readable instructions are called and executed by a processor, the processor is prompted to implement the method for information merging of any embodiment of the present disclosure.
[0021] According to a fourth aspect of the present disclosure, a protection device is provided, comprising a communication interface, a processor, a memory and a bus, wherein the communication interface, the processor and the memory are interconnected via a bus; the memory stores machine-readable instructions, and the processor executes the method for information merging of any embodiment of the present disclosure by calling the machine-readable instructions.
[0022] The technical solution provided by the disclosed embodiment aims at actual application needs. After the input information is saved in the hash node information area, the hash node association area is updated, and the hash node information area is immediately unlocked after being backed up, thereby reducing the waiting time for other threads to lock. The subsequent information merging process is carried out using the backup information. During the merging process, only one of the parties needs to be locked, thus avoiding the nesting problem of locks, reducing the risk of deadlock, and at the same time reducing the number of lock additions and subtractions, thereby improving the efficiency of information merging.
[0023] The technical solution provided by the embodiments of the present disclosure is further described in detail below through the accompanying drawings and implementation modes. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the technical solutions in one or more embodiments of the present disclosure or related technologies, the following briefly introduces the drawings required for use in the description of the embodiments or related technologies. Obviously, the drawings described below are only some embodiments recorded in one or more embodiments of the present disclosure. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative labor:
[0025] Figure 1 is a flow chart of an information merging method provided according to an exemplary embodiment of the present disclosure;
[0026] Figure 2 is a schematic diagram of a hash node structure provided according to an exemplary embodiment of the present disclosure;
[0027] Figure 3 is a flowchart of another information merging method provided according to an exemplary embodiment of the present disclosure;
[0028] Figure 4 is another schematic diagram of a hash node structure provided according to an exemplary embodiment of the present disclosure;
[0029] Figure 5is a flow chart of an information deletion method provided according to an exemplary embodiment of the present disclosure;
[0030] Figure 6 It is a structural diagram of an information merging device provided according to an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0031] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0032] At the same time, it should be understood that for the convenience of description, the sizes of the various parts shown in the drawings are not drawn according to the actual proportional relationship.
[0033] The terms used in this disclosure are only for the purpose of describing specific embodiments and are not intended to limit the disclosure. The singular forms of "a", "said" and "the" used in this disclosure and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0034] It should be understood that although the terms first, second, third, etc. may be used in the present disclosure to describe various information, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present disclosure, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0035] The disclosed embodiment provides a method for information merging to solve the problem in the related technology that, during the information merging process, multiple hash buckets need to be locked for a long time in a multi-threaded environment, which easily increases the nesting of locks and thus increases the risk of deadlock. At the same time, it also increases the waiting time for other threads to lock.
[0036] The information merging method of the embodiment of the present disclosure is described in detail below with reference to the accompanying drawings.
[0037] Figure 1 A flowchart of an information merging method provided by an exemplary embodiment of the present disclosure, the method of the embodiment may include the following processing:
[0038] Step S101, receiving and extracting a characteristic value of input information, and calculating a hash value corresponding to the characteristic value.
[0039] In an optional example, an input message may include multiple feature values, and each feature value may have its corresponding hash value calculated by a hash algorithm.
[0040] Step S102, locking the hash bucket corresponding to the hash value, and creating a corresponding hash node in the hash bucket according to the characteristic value and the corresponding hash value, wherein the hash node includes: a hash node information area and a hash node association area.
[0041] In an optional example, the amount of input information is large, so the information merging process needs to be performed by multiple threads. The information processing between each thread does not affect each other. However, when the information in multiple threads has the same characteristic value, the same hash node needs to be updated, and the hash bucket needs to be locked.
[0042] In an optional example, the hash value can uniquely identify a hash bucket, and the combination of the characteristic value and the corresponding hash value can uniquely identify a hash node. Therefore, a corresponding hash node can be created under the corresponding hash bucket based on the characteristic value and the corresponding hash value.
[0043] In an optional example, the hash node structure is as follows: Figure 2 As shown, the hash node includes a hash node description area, a hash node information area, and a hash node association area. The hash node description area is used to record the feature value type of the feature value extracted based on the input information and the hash value calculated based on the feature value; the hash node information area is used to record the input information; and the hash node association area is used to record the feature value and the corresponding hash value. The feature value type of the feature value can be directly obtained from the input information.
[0044] Step S103: Add the input information to the hash node information area, and add the feature value and the corresponding hash value contained in the input information to the hash node association area.
[0045] In an optional example, all hash nodes identified by the received and extracted feature values and corresponding hash values in the input information having the same feature value are referred to as associated hash nodes.
[0046] In an optional example, the input information includes not only information used as feature values but also information not used as feature values, and the hash node information area in the hash node is used to store the information used as feature values and the information not used as feature values.
[0047] In an optional example, the hash node association area is used to store other hash nodes associated with the hash node, and the feature value and the corresponding hash value can uniquely identify a hash node, so the feature value and the corresponding hash value received and extracted from the input information with the same feature value are added to the hash node association area to represent other hash nodes associated with the hash node.
[0048] Step S104, backing up the information in the hash node information area to obtain backup information, and unlocking the hash bucket.
[0049] In an optional example, when the input information is added to the hash node information area, and the characteristic value and the corresponding hash value contained in the input information are added to the hash node association area, the information in the hash node information area is backed up to obtain backup information, and the hash bucket is unlocked at the same time to facilitate other threads to operate on the hash bucket.
[0050] Step S105: Add the backup information to the hash node information area of at least one other hash node corresponding to the second node identifier, and complete the merging of information between the hash node and at least one other hash node corresponding to the second node identifier.
[0051] In an optional example, the combination of the characteristic value and the hash value corresponding to the hash node is called the first node identifier corresponding to the hash node, and the combination of the characteristic value and the corresponding hash value recorded in the hash node association area of the hash node is called the second node identifier.
[0052] For example, the combination of eigenvalue 1 and hash value 1 corresponding to the hash node can be called the first node identifier of the hash node, and the combination of eigenvalue 2 and hash value 2, eigenvalue 3 and hash value 3, etc. recorded in the hash node association area of the hash node can be called the second node identifier.
[0053] In an optional example, the backup information may be used to merge information between a hash node information area in a hash node corresponding to the first node identifier and information between hash node information areas in other hash nodes of at least one second node identifier.
[0054] In an optional example, there is only one second node identifier in the hash node association area of the hash node corresponding to the first node identifier. When it is necessary to merge the information in the hash node information area in the hash node corresponding to the first node identifier with the information in the hash node information area in the hash node corresponding to the second node identifier, it is only necessary to lock the hash node corresponding to the second node identifier, and then add the backup information of the hash node corresponding to the first node identifier to the hash node corresponding to the second node identifier.
[0055] In an optional example, there are multiple second node identifiers in the hash node association area of the hash node corresponding to the first node identifier. When it is necessary to merge the information in the hash node information area in the hash node corresponding to the first node identifier with the information in the hash node information area in the hash node corresponding to the multiple second node identifiers, firstly, according to a preset rule, find the first target hash node from the hash nodes corresponding to the multiple second node identifiers and lock it, add the backup information of the hash node in the hash node corresponding to the first node identifier to the hash node information area of the first target hash node, then back up the information of the first target hash node, find the second target hash node from the remaining multiple second node identifiers and lock it, add the backup information of the first target hash node to the hash node information area of the second target hash node, and repeat this process until the information in the hash node information area in the hash node is merged into the hash node information area of the hash node corresponding to the last second node identifier.
[0056] The information merging method of this embodiment updates the information of the hash node association area after saving the input information in the hash node information area, and unlocks it immediately after backing up the hash node information area, so as to facilitate other threads to operate on the hash bucket and reduce the waiting time of other threads; the subsequent information merging process is carried out using the backup information. During the merging process, only one of the merged parties needs to be locked, which reduces the number of lock additions and subtractions, thereby avoiding deadlocks and frequent waiting for locks and improving the efficiency of information merging.
[0057] In order to better understand the embodiments of the present disclosure, the process of information merging is further described below.
[0058] Figure 3 A flowchart of another information merging method provided by an exemplary embodiment of the present disclosure, the method of the embodiment may include the following processing:
[0059] Step S201, determining the characteristic value type corresponding to the business scenario.
[0060] In an optional example, different feature value types may be determined according to different business scenarios. For example, the business scenario is processing 5G information, and the feature value types of the 5G information are known to those of ordinary skill in the art, such as imsi, imei, ngap-id, seid, smctxid, ip+teid. Each feature value type includes multiple feature values.
[0061] Step S202: Create a hash table corresponding to the feature value type.
[0062] In an optional example, the hash tables corresponding to the respective feature value types may be created according to at least one feature value type, wherein the number of the feature value types is consistent with the number of the hash tables, and each hash table contains a plurality of hash buckets.
[0063] Step S203: pre-allocate storage space for the hash node to be created in the hash table.
[0064] In an optional example, the hash node includes a hash node description area, a hash node information area, and a hash node association area. Each area requires storage space to store the input information. Storage space is pre-allocated for the hash node to be created in the hash table. When the storage space is needed, a free storage space can be directly taken from the applied storage space, avoiding the problem of wasting time caused by applying for storage space when it is needed.
[0065] Step S204, receiving and extracting the characteristic value of the input information, and calculating the hash value corresponding to the characteristic value.
[0066] In an optional example, an input message may include multiple feature values, and each feature value has its corresponding hash value.
[0067] Step S205: lock the hash bucket corresponding to the hash value.
[0068] In an optional example, the amount of input information is large, so the process of information merging needs to be performed by multiple threads, and the information processing between each thread does not affect each other. However, when the information in multiple threads has the same feature value, the same hash node needs to be updated, and the hash bucket needs to be locked.
[0069] Step S206, determine whether the hash node corresponding to the first node identifier exists.
[0070] In an optional example, the hash node identified by the characteristic value and the corresponding hash value is called the hash node corresponding to the first node identifier.
[0071] In an optional example, after receiving the first node identifier, it can be determined whether the hash node exists based on the first node identifier. If not, execute step S207; if so, execute step S208.
[0072] Step S207, creating the hash node.
[0073] Step S208, update the information of the hash node information area and the hash node association area.
[0074] In an optional example, the hash node structure is as follows: Figure 4 As shown, the hash node includes a hash node description area, a hash node information area, and a hash node association area. The hash node description area is used to record the feature value type of the feature value extracted based on the input information and the hash value calculated based on the feature value; the hash node information area is used to record the input information; the hash node association area is used to record the feature value extracted based on the input information, the hash value calculated based on the feature value, and the node sequence parameter used to represent the order of hash node creation.
[0075] In an optional example, after the hash node is created, the input information is updated to the hash node information area, and the feature values extracted from the input information, the hash values calculated based on the feature values, and the node sequence parameters used to represent the order in which the hash nodes are created are updated to the hash node association area.
[0076] Step S209, backing up the information in the hash node information area.
[0077] Step S210, unlocking the hash bucket.
[0078] Step S211, determining whether the node sequence parameter of the hash node is the minimum value of the node sequence parameters recorded in the hash node association area of the hash node.
[0079] In an optional example, an input message contains multiple feature values, and a corresponding hash value is calculated based on each feature value. Each feature value and its corresponding hash value can uniquely identify a hash node. All hash nodes identified by the feature values and corresponding hash values received and extracted from the input message with the same feature value are called associated hash nodes.
[0080] In an optional example, the node order parameter of the hash node and the node order parameters of other hash nodes associated with the hash node are recorded in the hash node association area of the hash node. The node order parameter is used to indicate the order in which each hash node is created. The smaller the node order parameter is, the earlier the corresponding hash node is created.
[0081] In an optional example, the node order parameter of the first created hash node is named 1, the node order parameter of the second created hash node is named 2, and so on. Obviously, the creation time of the hash node with the node order parameter of 1 is earlier than the creation time of the hash node with the node order parameter of 2.
[0082] In an optional example, the node order parameter of the first created hash node is named a, the node order parameter of the second created hash node is named b, and so on. Obviously, the creation time of the hash node with the node order parameter a is earlier than the creation time of the hash node with the node order parameter b.
[0083] The naming rules of the node sequence parameters may be but are not limited to the above two types, and the embodiments of the present disclosure do not limit this.
[0084] If the node order parameter of the hash node is the minimum value of the node order parameters recorded in the hash node association area of the hash node, execute step S213; if the node order parameter of the hash node is not the minimum value of the node order parameters recorded in the hash node association area of the hash node, execute step S212.
[0085] Step S212, merging the information of the hash node information area into other hash nodes whose node sequence parameters are adjacent and smaller than the hash node.
[0086] In an optional example, if the node order parameter of the hash node is not the minimum value of the node order parameters recorded in the hash node association area of the hash node, the information in the hash node information area of the hash node is merged into other hash nodes whose node order parameters are adjacent and smaller than that of the hash node.
[0087] For example, if the node order parameter of the hash node is 3, and the node order parameters of other associated hash nodes recorded in the hash node association area of the hash node are 1 and 2 respectively, and the above-mentioned "2" is adjacent and less than "3", then the backup information of the hash node information area of the hash node is used to merge the information into the hash node information area of the hash node whose node order parameter is 2. At this time, the node order parameters recorded in the hash node association area of the hash node whose node order parameter is 2 are 1 and 2 respectively, and "1" is adjacent and less than "2", then the backup information of the hash node information area of the hash node whose node order parameter is 2 is used to merge the information into the hash node information area of the hash node whose node order parameter is 1.
[0088] In an optional example, if the node order parameter of the hash node is c, and the node order parameters of other associated hash nodes recorded in the hash node association area of the hash node are a and b respectively, then the backup information of the hash node information area of the hash node is used to merge the information into the hash node information area of the hash node whose node order parameter is b; at this time, if the node order parameters recorded in the hash node association area of the hash node whose node order parameter is b are a and b respectively, then the backup information of the hash node information area of the hash node whose node order parameter is b is used to merge the information into the hash node information area of the hash node whose node order parameter is a.
[0089] Step S213, output the information of the hash node information area in the hash node.
[0090] In an optional example, if the node order parameter of the hash node is the minimum value of the node order parameters recorded in the hash node association area of the hash node, then the information in the hash node information area of the hash node is output, which is the union of the information of each associated node.
[0091] In an optional example, if the information in the hash node information area of the hash node corresponding to the first node identifier is input information 1, the node sequence parameters recorded in the hash node association area are 1 and 2, and the node sequence parameter of the hash node corresponding to the first node identifier is 2; the information in the hash node information area of the hash node corresponding to the second node identifier is input information 2, the node sequence parameters recorded in the hash node association area are 1 and 2, and the node sequence parameter of the hash node corresponding to the second node identifier is 1. When merging the information in the hash node information areas of the above two hash nodes, it is necessary to back up the information of the hash node corresponding to the first node identifier to obtain the backup information and lock the hash node corresponding to the second node identifier, and then add the backup information to the hash node information area of the hash node corresponding to the second node identifier. At this time, the information stored in the hash node information area of the hash node corresponding to the second node identifier is input information 1 and input information 2. Since the node sequence parameter of the hash node corresponding to the second node identifier is 1, the node sequence parameters stored in the hash node association area are 1 and 2, and "1" is less than "2". Therefore, the information in the hash node information area of the hash node corresponding to the second node identifier is directly output, which is the union of the associated node information, that is, outputting "input information 1" and "input information 2".
[0092] The information merging method of this embodiment performs an initialization process before receiving and extracting the characteristic value of the input information, creates the hash table according to the characteristic value type, and pre-allocates storage space for the hash node to be created in advance. When storage space is needed later, a free storage space can be directly taken from the storage space applied for in advance, thereby avoiding the problem of wasting time caused by applying for it when it is needed; and, the method for merging information in the hash node information area of the hash node is specified according to the node sequence parameter, which simplifies the implementation logic and is easy to understand and maintain.
[0093] Figure 5 This is a flowchart of an information deletion method provided by an exemplary embodiment of the present disclosure. A hash node can be deleted by the method of this embodiment. The method of this embodiment may include the following processing:
[0094] Step S301, receiving and extracting the characteristic value of the information to be deleted, and calculating the hash value corresponding to the characteristic value.
[0095] Step S302, determining the hash node to be deleted according to the characteristic value and the corresponding hash value, and backing up at least one second node identifier in the hash node association area of the hash node.
[0096] Step S303: delete the hash node, and based on the backed-up at least one second node identifier, delete other hash nodes corresponding to the at least one second node identifier.
[0097] In an optional example, when the input information is information to be deleted, the hash node determined based on the characteristic value and the corresponding hash value is the hash node corresponding to the information to be deleted. However, since the information to be deleted may have been merged into other hash nodes associated with the hash node during the information merging process, the other hash nodes associated with the hash node need to be deleted together.
[0098] In an optional example, at least one second node identifier in the hash node association area of the hash node may be backed up, and other hash nodes associated with the hash node may be deleted based on the second node identifier.
[0099] The information deletion method of this embodiment uses the at least one second node identifier recorded to delete other hash nodes associated with the hash node, ensuring that the input information is completely deleted so as not to affect subsequent information merging and other operations.
[0100] Corresponding to the above-mentioned embodiment of the information merging method, the embodiment of the present disclosure also provides an embodiment of the information merging device. Figure 6 is a structural diagram of an information merging device in an exemplary embodiment of the present disclosure, such as Figure 6 As shown, the information merging device may include:
[0101] A first calculation module 61 is used to receive and extract a characteristic value of input information, and calculate a hash value corresponding to the characteristic value;
[0102] A creation module 62, used for locking the hash bucket corresponding to the hash value, and creating a corresponding hash node in the hash bucket according to the characteristic value and the corresponding hash value, wherein the hash node includes: a hash node information area and a hash node association area;
[0103] An adding module 63 is used to add the input information to the hash node information area, and add the characteristic value and the corresponding hash value contained in the input information to the hash node association area, in which the characteristic value and the corresponding hash value are used as the first node identifier corresponding to the hash node, and the hash node association area also includes at least one second node identifier for identifying other hash nodes;
[0104] A backup module 64, used to back up the information in the hash node information area to obtain backup information, and unlock the hash bucket;
[0105] The merging module 65 is used to add the backup information to the hash node information area of at least one other hash node corresponding to the second node identifier, and complete the merging of information between the hash node and at least one other hash node corresponding to the second node identifier.
[0106] Optional, in Figure 6 On the basis of the modules shown, the information merging device may further include: an initialization module;
[0107] The initialization module is used to: execute an initialization process before the first calculation module receives and extracts the characteristic value of the input information;
[0108] The initialization process includes:
[0109] Determine at least one characteristic value type corresponding to the business scenario, each characteristic value type includes multiple characteristic values;
[0110] According to the at least one characteristic value type, respectively create the hash tables corresponding to the respective characteristic value types, wherein each hash table includes a plurality of hash buckets;
[0111] Pre-allocating storage space for the hash nodes to be created in the hash bucket;
[0112] The creation module 62, when used to lock the hash bucket corresponding to the hash value, includes:
[0113] Determine the corresponding feature value type according to the business scenario to which the input information belongs;
[0114] In the hash table corresponding to the characteristic value type, determining a corresponding hash bucket according to the hash value;
[0115] The hash bucket is locked.
[0116] Optionally, the adding module, when used to add the feature value and the corresponding hash value contained in the input information to the hash node association area, and in the hash node association area, the feature value and the corresponding hash value are used as the first node identifier corresponding to the hash node, includes:
[0117] Recording a node sequence parameter corresponding to the first node identifier in the hash node association area, wherein the node sequence parameter is used to indicate the order in which the hash nodes are created. The smaller the node sequence parameter is, the earlier the corresponding hash node is created.
[0118] The merging module 65, when used to add the backup information to the hash node information area of at least one other hash node corresponding to the second node identifier, and complete the merging of information between the hash node and at least one other hash node corresponding to the second node identifier, includes:
[0119] Merging the backup information into the hash node information area of other hash nodes corresponding to the first target node identifier, wherein the node sequence parameters of the first target node identifier are adjacent and smaller than the node sequence parameter of the first node identifier;
[0120] In response to the node sequence parameter of the first target node identifier being the minimum value among the node sequence parameters recorded in the hash node association area, outputting information of the hash node information area of the hash node corresponding to the first target node identifier;
[0121] In response to the node sequence parameter of the first target node identifier being not the minimum value among the node sequence parameters recorded in the hash node association area, the information in the hash node information area in the hash node corresponding to the first target node identifier is further merged into the hash node information area of the hash node corresponding to the second target node identifier, and the node sequence parameters of the second target node identifier are adjacent and smaller than the node sequence parameters of the first target node identifier.
[0122] Optional, in Figure 6 On the basis of the modules shown, the information merging device may further include: a second calculation module and a deletion module;
[0123] The second calculation module is used to receive and extract the characteristic value of the information to be deleted, and calculate the hash value corresponding to the characteristic value;
[0124] The backup module 64 is further used to determine the hash node to be deleted based on the characteristic value and the corresponding hash value, and to back up at least one second node identifier in the hash node association area in the hash node;
[0125] The deletion module is used to delete the hash node and, based on the backed-up at least one second node identifier, delete other hash nodes corresponding to the at least one second node identifier.
[0126] The implementation process of the functions and effects of each module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, which will not be repeated here.
[0127] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the technical solution disclosed herein. Ordinary technicians in this field can understand and implement it without creative work.
[0128] Although this specification includes many specific implementation details, these should not be interpreted as limiting the scope of any invention or the scope of protection claimed, but are mainly used to describe the features of the specific embodiments of specific inventions. Certain features described in multiple embodiments in this specification may also be implemented in combination in a single embodiment. On the other hand, the various features described in a single embodiment may also be implemented separately in multiple embodiments or in any suitable sub-combination. In addition, although features may work in certain combinations as described above and even initially claim protection, one or more features from the claimed combination may be removed from the combination in some cases, and the claimed combination may point to a sub-combination or a variation of a sub-combination.
[0129] The above description is only a preferred embodiment of the present disclosure and is not intended to limit the present disclosure. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present disclosure should be included in the scope of protection of the present disclosure.
Claims
1. A method for information merging, It is characterized in that The method comprises: Receive and extract the characteristic value of the input information, and calculate the hash value corresponding to the characteristic value; Locking the hash bucket corresponding to the hash value, creating a corresponding hash node in the hash bucket according to the characteristic value and the corresponding hash value, wherein the hash node includes: a hash node information area and a hash node association area; Adding the input information to the hash node information area, and adding the characteristic value and the corresponding hash value contained in the input information to the hash node association area, wherein the characteristic value and the corresponding hash value are used as the first node identifier corresponding to the hash node in the hash node association area, and the hash node association area also includes at least one second node identifier for identifying other hash nodes; Backing up the information in the hash node information area to obtain backup information, and unlocking the hash bucket; The backup information is added to the hash node information area of at least one other hash node corresponding to the second node identifier, thereby completing the merging of information between the hash node and at least one other hash node corresponding to the second node identifier.
2. The method according to claim 1, It is characterized in that Before receiving and extracting the characteristic value of the input information and calculating the hash value corresponding to the characteristic value, the method further includes: an initialization process; The initialization process includes: Determine at least one characteristic value type corresponding to the business scenario, each characteristic value type includes multiple characteristic values; According to the at least one characteristic value type, respectively create hash tables corresponding to each characteristic value type, wherein each hash table includes a plurality of hash buckets; Pre-allocating storage space for the hash nodes to be created in the hash bucket; The step of locking the hash bucket corresponding to the hash value includes: Determine the corresponding feature value type according to the business scenario to which the input information belongs; In the hash table corresponding to the characteristic value type, determining a corresponding hash bucket according to the hash value; The hash bucket is locked.
3. The method according to claim 1, It is characterized in that The step of adding the feature value and the corresponding hash value contained in the input information to the hash node association area, wherein the feature value and the corresponding hash value are used as the first node identifier corresponding to the hash node in the hash node association area, includes: The node sequence parameter corresponding to the first node identifier is recorded in the hash node association area, and the node sequence parameter is used to indicate the order in which the hash nodes are created. The smaller the node sequence parameter is, the earlier the corresponding hash node is created. The step of adding the backup information to the hash node information area of at least one other hash node corresponding to the second node identifier, and completing the merging of information between the hash node and at least one other hash node corresponding to the second node identifier, includes: Merging the backup information into the hash node information area of other hash nodes corresponding to the first target node identifier, wherein the node sequence parameters of the first target node identifier are adjacent and smaller than the node sequence parameter of the first node identifier; In response to the node sequence parameter of the first target node identifier being the minimum value among the node sequence parameters recorded in the hash node association area, outputting information of the hash node information area of the hash node corresponding to the first target node identifier; In response to the node sequence parameter of the first target node identifier being not the minimum value among the node sequence parameters recorded in the hash node association area, the information in the hash node information area in the hash node corresponding to the first target node identifier is further merged into the hash node information area of the hash node corresponding to the second target node identifier, and the node sequence parameters of the second target node identifier are adjacent and smaller than the node sequence parameters of the first target node identifier.
4. The method according to claim 1, It is characterized in that The method further comprises: Receive and extract the characteristic value of the information to be deleted, and calculate the hash value corresponding to the characteristic value; Determine the hash node to be deleted according to the characteristic value and the corresponding hash value, and back up at least one second node identifier in the hash node association area of the hash node; The hash node is deleted, and according to the backed-up at least one second node identifier, other hash nodes corresponding to the at least one second node identifier are deleted.
5. A device for merging information, It is characterized in that The device comprises: A first calculation module, used to receive and extract a characteristic value of input information, and calculate a hash value corresponding to the characteristic value; A creation module, used for locking the hash bucket corresponding to the hash value, and creating a corresponding hash node in the hash bucket according to the characteristic value and the corresponding hash value, wherein the hash node includes: a hash node information area and a hash node association area; An adding module, used for adding the input information to the hash node information area, and adding the characteristic value and the corresponding hash value contained in the input information to the hash node association area, wherein the characteristic value and the corresponding hash value are used as the first node identifier corresponding to the hash node in the hash node association area, and the hash node association area also includes at least one second node identifier for identifying other hash nodes; A backup module, used for backing up the information in the hash node information area to obtain backup information, and unlocking the hash bucket; A merging module is used to add the backup information to the hash node information area of at least one other hash node corresponding to the second node identifier, and complete the merging of information between the hash node and at least one other hash node corresponding to the second node identifier.
6. The device according to claim 5, It is characterized in that The device further includes: an initialization module; the initialization module is used to: execute an initialization process before the first calculation module receives and extracts the characteristic value of the input information; The initialization process includes: Determine at least one characteristic value type corresponding to the business scenario, each characteristic value type includes multiple characteristic values; According to the at least one characteristic value type, respectively create hash tables corresponding to each characteristic value type, wherein each hash table includes a plurality of hash buckets; Pre-allocating storage space for the hash nodes to be created in the hash bucket; The step of locking the hash bucket corresponding to the hash value includes: Determine the corresponding feature value type according to the business scenario to which the input information belongs; In the hash table corresponding to the characteristic value type, determining a corresponding hash bucket according to the hash value; The hash bucket is locked.
7. The device according to claim 5, It is characterized in that The adding module, when used to add the feature value and the corresponding hash value contained in the input information to the hash node association area, in the hash node association area, when the feature value and the corresponding hash value are used as the first node identifier corresponding to the hash node, includes: The node sequence parameter corresponding to the first node identifier is recorded in the hash node association area, and the node sequence parameter is used to indicate the order in which the hash nodes are created. The smaller the node sequence parameter is, the earlier the corresponding hash node is created. The merging module, when used to add the backup information to the hash node information area of at least one other hash node corresponding to the second node identifier, to complete the merging of information between the hash node and at least one other hash node corresponding to the second node identifier, includes: Merging the backup information into the hash node information area of other hash nodes corresponding to the first target node identifier, wherein the node sequence parameters of the first target node identifier are adjacent and smaller than the node sequence parameter of the first node identifier; In response to the node sequence parameter of the first target node identifier being the minimum value among the node sequence parameters recorded in the hash node association area, outputting information of the hash node information area of the hash node corresponding to the first target node identifier; In response to the node sequence parameter of the first target node identifier being not the minimum value among the node sequence parameters recorded in the hash node association area, the information in the hash node information area in the hash node corresponding to the first target node identifier is further merged into the hash node information area of the hash node corresponding to the second target node identifier, and the node sequence parameters of the second target node identifier are adjacent and smaller than the node sequence parameters of the first target node identifier.
8. The device according to claim 5, It is characterized in that The device further comprises: a second calculation module and a deletion module; The second calculation module is used to receive and extract the characteristic value of the information to be deleted, and calculate the hash value corresponding to the characteristic value; The backup module is further used to determine the hash node to be deleted based on the characteristic value and the corresponding hash value, and to back up at least one second node identifier in the hash node association area in the hash node; The deletion module is used to delete the hash node and, based on the backed-up at least one second node identifier, delete other hash nodes corresponding to the at least one second node identifier.
9. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores machine-readable instructions, which, when called and executed by a processor, prompt the processor to implement the method according to any one of claims 1 to 4.
10. A protective device, It is characterized in that It includes a communication interface, a processor, a memory and a bus, wherein the communication interface, the processor and the memory are interconnected via a bus; the memory stores machine-readable instructions, and the processor executes the method according to any one of claims 1 to 4 by calling the machine-readable instructions.
