A data storage method and device, electronic equipment and storage medium
By directly interacting with the driver layer and storing data in hash tables, the problem of low efficiency in accessing unstructured data is solved, achieving high-efficiency data processing and response speed.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHANDONG YUNHAI GUOCHUANG CLOUD COMPUTING EQUIP IND INNOVATION CENT CO LTD
- Filing Date
- 2026-01-23
- Publication Date
- 2026-06-09
AI Technical Summary
In existing technologies, access to unstructured data relies on file system path resolution and address mapping, resulting in low data processing efficiency, especially increasing I/O overhead during frequent queries, deletions, and updates.
By obtaining hard disk access commands, the target driver controller and hash table are determined based on the database number. Data can be written or read directly in the storage controller, avoiding file system processing. Data is stored using a hash table, enabling direct interaction at the driver layer.
It improves data processing efficiency, reduces system overhead and write amplification effect, and is suitable for scenarios such as databases, log-based applications and high-speed edge computing nodes.
Smart Images

Figure CN122173019A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and more specifically to a data storage method, apparatus, electronic device, and storage medium. Background Technology
[0002] Unstructured data includes various forms such as text, graphics, audio, or video, and its data volume is enormous. When accessing unstructured data, the system first needs to search the file system according to the file name and path corresponding to the data to determine the corresponding Logical Block Address (LBA). Then, the address information and instructions are sent to the Redundant Array of Independent Disks (RAID) controller. The RAID controller maps the logical block address to a specific physical address, reads the data according to the physical address, and sends the read data back to the file system.
[0003] In related technologies, RAID is typically used to manage data in the traditional block storage mode. Data access relies on file system path resolution and address mapping. Since unstructured data needs to be frequently queried, deleted, and updated, it increases I / O overhead and reduces data processing efficiency. Summary of the Invention
[0004] This application provides a data storage method, apparatus, electronic device, and storage medium to at least solve the problem in the related art that data access relies on a file system, resulting in low data processing efficiency.
[0005] This application provides a data storage method, including: Obtain the disk access command; the disk access command includes the data to be accessed and the corresponding database number; Based on the database number, the target drive controller is determined among multiple drive controllers; Based on the database number, determine the corresponding target hash table from among the multiple hash tables of the target driver controller; When the hard disk access command is a data write command, the data to be accessed is sent to the storage controller so that the storage controller writes the data to be accessed as storage data to the hard disk. In response to a write success command sent by the storage controller, the stored data is written to the corresponding target hash table; When the hard disk access command is a data read command, the corresponding stored data is read from the target hash table according to the query information to be accessed; Specifically, when the hard disk access command is a data write command, the data to be accessed includes the query information to be accessed and the data content; when the hard disk access command is a data read command, the data to be accessed includes the query information to be accessed.
[0006] This application also provides a data storage device, including: The first acquisition module is used to acquire hard disk access commands; wherein, the hard disk access commands include the data to be accessed and the corresponding database number; The first determining module is used to determine the target drive controller among multiple drive controllers based on the database number; The second determining module is used to determine the corresponding target hash table from multiple hash tables of the target driver controller based on the database number; The sending module is used to send the data to be accessed to the storage controller when the hard disk access command is a data write command, so that the storage controller writes the data to be accessed to the hard disk as storage data. The write module is used to write the stored data to the corresponding target hash table in response to a write success command sent by the storage controller; The read module is used to read the corresponding stored data from the target hash table based on the query information to be accessed when the hard disk access command is a data read command. Specifically, when the hard disk access command is a data write command, the data to be accessed includes the query information to be accessed and the data content; when the hard disk access command is a data read command, the data to be accessed includes the query information to be accessed.
[0007] This application also provides an electronic device, including: a memory for storing a computer program; and a processor for implementing the data storage method described above when executing the computer program.
[0008] This application also provides a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of any of the above-described data storage methods.
[0009] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the above-described data storage methods.
[0010] This application achieves a direct interaction with the driver controller by determining the corresponding target driver controller and target hash table based on the database number represented by the hard disk access command. When the hard disk access command is a data write command, the data to be accessed is sent to the storage controller, and in response to the write success command sent by the storage controller, the stored data is written to the corresponding target hash table. When the hard disk access command is a data read command, the corresponding stored data is directly read from the target hash table based on the query information to be accessed. This enables direct interaction with the driver controller through the hard disk access command and stores the data to be accessed through the hash table, thereby achieving direct storage or retrieval of data content at the driver layer based on the query information to be accessed, thus improving the efficiency of data processing. Attached Figure Description
[0011] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 This is a schematic diagram of the data storage system on which the embodiments of this application are based; Figure 2 A flowchart illustrating the data storage method provided in an embodiment of this application; Figure 3 A schematic diagram of the structure of an exemplary driving function module provided in an embodiment of this application; Figure 4 A flowchart illustrating an exemplary data write command provided in an embodiment of this application; Figure 5 A schematic diagram of an exemplary fixed-length KV pair data storage structure provided for embodiments of this application; Figure 6 A schematic diagram of the structure of the data storage device provided in the embodiments of this application; Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0013] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.
[0014] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.
[0015] With the increasing demand for high reliability and large-capacity data access capabilities in enterprise data centers and storage servers, RAID cards provide redundancy protection and performance optimization by managing multiple physical disks in a unified manner. RAID cards are responsible for data striping, mirroring, parity calculation, and cache management.
[0016] In traditional block storage, RAID cards use logical block addresses as the unit of access, which introduces a large number of random read / write operations and space fragmentation when processing unstructured or small file data. Furthermore, RAID cards typically manage disk mapping through LBA, which results in significant shortcomings in efficiency and flexibility for small data objects that require frequent queries, deletions, and updates, such as logs, metadata, or intermediate caches.
[0017] Key-Value (KV) storage models are increasingly being adopted in the design of new storage devices and systems. By directly accessing values using keys as indexes, the traditional block address translation process is simplified, reducing data management overhead.
[0018] In related technologies, RAID is typically used to manage data in the traditional block storage mode. Data access relies on file system path resolution and address mapping. Since unstructured data needs to be frequently queried, deleted, and updated, it increases I / O overhead and reduces data processing efficiency.
[0019] To address the aforementioned technical problems, this application provides a data storage method, apparatus, electronic device, and storage medium. The method includes: acquiring a hard disk access command; wherein the hard disk access command includes data to be accessed and a corresponding database number; determining a target drive controller from among multiple drive controllers based on the database number; determining a corresponding target hash table from among multiple hash tables of the target drive controller based on the database number; when the hard disk access command is a data write command, sending the data to be accessed to a storage controller so that the storage controller writes the data to be accessed as storage data to the hard disk; responding to a write success command sent by the storage controller, writing the storage data to the corresponding target hash table; and when the hard disk access command is a data read command, reading the corresponding storage data from the target hash table based on query information to be accessed; wherein when the hard disk access command is a data write command, the data to be accessed includes query information to be accessed and data content; and when the hard disk access command is a data read command, the data to be accessed includes query information to be accessed.
[0020] The method provided by the above scheme determines the corresponding target driver controller and target hash table based on the database number represented by the hard disk access command. When the hard disk access command is a data write command, the data to be accessed is sent to the storage controller, and in response to the write success command sent by the storage controller, the storage data is written to the corresponding target hash table. When the hard disk access command is a data read command, the corresponding storage data is directly read from the target hash table according to the query information to be accessed. Direct interaction with the driver controller is realized through the hard disk access command, and the data to be accessed is stored through the hash table. This enables direct storage or retrieval of data content at the driver layer based on the query information to be accessed, thereby improving the efficiency of data processing.
[0021] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0022] The specific application environment architecture or specific hardware architecture on which the execution of the data storage method depends is described here.
[0023] First, the structure of the data storage system on which this application is based will be described: The data storage method, apparatus, electronic device, and storage medium provided in the embodiments of this application are applicable to KV pair data storage, such as... Figure 1 The diagram shown is a structural schematic of the data storage system based on the embodiments of this application, mainly including data to be stored, a data acquisition device, and a data storage device. The data acquisition device is used to obtain hard disk access commands, and the data storage device is used to store the KV pair data based on the data storage method provided in the embodiments of this application.
[0024] This application provides a data storage method for storing key-value pairs (KV pairs). The execution subject of this application embodiment is an electronic device, such as a server, desktop computer, laptop computer, tablet computer, or other electronic devices that can be used for data storage.
[0025] like Figure 2 The diagram shown is a flowchart illustrating a data storage method provided in an embodiment of this application. The method includes: Step 201: Obtain the hard disk access command.
[0026] The hard disk access command includes the data to be accessed and the corresponding database number.
[0027] For example, such as Figure 3 The diagram shown is a schematic of the structure of an exemplary driver function module provided in an embodiment of this application. The NVMe driver function module includes NVMe regular driver functions and custom KV functions. The custom KV functions include custom commands related to NVMe KV, such as KV database management commands, KV database input / output commands, and KV database related resource commands.
[0028] Specifically, the KV function module in the custom NVMe driver includes commands for regular NVMe driver functions, KV database management commands, and KV database input / output commands. The driver controller directly responds to the hard disk control commands.
[0029] NVMe standard driver functions include standard NVMe operations, allowing users to use RAID cards in a regular manner, such as creating and deleting volumes, reading and writing volumes, creating Submission Queue Entry (SQE) cache buffers based on logical block addresses, and Completion Queue Entry (CQE) cache buffers, etc.
[0030] KV Database Management Commands (KVDMC) contain basic database management commands such as create, delete, and query, using custom opcodes. The command structure is identical to the structure of the commit queue entries, using the CDW10-CDW15 areas to pass custom information.
[0031] For example, when creating a KV database with fixed-length data content, you can use CDW10 to specify the size of the information (key) and data content (value) to be accessed and queried. The usage of Dword10 when creating a KVDB in a custom driver is shown in Table 1: Table 1. Use of Dword10 when creating a KVDB in a custom driver
[0032] The database creation command includes information such as the database name, database number, number and size of key-value pairs (KV pairs) to be contained, and stores the information temporarily in the memory space pointed to by the pointer (PRP). The database creation command is then sent to the driver controller to create the KV database.
[0033] Since each key-value database stores key-value pairs of different sizes, after the key-value database is created, its related information is stored in a database information cache. This cache is allocated by the driver during database creation. The key-value database information includes the database name, database number, number and size of key-value pairs (KV pairs) contained in the database creation command, as well as the database's starting address, size, key length, and value length.
[0034] KV Database IO Commands (KVIO) are used to read, write, and delete KV pairs of data. Each operation involves a single KV pair.
[0035] The format of hard disk access commands is shown in Table 2: Table 2 Hard Disk Access Command Format
[0036] When the data content is large, the data content can be cached across pages.
[0037] Correspondingly, by customizing the KV function module in the NVMe driver, a direct key-value access interface is provided, enabling the driver controller to directly respond to hard disk control commands, avoiding processing through the file system, shortening the data read / write path length, and improving data storage efficiency.
[0038] Step 202: Based on the database number, determine the target drive controller among multiple drive controllers.
[0039] Step 203: Based on the database number, determine the corresponding target hash table from among the multiple hash tables of the target driver controller.
[0040] Specifically, the hash table contains multiple records used to record key-value pair information. Information about key-value pairs can be retrieved by querying the hash table. The hash table is stored in the driver controller. Based on the database number, the target driver controller is determined among multiple driver controllers, and the target hash table is then selected from the multiple hash tables of the target driver controller.
[0041] Accordingly, the hash table stores information related to key-value pairs, allowing data access to be performed directly by retrieving the data content stored in the hash table, avoiding layers of indexing and improving the efficiency of data writing or reading. Step 204: If the hard disk access command is a data write command, the data to be accessed is sent to the storage controller so that the storage controller writes the data to be accessed as storage data to the hard disk.
[0042] Step 205: In response to the write success command sent by the storage controller, the stored data is written to the corresponding target hash table.
[0043] Specifically, the host sends a data write command through a custom NVMe driver interface. The command is passed to the NVMe driver, which sends the data to be accessed to the storage controller, i.e., the RAID controller. The data to be accessed includes the query information (Key), the data content (Value), and the corresponding verification content. The RAID controller processes the data internally and writes the data to be accessed as storage data to the hard drive. After the write is completed, the storage controller sends a write success command to the driver controller. After confirming the success, the storage data is written to the target hash table.
[0044] Step 206: If the hard disk access command is a data read command, read the corresponding stored data from the target hash table according to the query information to be accessed.
[0045] Specifically, when the hard disk access command is a data write command, the data to be accessed includes the query information to be accessed and the data content; when the hard disk access command is a data read command, the data to be accessed includes the query information to be accessed.
[0046] Specifically, the target hash table stores the data content. The host sends a data read command through a custom NVMe driver interface. The command is passed to the NVMe driver. The driver determines the corresponding target driver controller, i.e., the NVMe controller, through the database number. Among the multiple hash tables in the target driver controller, the target hash table is determined and read. Based on the query information to be accessed, the corresponding stored data is read from the target hash table and returned to the user.
[0047] Correspondingly, for unstructured or semi-structured data, the KV method improves the efficiency of data access. By adding KV functionality to the drive controller, the drive controller can directly respond to hard drive access commands, thereby scheduling the RAID controller. This provides efficient small data read and write capabilities, reduces system overhead and write amplification effect, and improves data processing efficiency and response speed. It is suitable for scenarios that are sensitive to both performance and reliability, such as databases, log applications, distributed caches, and high-speed edge computing nodes.
[0048] Based on the above embodiments, as one implementable approach, in one embodiment, in response to a write success command sent by the storage controller, the storage data is written to the corresponding target hash table, including: Step 2051: In response to the write success command sent by the storage controller, determine whether the data content is greater than the preset storage threshold. Step 2052: If the data content is not greater than the preset storage threshold, write the data content to the corresponding target hash table.
[0049] Specifically, in one embodiment, when the data content is greater than a preset storage threshold, the logical address of the data content on the hard disk is obtained; the logical address and the query information to be accessed are written into the corresponding target hash table.
[0050] For example, such as Figure 4The diagram illustrates an exemplary data write command flow provided in this application embodiment. The host sends a data write command through a custom NVMe driver interface. The command is transmitted to the NVMe driver, which determines the corresponding target driver controller (NVMe controller) using the database number. The driver then selects the target hash table from among multiple hash tables in the target driver controller and reads it. Based on the query information to be accessed, it checks whether a corresponding record exists in the target hash table. If not, the data to be accessed is packaged, including the query information, data content, and corresponding verification content. The data is temporarily stored in the storage area pointed to by the PRP. The target driver controller then sends a write command to the storage controller. The command sends the data to be accessed to the storage controller, i.e., the RAID controller. The RAID controller processes the data internally, writing it to the hard drive as storage data. After writing is complete, it notifies the upstream controller via an MSI or MSI-X interrupt, indicating a successful write. The target drive controller receives the completion queue entry after the interrupt processing. Upon confirmation of success, it retrieves an empty record from the idle record queue. If the data content exceeds a preset storage threshold, it fills the record with the logical address and the query information to be accessed, and adds the record to the target hash table. If the data content is not greater than the preset storage threshold, it fills the record with the data content and the query information to be accessed, and adds the record to the target hash table. The idle queue contains at least one idle record.
[0051] Specifically, when the drive controller executes a data write command, if a corresponding record exists in the target hash table, the target drive controller sends a write command to the storage controller, sending the data to be accessed to the storage controller. The storage controller processes the data internally, overwriting the original data on the hard drive with the new data to be accessed, and simultaneously overwriting the original record in the target hash table with the new data to be accessed. When creating a record, if the number of key-value pairs in the current key-value database has already reached the maximum number supported by the key-value database, the system returns a message to the user that the space is full.
[0052] Accordingly, by setting a preset storage threshold, the data content itself or the logical address corresponding to the data content is stored in the hash table according to the size of the data content. Since the space for storing data content in the hash table is of fixed length, it avoids the inability to store data due to excessively large data content or the waste of space due to excessively small data content.
[0053] Specifically, in one embodiment, when the hard disk access command is a data read command, the corresponding logical address is read from the target hash table according to the query information to be accessed; the logical address is sent to the storage controller so that the storage controller can obtain the storage data from the hard disk according to the logical address.
[0054] Specifically, when the data content exceeds a preset storage threshold, the target hash table stores the logical address corresponding to the data content.
[0055] The host sends a data read command through a custom NVMe driver interface. The command is passed to the NVMe driver, which uses the database number to determine the corresponding target driver controller, i.e., the NVMe controller. The target hash table is selected from multiple hash tables in the target driver controller and read. Based on the query information to be accessed, the corresponding logical address is read from the target hash table. The target driver controller sends a read command to the storage controller. The RAID controller processes the command internally, retrieves the corresponding storage data based on the logical address, and returns the storage data to the user.
[0056] Based on the above embodiments, as an implementable approach, in one embodiment, the method further includes: Step 301: Obtain the database creation command.
[0057] Step 302: Determine the size of the hash table based on the length of the query information to be accessed as represented by the database creation command, the preset storage threshold of the data content, the pointer size, and the number of records in the hash table.
[0058] Step 303: Create multiple hash tables in each driver controller according to the size of the hash table.
[0059] Specifically, in one embodiment, the size of the hash table can be determined based on the following formula:
[0060] in, Indicates the size of the hash table. Indicates the length of the query information to be accessed. This represents the preset storage threshold for the data content. Indicates pointer size, This indicates the number of records in the hash table.
[0061] Specifically, a hash table consists of at least one record, which includes the query information to be accessed, the data content, and a pointer. The size of the hash table is determined based on the length of the query information to be accessed as represented by the database creation command, the preset storage threshold of the data content, the pointer size, and the number of records in the hash table. The driver controller requests memory space from the host and stores the hash table during KVDB creation using the HMB function. When the data content is not greater than the preset storage threshold, the data content is stored in the hash table; when the data content is greater than the preset storage threshold, the logical address of the data content on the hard disk is stored in the hash table.
[0062] Correspondingly, since the internal storage space of the drive controller is small, the requirement to store a hash table is met by using the HMB function.
[0063] Based on the above embodiments, as an implementable approach, in one embodiment, the method further includes: Step 401: When the hard disk access command is a data deletion command, set the status value of the corresponding record in the target hash table to invalid; wherein, the record includes the information to be accessed and queried and the data content, and the information to be accessed and queried includes the status value. Step 402: Send the query information to be accessed to the storage controller so that the storage controller deletes the stored data from the hard disk; Step 403: In response to the deletion success command sent by the storage controller, delete the corresponding record in the target hash table.
[0064] Specifically, the host sends a data deletion command through a custom NVMe driver interface. The command is passed to the NVMe driver, which uses the database number to determine the corresponding target driver controller (NVMe controller). The target driver controller then selects and reads the target hash table from among multiple hash tables. Based on the query information, it identifies the corresponding record in the target hash table, sets its status as invalid, and sends a deletion command to the storage controller. The storage controller, based on the query information, locates the corresponding storage data on the hard drive and deletes it. After deletion, it notifies the system via an MSI or MSI-X interrupt, indicating successful deletion. Upon receiving the interrupt completion queue entry, the target driver controller confirms success, deletes the corresponding record from the target hash table, and releases it to the idle record queue. When deleting non-existent data, if no corresponding record is found in the target hash table of the driver controller, a "not found" message is returned to the user.
[0065] Correspondingly, fixed-length key-value pairs will not become fragmented after multiple creations and deletions, improving space utilization and avoiding the need to provide free storage space through defragmentation.
[0066] For example, such as Figure 5 The diagram shown is an exemplary fixed-length KV pair data storage structure provided in this application embodiment. In the RAID controller, the storage data is stored on the stripes of the RAID array, including the query information to be accessed, the data content, and the CRC check information. The first byte in the query information to be accessed is the status control information, which is used to indicate whether the current key is valid. Specifically, in one embodiment, the hard disk access command includes a priority tag. After receiving the hard disk access command, the drive controller performs scheduling processing based on the priority tag, prioritizing high-priority hard disk access commands and returning the data content in the target hash table to the user. If the target hash table stores the logical address of the data content, the high-priority tag is carried in the command sent by the drive controller to the RAID controller so that the RAID controller can recognize the priority tag and prioritize the command, thus giving priority to hard disk access commands for critical services. Among these, hard disk access commands that require timely response, such as real-time interactive commands and critical services, are of high priority.
[0067] The data storage method provided in this application includes: obtaining a hard disk access command; wherein the hard disk access command includes data to be accessed and a corresponding database number; determining a target driver controller among multiple driver controllers based on the database number; determining a corresponding target hash table among multiple hash tables of the target driver controller based on the database number; when the hard disk access command is a data write command, sending the data to be accessed to a storage controller so that the storage controller writes the data to be accessed as storage data to the hard disk; and writing the storage data to the corresponding target hash table in response to a write success command sent by the storage controller; when the hard disk access command is a data read command, reading the corresponding storage data from the target hash table based on the query information to be accessed; wherein when the hard disk access command is a data write command, the data to be accessed includes the query information to be accessed and data content, and when the hard disk access command is a data read command, the data to be accessed includes the query information to be accessed.
[0068] The method provided by the above scheme determines the corresponding target driver controller and target hash table based on the database number represented by the hard disk access command. When the hard disk access command is a data write command, the data to be accessed is sent to the storage controller, and in response to the write success command sent by the storage controller, the storage data is written to the corresponding target hash table. When the hard disk access command is a data read command, the corresponding storage data is directly read from the target hash table according to the query information to be accessed. Direct interaction with the driver controller is realized through the hard disk access command, and the data to be accessed is stored through the hash table. This enables direct storage or retrieval of data content at the driver layer based on the query information to be accessed, thereby improving the efficiency of data storage.
[0069] Furthermore, by customizing the KV (Key-Value) module in the NVMe driver, a direct key-value access interface is provided, allowing the driver controller to directly respond to hard drive control commands. This avoids processing through the file system, shortens the data read / write path, and improves data storage efficiency. A hash table stores information related to KV pairs, enabling direct access to data by retrieving either the data content stored in the hash table or the logical address corresponding to the data content. This avoids layered indexing and improves data write and read efficiency. For unstructured or semi-structured data, the KV approach enhances data access efficiency. By adding KV functionality to the driver controller, it allows direct response to hard drive access commands, thereby scheduling the RAID controller. This provides efficient small data read / write capabilities, reduces system overhead and write amplification, and improves data processing efficiency and response speed. It is suitable for scenarios sensitive to both performance and reliability, such as databases, log applications, distributed caching, and high-speed edge computing nodes. By setting a preset storage threshold, the data content itself or its corresponding logical address is stored in a hash table based on the data size. Since the hash table has a fixed storage space, it avoids situations where the data is too large to store or too small, resulting in wasted space. Because the internal storage space of the drive controller is limited, the HMB (Hash Table Memory) function is used to meet the requirement of storing the hash table.
[0070] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method.
[0071] Embodiments of this application also provide a data storage device for executing the data storage method provided in the above embodiments.
[0072] like Figure 6 The diagram shown is a structural schematic of a data storage device provided in an embodiment of this application. The data storage device 60 includes: a first acquisition module 601, a first determination module 602, a second determination module 603, a sending module 604, a writing module 605, and a reading module 606.
[0073] The system comprises the following modules: a first acquisition module for acquiring a hard disk access command, wherein the hard disk access command includes the data to be accessed and the corresponding database number; a first determination module for determining a target drive controller among multiple drive controllers based on the database number; a second determination module for determining a corresponding target hash table among multiple hash tables of the target drive controller based on the database number; a sending module for sending the data to be accessed to the storage controller when the hard disk access command is a data write command, so that the storage controller writes the data to be accessed as storage data to the hard disk; a writing module for writing the storage data to the corresponding target hash table in response to a write success command sent by the storage controller; and a reading module for reading the corresponding storage data from the target hash table based on the query information to be accessed when the hard disk access command is a data read command, wherein the data to be accessed includes the query information to be accessed and the data content when the hard disk access command is a data write command, and the data to be accessed includes the query information to be accessed when the hard disk access command is a data read command.
[0074] For a description of the features in the embodiment corresponding to the data storage device, please refer to the relevant description in the embodiment corresponding to the data storage method, which will not be repeated here.
[0075] Embodiments of this application also provide an electronic device, such as... Figure 7 The diagram shown is a schematic diagram of the structure of an electronic device provided in an embodiment of this application, including a processor 10 and a memory 20. The memory 20 stores a computer program, and the processor 10 is configured to run the computer program to execute the steps in any of the above-described data storage method embodiments.
[0076] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above-described data storage method embodiments when it is run.
[0077] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.
[0078] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above-described data storage method embodiments.
[0079] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in any of the above-described data storage method embodiments.
[0080] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0081] The data storage method, apparatus, electronic device, and storage medium provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are only intended to help understand the method and core ideas of this application. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of the claims of this application.
Claims
1. A data storage method, characterized in that, The method includes: Obtain a hard disk access command; wherein the hard disk access command includes the data to be accessed and the corresponding database number; Based on the database number, the target drive controller is determined among multiple drive controllers; Based on the database number, determine the corresponding target hash table from among the multiple hash tables of the target drive controller; When the hard disk access command is a data write command, the data to be accessed is sent to the storage controller so that the storage controller writes the data to be accessed as storage data to the hard disk; In response to a write success command sent by the storage controller, the stored data is written to the corresponding target hash table; When the hard disk access command is a data read command, the corresponding stored data is read from the target hash table according to the query information to be accessed; Wherein, when the hard disk access command is a data write command, the data to be accessed includes query information to be accessed and data content; when the hard disk access command is a data read command, the data to be accessed includes query information to be accessed.
2. The data storage method according to claim 1, characterized in that, The step of writing the stored data to the corresponding target hash table in response to a write success command sent by the storage controller includes: In response to a write success command sent by the storage controller, determine whether the data content is greater than a preset storage threshold; If the data content is not greater than the preset storage threshold, the data content is written to the corresponding target hash table.
3. The data storage method according to claim 2, characterized in that, The method further includes: If the data content is greater than the preset storage threshold, obtain the logical address of the data content on the hard disk; Write the logical address and the query information to be accessed into the corresponding target hash table.
4. The data storage method according to claim 3, characterized in that, The method further includes: When the hard disk access command is a data read command, the corresponding logical address is read from the target hash table according to the query information to be accessed; The logical address is sent to the storage controller so that the storage controller can retrieve the storage data from the hard disk based on the logical address.
5. The data storage method according to claim 1, characterized in that, The method further includes: Get the database creation command; The size of the hash table is determined based on the length of the query information to be accessed represented by the database creation command, the preset storage threshold of the data content, the pointer size, and the number of records in the hash table. Multiple hash tables are created in each of the driver controllers according to the size of the hash table.
6. The data storage method according to claim 5, characterized in that, The step of determining the size of the hash table based on the length of the query information to be accessed, the preset storage threshold of the data content, the pointer size, and the number of records in the hash table, as represented by the database creation command, includes: The size of the hash table is determined based on the following formula: in, Indicates the size of the hash table. Indicates the length of the query information to be accessed. This represents the preset storage threshold for the data content. Indicates pointer size, This indicates the number of records in the hash table.
7. The data storage method according to claim 1, characterized in that, The method further includes: When the hard disk access command is a data deletion command, the status value of the corresponding record in the target hash table is set to invalid; wherein, the record includes query information to be accessed and data content, and the query information to be accessed includes a status value; The query information to be accessed is sent to the storage controller, so that the storage controller deletes the stored data from the hard disk; In response to a successful deletion command sent by the storage controller, the corresponding record is deleted from the target hash table.
8. A data storage device, characterized in that, The device includes: The first acquisition module is used to acquire a hard disk access command; wherein, the hard disk access command includes the data to be accessed and the corresponding database number; The first determining module is used to determine the target drive controller among multiple drive controllers based on the database number; The second determining module is used to determine the corresponding target hash table from multiple hash tables of the target drive controller based on the database number; The sending module is used to send the data to be accessed to the storage controller when the hard disk access command is a data write command, so that the storage controller writes the data to be accessed as storage data to the hard disk; The write module is used to write the stored data to the corresponding target hash table in response to a write success command sent by the storage controller; The read module is used to read the corresponding stored data from the target hash table according to the query information to be accessed when the hard disk access command is a data read command; Wherein, when the hard disk access command is a data write command, the data to be accessed includes query information to be accessed and data content; when the hard disk access command is a data read command, the data to be accessed includes query information to be accessed.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the data storage method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of the data storage method as described in any one of claims 1 to 7.