Primary key processing method and device, electronic equipment and storage medium

By checking the target primary key and target value in the hash table and performing batch processing in the conflict index table, the performance bottleneck problem caused by primary key conflicts in hash table processing is solved and the efficiency and accuracy of data processing are improved.

CN118551083APending Publication Date: 2024-08-27CHINA ELECTRONICS CLOUD DIGITAL INTELLIGENCE TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202410640794.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-22
Publication Date
2024-08-27

AI Technical Summary

Technical Problem

Existing hash table processing methods have performance bottlenecks when primary key conflicts occur and need to be improved to improve data processing efficiency.

Method used

By checking the target primary key and target value in the hash table, if they exist in the hash table, add the conflict index table, and perform batch processing when the number of target primary keys in the conflict index table reaches the preset value to avoid multiple accesses to the hash table .

Benefits of technology

Effectively handle primary key conflicts in hash tables, improve the efficiency and accuracy of data processing, and avoid performance degradation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118551083A
    Figure CN118551083A
Patent Text Reader

Abstract

The invention relates to a primary key processing method and device, electronic equipment and a storage medium, and relates to the technical field of computers. The method comprises the following steps: in response to an obtained target primary key and a corresponding target value, determining whether a preset hash table comprises the target primary key or not; in response to determining that the preset hash table does not include the target primary key, determining whether the hash table includes a target value or not; in response to determining that the hash table comprises the target value, adding the target primary key and the target value into a preset conflict index table; and in response to determining that the number of the target primary keys in the preset conflict index table reaches a preset value, processing the target values in the preset conflict index table. By applying the method, performance reduction caused by multiple access to the hash table is not needed, so that the data processing efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a primary key processing method, device, electronic device and storage medium. Background Art

[0002] In the process of big data processing, in order to improve the efficiency of data processing, hash tables or hash maps are usually used to store and search data. Hash tables are an efficient data structure in many application fields such as social media, search engines, and databases. However, when the same primary key appears, the hash table will cause a primary key conflict.

[0003] When a primary key conflict occurs in a hash table, the hash table needs to be processed. The existing hash table processing method has performance bottlenecks and needs to be further improved and perfected. Summary of the invention

[0004] Embodiments of the present disclosure provide a master key processing method, device, electronic device, and storage medium.

[0005] In a first aspect, an embodiment of the present disclosure provides a primary key processing method, including: in response to obtaining a target primary key and a corresponding target value, determining whether the target primary key is included in a preset hash table; in response to determining that the target primary key is not included in the preset hash table, determining whether the target value is included in the hash table; in response to determining that the target value is included in the hash table, adding the target primary key and the target value to a preset conflict index table; in response to determining that the number of target primary keys in the preset conflict index table reaches a preset value, processing the target value in the preset conflict index table.

[0006] In the second aspect, an embodiment of the present disclosure provides a primary key processing device, comprising: a first determination unit, configured to determine whether a preset hash table includes a target primary key in response to obtaining a target primary key and a corresponding target value; a second determination unit, configured to determine whether the target value is included in the hash table in response to determining that the preset hash table does not include the target primary key; a data adding unit, configured to add the target primary key and the target value to a preset conflict index table in response to determining that the target value is included in the hash table; a data updating unit, configured to process the target value in the preset conflict index table in response to determining that the number of target primary keys in the preset conflict index table reaches a preset value.

[0007] In a third aspect, an embodiment of the present disclosure provides an electronic device, comprising a memory, a processor, a bus, and a computer program stored in the memory and executable on the processor, wherein the processor implements the primary key processing method described in the first aspect when executing the computer program.

[0008] In a fourth aspect, an embodiment of the present disclosure provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the primary key processing method as described in the first aspect.

[0009] By applying the technical solution disclosed in the present invention, when the target primary key and the corresponding target value are obtained, the hash table can be checked first. If the hash table includes the target primary key and the target value, the target primary key and the target value are added to the preset conflict index table. When the number of target primary keys in the conflict index table reaches a preset value, the target values ​​in the conflict index table are processed in batches. Thus, the performance degradation caused by multiple accesses to the hash table is not required.

[0010] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.

[0012] Figure 1 A schematic diagram of a flow chart of an embodiment of the primary key processing method disclosed in the present invention;

[0013] Figure 2 A flowchart of another embodiment of the primary key processing method disclosed in the present invention;

[0014] Figure 3 It is a structural schematic diagram of an embodiment of the primary key processing device disclosed in the present invention;

[0015] Figure 4 A schematic diagram of the structure of an embodiment of an electronic device disclosed herein. DETAILED DESCRIPTION

[0016] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present disclosure. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present disclosure belongs.

[0017] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present disclosure. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprising" and / or "including" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.

[0018] In the absence of conflict, the embodiments in the present disclosure and the features in the embodiments may be combined with each other.

[0019] In order to make the technical solutions and advantages of the present disclosure more clearly understood, the present disclosure is further described in detail below in conjunction with the accompanying drawings and specific embodiments.

[0020] Figure 1 An exemplary system architecture 100 is shown to which an embodiment of the primary key processing method or primary key processing apparatus disclosed herein can be applied.

[0021] Figure 1 FIG. 1 shows a process 100 of an embodiment of the primary key processing method of the present disclosure. Figure 1 As shown, the primary key processing method of this embodiment may include the following steps:

[0022] Step 101: In response to obtaining a target primary key and a corresponding target value, determine whether a preset hash table includes the target primary key.

[0023] In this embodiment, the execution subject of the primary key processing method can obtain the target primary key and the corresponding target value in a variety of ways. Here, the target primary key can be the primary key of the data table, and the corresponding target value can be obtained by performing a hash calculation on the target primary key. It can be understood that there is a one-to-one correspondence between the target primary key and the target value.

[0024] After receiving the target primary key, it can be checked whether the preset hash table includes the target primary key. Specifically, the hash table can be searched to determine whether the target primary key is included.

[0025] Step 102: In response to determining that the preset hash table does not include the target primary key, determine whether the hash table includes the target value.

[0026] If the target primary key is not included in the preset hash table, it can be further determined whether the target value is included in the hash table. Specifically, the target value can be retrieved in the hash table. If the target value is retrieved, it means that the hash table includes the target value. If the target value is not retrieved, it means that the hash table does not include the target value.

[0027] Step 103: In response to determining that the target value is included in the hash table, add the target primary key and the target value to a preset conflict index table.

[0028] If the target value is not included in the hash table, the target primary key and the target value can be added to a preset conflict index table. Here, the structure of the conflict index table can be the same as that of the hash table, or the conflict index table is a data table for representing key-value pairs.

[0029] Step 104 , in response to determining that the number of target primary keys in the preset conflict index table reaches a preset value, processing the target value in the preset conflict index table.

[0030] In this embodiment, the execution subject can judge the conflict index table at a preset time interval to determine whether the number of target primary keys reaches a preset value. If the preset value is reached, the target values ​​in the conflict index table can be batch processed. The processing here can refer to updating the target value. Specifically, other algorithms can be used to calculate the target primary key to obtain a new target value.

[0031] The primary key processing method provided by the above embodiment of the present disclosure can first check the hash table when the target primary key and the corresponding target value are obtained. If the hash table includes the target primary key and the target value, the target primary key and the target value are added to the preset conflict index table. When the number of target primary keys in the conflict index table reaches a preset value, the target values ​​in the conflict index table are batch processed. Thus, the performance degradation caused by multiple accesses to the hash table is not required.

[0032] Continue to see Figure 2 , which shows a process 200 of another embodiment of the primary key processing method according to the present disclosure. Figure 2 As shown, the method in this embodiment may include the following steps:

[0033] Step 201, obtaining a target key and a target value from a preset key-value pair list.

[0034] In this embodiment, the target primary key and the target value can be obtained from a preset key-value pair list. Here, the preset key-value pair list can be a data table or a memory data structure similar to the structure of a hash table. The target primary key can be an ID of a specified type, and the target value is a hash value obtained by hashing the target primary key.

[0035] Step 202: In response to obtaining the target primary key and the corresponding target value, determine whether the target primary key is included in a preset hash table.

[0036] Step 203: In response to determining that the preset hash table does not include the target primary key, determine whether the hash table includes the target value.

[0037] Step 204 , in response to determining that the target value is included in the hash table, adding the target primary key and the target value to a preset conflict index table.

[0038] Step 205 , in response to determining that the number of target primary keys in the preset conflict index table reaches a preset value, processing the target value in the preset conflict index table.

[0039] Step 206 : In response to determining that the preset hash table does not include the target primary key, store the target primary key and the target value in the preset hash table.

[0040] In this embodiment, if the preset hash table does not include the target primary key, the target primary key and the target value may be stored in the hash table to implement updating of the hash table.

[0041] Step 207 : in response to determining that the preset hash table includes the target primary key, updating the target value so that the target value is different from the value in the preset hash table.

[0042] If the target primary key is included in the hash table, the target value can be updated so that the target value is different from the value in the hash table, which ensures that the primary key and value in the hash table are always in a one-to-one correspondence.

[0043] In some optional implementations of this embodiment, before searching the hash table, the list storing primary keys and values ​​may be self-checked. If the list includes duplicate primary keys and values, the duplicate primary keys and values ​​may be added to the conflict index table.

[0044] In a specific application scenario of this embodiment, when developing a labeling system, technicians can map the primary key of a data table and the hash value of the primary key to a labeling table. In order to ensure that each different primary key has a unique hash value, the hash value needs to be checked for uniqueness. If the hash value already exists repeatedly, it needs to be processed. Specifically, a hash table (Hashtable) or a similar memory structure can be used to store the tag ID of the table and the hash value calculated by the hash algorithm. The key of the Hashtable (that is, the hash value calculated by the hash algorithm) is unique, which helps us quickly retrieve whether the hash value already exists.

[0045] When a target ID is received, the record matching the target ID needs to be retrieved from the Hashtable first. If a matching record is found, it means that the data has been stored in the database and the system should ignore it. If no matching record is found, it means that the data has not been stored in the database and the storage operation can be performed.

[0046] If a hash value conflict of a tag id is detected, that is, different tag ids correspond to the same hash value, we can adopt the following strategy to handle it:

[0047] (1) Continue to execute the storage operation.

[0048] (2) The primary key and the corresponding hash value are added to the conflict index table.

[0049] (3) Check whether the conflicting index table reaches a preset threshold. If so, perform batch operations to repair the conflicting hash values ​​and delete the conflicting indexes.

[0050] The primary key processing method provided by the above-mentioned embodiment of the present disclosure can effectively handle the primary key duplication problem in the hash table, thereby improving the efficiency and accuracy of data processing.

[0051] Further references Figure 3 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a primary key processing device. Figure 1 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0052] like Figure 3 As shown, the primary key processing device 300 of this embodiment includes: a first determining unit 301 , a second determining unit 302 , a data adding unit 303 and a data updating unit 304 .

[0053] The first determining unit 301 is configured to determine whether the target primary key is included in a preset hash table in response to obtaining the target primary key and the corresponding target value;

[0054] A second determining unit 302 is configured to determine whether the target value is included in the hash table in response to determining that the preset hash table does not include the target primary key;

[0055] A data adding unit 303 is configured to add the target primary key and the target value to a preset conflict index table in response to determining that the target value is included in the hash table;

[0056] The data updating unit 304 is configured to process the target value in the preset conflict index table in response to determining that the number of target primary keys in the preset conflict index table reaches a preset value.

[0057] In some optional implementations of this embodiment, the apparatus 300 may further include: Figure 3 The data storage unit not shown in the figure is configured to store the target primary key and the target value in the preset hash table in response to determining that the preset hash table does not include the target primary key.

[0058] In some optional implementations of this embodiment, the data updating unit 304 may be further configured to: in response to determining that the preset hash table includes the target primary key, update the target value so that the target value is different from the value in the preset hash table.

[0059] In addition, in the technical solution of the present application, an electronic device is also proposed.

[0060] Figure 4A schematic structural diagram of an electronic device provided by an embodiment of the present disclosure is shown.

[0061] like Figure 4 As shown, the electronic device may include a processor 401, a memory 402, a bus 403, and a computer program stored in the memory 402 and executable on the processor 401, wherein the processor 401 and the memory 402 communicate with each other through the bus 403. When the processor 401 executes the computer program, the steps of implementing the above method include, for example: in response to obtaining a target primary key and a corresponding target value, determining whether the target primary key is included in a preset hash table; in response to determining that the target primary key is not included in the preset hash table, determining whether the target value is included in the hash table; in response to determining that the target value is included in the hash table, adding the target primary key and the target value to a preset conflict index table; in response to determining that the number of target primary keys in the preset conflict index table reaches a preset value, processing the target value in the preset conflict index table.

[0062] In addition, in one embodiment of the present disclosure, a non-transitory computer-readable storage medium is also provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above method are implemented, for example, including: in response to obtaining a target primary key and a corresponding target value, determining whether the target primary key is included in a preset hash table; in response to determining that the target primary key is not included in the preset hash table, determining whether the target value is included in the hash table; in response to determining that the target value is included in the hash table, adding the target primary key and the target value to a preset conflict index table; in response to determining that the number of target primary keys in the preset conflict index table reaches a preset value, processing the target value in the preset conflict index table.

[0063] In summary, in the technical solution disclosed in the present invention, when the target primary key and the corresponding target value are obtained, the hash table can be checked first. If the hash table includes the target primary key and the target value, the target primary key and the target value are added to the preset conflict index table. When the number of target primary keys in the conflict index table reaches a preset value, the target values ​​in the conflict index table are processed in batches. Thus, the performance degradation caused by multiple accesses to the hash table is not required.

[0064] 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 shall be included in the scope of protection of the present disclosure.

Claims

1. A primary key processing method, include: In response to obtaining the target primary key and the corresponding target value, determining whether the target primary key is included in a preset hash table; In response to determining that the preset hash table does not include the target primary key, determining whether the hash table includes the target value; In response to determining that the target value is included in the hash table, adding the target primary key and the target value to a preset conflict index table; In response to determining that the number of target primary keys in the preset conflict index table reaches a preset value, the target value in the preset conflict index table is processed.

2. The method according to claim 1, in, The method further comprises: In response to determining that the preset hash table does not include the target primary key, the target primary key and the target value are stored in the preset hash table.

3. The method according to claim 1, in, The method further comprises: In response to determining that the preset hash table includes the target primary key, the target value is updated so that the target value is different from the value in the preset hash table.

4. The method according to claim 1, in, The method further comprises: The target primary key and the target value are obtained from a preset key-value pair list.

5. The method according to claim 4, in, The method further comprises: Determining whether the preset key-value pair list includes the same primary key or the same value; In response to determining that the preset key-value pair list includes the same key or the same value, the key-value pair to which the same key or the same value belongs is stored in the index conflict table.

6. A primary key processing device, include: A first determining unit is configured to determine whether a preset hash table includes the target primary key in response to acquiring the target primary key and the corresponding target value; a second determining unit, configured to, in response to determining that the preset hash table does not include the target primary key, determine whether the hash table includes the target value; a data adding unit, configured to, in response to determining that the target value is included in the hash table, add the target primary key and the target value to a preset conflict index table; The data updating unit is configured to process the target value in the preset conflict index table in response to determining that the number of target primary keys in the preset conflict index table reaches a preset value.

7. The device according to claim 6, in, The device also includes: The data storage unit is configured to store the target primary key and the target value in the preset hash table in response to determining that the preset hash table does not include the target primary key.

8. The device according to claim 6, in, The data updating unit is further configured to: In response to determining that the preset hash table includes the target primary key, the target value is updated so that the target value is different from the value in the preset hash table.

9. An electronic device comprising a memory, a processor, a bus, and a computer program stored in the memory and executable on the processor, in, When the processor executes the computer program, the primary key processing method according to any one of claims 1 to 5 is implemented.

10. A non-transitory computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the primary key processing method according to any one of claims 1 to 5 is implemented.

Citation Information

Cited By

  • Equipment communication method and device based on single-bus communication system and quick turn-off system

    CN119493753A

  • Device communication method, device and fast shutdown system based on single bus communication system

    CN119493753B