Memory data management system, resource data storage method and resource data retrieval method
By using static and dynamic memory allocation methods in embedded devices to build a hash table, combined with hash algorithms, the problems of inefficient memory allocation and data retrieval under traditional memory management methods are solved, and efficient utilization of memory resources and rapid storage and retrieval of resource data are achieved.
Patent Information
- Application Number
- CN202411819315.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-11
- Publication Date
- 2025-04-29
AI Technical Summary
Traditional memory management methods are difficult to accurately adapt to the limited memory resources of embedded devices, resulting in inefficient and wasteful memory allocation, which cannot meet the needs of real-time and reliability. At the same time, there is a lack of systematic integration solutions in data retrieval, deletion and other operations, making it difficult to achieve fast and efficient execution.
Provides a memory data management system, uses static memory allocation method to build an array hash table and dynamic memory allocation method to build a linked list hash table, and combines a hash algorithm to realize the rapid storage and retrieval of resource data.
It realizes efficient utilization of memory resources and rapid storage and retrieval of resource data, improves the overall performance and reliability of the system, and meets the needs of embedded devices for memory data processing.
Smart Images

Figure CN119902879A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to a memory data management system, a resource data storage method and a resource data retrieval method. Background Art
[0002] In the field of embedded systems, with the continuous evolution of technology, many embedded devices are increasingly dependent on real-time and reliability in various application scenarios, and the requirements for memory data processing capabilities of embedded devices are gradually increasing.
[0003] From the perspective of memory resource characteristics, embedded devices are strongly constrained by factors such as cost, volume, and power consumption, and their memory resources are extremely limited and precious. Traditional memory management methods are often difficult to adapt accurately, which can easily lead to inefficient and wasteful memory allocation, and cannot maximize the performance of limited memory. In terms of memory allocation strategy, system reliability requires that memory allocation requests must be responded to and satisfied in a timely manner. However, the frequent dynamic memory allocation and release mechanism of the existing technology will not only significantly increase system overhead, but also weaken the overall performance of the system to a certain extent, making it difficult to choose a suitable memory allocation solution in different business scenarios. In addition, at the data operation level, routine operations such as retrieval and deletion of data in memory also need to achieve fast and efficient execution standards to ensure that the system can respond in real time and accurately. However, when dealing with these complex requirements, the existing technology often lacks a systematic integration solution, making it difficult to flexibly allocate memory allocation methods, reduce system overhead, and maintain efficient memory resource utilization and data operation performance while ensuring data storage reliability. Traditional data structures and algorithm designs make it difficult to strike a balance between retrieval speed and memory resource utilization efficiency. When the amount of data grows or the business complexity increases, the retrieval speed drops sharply, and the ineffective occupation of memory resources also increases, which cannot effectively meet the needs of embedded devices for memory data processing. Summary of the invention
[0004] In order to achieve efficient utilization of memory resources and rapid storage and retrieval of resource data, the present invention provides a memory data management system, a resource data storage method and a resource data retrieval method. The technical solutions adopted are as follows:
[0005] The technical solution of the first aspect of the present invention provides a memory data management system, the system comprising:
[0006] A first memory storage module is configured to construct an array-type hash table using a static memory allocation method;
[0007] A second memory storage module is configured to construct a linked list hash table using a dynamic memory allocation method;
[0008] A first counting module configured to extract the number of elements in the static memory data;
[0009] The second counting module is configured to extract the number of dynamic memory structures allocated by the dynamic memory.
[0010] Furthermore, the second memory storage module includes a secondary pointer array and a first data structure, and the pointer of the secondary pointer array points to the first data structure constructed by dynamically allocating memory.
[0011] Furthermore, the second memory storage module is used to perform hash conflict processing on the target index position based on the target index position and using the linked list hash table when the array hash table has a hash conflict.
[0012] Furthermore, hash conflict processing is performed on the target index position based on the target index position using a linked list hash table, including: if there is no hash conflict between the target index position and the linked list hash table, inserting a new first data structure as a hash node to store resource data, and making the pointer of the secondary pointer array point to the hash node; if there is a hash conflict between the target index position and the target index of the linked list hash table, inserting the new first data structure into the hash table header of the linked list hash table.
[0013] Furthermore, the first memory storage module includes a static memory array and a second data structure, the static memory array allocates continuous memory space through a static memory allocation method, and the second data structure is provided with a preset length data storage area.
[0014] Furthermore, the first memory storage module is used to perform hash conflict processing on the target index position when the length of the resource data to be stored does not exceed the preset length data storage area in the second data structure; if there is no hash conflict at the target index position, the resource data is stored in the second data structure; if there is a hash conflict, the hash conflict is processed using the second memory storage module.
[0015] The technical solution of the second aspect of the present invention provides a resource data storage method, including the memory data management system described in the technical solution of the first aspect of the present invention, and the method includes:
[0016] Extract the location index of the target data based on the hash algorithm;
[0017] Using a preset data length threshold to match the target data to a target hash table, the target hash table includes a linked list hash table and an array hash table;
[0018] Extracting the hash collision result of the target hash table and storing the target data according to the hash collision result, including:
[0019] When the target data is stored in the array hash table, if there is no hash conflict at the index position in the array hash table, the target data is stored in the array hash table; if there is a hash conflict at the index position in the array hash table, check whether there is a hash conflict at the index position in the linked list hash table;
[0020] When the target data is stored in a linked list hash table, if there is no hash conflict at the index position in the linked list hash table, the target data is stored in the linked list hash table; if there is a hash conflict at the index position in the linked list hash table, a new hash node is inserted into the linked list corresponding to the conflicting slot to store the target data.
[0021] The technical solution of the third aspect of the present invention provides a resource data retrieval method, including the memory data management system described in the technical solution of the first aspect of the present invention, the method comprising:
[0022] Extract the location index of the target data based on the hash algorithm;
[0023] Determine whether the target data exists in the array hash table and the linked list hash table, including:
[0024] If the target data exists in the corresponding position index in the array-type hash table, keyword judgment processing is performed; if the target data does not exist in the corresponding position index in the array-type hash table, a search is performed in the linked list hash table.
[0025] The technical solution of the fourth aspect of the present invention provides an electronic device, comprising: a processor and a memory communicatively connected to the processor; wherein the memory stores instructions executable by the processor, and the instructions are executed by the processor so that the processor can execute the instructions of the memory data management system described in the technical solution of the first aspect of the present invention.
[0026] The technical solution of the fifth aspect of the present invention provides a computer-readable storage medium, on which is stored a program for implementing a memory data management system, and the program for implementing the memory data management system is executed by a processor to implement the instructions of the memory data management system described in the technical solution of the first aspect of the present invention.
[0027] The present invention has the following beneficial effects:
[0028] The memory data management system provided by the present invention aims to realize the efficient utilization of memory resources and the rapid storage and retrieval of resource data through the cooperation of various modules; wherein, the second memory storage module uses a dynamic memory allocation method to construct a linked list hash table. When the amount of resource data increases temporarily or a hash conflict occurs in the array hash table, a new dynamic memory structure can be flexibly selected to be inserted to form a linked list node to store data, thereby avoiding the data storage problem caused by a sudden increase or conflict in the amount of data, making full use of the flexibility of dynamic memory allocation, and ensuring that resource data can be stored continuously and quickly; on the other hand, the first memory storage module uses a static memory allocation method to construct an array hash table. With the characteristics of continuous allocation of static memory, the cache hit rate is improved. For resource data with a length that meets the requirements, the index calculated by the hash can be directly stored in the corresponding position quickly to achieve rapid storage. In terms of retrieval, after obtaining the index based on the hash algorithm, it is first searched in the array hash table of the first memory storage module. If it does not exist, it is searched through the linked list hash table of the second memory storage module, thereby improving the retrieval efficiency. The first counting module counts the number of elements in the static memory data, while the second counting module extracts the number of dynamic memory structures allocated by the dynamic memory. It can provide real-time feedback on memory usage, allowing the system to reasonably allocate memory resources based on actual occupancy, avoid wasting memory resources, and achieve efficient use of memory resources. This ensures that the entire system is both efficient and reliable in the storage and retrieval of resource data. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0030] Figure 1 A schematic diagram of the structure of a memory data management system provided by an embodiment of the present invention;
[0031] Figure 2 A method flow chart of a resource data storage method provided by an embodiment of the present invention;
[0032] Figure 3 A method flow chart of a resource data retrieval method provided by an embodiment of the present invention;
[0033] Figure 4 A schematic diagram of the overall process of a resource data storage method provided by an embodiment of the invention;
[0034] Figure 5A schematic diagram of data structure relationships of a memory data management system provided by an embodiment of the present invention;
[0035] Figure 6 A schematic diagram of the structural relationship of a linked list hash table provided by an embodiment of the invention;
[0036] Figure 7 A schematic diagram of the structural relationship of an array-type hash table provided in one embodiment of the invention. DETAILED DESCRIPTION
[0037] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the following is a detailed description of the specific implementation methods, structures, features and effects of a memory data management system, a resource data storage method and a resource data retrieval method proposed according to the present invention in combination with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics in one or more embodiments may be combined in any suitable form.
[0038] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
[0039] The specific scheme of a memory data management system, a resource data storage method and a resource data retrieval method provided by the present invention is described in detail below with reference to the accompanying drawings.
[0040] See also Figure 1 , which shows a schematic diagram of the structure of a memory data management system provided by an embodiment of the present invention. The technical solution of the first aspect of the present invention provides a memory data management system, the system comprising:
[0041] The first memory storage module is configured to construct an array hash table using a static memory allocation method; specifically, the first memory storage module uses a linked list hash table mainly to solve the problem of hash conflicts in the array hash table and store a small amount of relatively long resource data, and to avoid saturation of entries in the array hash table when the amount of resource data temporarily increases; it should be noted that since the resource data in the linked list hash table is stored in non-continuous addresses of the memory, it will not only increase the probability of cache misses, but also reduce the access efficiency of resource data; and if it is necessary to find matching resource data in the linked list, a linear search is required, which has a certain impact on performance; in this embodiment, the linked list hash table is mainly used in conjunction with the array hash table to use and store a small amount of long data resources, maximizing the fast and reliable operation of resource data and the efficient use of memory resources;
[0042] The second memory storage module is configured to construct a linked list hash table using a dynamic memory allocation method; specifically, when the system is initialized, the secondary pointer array of the second memory storage module all points to NULL, and memory allocation is requested when needed;
[0043] A first counting module configured to extract the number of elements in the static memory data;
[0044] A second counting module is configured to extract the number of dynamic memory structures allocated by the dynamic memory;
[0045] The memory data management system is particularly suitable for scenarios where the amount of resource data stored in the memory of the business is small and stable, the length of each resource data is fixed, there are more short data resources and a limited number of long data resources; the resource data is frequently added, deleted, modified and checked; the data-type hash table stores short data resources (for example, the data length is not more than 36 bytes), and since the resource data needs to be frequently added, modified and deleted, in order to maximize the utilization and efficiency of memory resources, static allocation is adopted; the linked list hash table is used to store long data resources, the number of long data resources is small, but the data length is long, since the static memory resources are limited and the frequency of addition, modification and deletion of this part of the resources is relatively low, dynamic memory allocation is adopted to solve the data-type hash table conflict problem; the memory data management system provided in this embodiment, by combining the array-type hash table and the linked list-type hash table, uses the continuous memory characteristics and efficient direct access advantages of the array-type hash table to store short data, thereby improving the speed of conventional data storage and retrieval; at the same time, the dynamic scalability of the linked list-type hash table is used to handle long data, hash conflicts and temporary increases in data volume, thereby ensuring the reliability and flexibility of the system. The existence of the counting module makes memory resource management more refined, and can reasonably allocate resources according to actual usage to avoid memory waste or over-allocation, thereby realizing efficient utilization of memory resources and rapid storage and retrieval of resource data, effectively meeting various complex requirements for memory data management, and achieving a good balance in overall performance, reliability and resource utilization. It is especially suitable for scenarios such as embedded devices that have strict memory requirements and focus on real-time and reliability.
[0046] Preferably, the second memory storage module includes a secondary pointer array and a first data structure, the pointer of the secondary pointer array points to the first data structure constructed by dynamically allocating memory; the second memory storage module is used to perform hash conflict processing on the target index position based on the target index position and using the linked list hash table when the array hash table has a hash conflict, including: if there is no hash conflict between the target index position and the linked list hash table, insert a new first data structure as a hash node to store resource data, and make the pointer of the secondary pointer array point to the hash node; if there is a hash conflict between the target index position and the linked list hash table, insert the new first data structure into the hash table header where the index of the linked list hash table is located, and arrange it before other existing nodes, in order to improve the response rate; specifically, please refer to Figure 5 As shown, "table" is a secondary pointer array, each element in the secondary pointer array is a pointer to the first data structure "malloc_dict", each first data structure stores key, value and value length information and the use space of the first data structure is allocated through dynamic memory; for example, see Figure 6 As shown, in the system startup initialization phase, the secondary pointer array dynamically applies for a memory space of 32*sizeof(malloc_dict*) size when the system is powered on and initialized. Each element of the array points to NULL, and a linked list hash table is used to store key-value pairs during system operation. When resource data needs to be stored in the linked list hash table, the keyword of the resource data is first hashed to obtain the corresponding index value, and then the pointer corresponding to the index position in the secondary pointer array is checked: if the pointer is NULL, it means that the linked list corresponding to this index position is empty. At this time, memory space is dynamically allocated for the new first data structure, and the key, value and value length information of the resource data are stored in the structure, and the pointer at the index position in the secondary pointer array is made to point to the newly created structure; if the pointer is not NULL, it means that a linked list already exists at this index position. Further check whether there is a structure in the linked list that is the same as the current resource data key: if it exists, update the value information in the corresponding structure; if it does not exist, create a new first data structure, store the resource data information in it, and insert it into the appropriate position of the linked list (according to the hash conflict handling rules, it may be the head or the tail of the table), and update the pointer of the corresponding index position in the secondary pointer array. Secondly, in the data retrieval stage, the keyword to be retrieved for resource data is also hashed to obtain the index value, and then the linked list head pointer corresponding to the index position is obtained through the secondary pointer array, and the first data structure in the linked list is traversed to compare whether the key in the structure is consistent with the key to be retrieved. If they are consistent, the corresponding value information is returned. If no match is found after traversing the linked list, it means that the data does not exist.
[0047] This embodiment constructs a linked list hash table through a combination of a secondary pointer array and a first data structure, thereby realizing efficient organization and management of resource data; wherein the secondary pointer array, as an index structure, can quickly locate the linked list location where resource data may be stored, thereby reducing the time complexity of retrieval. The first data structure that dynamically allocates memory provides a flexible storage unit that can adapt to the storage requirements of resource data of different lengths and types, and is particularly suitable for processing longer resource data and dealing with hash conflicts. This structural design enables the use of the fast positioning advantage of the hash table in the storage, retrieval and update operations of resource data, and the use of the scalability of the linked list to handle conflicts and dynamic data changes, effectively improving the overall performance, flexibility and reliability of the memory data management system, and has significant advantages in scenarios where memory resources are limited and data operations are frequent.
[0048] Preferably, the first memory storage module includes a static memory array and a second data structure, the static memory array allocates continuous memory space by a static memory allocation method, and a preset length data storage area is provided in the second data structure; the first memory storage module is used to perform hash conflict processing on the target index position when the length of the resource data to be stored does not exceed the preset length data storage area in the second data structure; if there is no hash conflict at the target index position, the resource data is stored in the second data structure; if there is a hash conflict, the hash conflict is processed by the second memory storage module; specifically, please refer to Figure 5 As shown, Figure 5 In the example, "stack_dict_data" is a static memory array, and "stack_dict" is a second data structure. Each element in the static memory array stores key, value, and value length information. The space used by the second data structure is allocated through static memory. For example, see Figure 7As shown, when the system is initialized, the static memory array "stack_dict_data" of the first memory storage module completes the static memory allocation, and the multiple "stack_dict" second data structures it contains are also determined in memory layout. Each "stack_dict" structure has a specific area for storing key, value, and value length information, as well as a data storage area of preset length (36 bytes); when there is resource data to be stored, the keyword of the resource data is first hashed to obtain the target index position; if the resource data length does not exceed the preset length data storage area in the "stack_dict" structure: then check whether there is a hash conflict at the target index position of the static memory array, that is, check whether the "stack_dict" structure corresponding to the position has stored data and the key value is the same as the key of the current resource data; if there is no conflict, directly store the key, value, and value length information of the resource data into the "stack_dict" structure corresponding to the target index position. If there is a conflict, the resource data is transferred to the second memory storage module for processing. The second memory storage module will follow the processing logic of its linked list hash table, first hash the keyword of the resource data again to obtain the index in the linked list hash table, and then check the linked list corresponding to the index position. If it is empty, create a new node to store the data. If it is not empty, insert the data into the hash table header where the index of the linked list hash table is located according to the conflict handling rules, and arrange it before other existing nodes. On the other hand, when retrieving data, the keyword of the retrieved data is also hashed to obtain the target index position, and then search in the "stack_dict" structure corresponding to the position in the static memory array. If found and the key value matches, the data is returned. If not found or the key value does not match, continue to search in the linked list hash table of the first memory storage module, and traverse the linked list to find the matching key value pair.
[0049] This embodiment ensures the certainty and continuity of the memory space through static memory allocation by combining the static memory array and the second data structure, satisfies the principle of locality, and thus improves the cache hit rate, making data access faster, especially in batch data operations, because the complex process of dynamic memory allocation and release is not required, reducing system overhead and operation delays. It provides an efficient and reliable storage method for resource data that is short in length and meets the preset length requirements, and the collaborative processing mechanism with the first memory storage module when encountering hash conflicts ensures the flexibility and integrity of the entire system in the face of various data storage situations, effectively improving the comprehensive performance of the memory data management system in terms of data storage, retrieval and operation performance, while taking into account the efficiency of memory resource utilization and the reliability of data processing, and is suitable for application scenarios where the amount of resource data is relatively stable and short data operations are frequent.
[0050] In summary, the memory data management system provided by the present invention uses a hash table algorithm to realize the retrieval of resource data. Its core principle is to obtain a corresponding position index by applying a specific hash function to the keyword of the resource data. Based on this index, the location where the resource data may be stored can be quickly located, avoiding the inefficiency of the traditional linear search method that needs to traverse the memory space one by one, thereby greatly improving the speed of data retrieval and meeting the requirements of fast and efficient data access. The array hash table stores the resource data in the corresponding position according to the index corresponding to its hash value by pre-allocating an array space of a certain size; since most resource data are short and relatively regular, they meet the conventional requirements of array hash table storage, so most resource data are selected to be stored here. In addition, the layout of the array hash table in the memory is relatively regular and continuous, which makes it possible to directly and quickly obtain the corresponding data when searching, if the index position calculated by the hash algorithm is accurately hit (i.e., there is no hash conflict), the cache hit rate is relatively high, and efficient retrieval is achieved, thereby improving the overall data access efficiency. However, when encountering a small amount of resource data with a long length, the array hash table may face some limitations. On the one hand, due to its fixed-size array structure, longer data cannot be stored completely; on the other hand, if it is forcibly stored, it may destroy its regularity or cause the hash conflict processing to become complicated. The present invention constructs a linked list structure by dynamically allocating memory, and each node can flexibly accommodate longer resource data and be connected in series in the form of a linked list. Even if a hash conflict occurs, the specific data can be located by searching in the linked list in sequence. Although it is slightly less efficient than the direct hit of the array hash table, it is an effective supplementary storage method for special cases such as a small amount of long data; the present invention can store the resource data in the array hash table and the linked list hash table according to its length, quantity and other characteristics, giving full play to the advantages of the two hash table structures, and using the hash table algorithm to achieve fast and efficient retrieval of all resource data in the memory.
[0051] See also Figure 2 and Figure 4 As shown, the technical solution of the second aspect of the present invention provides a resource data storage method, including the memory data management system described in the technical solution of the first aspect of the present invention, and the method includes:
[0052] Step S100: extract the location index of the target data based on the hash algorithm; specifically, when the system is powered on, first perform the memory data structure initialization operation; including allocating continuous memory space for the array hash table (static memory array represented by stack_dict_data), and performing corresponding initialization settings for the structure related to the linked list hash table (structure constructed by the secondary pointer array and the malloc_dict structure), such as dynamically applying for a memory space of a suitable size for the secondary pointer array, and initializing each element to point to NULL, etc., so as to prepare two hash table structures for storing resource data; when there is resource data to be stored, first extract the keyword of the resource data, and then use the preset hash algorithm to calculate the keyword to obtain the corresponding location index (referred to as index), which will be used as the key basis for determining the resource data storage location in the future;
[0053] Step S200: using a preset data length threshold to match the target data to a target hash table, where the target hash table includes a linked list hash table and an array hash table;
[0054] Step S300: extracting the hash conflict result of the target hash table and storing the target data according to the hash conflict result, including: when the target data is stored in the array hash table, if the index position does not have a hash conflict in the array hash table, the target data is stored in the array hash table; if the index position has a hash conflict in the array hash table, checking whether the linked list hash table has a hash conflict at the index position; when the target data is stored in the linked list hash table, if the index position does not have a hash conflict in the linked list hash table, the target data is stored in the linked list hash table; if the index position has a hash conflict in the linked list hash table, a new hash node is inserted into the linked list corresponding to the conflict slot to store the target data; specifically:
[0055] Array hash table has no conflicts: Check whether there is data at the index position in the array hash table (i.e., determine whether there is a conflict). If there is no conflict, it means that the stack_dict_data[index] corresponding to the position is free and available. At this time, the resource data is directly stored in the corresponding structure position of stack_dict_data[index]. The corresponding fields in the structure (such as key, value, and value length fields) are filled with the corresponding information of the resource data.
[0056] Array hash table has conflicts: If it is found that the array hash table already has data at the index position, that is, a conflict occurs, then turn to determine whether the linked list hash table has a conflict at the index position; if the linked list hash table does not have a conflict at the index position, this indicates that there is no node or no node with the same key value at the index position corresponding to the linked list hash table. At this time, a new hash node is created for the new resource data, and the key, value and other information of the resource data are stored in the structure. Then, the malloc_dict[index] pointer is made to point to the newly created node, so that the resource data is inserted into the linked list hash table for storage;
[0057] Linked list hash tables also have conflicts: if there is a conflict at the index position in the linked list, that is, there is already a node in the linked list corresponding to the position, a new hash node is created to store the resource data, and then the tail hash node of the linked list corresponding to the malloc_dict[index] position is found, and its pointer is pointed to the newly inserted hash node, and the new resource data is added to the head of the linked list to realize the storage of resource data in the linked list hash table;
[0058] If the length of the resource data is greater than 36 bytes, the operation is performed directly according to the storage logic of the linked list hash table. First, determine whether the linked list hash table has a conflict at the calculated index position. If there is no conflict, insert a new node for storage (the operation is the same as the insertion method when there is no conflict in the above linked list hash table). If there is a conflict, insert it after the end hash node of the linked list (the operation is the same as the insertion method when there is a conflict in the above linked list hash table);
[0059] In summary, this resource data storage method combines array hash tables and linked list hash tables to flexibly select storage locations based on data length and hash conflict situations, giving full play to the advantages of the two hash table structures. For shorter resource data, array hash tables are preferentially used for storage, and the cache hit rate is improved by virtue of its continuous memory allocation characteristics, which enables fast and direct storage and access, and improves the efficiency of most common data storage and retrieval. When hash conflicts occur or when processing longer resource data, the dynamic scalability and flexible linked list structure of linked list hash tables can properly handle conflicts, ensure that resource data of various lengths can be effectively stored, avoid storage problems caused by differences in data characteristics, enhance the adaptability and reliability of the entire memory data storage system, and meet the resource data storage needs in different business scenarios. At the same time, it ensures the efficiency and accuracy of data storage operations and optimizes the utilization efficiency of memory resources.
[0060] See also Figure 3The technical solution of the third aspect of the present invention provides a resource data retrieval method, including the memory data management system described in the technical solution of the first aspect of the present invention, the method comprising:
[0061] Step S1: extracting the location index of the target data based on the hash algorithm; specifically, when it is necessary to retrieve resource data, first obtain the keyword of the target data, and use the preset hash algorithm to calculate the keyword, so as to obtain the location index index corresponding to the target data;
[0062] Step S2: Determine whether the target data exists in the array hash table and the linked list hash table, including: if the target data exists in the corresponding position index in the array hash table, perform keyword judgment processing; if the target data does not exist in the corresponding position index in the array hash table, search in the linked list hash table. Specifically, check whether the target data exists in the array hash table (i.e., stack_dict_data[index] position) based on the calculated index; determine whether the relevant resource data exists by determining whether the structure at the corresponding position (stack_dict structure) has stored the relevant resource data:
[0063] Target data exists: If the target data is found at the index position in the array hash table, further keyword judgment processing is required; that is, the keyword of the target data is compared with the keyword of the resource data stored at this position. If the two keywords are exactly the same, it means that the matching target data is found, and then the resource data and its corresponding length information are returned for subsequent use or display operations; if the keywords are inconsistent after comparison, it means that although there is data stored at this position, it is not the target data to be retrieved. At this time, the "error" return code is returned, indicating that the search has a keyword mismatch; Target data does not exist: If it is determined that the target data does not exist at the index position in the array hash table, this indicates that the target data to be retrieved may be stored in the linked list hash table, so it is necessary to perform a search operation in the linked list hash table.
[0064] Linked list hash table retrieval stage: When searching in a linked list hash table, the index is also used as a clue to find the corresponding linked list head node (located by malloc_dict[index]), and then each node is traversed along the linked list in turn; for the resource data in each node, a keyword comparison is performed to determine whether its keyword is consistent with the keyword of the target data to be retrieved; if in the process of traversing the linked list, it is found that the keyword in a node is consistent with the keyword of the target data, it means that the target data has been found, and the resource data stored in the node and the corresponding length information are also returned; if after traversing all the nodes at the corresponding index position in the linked list hash table, no consistent keywords are found, it means that the target data to be retrieved does not exist in the entire memory data management system, and a "non-existent" return code is returned at this time, indicating that the search result is that the corresponding data was not found.
[0065] This resource data retrieval method relies on the hash algorithm to quickly locate the possible storage location first. It is based on the orderly process of first checking the array hash table and then retrieving the linked list hash table on demand. It fully utilizes the efficiency of the array hash table in directly hitting the data without conflict. It can quickly determine whether most of the regular data exists and complete the retrieval, reducing the overall retrieval time. When the array hash table does not hit, the traversal retrieval mechanism of the linked list hash table ensures a comprehensive investigation of all possible storage locations, and does not miss any nodes that may store the target data, ensuring the accuracy and completeness of the retrieval. Overall, while improving the retrieval efficiency, this retrieval method takes into account the complexity of the data storage structure, can adapt to different storage situations, and effectively deal with the impact of factors such as hash conflicts. It provides users or systems with a reliable and efficient resource data retrieval method, and meets the requirements of the memory data management system for fast and accurate data retrieval.
[0066] The technical solution of the fourth aspect of the present invention provides an electronic device, comprising: a processor and a memory communicatively connected to the processor; wherein the memory stores instructions executable by the processor, and the instructions are executed by the processor so that the processor can execute the instructions of the memory data management system described in the technical solution of the first aspect of the present invention.
[0067] The technical solution of the fifth aspect of the present invention provides a computer-readable storage medium, on which is stored a program for implementing a memory data management system, and the program for implementing the memory data management system is executed by a processor to implement the instructions of the memory data management system described in the technical solution of the first aspect of the present invention.
[0068] It should be noted that the sequence of the above embodiments of the present invention is only for description and does not represent the advantages and disadvantages of the embodiments. The processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0069] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.
Claims
1. A memory data management system, characterized in that: The system comprises: A first memory storage module is configured to construct an array-type hash table using a static memory allocation method; A second memory storage module is configured to construct a linked list hash table using a dynamic memory allocation method; A first counting module configured to extract the number of elements in the static memory data; The second counting module is configured to extract the number of dynamic memory structures allocated by the dynamic memory.
2. The memory data management system according to claim 1, characterized in that: The second memory storage module includes a secondary pointer array and a first data structure, and the pointer of the secondary pointer array points to the first data structure constructed by dynamically allocating memory.
3. The memory data management system according to claim 2, characterized in that: The second memory storage module is used to perform hash conflict processing on the target index position based on the target index position and using the linked list hash table when the array hash table has a hash conflict.
4. The memory data management system according to claim 3, characterized in that: The method comprises: if there is no hash conflict between the target index position and the linked list hash table, inserting a new first data structure as a hash node to store resource data, and making the pointer of the secondary pointer array point to the hash node; if there is a hash conflict between the target index position and the target index of the linked list hash table, inserting the new first data structure into the hash table header of the linked list hash table.
5. The memory data management system according to any one of claims 1 to 4, characterized in that: The first memory storage module includes a static memory array and a second data structure. The static memory array allocates continuous memory space through a static memory allocation method. The second data structure is provided with a preset length data storage area.
6. The memory data management system according to claim 5, characterized in that: The first memory storage module is used to perform hash conflict processing on the target index position when the length of the resource data to be stored does not exceed the preset length data storage area in the second data structure; If there is no hash conflict at the target index position, the resource data is stored in the second data structure; If there is a hash conflict, the second memory storage module is used to handle the hash conflict.
7. A resource data storage method, characterized in that: The memory data management system according to any one of claims 1 to 6, wherein the method comprises: Extract the location index of the target data based on the hash algorithm; Using a preset data length threshold to match the target data to a target hash table, the target hash table includes a linked list hash table and an array hash table; Extracting the hash collision result of the target hash table and storing the target data according to the hash collision result, including: When the target data is stored in the array hash table, if there is no hash conflict at the index position in the array hash table, the target data is stored in the array hash table; if there is a hash conflict at the index position in the array hash table, check whether there is a hash conflict at the index position in the linked list hash table; When the target data is stored in a linked list hash table, if there is no hash conflict at the index position in the linked list hash table, the target data is stored in the linked list hash table; if there is a hash conflict at the index position in the linked list hash table, a new hash node is inserted into the linked list corresponding to the conflicting slot to store the target data.
8. A resource data retrieval method, characterized in that: The memory data management system according to any one of claims 1 to 6, wherein the method comprises: Extract the location index of the target data based on the hash algorithm; Determine whether the target data exists in the array hash table and the linked list hash table, including: If the target data exists in the corresponding position index in the array-type hash table, keyword judgment processing is performed; if the target data does not exist in the corresponding position index in the array-type hash table, a search is performed in the linked list hash table.
9. An electronic device, characterized in that: The electronic device includes: a processor and a memory communicatively connected to the processor; wherein the memory stores instructions executable by the processor, and the instructions are executed by the processor so that the processor can execute the instructions of the memory data management system described in any one of claims 1 to 6.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a program for implementing a memory data management system, and the program for implementing the memory data management system is executed by a processor to implement instructions of the memory data management system according to any one of claims 1 to 6.
Citation Information
Cited By
Digital media resource intelligent retrieval and management system based on multi-modal interaction
CN121278155A
Intelligent retrieval and management system of digital media resources based on multi-modal interaction
CN121278155B