Method, device, equipment and storage medium for managing data based on hash table
By using a hash table-based data management method, the first hash table is used to query the index address and the second hash table is used to store data, which solves the low query efficiency and conflict problems of memory cache in high concurrency scenarios and achieves efficient data management.
Patent Information
- Application Number
- CN202011065167.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-30
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2040-09-30
AI Technical Summary
Existing memory caching methods have low query efficiency in high-concurrency scenarios, and are prone to operation conflicts when updating and querying data, resulting in low efficiency.
A method of managing data based on hash tables is adopted. The index address of the target data is queried through the first hash table, and the position of the second hash table is confirmed by the index address, and then the target data is stored in the corresponding storage address to realize segmented storage of the target data.
Improves the query efficiency of memory cache under high concurrency and reduces conflicts in data update and query scenarios.
Smart Images

Figure CN114328503B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of data caching, and in particular relates to a method, apparatus, device and storage medium for managing data based on a hash table. Background Art
[0002] In-memory caching is a method for improving data access performance at the expense of memory space. It reduces server-side computation, shortens the request process, and maximizes throughput using limited resources. In-memory caching technology is widely used, particularly in database products.
[0003] However, the existing memory caching method has low query efficiency in high-concurrency scenarios, and memory cache data updates and data queries will cause operation conflicts, resulting in low memory caching efficiency. Summary of the Invention
[0004] The embodiments of the present invention provide a method, apparatus, device and storage medium for managing data based on a hash table, which can solve the technical problem of low memory cache efficiency in the prior art.
[0005] In a first aspect, an embodiment of the present invention provides a method for managing data based on a hash table, wherein the hash table includes a first hash table and multiple second hash tables, the first hash table includes multiple index addresses, each index address is associated with a second hash table, and each second hash table includes multiple storage addresses, the method comprising:
[0006] Get target data;
[0007] Determine the key code corresponding to the target data according to the preset strategy;
[0008] Calculate the key code by using the first hash function corresponding to the first hash table to obtain the index address corresponding to the key code;
[0009] Get the second hash table corresponding to the index address;
[0010] Calculate the key code by using the second hash function corresponding to the second hash table to obtain the storage address corresponding to the key code;
[0011] Store the target data in the storage location corresponding to the storage address.
[0012] Furthermore, in one embodiment, each index address includes first offset information;
[0013] Calculating the key code by using the first hash function corresponding to the first hash table to obtain the index address corresponding to the key code includes:
[0014] The key code is calculated by using the first hash function to obtain the first offset information, and the index address corresponding to the first offset information is obtained.
[0015] Further, in one embodiment, each storage address includes second offset information;
[0016] Calculating the key code by using the second hash function corresponding to the second hash table to obtain a storage address corresponding to the key code includes:
[0017] The key code is calculated by the second hash function to obtain the second offset information, and the storage address corresponding to the second offset information is obtained.
[0018] Furthermore, in one embodiment, each second hash table includes lock information, and the lock information included in each second hash table is different;
[0019] The method further includes:
[0020] Get query data;
[0021] Determine the key code corresponding to the query data according to the preset strategy;
[0022] Calculate the key code by using the first hash function corresponding to the first hash table to obtain the index address corresponding to the key code;
[0023] Obtain the second hash table corresponding to the index address and the lock information included in the second hash table;
[0024] Calculate the key code by using the second hash function corresponding to the second hash table to obtain the storage address corresponding to the key code;
[0025] According to the lock information, the target data stored in the storage address is read.
[0026] Furthermore, in one embodiment, the method further includes:
[0027] Get updated data;
[0028] Determine the key code corresponding to the updated data according to the preset strategy;
[0029] Calculate the key code by using the first hash function corresponding to the first hash table to obtain the index address corresponding to the key code;
[0030] Obtain the second hash table corresponding to the index address and the lock information included in the second hash table;
[0031] Calculate the key code by using the second hash function corresponding to the second hash table to obtain the storage address corresponding to the key code;
[0032] According to the lock information, the original data stored in the storage address is updated to the updated data.
[0033] In a second aspect, an embodiment of the present application provides a device for managing data based on a hash table, wherein the hash table includes a first hash table and multiple second hash tables, the first hash table includes multiple index addresses, each index address is associated with a second hash table, and each second hash table includes multiple storage addresses, the device including:
[0034] Acquisition module, used to obtain target data;
[0035] A determination module, configured to determine a key code corresponding to the target data according to a preset strategy;
[0036] The acquisition module is further configured to calculate the key code by using the first hash function corresponding to the first hash table to obtain the index address corresponding to the key code;
[0037] The acquisition module is further used to obtain the second hash table corresponding to the index address;
[0038] The acquisition module is further configured to calculate the key code by using the second hash function corresponding to the second hash table to obtain the storage address corresponding to the key code;
[0039] The storage module is used to store the target data in a storage location corresponding to the storage address.
[0040] Furthermore, in one embodiment, each index address includes first offset information;
[0041] Get the module, specifically for:
[0042] The key code is calculated by using the first hash function to obtain the first offset information, and the index address corresponding to the first offset information is obtained.
[0043] Further, in one embodiment, each storage address includes second offset information;
[0044] Get the module, specifically for:
[0045] The key code is calculated by the second hash function to obtain the second offset information, and the storage address corresponding to the second offset information is obtained.
[0046] Furthermore, in one embodiment, each second hash table includes lock information, and the lock information included in each second hash table is different;
[0047] The acquisition module is also used to obtain query data;
[0048] The determination module is further used to determine the key code corresponding to the query data according to a preset strategy;
[0049] The acquisition module is further configured to calculate the key code by using the first hash function corresponding to the first hash table to obtain the index address corresponding to the key code;
[0050] The acquisition module is further used to obtain the second hash table corresponding to the index address and the lock information included in the second hash table;
[0051] The acquisition module is further configured to calculate the key code by using the second hash function corresponding to the second hash table to obtain the storage address corresponding to the key code;
[0052] The device also includes:
[0053] The reading module is used to read the target data stored in the storage address according to the lock information.
[0054] Furthermore, in one embodiment,
[0055] The acquisition module is also used to obtain update data;
[0056] The determination module is further used to determine the key code corresponding to the updated data according to a preset strategy;
[0057] The acquisition module is further configured to calculate the key code by using the first hash function corresponding to the first hash table to obtain the index address corresponding to the key code;
[0058] The acquisition module is further used to obtain the second hash table corresponding to the index address and the lock information included in the second hash table;
[0059] The acquisition module is further configured to calculate the key code by using the second hash function corresponding to the second hash table to obtain the storage address corresponding to the key code;
[0060] The device also includes:
[0061] The update module is used to update the original data stored in the storage address into updated data according to the lock information.
[0062] In a third aspect, an embodiment of the present application provides a device for managing data based on a hash table, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements a method for managing data based on a hash table when executed by the processor.
[0063] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a program for implementing information transmission is stored. When the program is executed by a processor, a method for managing data based on a hash table is implemented.
[0064] The method, apparatus, device and storage medium for managing data based on hash tables in the embodiments of the present invention use a first hash table to query the target data index address, then confirm the location of a second hash table through the index address, and then apply the second hash table to store the storage address of the target data, thereby storing the target data in the corresponding storage address; for multiple different target data, their corresponding storage addresses are stored in different second hash tables, thereby realizing segmented storage of the target data storage address, thereby improving the query efficiency of the memory cache under high concurrency and reducing conflicts in the memory cache in data update and data query scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0066] Figure 1 This is a schematic diagram of the memory cache principle provided by an embodiment of the present invention;
[0067] Figure 2 This is a schematic diagram of the structure of an existing memory cache hash table provided by an embodiment of the present invention;
[0068] Figure 3 This is a schematic diagram of a hash table structure provided by an embodiment of the present application;
[0069] Figure 4 1 is a flow chart of a method for managing data based on a hash table provided by one embodiment of the present invention;
[0070] Figure 5 1 is a schematic diagram of the structure of a device for managing data based on a hash table provided by an embodiment of the present invention;
[0071] Figure 6 It is a structural diagram of a device for managing data based on a hash table provided by one embodiment of the present invention. DETAILED DESCRIPTION
[0072] The features and exemplary embodiments of various aspects of the present invention will be described in detail below. In order to make the objects, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only configured to explain the present invention and are not configured to limit the present invention. For those skilled in the art, the present invention can be implemented without the need for some of these specific details. The following description of the embodiments is merely to provide a better understanding of the present invention by illustrating examples of the present invention.
[0073] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, the elements defined by the phrase "comprising..." do not exclude the presence of other identical elements in the process, method, article, or device comprising the elements.
[0074] In-memory caching is a method for improving data access performance at the expense of memory space. It reduces server-side computation, shortens the request process, and maximizes throughput using limited resources. In-memory caching technology is widely used, particularly in database products.
[0075] Figure 1 Figure 2 shows a schematic diagram of the memory cache principle. Figure 1 As shown, the in-memory cache resides in memory, while the database is stored on disk. Disk response speed is much slower than that of in-memory. Using an in-memory cache can improve query efficiency. Database contents are synchronized to the in-memory cache. When an application service performs a query, it prioritizes access to the in-memory cache. If the queried data exists in the in-memory cache, it is returned, significantly improving query efficiency. Database data updates must be promptly synchronized to the in-memory database to prevent the application service from querying stale data.
[0076] The technical core of memory cache is actually maintaining a huge hash table in memory - Hash Map. Figure 2 A schematic diagram of the existing memory cache hash table structure is shown in FIG. Figure 2 As shown, Hash Map is based on array: first position DATA + hash function + key code Key and linked list: key code Key + value + first position DATA + empty value NULL. The comprehensive application of these two data structures achieves the technical effect of easy addressing, insertion and deletion.
[0077] A HashMap stores data in a large array structure. Adding, deleting, querying, and modifying HashMap data are all array-based operations. To ensure thread safety during concurrent operations, locking structures must be used for concurrent processing. Therefore, high concurrency inevitably results in lock waits between threads, resulting in low concurrent data processing efficiency.
[0078] In order to solve the problems of the prior art, an embodiment of the present invention provides a method, apparatus, device and storage medium for managing data based on a hash table. The embodiment of the present invention queries the target data index address through a first hash table, then confirms the location of a second hash table through the index address, and then applies the second hash table to store the storage address of the target data, and then stores the target data in the corresponding storage address; for multiple different target data, their corresponding storage addresses are stored in different second hash tables, thereby realizing segmented storage of the target data storage address, thereby improving the query efficiency of the memory cache under high concurrency and reducing conflicts in the memory cache in data update and data query scenarios. The following first introduces the method for managing data based on a hash table provided by an embodiment of the present invention.
[0079] Figure 3 FIG. 1 shows a schematic diagram of a hash table structure provided by an embodiment of the present application. Figure 3 As shown, the hash table includes a first hash table and multiple second hash tables. The first hash table includes multiple index addresses, each index address is associated with a second hash table, and each second hash table includes multiple storage addresses.
[0080] Based on the above hash table, an embodiment of the present invention provides a method for managing data based on a hash table. The method is described below in conjunction with managing student information. Figure 4 The flow chart of the method is shown in FIG. Figure 4 As shown, the method may include the following steps:
[0081] S400, acquiring target data.
[0082] The target data is usually obtained from a database on disk. The target data may include the student's name, date of birth, gender, ethnicity, home address, and grades.
[0083] S402: Determine a key code corresponding to the target data according to a preset strategy.
[0084] Using "name + date of birth + gender + ethnicity + home address" as the key is a preset strategy.
[0085] S404: Calculate the key code using the first hash function corresponding to the first hash table to obtain an index address corresponding to the key code.
[0086] In one embodiment, each index address includes first offset information, and S404 may include:
[0087] The key code is calculated by using the first hash function to obtain the first offset information, and the index address corresponding to the first offset information is obtained.
[0088] Use the first hash function to calculate "name + date of birth + gender + ethnicity + home address", the calculation result is "098100", and "98" is the first offset information. After confirming the first offset information, the corresponding index address can be determined.
[0089] S406: Obtain a second hash table corresponding to the index address.
[0090] Since the index address is associated with the second hash table, the corresponding second hash table can be obtained by determining the index address.
[0091] S408 , calculating the key code by using the second hash function corresponding to the second hash table to obtain a storage address corresponding to the key code.
[0092] In one embodiment, each storage address includes second offset information, and S408 may include:
[0093] The key code is calculated by the second hash function to obtain the second offset information, and the storage address corresponding to the second offset information is obtained.
[0094] Use the second hash function to calculate "name + date of birth + gender + ethnicity + home address", the calculation result is "036100", and "36" is the second offset information. After confirming the second offset information, you can get its corresponding storage address.
[0095] S410: Store the target data in a storage location corresponding to the storage address.
[0096] When storing, store the key code + score into the storage location.
[0097] In one embodiment, each second hash table includes lock information, and the lock information included in each second hash table is different. The method may further include:
[0098] S412, obtaining query data.
[0099] The query data is usually determined based on the actual query requirements. For example, you need to query the grades of student Zhang San.
[0100] S416: Determine the key code corresponding to the query data according to a preset strategy.
[0101] Using "name + date of birth + gender + ethnicity + home address" as the key is a preset strategy.
[0102] S418: Calculate the key code using the first hash function corresponding to the first hash table to obtain an index address corresponding to the key code.
[0103] Specifically, the first hash function is used to calculate "name + date of birth + gender + ethnicity + home address", and the calculation result is "098100". "98" is the first offset information. After confirming the first offset information, its corresponding index address can be determined.
[0104] S420: Obtain a second hash table corresponding to the index address and lock information included in the second hash table.
[0105] S422: Calculate the key code using the second hash function corresponding to the second hash table to obtain a storage address corresponding to the key code.
[0106] Use the second hash function to calculate "name + date of birth + gender + ethnicity + home address", the calculation result is "036100", and "36" is the second offset information. After confirming the second offset information, you can get its corresponding storage address.
[0107] S424: Read the target data stored in the storage address according to the lock information.
[0108] When reading target data, lock information is required to maintain data consistency.
[0109] In one embodiment, the method may include:
[0110] S426, obtain update data.
[0111] For example, after a test, new student data is generated and needs to be updated. The updated data includes name, date of birth, gender, ethnicity, home address, and updated grades.
[0112] S428: Determine the key code corresponding to the updated data according to a preset strategy.
[0113] Using "name + date of birth + gender + ethnicity + home address" as the key is a preset strategy.
[0114] S430: Calculate a key code using a first hash function corresponding to the first hash table to obtain an index address corresponding to the key code.
[0115] Specifically, the first hash function is used to calculate "name + date of birth + gender + ethnicity + home address", and the calculation result is "098100". "98" is the first offset information. After confirming the first offset information, its corresponding index address can be determined.
[0116] S432: Obtain a second hash table corresponding to the index address and lock information included in the second hash table.
[0117] S434: Calculate the key code using the second hash function corresponding to the second hash table to obtain a storage address corresponding to the key code.
[0118] Use the second hash function to calculate "name + date of birth + gender + ethnicity + home address", the calculation result is "036100", and "36" is the second offset information. After confirming the second offset information, you can get its corresponding storage address.
[0119] S436: Update the original data stored in the storage address to updated data according to the lock information.
[0120] When updating the target data, the lock information needs to be used to update it to maintain data consistency. The storage address after the update stores the "key code + updated results".
[0121] The hash table-based data management method of an embodiment of the present invention queries the target data index address through the first hash table, then confirms the position of the second hash table through the index address, and then applies the second hash table to store the storage address of the target data, and then stores the target data in the corresponding storage address; for multiple different target data, their corresponding storage addresses are stored in different second hash tables, realizing segmented storage of the target data storage address, thereby improving the query efficiency of the memory cache under high concurrency and reducing conflicts in the memory cache in data update and data query scenarios.
[0122] Figure 1-4 The method of managing data based on hash table is described below. Figure 5 and attached Figure 6 The device provided by the embodiment of the present invention is described.
[0123] Figure 3 FIG. 1 shows a schematic diagram of a hash table structure provided by an embodiment of the present application. Figure 3 As shown, the hash table includes a first hash table and multiple second hash tables. The first hash table includes multiple index addresses, each index address is associated with a second hash table, and each second hash table includes multiple storage addresses.
[0124] Based on the above hash table, an embodiment of the present invention provides a device for managing data based on the hash table. The device is described below in conjunction with managing student information. Figure 5 shows a schematic structural diagram of the device, Figure 5 Each module in the device shown has the function of realizing Figure 4 The functions of each step in the process can achieve the corresponding technical effects. Figure 5 As shown, the device may include:
[0125] The acquisition module 500 is used to acquire target data.
[0126] The target data is usually obtained from a database on disk. The target data may include the student's name, date of birth, gender, ethnicity, home address, and grades.
[0127] The determination module 502 is configured to determine a key code corresponding to the target data according to a preset strategy.
[0128] Using "name + date of birth + gender + ethnicity + home address" as the key is a preset strategy.
[0129] The acquisition module 500 is further configured to calculate a key code using a first hash function corresponding to the first hash table to obtain an index address corresponding to the key code.
[0130] In one embodiment, each index address includes first offset information, and the acquisition module 500 may be specifically configured to:
[0131] The key code is calculated by using the first hash function to obtain the first offset information, and the index address corresponding to the first offset information is obtained.
[0132] For example, the first hash function is used to calculate "name + date of birth + gender + ethnicity + home address", and the calculation result is "098100". "98" is the first offset information. After confirming the first offset information, the corresponding index address can be determined.
[0133] The acquisition module 500 is further configured to acquire the second hash table corresponding to the index address.
[0134] Since the index address is associated with the second hash table, the corresponding second hash table can be obtained by determining the index address.
[0135] The acquisition module 500 is further configured to calculate the key code by using the second hash function corresponding to the second hash table to obtain the storage address corresponding to the key code.
[0136] In one embodiment, each storage address includes second offset information, and the acquisition module 500 may be specifically configured to:
[0137] The key code is calculated by the second hash function to obtain the second offset information, and the storage address corresponding to the second offset information is obtained.
[0138] For example, the second hash function is used to calculate "name + date of birth + gender + ethnicity + home address", and the calculation result is "036100". "36" is the second offset information. After confirming the second offset information, the corresponding storage address can be obtained.
[0139] The storage module 504 is configured to store the target data in a storage location corresponding to the storage address.
[0140] For example, when storing, the key code + score is stored in the storage location.
[0141] In one embodiment, each second hash table includes lock information, and the lock information included in each second hash table is different.
[0142] The acquisition module 500 is also used to acquire query data.
[0143] The query data is usually determined based on the actual query requirements. For example, you need to query the grades of student Zhang San.
[0144] The determination module 502 is further configured to determine a key code corresponding to the query data according to a preset strategy.
[0145] Using "name + date of birth + gender + ethnicity + home address" as the key is a preset strategy.
[0146] The acquisition module 500 is further configured to calculate a key code using a first hash function corresponding to the first hash table to obtain an index address corresponding to the key code.
[0147] Specifically, the first hash function is used to calculate "name + date of birth + gender + ethnicity + home address", and the calculation result is "098100". "98" is the first offset information. After confirming the first offset information, its corresponding index address can be determined.
[0148] The acquisition module 500 is further configured to acquire the second hash table corresponding to the index address and the lock information included in the second hash table.
[0149] The acquisition module 500 is further configured to calculate the key code by using the second hash function corresponding to the second hash table to obtain the storage address corresponding to the key code.
[0150] Use the second hash function to calculate "name + date of birth + gender + ethnicity + home address", the calculation result is "036100", and "36" is the second offset information. After confirming the second offset information, you can get its corresponding storage address.
[0151] The device may also include:
[0152] The reading module 506 is configured to read the target data stored in the storage address according to the lock information.
[0153] When reading target data, lock information is required to maintain data consistency.
[0154] In one embodiment:
[0155] The acquisition module 500 is also used to acquire update data.
[0156] For example, after a test, new student data is generated and needs to be updated. The updated data includes name, date of birth, gender, ethnicity, home address, and updated grades.
[0157] The determination module 502 is further configured to determine a key code corresponding to the update data according to a preset strategy.
[0158] Using "name + date of birth + gender + ethnicity + home address" as the key is a preset strategy.
[0159] The acquisition module 500 is further configured to calculate a key code using a first hash function corresponding to the first hash table to obtain an index address corresponding to the key code.
[0160] Specifically, the first hash function is used to calculate "name + date of birth + gender + ethnicity + home address", and the calculation result is "098100". "98" is the first offset information. After confirming the first offset information, its corresponding index address can be determined.
[0161] The acquisition module 500 is further configured to acquire the second hash table corresponding to the index address and the lock information included in the second hash table.
[0162] The acquisition module 500 is further configured to calculate the key code by using the second hash function corresponding to the second hash table to obtain the storage address corresponding to the key code.
[0163] Use the second hash function to calculate "name + date of birth + gender + ethnicity + home address", the calculation result is "036100", and "36" is the second offset information. After confirming the second offset information, you can get its corresponding storage address.
[0164] The device may also include:
[0165] The updating module 508 is configured to update the original data stored at the storage address into updated data according to the lock information.
[0166] When updating the target data, the lock information needs to be used to update it to maintain data consistency. After the update, the storage address stores the "key code + updated results".
[0167] In an embodiment of the present invention, a device for managing data based on a hash table queries the target data index address through a first hash table, confirms the position of a second hash table through the index address, and then applies the second hash table to store the storage address of the target data, thereby storing the target data in the corresponding storage address; for multiple different target data, their corresponding storage addresses are stored in different second hash tables, thereby realizing segmented storage of the target data storage address, thereby improving the query efficiency of the memory cache under high concurrency and reducing conflicts in the memory cache in data update and data query scenarios.
[0168] Figure 6 FIG. 1 shows a schematic diagram of a device for managing data based on a hash table according to an embodiment of the present invention. Figure 6 As shown, the device may include a processor 601 and a memory 602 storing computer program instructions.
[0169] Specifically, the processor 601 may include a central processing unit (CPU) or an application specific integrated circuit (ASIC), or may be configured as one or more integrated circuits implementing the embodiments of the present invention.
[0170] The memory 602 may include a large capacity memory for data or instructions. By way of example and not limitation, the memory 602 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive, or a combination of two or more of these. In one example, the memory 602 may include a removable or non-removable (or fixed) medium, or the memory 602 may be a non-volatile solid-state memory. The memory 602 may be inside or outside the integrated gateway disaster recovery device.
[0171] In one example, the memory 602 may be a read-only memory (ROM). In one example, the ROM may be a mask-programmable ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically rewritable ROM (EAROM), or a flash memory, or a combination of two or more of these.
[0172] The processor 601 reads and executes the computer program instructions stored in the memory 602 to implement Figure 4 The steps of the method in the embodiment shown are as follows: Figure 4 The corresponding technical effects achieved by executing the method in the example shown are not repeated here for the sake of brevity.
[0173] In one example, the device for managing data based on a hash table may further include a communication interface 603 and a bus 610. Figure 6 As shown, the processor 601, the memory 602, and the communication interface 603 are connected via a bus 610 and communicate with each other.
[0174] The communication interface 603 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiment of the present invention.
[0175] The bus 610 includes hardware, software, or both, coupling the components of the online data traffic metering device to each other. By way of example and not limitation, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an InfiniBand interconnect, a Low Pin Count (LPC) bus, a memory bus, a Micro Channel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or other suitable buses or a combination of two or more of these. Where appropriate, the bus 610 may include one or more buses. Although the embodiments of the present invention describe and illustrate specific buses, the present invention contemplates any suitable bus or interconnect.
[0176] The device for managing data based on a hash table can execute the method for managing data based on a hash table in an embodiment of the present invention, thereby achieving Figure 4 The described method for managing data based on a hash table has corresponding technical effects.
[0177] In addition, in conjunction with the hash table-based data management method in the above embodiments, embodiments of the present invention may provide a computer storage medium for implementation. The computer storage medium stores computer program instructions; when executed by a processor, the computer program instructions implement any of the hash table-based data management methods in the above embodiments.
[0178] It should be understood that the present invention is not limited to the specific configurations and processes described above and illustrated in the figures. For the sake of brevity, a detailed description of known methods is omitted. In the above embodiments, several specific steps are described and illustrated as examples. However, the method of the present invention is not limited to the specific steps described and illustrated. Those skilled in the art may make various changes, modifications, and additions, or change the order of the steps after understanding the spirit of the present invention.
[0179] The functional blocks shown in the above-described block diagram can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in unit, a function card, etc. When implemented in software, the elements of the present invention are programs or code segments that are used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link by a data signal carried in a carrier wave. "Machine-readable medium" can include any medium that can store or transmit information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROMs, flash memories, erasable ROMs (EROMs), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, etc. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.
[0180] It should also be noted that the exemplary embodiments described herein describe methods or systems based on a series of steps or devices. However, the present invention is not limited to the order of the steps described above. In other words, the steps may be performed in the order described in the embodiments, or in a different order, or several steps may be performed simultaneously.
[0181] Aspects of the present disclosure have been described above with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer or other programmable data processing device to produce a machine so that these instructions executed by the processor of the computer or other programmable data processing device enable the implementation of the function / action specified in one or more boxes of the flowchart and / or block diagram. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor or a field programmable logic circuit. It is also understood that each box in the block diagram and / or flowchart and the combination of the boxes in the block diagram and / or flowchart can also be implemented by dedicated hardware that performs the specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions.
[0182] The above description is only a specific embodiment of the present invention. Those skilled in the art will clearly understand that for the convenience and brevity of description, the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. It should be understood that the protection scope of the present invention is not limited to this. Any person skilled in the art can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention.
Claims
1. A method for managing data based on a hash table, characterized in that: The hash table includes a first hash table and multiple second hash tables, the first hash table includes multiple index addresses, each of the index addresses is associated with a second hash table, each of the second hash tables includes multiple storage addresses, each of the second hash tables includes lock information, and the lock information included in each of the second hash tables is different; the method includes: Get target data; Determine the key code corresponding to the target data according to a preset strategy; Calculate the key code by using a first hash function corresponding to the first hash table to obtain the index address corresponding to the key code; Obtain the second hash table corresponding to the index address; Calculate the key code by using a second hash function corresponding to the second hash table to obtain the storage address corresponding to the key code; storing the target data in a storage location corresponding to the storage address; The method further comprises: Get query data; Determine the key code corresponding to the query data according to the preset strategy; Calculate the key code by using a first hash function corresponding to the first hash table to obtain the index address corresponding to the key code; Obtain the second hash table corresponding to the index address and the lock information included in the second hash table; Calculate the key code by using a second hash function corresponding to the second hash table to obtain the storage address corresponding to the key code; The target data stored in the storage address is read according to the lock information.
2. The method for managing data based on a hash table according to claim 1, wherein: Each of the index addresses includes first offset information; The calculating the key code by using the first hash function corresponding to the first hash table to obtain the index address corresponding to the key code includes: The first offset information is obtained by calculating the key code using the first hash function, and the index address corresponding to the first offset information is obtained.
3. The method for managing data based on a hash table according to claim 1, wherein: Each of the storage addresses includes second offset information; The calculating the key code by using the second hash function corresponding to the second hash table to obtain the storage address corresponding to the key code includes: The second offset information is obtained by calculating the key code through the second hash function, and the storage address corresponding to the second offset information is obtained.
4. The method for managing data based on a hash table according to claim 1, wherein: The method further comprises: Get updated data; Determining a key code corresponding to the update data according to the preset strategy; Calculate the key code by using a first hash function corresponding to the first hash table to obtain the index address corresponding to the key code; Obtain the second hash table corresponding to the index address and the lock information included in the second hash table; Calculate the key code by using a second hash function corresponding to the second hash table to obtain the storage address corresponding to the key code; According to the lock information, the original data stored at the storage address is updated to the updated data.
5. A device for managing data based on a hash table, characterized in that: The hash table includes a first hash table and multiple second hash tables, the first hash table includes multiple index addresses, each of the index addresses is associated with a second hash table, each of the second hash tables includes multiple storage addresses, each of the second hash tables includes lock information, and the lock information included in each of the second hash tables is different; the device includes: Acquisition module, used to obtain target data; A determination module, configured to determine a key code corresponding to the target data according to a preset strategy; The acquisition module is further configured to calculate the key code by using a first hash function corresponding to the first hash table to obtain the index address corresponding to the key code; The acquisition module is further configured to acquire the second hash table corresponding to the index address; The acquisition module is further configured to calculate the key code by using a second hash function corresponding to the second hash table to obtain the storage address corresponding to the key code; A storage module, configured to store the target data in a storage location corresponding to the storage address; The acquisition module is further used to acquire query data; The determining module is further configured to determine a key code corresponding to the query data according to the preset strategy; The acquisition module is further configured to calculate the key code by using a first hash function corresponding to the first hash table to obtain the index address corresponding to the key code; The acquisition module is further configured to acquire the second hash table corresponding to the index address and the lock information included in the second hash table; The acquisition module is further configured to calculate the key code by using a second hash function corresponding to the second hash table to obtain the storage address corresponding to the key code; The device further comprises: A reading module is used to read the target data stored in the storage address according to the lock information.
6. The device for managing data based on a hash table according to claim 5, wherein: Each of the index addresses includes first offset information; The acquisition module is specifically used to: The first offset information is obtained by calculating the key code using the first hash function, and the index address corresponding to the first offset information is obtained.
7. The device for managing data based on a hash table according to claim 5, wherein: Each of the storage addresses includes second offset information; The acquisition module is specifically used to: The second offset information is obtained by calculating the key code through the second hash function, and the storage address corresponding to the second offset information is obtained.
8. The device for managing data based on a hash table according to claim 5, wherein: The acquisition module is further used to acquire update data; The determining module is further configured to determine a key code corresponding to the update data according to the preset strategy; The acquisition module is further configured to calculate the key code by using a first hash function corresponding to the first hash table to obtain the index address corresponding to the key code; The acquisition module is further configured to acquire the second hash table corresponding to the index address and the lock information included in the second hash table; The acquisition module is further configured to calculate the key code by using a second hash function corresponding to the second hash table to obtain the storage address corresponding to the key code; The device further comprises: An updating module is used to update the original data stored in the storage address to the updated data according to the lock information.
9. A device for managing data based on a hash table, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, the method for managing data based on a hash table according to any one of claims 1 to 4 is implemented.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores an implementation program for information transmission, and when the program is executed by a processor, the method for managing data based on a hash table according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Method for providing file system by using KV storage device and file system thereof
CN110019073A
Hash conflict processing method and device and computer readable storage medium
CN111352931A