Data storage method and device, computer device and storage medium

By splitting large file data into data blocks and using hash operations and memory usage to determine the storage location, the problem of insufficient client computing power is solved, and secure and reliable data storage and retrieval are achieved.

CN117573036BActive Publication Date: 2026-11-06INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311595016.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-27
Publication Date
2026-11-06
Estimated Expiration
2043-11-27

AI Technical Summary

Technical Problem

The client's computing power is insufficient to meet the storage requirements of large file data, resulting in the risk of data corruption when storing large files.

Method used

The data to be stored is split into multiple data blocks, and adjacent data blocks are determined according to their sequence number. The storage location is determined by using the hash operation message authentication code and the memory usage of the storage file. The storage and location of data blocks are realized by supplementing storage information.

Benefits of technology

It reduces the demand for client-side computing power, prevents data loss, ensures the security and reliability of data storage, and improves the smoothness of data retrieval.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117573036B_ABST
    Figure CN117573036B_ABST
Patent Text Reader

Abstract

The application relates to a data storage method and device, computer equipment and a storage medium, and relates to the technical field of artificial intelligence. The method comprises the following steps: splitting to-be-stored data into at least one to-be-stored data block, sorting the to-be-stored data blocks according to the positions of the to-be-stored data blocks in the to-be-stored data before the to-be-stored data blocks are split, obtaining the arrangement serial numbers corresponding to the to-be-stored data blocks, further determining adjacent data blocks adjacent to the to-be-stored data blocks, determining the storage positions of the to-be-stored data blocks from each candidate storage file, determining the storage positions of the adjacent data blocks according to the storage positions of the to-be-stored data blocks, and storing the storage positions of the to-be-stored data blocks and the adjacent data blocks in the storage positions of the to-be-stored data blocks. The application avoids the problem of large file data damage during storage, and realizes safe and efficient storage of large file data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, and in particular to a data storage method, apparatus, computer equipment, and storage medium. Background Technology

[0002] With the development of computer and network communication technologies, clients (such as mobile phones and personal PCs) have begun to have a need to process large file data (i.e., data that occupies a large amount of space). The data processing process on the client involves the storage operation of large file data.

[0003] In existing technologies, large file data occupies a large amount of space, thus requiring high computing power from storage devices. However, when a client needs to perform storage operations on large file data, the client's computing power is insufficient to meet the requirements for storing large file data, leading to the risk of large file data corruption when the client stores large file data. Summary of the Invention

[0004] Therefore, it is necessary to provide a data storage method, apparatus, computer equipment, and computer-readable storage medium to address the aforementioned technical problems.

[0005] Firstly, this application provides a data storage method. The method includes:

[0006] The data to be stored is split into at least one data block, and each data block is sorted according to its position in the data to be stored before splitting, so as to obtain the sorting number corresponding to each data block.

[0007] Based on the sequence number corresponding to each data block to be stored, determine the adjacent data blocks that are adjacent to each data block to be stored;

[0008] From each candidate storage file, determine the storage location of each data block to be stored, and based on the storage location of each data block to be stored, determine the storage location of each adjacent data block; wherein, the storage location includes the candidate storage file and the space number of the block space in the candidate storage file used to store the data block;

[0009] The storage locations of adjacent data blocks are used as supplementary storage information for each data block to be stored, and each data block to be stored and its supplementary storage information are stored in the storage location of each data block to be stored.

[0010] In one embodiment, each data block to be stored includes a first data block and a second data block, wherein the first data block is the data block whose sequence number is first in each data block to be stored, and the second data block is the data block other than the first data block in each data block to be stored.

[0011] Accordingly, from each candidate storage file, the storage location of each data block to be stored is determined, including:

[0012] Perform a hash operation on the user key corresponding to the data to be stored and the data name of the data to be stored to obtain the hash operation message authentication code of the data to be stored.

[0013] The storage location of the first data block is determined based on the hash operation message authentication code;

[0014] The storage location of the second data block is determined based on the memory usage of each candidate storage file.

[0015] In one embodiment, determining the storage location of the first data block based on the hash operation message authentication code includes:

[0016] Extract the target field value of the hash operation message authentication code, and perform data type conversion on the target field value to obtain the integer data corresponding to the target field value;

[0017] Based on the integer data and the total number of files in each candidate storage file, determine the first storage file used to store the first data block from among the candidate storage files;

[0018] Based on the block space usage record of the first storage file, determine the space number of the block space used to store the first data block in the first storage file.

[0019] In one embodiment, the method further includes:

[0020] Store the space number of the block space used to store the first data block in the first storage file into the preset target storage file.

[0021] In one embodiment, determining the storage location of the second data block based on the memory usage of each candidate storage file includes:

[0022] Based on the memory usage of each candidate storage file, a second storage file and a third storage file are determined from the candidate storage files to store the second data block; the second storage file is the file with the smallest memory usage among the candidate storage files, and the third storage file is the file with a memory usage that is only greater than that of the second storage file among the candidate storage files.

[0023] Based on the memory usage of the second storage file and the memory usage of the third storage file, determine the space number of the block space used to store the second data block in the second storage file, and the space number of the block space used to store the second data block in the third storage file.

[0024] In one embodiment, determining the space number of the block space used to store the second data block in the second storage file and the space number of the block space used to store the second data block in the third storage file, based on the memory usage of the second storage file and the memory usage of the third storage file, includes:

[0025] The difference between the memory usage of the third storage file and the memory usage of the second storage file is calculated to obtain the memory usage difference.

[0026] Perform a difference operation on the difference between the total number of the second data blocks and the occupied amount to obtain the first difference operation result, and use the integer part of half of the first difference operation result as the first storage amount of the second data blocks in the third storage file;

[0027] The total number of the second data blocks is calculated by subtracting the first storage amount to obtain the second difference result. The second difference result is used as the second storage amount for storing the second data blocks in the second storage file.

[0028] Based on the block space usage record and the second storage amount of the second storage file, determine the space number of the block space used to store the second data block in the second storage file;

[0029] Based on the block space usage record of the third storage file and the first storage amount, determine the space number of the block space in the third storage file used to store the second data block.

[0030] In one embodiment, determining adjacent data blocks based on the sequence number corresponding to each data block to be stored includes:

[0031] The adjacency relationship between each data block to be stored is determined based on the sequence number corresponding to each data block to be stored.

[0032] Based on the adjacency relationship between each data block to be stored, determine the adjacent data blocks that are adjacent to each data block to be stored.

[0033] Secondly, this application also provides a data storage device. The device includes:

[0034] The first determining module is used to split the data to be stored into at least one data block to be stored, and sort each data block to be stored according to its position in the data to be stored before splitting, so as to obtain the sorting number corresponding to each data block to be stored.

[0035] The second determining module is used to determine the adjacent data blocks that are adjacent to each data block to be stored based on the arrangement number corresponding to each data block to be stored.

[0036] The third determining module is used to determine the storage location of each data block to be stored from each candidate storage file, and to determine the storage location of each adjacent data block based on the storage location of each data block to be stored.

[0037] The storage module is used to use the storage location of each adjacent data block as supplementary storage information for each data block to be stored, and to store each data block to be stored and its supplementary storage information in the storage location of each data block to be stored.

[0038] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:

[0039] The data to be stored is split into at least one data block, and each data block is sorted according to its position in the data to be stored before splitting, so as to obtain the sorting number corresponding to each data block.

[0040] Based on the sequence number corresponding to each data block to be stored, determine the adjacent data blocks that are adjacent to each data block to be stored;

[0041] From each candidate storage file, determine the storage location of each data block to be stored, and based on the storage location of each data block to be stored, determine the storage location of each adjacent data block; wherein, the storage location includes the candidate storage file and the space number of the block space in the candidate storage file used to store the data block;

[0042] The storage locations of adjacent data blocks are used as supplementary storage information for each data block to be stored, and each data block to be stored and its supplementary storage information are stored in the storage location of each data block to be stored.

[0043] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:

[0044] The data to be stored is split into at least one data block, and each data block is sorted according to its position in the data to be stored before splitting, so as to obtain the sorting number corresponding to each data block.

[0045] Based on the sequence number corresponding to each data block to be stored, determine the adjacent data blocks that are adjacent to each data block to be stored;

[0046] From each candidate storage file, determine the storage location of each data block to be stored, and based on the storage location of each data block to be stored, determine the storage location of each adjacent data block; wherein, the storage location includes the candidate storage file and the space number of the block space in the candidate storage file used to store the data block;

[0047] The storage locations of adjacent data blocks are used as supplementary storage information for each data block to be stored, and each data block to be stored and its supplementary storage information are stored in the storage location of each data block to be stored.

[0048] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps:

[0049] The data to be stored is split into at least one data block, and each data block is sorted according to its position in the data to be stored before splitting, so as to obtain the sorting number corresponding to each data block.

[0050] Based on the sequence number corresponding to each data block to be stored, determine the adjacent data blocks that are adjacent to each data block to be stored;

[0051] From each candidate storage file, determine the storage location of each data block to be stored, and based on the storage location of each data block to be stored, determine the storage location of each adjacent data block; wherein, the storage location includes the candidate storage file and the space number of the block space in the candidate storage file used to store the data block;

[0052] The storage locations of adjacent data blocks are used as supplementary storage information for each data block to be stored, and each data block to be stored and its supplementary storage information are stored in the storage location of each data block to be stored.

[0053] The aforementioned data storage method, apparatus, computer equipment, and storage medium divide the data to be stored into at least one data block to be stored, and determine the adjacent data blocks corresponding to each data block to be stored; determine the storage location of each data block to be stored and each adjacent data block; use the storage location of each adjacent data block as supplementary storage information for each data block to be stored, and store each data block to be stored and its supplementary storage information in the storage location of each data block to be stored. In the aforementioned process, this application does not directly store the data to be stored when storing the data to be stored. Instead, it splits the data to be stored into at least one data block and stores each data block and its supplementary storage information together in the storage location of each data block. This reduces the computing power requirement on the client when storing the data to be stored, ensures the smooth storage of the data to be stored, and prevents data loss during storage. Furthermore, by storing the supplementary storage information of each data block together with the data block in the storage location of each data block, it ensures that when a user reads the data to be stored, the storage location of the next data block can be successfully determined based on the supplementary storage information of the current data block. This achieves the goal of ensuring the smooth reading of the data to be stored while improving data security. Attached Figure Description

[0054] Figure 1 An application environment diagram of a data storage method provided in an embodiment of this application;

[0055] Figure 2 A flowchart illustrating a data storage method provided in an embodiment of this application;

[0056] Figure 3 A flowchart illustrating the steps for determining the storage location of each data block to be stored, provided in an embodiment of this application;

[0057] Figure 4 A flowchart illustrating the steps for determining the storage location of a first data block, provided in an embodiment of this application;

[0058] Figure 5 A flowchart illustrating the steps for determining the storage location of a second data block, provided in an embodiment of this application;

[0059] Figure 6 A flowchart illustrating the steps for determining adjacent data blocks is provided in an embodiment of this application.

[0060] Figure 7 A flowchart illustrating another data storage method provided in this application embodiment;

[0061] Figure 8 A structural block diagram of a first type of data storage device provided in the embodiments of this application;

[0062] Figure 9 This is a structural block diagram of a second type of data storage device provided in an embodiment of this application;

[0063] Figure 10 A structural block diagram of a third data storage device provided in the embodiments of this application;

[0064] Figure 11 A structural block diagram of the fourth data storage device provided in the embodiments of this application;

[0065] Figure 12 A structural block diagram of the fifth data storage device provided in the embodiments of this application;

[0066] Figure 13 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0067] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0068] It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit this application. In the description of this application, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in a suitable manner in any one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.

[0069] Based on the above, the data storage method provided in this application embodiment can be applied to, for example... Figure 1 In the application environment shown, in one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows. Figure 1As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and data blocks. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The data blocks store data acquired by a data storage method. The network interface communicates with external terminals via a network connection. When the computer program is executed by the processor, it implements a data storage method.

[0070] This application discloses a data storage method, apparatus, computer device, and storage medium thereof. The computer device of this application divides the data to be stored into at least one data block to be stored and determines the adjacent data blocks corresponding to each data block to be stored; determines the storage location of each data block to be stored and each adjacent data block; uses the storage location of each adjacent data block as supplementary storage information for each data block to be stored, and stores each data block to be stored and its supplementary storage information in the storage location of each data block to be stored.

[0071] In one exemplary embodiment, such as Figure 2 As shown, Figure 2 This application provides a flowchart of a data storage method according to an embodiment of the present application, which provides a data storage method for application to... Figure 1 The following steps are used as an example of computer equipment, including steps 201 to 204. Wherein:

[0072] Step 201: Split the data to be stored into at least one data block to be stored, and sort each data block to be stored according to its position in the data to be stored before splitting, so as to obtain the sorting number corresponding to each data block to be stored.

[0073] Among them, the data to be stored refers to the data that needs to be stored. The data to be stored can be AI (Artificial Intelligence) update data, short video data, email attachment data, a document, etc.

[0074] It should be noted that when it is necessary to split the data to be stored, the space occupied by the split data blocks can be adjusted according to the size of the space occupied by the data to be stored, thereby reducing the computing power requirement when storing the data blocks. Therefore, before splitting the data to be stored into at least one data block, the space occupied by the data blocks to be stored must be determined first. Then, based on the space occupied by each data block, the data to be stored is split into at least one data block.

[0075] To further explain, in order to prevent the number of at least one data block to be stored from being too large after splitting, thereby increasing the computing power requirement when storing the data block, it is necessary to control the number of data blocks to be stored after splitting the data to be stored. That is: if the space occupied by the data to be stored is large, then the data to be stored is split into data blocks with large space occupied; if the space occupied by the data to be stored is small, then the data to be stored is split into data blocks with small space occupied.

[0076] As an example, if there are two pieces of data to be stored, both of which are AI update data, and data A has a storage space requirement of 10GB while data B has a storage space requirement of 100MB, then, because data A has a larger storage space requirement, it can be split into larger storage blocks (e.g., 500MB). Similarly, because data B has a smaller storage space requirement, data A can be split into smaller storage blocks (e.g., 5MB).

[0077] Step 202: Determine the adjacent data blocks that are adjacent to each data block to be stored according to the sequence number corresponding to each data block to be stored.

[0078] Here, the sequence number refers to the position number of each data block to be stored in the data to be stored; the difference between the sequence number of the adjacent data block and the sequence number of the data block to be stored is 1, which can be understood as the sequence number of the adjacent data block being equal to the sequence number of the data block to be stored plus one, or the sequence number of the adjacent data block being equal to the sequence number of the data block to be stored minus one.

[0079] In one embodiment of this application, if the arrangement number of adjacent data blocks is predetermined to be equal to the arrangement number of the data block to be stored plus one, and it is determined that the data to be stored is divided into 10 data blocks to be stored, wherein the arrangement number of the data block to be stored C is 1, and since the arrangement number of adjacent data blocks is equal to the arrangement number of the data block to be stored plus one, the adjacent data block to the data block to be stored C is the data block to be stored with the arrangement number 2.

[0080] In one embodiment of this application, if the arrangement number of adjacent data blocks is predetermined to be equal to the arrangement number of the data block to be stored minus one, and it is determined that the data to be stored is divided into 10 data blocks to be stored, wherein the arrangement number of the data block to be stored D is 10, and since the arrangement number of adjacent data blocks is equal to the arrangement number of the data block to be stored minus one, the adjacent data block to the data block to be stored D is the data block to be stored with the arrangement number 9.

[0081] Step 203: Determine the storage location of each data block to be stored from each candidate storage file, and determine the storage location of each adjacent data block based on the storage location of each data block to be stored.

[0082] The storage location includes candidate storage files and space numbers of block spaces in the candidate storage files used to store data blocks. Furthermore, a candidate storage file refers to a file in the client that can be used to store data to be stored, and a block space refers to the space in the candidate storage file used to store data blocks to be stored. The candidate storage file may include at least one block space.

[0083] In one embodiment of this application, when it is necessary to determine the storage location of each data block to be stored, the data blocks to be stored can be evenly distributed to each candidate storage file according to the number of data blocks to be stored. Therefore, based on the distribution result of each data block to be stored, the candidate storage text corresponding to the data block to be stored and the space number of the block space of the data block to be stored in the candidate storage file are determined.

[0084] In another embodiment of this application, when it is necessary to determine the storage location of each data block to be stored, the number of data blocks to be stored allocated to each candidate storage file is determined according to the space occupancy of the candidate storage file. Further, if the space occupancy of a candidate storage file is large, the number of data blocks to be stored allocated to that candidate storage file is small; if the space occupancy of a candidate storage file is small, the number of data blocks to be stored allocated to that candidate storage file is large. Thus, the corresponding number of data blocks to be stored are allocated to each candidate storage file. Therefore, based on the allocation result of each data block to be stored, the candidate storage text corresponding to the data block to be stored and the space number of the block space of the data block to be stored in the candidate storage file are determined.

[0085] In another embodiment of this application, when it is necessary to determine the storage location of each data block to be stored, the candidate storage file with the smallest space occupation and the second smallest space occupation are selected from the candidate storage files according to the space occupation of the candidate storage files. The second smallest candidate storage file refers to the candidate storage file whose space occupation is only greater than that of the smallest candidate storage file. Then, the data blocks to be stored are allocated to the selected smallest and second smallest candidate storage files. Therefore, based on the allocation result of each data block to be stored, the candidate storage text corresponding to the data block to be stored and the space number of the block space of the data block to be stored in the candidate storage file are determined.

[0086] To further explain, since adjacent data blocks refer to other data blocks to be stored whose sequence number is 1 when the difference between the sequence number and the data block to be stored is 1, when it is necessary to determine the storage location of adjacent data blocks of a certain data block to be stored, the storage location of other data blocks to be stored whose sequence number is 1 when the difference between the sequence number and the data block to be stored is 1 can be determined from the storage locations of other data blocks to be stored. This storage location is the storage location of the adjacent data block.

[0087] Step 204: Use the storage location of each adjacent data block as supplementary storage information for each data block to be stored, and store each data block to be stored and its supplementary storage information in the storage location of each data block to be stored.

[0088] It should be noted that the storage location of each data block to be stored contains at least two parts: (1) each data block to be stored; (2) supplementary storage information of each data block to be stored (i.e., the storage location of each adjacent data block). Through this storage method, a connection is established between each data block to be stored, so that the storage location of the adjacent data block (i.e., the second data block to be stored) corresponding to the first data block to be stored can be obtained through the supplementary storage information contained in the storage location of the first data block to be stored; then, the storage location of the adjacent data block (i.e., the third data block to be stored) corresponding to the second data block to be stored can be obtained based on the supplementary storage information contained in the storage location of the second data block to be stored, and so on, until each data block to be stored is determined.

[0089] In one embodiment of this application, if the data to be stored is divided into data block 4, data block 5, and data block 6, wherein the adjacent data block of data block 4 is data block 5, the adjacent data block of data block 5 is data block 6, the storage location of data block 4 is m4, the storage location of data block 5 is m5, and the storage location of data block 6 is m6, then the content stored in storage location m4 of data block 4 is: {data block 4, m5}, and the content stored in storage location m5 of data block 5 is: {data block 5, m6}.

[0090] In one embodiment of this application, when it is necessary to store each data block to be stored and the supplementary storage information of each data block to be stored into the storage location of each data block to be stored, the method further includes the following: determining the data security requirement level, and storing each data block to be stored and the supplementary storage information of each data block to be stored into the storage location of each data block to be stored according to the data security requirement level.

[0091] The data security requirements can be divided into a first security level and a second security level. The first security level has lower requirements for the security of the data to be stored, while the second security level has higher requirements for the security of the data to be stored.

[0092] Specifically, if the data security requirement level is the first security level, then the data blocks to be stored are not encrypted, and the data blocks to be stored and their supplementary storage information are stored in the storage location of each data block; if the data security requirement level is the second security level, then the data blocks to be stored are encrypted, and then the encrypted data blocks to be stored and their supplementary storage information are stored in the storage location of each data block.

[0093] The encryption methods can include, but are not limited to, symmetric cryptography and asymmetric cryptography. Furthermore, there are many methods for encrypting each block of data to be stored; therefore, no specific method is limited here.

[0094] The above data storage method involves splitting the data to be stored into at least one data block and determining the adjacent data blocks corresponding to each data block; determining the storage location of each data block and each adjacent data block; using the storage location of each adjacent data block as supplementary storage information for each data block; and storing each data block and its supplementary storage information in the storage location of each data block. In the aforementioned process, this application does not directly store the data to be stored when storing the data to be stored. Instead, it splits the data to be stored into at least one data block and stores each data block and its supplementary storage information together in the storage location of each data block. This reduces the computing power requirement on the client when storing the data to be stored, ensures the smooth storage of the data to be stored, and prevents data loss during storage. Furthermore, by storing the supplementary storage information of each data block together with the data block in the storage location of each data block, it ensures that when a user reads the data to be stored, the storage location of the next data block can be successfully determined based on the supplementary storage information of the current data block. This achieves the goal of ensuring the smooth reading of the data to be stored while improving data security.

[0095] In one embodiment, when a client needs to store large file data, the client's computing power is insufficient to meet the requirements for storing large file data, leading to a risk of large file data corruption during storage. To solve the above technical problem, the computer device of this application can, as follows: Figure 3The method shown determines the storage location of each data block to be stored from each candidate storage file. Each data block to be stored includes a first data block and a second data block. Further, the first data block is the data block whose sequence number is the first in each data block to be stored, and the second data block is the data block excluding the first data block. This includes steps 301 to 303. Wherein:

[0096] Step 301: Perform a hash operation on the user key corresponding to the data to be stored and the data name of the data to be stored to obtain the hash operation message authentication code of the data to be stored.

[0097] The data name refers to the name of the data to be stored, which is included in the data summary information.

[0098] It should be noted that when it is necessary to obtain the hash-based message authentication code of the data to be stored, the following can be included: obtaining the user key and the data name of the data to be stored, performing a hash operation on the user key and the data name of the data to be stored, and obtaining the hash operation result, which is the hash-based message authentication code (HMAC) of the data to be stored.

[0099] Specifically, the user key corresponding to the data to be stored is obtained from the server, the data name of the data to be stored is obtained from the digest information of the data to be stored, the user key corresponding to the data to be stored and the data name of the data to be stored are input into the hash function, and after hash operation, the output result is obtained. This output result is the hash operation message authentication code of the data to be stored.

[0100] There are many types of hash functions, such as MD5 (Message Digest Algorithm 5), SHA-1 (Secure Hash Algorithm 1), SHA-256 (Secure Hash Algorithm 256), and SHA-512 (Secure Hash Algorithm 512). No specific hash function will be specified here.

[0101] For example, the user key corresponding to the data to be stored is obtained from the server as key, and the data name of the data to be stored is obtained from the digest information of the data to be stored as name. The user key key and the data name name are input into the hash function, and the output result is the hash operation message authentication code of the data to be stored.

[0102] Step 302: Determine the storage location of the first data block based on the hash operation message authentication code.

[0103] The first data block is the data block whose sequence number is the first one among all the data blocks to be stored.

[0104] It should be noted that, since the storage location includes candidate storage files and the space numbers of the block spaces within the candidate storage files used to store data blocks, determining the storage location of the first data block may specifically include the following: converting the data type of the hash operation message authentication code to obtain the integer data corresponding to the hash operation message authentication code; determining the first storage file for storing the first data block from each candidate screening storage file based on the integer data; furthermore, to prevent multiple data blocks from being stored in the same block space, it is necessary to determine the space numbers of the block spaces in the first storage file that do not store data blocks based on the block space usage records of the first storage file; and then, selecting the space number of the block space used to store the first data block from the space numbers of the block spaces in the first storage file that do not store data blocks.

[0105] Step 303: Determine the storage location of the second data block based on the memory usage of each candidate storage file.

[0106] Here, memory usage represents the amount of memory occupied by the existing data in each candidate file, and the second data block is the data block other than the first data block in each data block to be stored.

[0107] In one embodiment of this application, when it is necessary to determine the storage location of the second data block, the following may be included: the second data block may be evenly distributed to each candidate storage file according to the number of the second data block. Therefore, the candidate storage file corresponding to the second data block after distribution, and the space number of the second data block in the block space corresponding to the candidate storage file are the storage locations corresponding to the second data block.

[0108] In another embodiment of this application, when it is necessary to determine the storage location of the second data block, the following may be included: based on the memory usage of each candidate storage file, select N candidate storage files with the smallest memory usage (where N is a non-zero positive integer, for example, N can be 2) from each candidate storage file; then, according to the pre-set second data block allocation rules, store the second data block into the N candidate storage files respectively. Therefore, the candidate storage file corresponding to the second data block after allocation, and the space number of the second data block in the block space corresponding to the candidate storage file are the storage locations corresponding to the second data block.

[0109] In the above data storage method, by determining the first data block and the second data block in the data block to be stored, the storage location of each data block to be stored can be successfully determined. Furthermore, by determining the storage location of the first data block through a hash operation message authentication code, the randomness of the storage location of the first data block is guaranteed, thereby increasing the storage security of the data to be stored.

[0110] In an exemplary embodiment, when it is necessary to determine the storage location of the first data block based on the hash operation message authentication code, it can be done as follows: Figure 4 The method shown includes steps 401 to 403.

[0111] in:

[0112] Step 401: Extract the target field value of the hash operation message authentication code, and perform data type conversion on the target field value to obtain the integer data corresponding to the target field value.

[0113] The target field value refers to a portion of the field values ​​in the hash operation message authentication code. Furthermore, the length and position of the target field value can be preset based on the staff's historical experience, and there is no limitation on the length and position of the target field here.

[0114] It should be noted that when it is necessary to obtain the integer data corresponding to the target field value, the specific steps may include the following: extracting the target field value from the hash operation message authentication code, converting the target field value to an integer data type using a type conversion function, and the result after type conversion is the integer data corresponding to the target field value.

[0115] Among them, the type conversion function can be used to convert the target field value in the hash operation message authentication code to an integer, thereby determining the integer data of the target field value.

[0116] In one embodiment of this application, if the target field value is preset to be the last three digits of the hash operation message authentication code, and the hash operation message authentication code is gshsnbcvwd5, then the target field value is wd5. The wd5 is input into the type conversion function to obtain the output result of the type conversion function, which is the integer data corresponding to the target field value.

[0117] Step 402: Based on the integer data and the total number of files in each candidate storage file, determine the first storage file to store the first data block from each candidate storage file.

[0118] It should be noted that when it is necessary to determine the first storage file for storing the first data block from among the candidate storage files, this can be achieved by performing a modulo operation on the integer data and the total number of files in each candidate storage file. Specifically, performing a modulo operation on the integer data and the total number of files in each candidate storage file may include the following: performing a division operation on the integer data and the total number of files in each candidate storage file, taking the integer part of the result as the first operation result, multiplying the first operation result by the total number of storage files to obtain the second operation result, and subtracting the integer data from the second operation result to obtain the third operation result; and selecting the candidate storage file whose file number is the same as the third operation result as the first storage file for storing the first data block according to the file number corresponding to each candidate storage file.

[0119] In one embodiment of this application, the integer data is 423, and the total number of candidate storage files is 200. The integer data and the total number of candidate storage files are divided, and the integer part of the result is 2, which is the first result. The first result is multiplied by the total number of storage files, i.e., 2*200 equals 400, which is the second result. The integer data is subtracted from the second result to obtain the third result 23. Therefore, the candidate storage file with file number 23 is the first storage file storing the first data block.

[0120] Step 403: Determine the space number of the block space used to store the first data block in the first storage file based on the block space usage record of the first storage file.

[0121] Here, block space refers to the location in the first storage file used to store the data blocks to be stored.

[0122] The block space usage record indicates the usage status of the block space, recording the usage status of each data block. Further, the usage status can include: data blocks already stored, deleted and reassignable, and the end of the allocated block space. For example, 1 indicates that the block space has stored data blocks, 0 indicates that the block data in the block space has been deleted and can be reassigned, and E indicates the end of the allocated block space. Furthermore, if a block space exists with a usage status of "deleted and reassignable," that block space is used to store the data blocks to be stored; if no block space exists with a usage status of "deleted and reassignable," a new block space is added to the end of the block space contained in each candidate storage file, and this new block space is used to store the data blocks to be stored.

[0123] It should be noted that when it is necessary to determine the space number of the block space used to store the first data block in the first storage file, the following may be included: according to the block space usage record of the first storage file, check whether there is a block space with a usage status of "deleted and available for reallocation". If it exists, the block space is used to store each data block to be stored; if it does not exist, a new block space is added to the end of the block space in each candidate storage file, and the new block space is used to store each data block to be stored; furthermore, the space number of the block space used to store the first data block in the first storage file is the space number of the new block space.

[0124] In one embodiment of this application, the block space usage record of the first storage file is [1,1,1,1,E]. Since 1 indicates that the block space has stored data, there is no block space in the first storage file whose usage status is "deleted and can be reallocated". Therefore, a new block space P needs to be added to the end of the block space in the first storage file. The new block space P is the block space for storing the first data block, and the space number corresponding to the new block space P is the space number of the block space used to store the first data block in the first storage file.

[0125] In another embodiment of this application, the block space usage record of the first storage file is [1,0,1,1,E]. Since 0 indicates that the block data in the block space has been deleted and can be reallocated, there is a block space in the first storage file with the usage status of "deleted and can be reallocated". This block space can be used as the block space for storing the first data block. The space number corresponding to this block space is the space number of the block space used to store the first data block in the first storage file.

[0126] To further explain, after determining the space number of the block space used to store the first data block in the first storage file, the file identifier of the first storage file and the space number of the block space used to store the first data block in the first storage file can be stored in a preset target storage file to achieve encrypted storage of the first database storage location.

[0127] The above data storage method uses a hash operation message authentication code to determine the first storage file of the first data block from each candidate storage file, as well as the space number of the block space in the first storage file used to store the first data block, thereby realizing the storage operation of the first data block and improving the security of the first data block storage.

[0128] In an exemplary embodiment, when it is necessary to determine the storage location of the second data block based on the memory usage of each candidate storage file, it can be done as follows: Figure 5 The method shown includes steps 501 and 502. Wherein:

[0129] Step 501: Based on the memory usage of each candidate storage file, determine the second storage file and the third storage file used to store the second data block from each candidate storage file.

[0130] The second data block is the data block other than the first data block among the data blocks to be stored. The second storage file refers to the file with the smallest memory usage among the candidate storage files. The third storage file refers to the file whose memory usage is only greater than that of the second storage file among the candidate storage files.

[0131] It should be noted that when it is necessary to determine the second and third storage files for storing the second data block from among the candidate storage files, the following can be included: sort the candidate storage files by their memory usage from smallest to largest, and the candidate storage file ranked first after sorting is the second storage file, and the candidate storage file ranked second after sorting is the third storage file.

[0132] For example, if candidate file 1 has a memory footprint of 20MB, candidate file 2 has a memory footprint of 30MB, and candidate file 3 has a memory footprint of 5MB, then sorting the candidate files by their memory footprint from smallest to largest will result in: candidate file 3 < candidate file 1 < candidate file 2. Therefore, candidate file 3 is determined to be the second file and candidate file 1 is determined to be the third file.

[0133] Step 502: Based on the memory usage of the second storage file and the memory usage of the third storage file, determine the space number of the block space used to store the second data block in the second storage file and the space number of the block space used to store the second data block in the third storage file.

[0134] Among them, memory usage refers to the amount of memory occupied by the data blocks already stored in the storage file.

[0135] It should be noted that when it is necessary to determine the space number of the block space used to store the second data block in the second storage file, and the space number of the block space used to store the second data block in the third storage file, the following may be included: performing a difference and rounding operation on the memory usage of the third storage file and the memory usage of the second storage file; determining the first storage amount and the second storage amount of the second data block in the third storage file based on the operation result; determining the space number of the block space used to store the second data block in the second storage file based on the block space usage record and the second storage amount in the second storage file; and determining the space number of the block space used to store the second data block in the third storage file based on the block space usage record and the first storage amount in the third storage file.

[0136] To further explain, when it is necessary to determine the first storage amount of the second data block stored in the third storage file and the second storage amount of the second data block stored in the second storage file, the following may be included: performing a difference operation on the memory usage of the third storage file and the memory usage of the second storage file to obtain the usage difference; performing a difference operation on the total number of the second data blocks and the usage difference to obtain a first difference operation result, and taking the integer part of half of the first difference operation result as the first storage amount of the second data block stored in the third storage file; performing a difference operation on the total number of the second data blocks and the first storage amount to obtain a second difference operation result, and taking the second difference operation result as the second storage amount of the second data block stored in the second storage file.

[0137] As an example, the data to be stored is split into T blocks, the second storage file is Y, the third storage file is Z, and the difference in storage space is n. Then, the first storage space Tz for storing the second data block in the third storage file is: pin((T-1-n) / 2), where pin() is used to take the integer part of the data in parentheses. The second storage space Ty for storing the second data block in the second storage file is: T-Tz-1.

[0138] The above data storage method compares and selects the second and third storage files by considering the memory usage of each candidate storage file. This ensures a more balanced memory usage among the candidate storage files after storing the first and second data blocks, thus improving storage access efficiency. This enables the storage of the second data block.

[0139] In an exemplary embodiment, when it is necessary to determine the adjacent data blocks adjacent to each data block to be stored based on the sequence number corresponding to each data block to be stored, this can be achieved by, as follows: Figure 6 The method shown includes steps 601 and 602. Wherein:

[0140] Step 601: Determine the adjacency relationship between each data block to be stored based on the sequence number corresponding to each data block to be stored.

[0141] The adjacency relationship refers to the relationship between two data blocks to be stored whose permutation numbers are increased or decreased by 1.

[0142] In one embodiment of this application, the data to be stored is divided into data block 7, data block 8, and data block 9. The data block 7 is arranged in sequence 11, the data block 8 is arranged in sequence 12, and the data block 9 is arranged in sequence 13. Therefore, data block 7 and data block 8 are adjacent to each other, data block 8 is adjacent to both data block 7 and data block 9, and data block 9 is adjacent to data block 8.

[0143] Step 602: Determine the adjacent data blocks that are adjacent to each data block to be stored based on the adjacency relationship between the data blocks to be stored.

[0144] It should be noted that if the adjacency relationship is between two data blocks to be stored whose permutation number is 1 greater than the data block to be stored, then the permutation number of the adjacent data block is equal to the permutation number of the data block to be stored plus 1; if the adjacency relationship is between two data blocks to be stored whose permutation number is 1 less than the data block to be stored, then the permutation number of the adjacent data block is equal to the permutation number of the data block to be stored minus 1.

[0145] In one embodiment of this application, if the adjacent relationship is the relationship between two data blocks to be stored whose permutation number is 1 plus the number of the data block to be stored, and it is determined that the data to be stored is divided into 5 data blocks to be stored, wherein the permutation number of the data block to be stored E is 1, since the permutation number of the adjacent data block is equal to the permutation number of the data block to be stored plus one, the data block adjacent to the data block to be stored E is the data block to be stored with the permutation number 2.

[0146] In one embodiment of this application, if the adjacent relationship is the relationship between two data blocks to be stored whose permutation number is 1 minus the data block to be stored, and it is determined that the data to be stored is divided into 5 data blocks to be stored, wherein the permutation number corresponding to the data block to be stored F is 5, since the permutation number of the adjacent data block is equal to the permutation number of the data block to be stored minus one, the data block adjacent to the data block to be stored F is the data block to be stored with permutation number 4.

[0147] The above data storage method determines the adjacent data blocks that are adjacent to each data block to be stored by the adjacency relationship between each data block to be stored, so that each data block to be stored can be stored in the future based on the adjacency relationship between each data block to be stored.

[0148] In an exemplary embodiment, when it is necessary to store each data block to be stored, the specific process may include the following steps: Figure 7 As shown:

[0149] Step 701: Split the data to be stored into at least one data block to be stored, and sort each data block to be stored according to its position in the data to be stored before splitting, so as to obtain the sorting number corresponding to each data block to be stored.

[0150] Step 702: Determine the adjacency relationship between each data block to be stored based on the sequence number corresponding to each data block to be stored.

[0151] Step 703: Determine the adjacent data blocks that are adjacent to each data block to be stored based on the adjacency relationship between the data blocks to be stored.

[0152] Step 704: Perform a hash operation on the user key corresponding to the data to be stored and the data name of the data to be stored to obtain the hash operation message authentication code of the data to be stored.

[0153] Step 705: Extract the target field value of the hash operation message authentication code, and perform data type conversion on the target field value to obtain the integer data corresponding to the target field value.

[0154] Step 706: Based on the integer data and the total number of files in each candidate storage file, determine the first storage file to store the first data block from each candidate storage file.

[0155] Step 707: Based on the block space usage record of the first storage file, determine the space number of the block space used to store the first data block in the first storage file, and store the space number of the block space used to store the first data block in the first storage file into a preset target storage file.

[0156] Step 708: Based on the memory usage of each candidate storage file, determine the second storage file and the third storage file used to store the second data block from each candidate storage file.

[0157] Step 709: Perform a difference calculation on the memory usage of the third storage file and the memory usage of the second storage file to obtain the memory usage difference.

[0158] Step 710: Perform a difference operation on the difference between the total number of the second data blocks and the occupied amount to obtain the first difference operation result, and use the integer part of half of the first difference operation result as the first storage amount of the second data blocks in the third storage file.

[0159] Step 711: Perform a difference operation between the total number of the second data blocks and the first storage amount to obtain the second difference operation result, and use the second difference operation result as the second storage amount for storing the second data blocks in the second storage file.

[0160] Step 712: Determine the space number of the block space used to store the second data block in the second storage file based on the block space usage record and the second storage amount of the second storage file.

[0161] Step 713: Determine the space number of the block space used to store the second data block in the third storage file based on the block space usage record of the third storage file and the first storage amount.

[0162] Step 714: Use the storage location of each adjacent data block as supplementary storage information for each data block to be stored, and store each data block to be stored and its supplementary storage information in the storage location of each data block to be stored.

[0163] In one embodiment of this application, before determining the data to be stored, the following steps are also included: the client sends user authentication information to the server, the server authenticates the user authentication information, and after successful authentication, the server sends the user key back to the client; the client downloads a copy of the data to be stored from the server, parses the format of the data to be stored to obtain the digest information of the data to be stored, and stores the digest information of the data to be stored in a preset target storage file.

[0164] The user authentication information includes username, password, and other information; the data summary information to be stored includes data name, data purpose, data format, accessing user, time, and other information; the target storage file refers to the file in the client that stores configuration information, such as user configuration information, data dictionary, software configuration information, etc.

[0165] In one embodiment of this application, after storing each data block to be stored, each data block to be stored can also be read. Specifically, this may include the following: the client sends user authentication information to the server, the server authenticates the user authentication information, and after successful authentication, the server returns the user key to the client; the client reads the digest information of the data to be stored and the space number of the block space of the first data block from the target storage file; performs hash operation processing based on the user key corresponding to the data to be stored and the data name of the data to be stored to obtain the first storage file storing the first data block; based on the first storage file of the first data block and the space number of the block space of the first data block, reads the storage location of the first data block and the adjacent data blocks corresponding to the first data block, and reads each data block to be stored sequentially based on the storage location of the adjacent data blocks.

[0166] The above data storage method involves splitting the data to be stored into at least one data block and determining the adjacent data blocks corresponding to each data block; determining the storage location of each data block and each adjacent data block; using the storage location of each adjacent data block as supplementary storage information for each data block; and storing each data block and its supplementary storage information in the storage location of each data block. In the aforementioned process, this application does not directly store the data to be stored when storing the data to be stored. Instead, it splits the data to be stored into at least one data block and stores each data block and its supplementary storage information together in the storage location of each data block. This reduces the computing power requirement on the client when storing the data to be stored, ensures the smooth storage of the data to be stored, and prevents data loss during storage. Furthermore, by storing the supplementary storage information of each data block together with the data block in the storage location of each data block, it ensures that when a user reads the data to be stored, the storage location of the next data block can be successfully determined based on the supplementary storage information of the current data block. This achieves the goal of ensuring the smooth reading of the data to be stored while improving data security.

[0167] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0168] Based on the same inventive concept, this application also provides a data storage device for implementing the data storage method described above. The solution provided by this device is similar to the solution described in the above method; therefore, the specific limitations in one or more data storage device embodiments provided below can be found in the limitations of the data storage method described above, and will not be repeated here.

[0169] In one embodiment, such as Figure 8 As shown, a data storage device is provided, comprising: a first determining module 10, a second determining module 20, a third determining module 30, and a storage module 40, wherein:

[0170] The first determining module 10 is used to split the data to be stored into at least one data block to be stored, and sort each data block to be stored according to its position in the data to be stored before splitting, so as to obtain the sorting number corresponding to each data block to be stored.

[0171] The second determining module 20 is used to determine the adjacent data blocks that are adjacent to each data block to be stored according to the arrangement number corresponding to each data block to be stored.

[0172] The third determining module 30 is used to determine the storage location of each data block to be stored from each candidate storage file, and to determine the storage location of each adjacent data block based on the storage location of each data block to be stored.

[0173] The storage module 40 is used to use the storage location of each adjacent data block as supplementary storage information for each data block to be stored, and to store each data block to be stored and its supplementary storage information in the storage location of each data block to be stored.

[0174] The aforementioned data storage device divides the data to be stored into at least one data block to be stored and determines the adjacent data blocks corresponding to each data block to be stored; determines the storage location of each data block to be stored and each adjacent data block; uses the storage location of each adjacent data block as supplementary storage information for each data block to be stored, and stores each data block to be stored and its supplementary storage information in the storage location of each data block to be stored. In the aforementioned process, this application does not directly store the data to be stored when storing the data to be stored. Instead, it splits the data to be stored into at least one data block and stores each data block and its supplementary storage information together in the storage location of each data block. This reduces the computing power requirement on the client when storing the data to be stored, ensures the smooth storage of the data to be stored, and prevents data loss during storage. Furthermore, by storing the supplementary storage information of each data block together with the data block in the storage location of each data block, it ensures that when a user reads the data to be stored, the storage location of the next data block can be successfully determined based on the supplementary storage information of the current data block. This achieves the goal of ensuring the smooth reading of the data to be stored while improving data security.

[0175] In one embodiment, such as Figure 9 As shown, a data storage device is provided. The third determining module 30 in this data storage device includes: a first determining unit 31, a second determining unit 32, and a third determining unit 33, wherein:

[0176] The first determining unit 31 is used to perform a hash operation on the user key corresponding to the data to be stored and the data name of the data to be stored to obtain the hash operation message authentication code of the data to be stored.

[0177] The second determining unit 32 is used to determine the storage location of the first data block based on the hash operation message authentication code.

[0178] The third determining unit 33 is used to determine the storage location of the second data block based on the memory usage of each candidate storage file.

[0179] In one embodiment, such as Figure 10 As shown, a data storage device is provided, wherein the second determining unit 32 in the data storage device includes: a first determining subunit 321, a second determining subunit 322, and a third determining subunit 323, wherein:

[0180] The first determining subunit 321 is used to extract the target field value of the hash operation message authentication code, and to perform data type conversion on the target field value to obtain the integer data corresponding to the target field value.

[0181] The second determining subunit 322 is used to determine the first storage file for storing the first data block from among the candidate storage files based on integer data and the total number of files in each candidate storage file.

[0182] The third determining subunit 323 is used to determine the space number of the block space used to store the first data block in the first storage file according to the block space usage record of the first storage file.

[0183] In one embodiment, such as Figure 11 As shown, a data storage device is provided, wherein the third determining unit 33 of the data storage device includes: a fourth determining subunit 331 and a fifth determining subunit 332, wherein:

[0184] The fourth determining subunit 331 is used to determine the second storage file and the third storage file for storing the second data block from each candidate storage file according to the memory usage of each candidate storage file; the second storage file is the file with the smallest memory usage among the candidate storage files, and the third storage file is the file whose memory usage among the candidate storage files is only greater than that of the second storage file.

[0185] The fifth determining subunit 332 is used to determine the space number of the block space used to store the second data block in the second storage file and the space number of the block space used to store the second data block in the third storage file, based on the memory usage of the second storage file and the memory usage of the third storage file.

[0186] The fifth determining subunit 332 is specifically used to perform a difference operation on the memory usage of the third storage file and the memory usage of the second storage file to obtain a usage difference; to perform a difference operation on the total number of second data blocks and the usage difference to obtain a first difference operation result, and to use the integer part of half of the first difference operation result as the first storage amount for storing the second data blocks in the third storage file; to perform a difference operation on the total number of second data blocks and the first storage amount to obtain a second difference operation result, and to use the second difference operation result as the second storage amount for storing the second data blocks in the second storage file; to determine the space number of the block space used to store the second data blocks in the second storage file according to the block space usage record and the second storage amount of the second storage file; and to determine the space number of the block space used to store the second data blocks in the third storage file according to the block space usage record and the first storage amount of the third storage file.

[0187] In one embodiment, such as Figure 12 As shown, a data storage device is provided, wherein the second determining module 20 of the data storage device includes: a fourth determining unit 21 and a fifth determining unit 22, wherein:

[0188] The fourth determining unit 21 is used to determine the adjacency relationship between each data block to be stored based on the arrangement number corresponding to each data block to be stored.

[0189] The fifth determining unit 22 is used to determine the adjacent data blocks adjacent to each data block to be stored based on the adjacency relationship between each data block to be stored.

[0190] Each module in the aforementioned data storage device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.

[0191] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 13As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a data storage method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.

[0192] Those skilled in the art will understand that Figure 13 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0193] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:

[0194] The data to be stored is split into at least one data block, and each data block is sorted according to its position in the data to be stored before splitting, so as to obtain the sorting number corresponding to each data block.

[0195] Based on the sequence number corresponding to each data block to be stored, determine the adjacent data blocks that are adjacent to each data block to be stored;

[0196] From each candidate storage file, determine the storage location of each data block to be stored, and based on the storage location of each data block to be stored, determine the storage location of each adjacent data block; wherein, the storage location includes the candidate storage file and the space number of the block space in the candidate storage file used to store the data block;

[0197] The storage locations of adjacent data blocks are used as supplementary storage information for each data block to be stored, and each data block to be stored and its supplementary storage information are stored in the storage location of each data block to be stored.

[0198] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0199] Perform a hash operation on the user key corresponding to the data to be stored and the data name of the data to be stored to obtain the hash operation message authentication code of the data to be stored.

[0200] The storage location of the first data block is determined based on the hash operation message authentication code;

[0201] The storage location of the second data block is determined based on the memory usage of each candidate storage file.

[0202] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0203] Extract the target field value of the hash operation message authentication code, and perform data type conversion on the target field value to obtain the integer data corresponding to the target field value;

[0204] Based on the integer data and the total number of files in each candidate storage file, determine the first storage file used to store the first data block from among the candidate storage files;

[0205] Based on the block space usage record of the first storage file, determine the space number of the block space used to store the first data block in the first storage file.

[0206] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0207] Store the space number of the block space used to store the first data block in the first storage file into the preset target storage file.

[0208] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0209] Based on the memory usage of each candidate storage file, a second storage file and a third storage file are determined from the candidate storage files to store the second data block; the second storage file is the file with the smallest memory usage among the candidate storage files, and the third storage file is the file with a memory usage that is only greater than that of the second storage file among the candidate storage files.

[0210] Based on the memory usage of the second storage file and the memory usage of the third storage file, determine the space number of the block space used to store the second data block in the second storage file, and the space number of the block space used to store the second data block in the third storage file.

[0211] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0212] The difference between the memory usage of the third storage file and the memory usage of the second storage file is calculated to obtain the memory usage difference.

[0213] Perform a difference operation on the difference between the total number of the second data blocks and the occupied amount to obtain the first difference operation result, and use the integer part of half of the first difference operation result as the first storage amount of the second data blocks in the third storage file;

[0214] The total number of the second data blocks is calculated by subtracting the first storage amount to obtain the second difference result. The second difference result is used as the second storage amount for storing the second data blocks in the second storage file.

[0215] Based on the block space usage record and the second storage amount of the second storage file, determine the space number of the block space used to store the second data block in the second storage file;

[0216] Based on the block space usage record of the third storage file and the first storage amount, determine the space number of the block space in the third storage file used to store the second data block.

[0217] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0218] The adjacency relationship between each data block to be stored is determined based on the sequence number corresponding to each data block to be stored.

[0219] Based on the adjacency relationship between each data block to be stored, determine the adjacent data blocks that are adjacent to each data block to be stored.

[0220] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor:

[0221] The data to be stored is split into at least one data block, and each data block is sorted according to its position in the data to be stored before splitting, so as to obtain the sorting number corresponding to each data block.

[0222] Based on the sequence number corresponding to each data block to be stored, determine the adjacent data blocks that are adjacent to each data block to be stored;

[0223] From each candidate storage file, determine the storage location of each data block to be stored, and based on the storage location of each data block to be stored, determine the storage location of each adjacent data block; wherein, the storage location includes the candidate storage file and the space number of the block space in the candidate storage file used to store the data block;

[0224] The storage locations of adjacent data blocks are used as supplementary storage information for each data block to be stored, and each data block to be stored and its supplementary storage information are stored in the storage location of each data block to be stored.

[0225] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0226] Perform a hash operation on the user key corresponding to the data to be stored and the data name of the data to be stored to obtain the hash operation message authentication code of the data to be stored.

[0227] The storage location of the first data block is determined based on the hash operation message authentication code;

[0228] The storage location of the second data block is determined based on the memory usage of each candidate storage file.

[0229] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0230] Extract the target field value of the hash operation message authentication code, and perform data type conversion on the target field value to obtain the integer data corresponding to the target field value;

[0231] Based on the integer data and the total number of files in each candidate storage file, determine the first storage file used to store the first data block from among the candidate storage files;

[0232] Based on the block space usage record of the first storage file, determine the space number of the block space used to store the first data block in the first storage file.

[0233] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0234] Store the space number of the block space used to store the first data block in the first storage file into the preset target storage file.

[0235] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0236] Based on the memory usage of each candidate storage file, a second storage file and a third storage file are determined from the candidate storage files to store the second data block; the second storage file is the file with the smallest memory usage among the candidate storage files, and the third storage file is the file with a memory usage that is only greater than that of the second storage file among the candidate storage files.

[0237] Based on the memory usage of the second storage file and the memory usage of the third storage file, determine the space number of the block space used to store the second data block in the second storage file, and the space number of the block space used to store the second data block in the third storage file.

[0238] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0239] The difference between the memory usage of the third storage file and the memory usage of the second storage file is calculated to obtain the memory usage difference.

[0240] Perform a difference operation on the difference between the total number of the second data blocks and the occupied amount to obtain the first difference operation result, and use the integer part of half of the first difference operation result as the first storage amount of the second data blocks in the third storage file;

[0241] The total number of the second data blocks is calculated by subtracting the first storage amount to obtain the second difference result. The second difference result is used as the second storage amount for storing the second data blocks in the second storage file.

[0242] Based on the block space usage record and the second storage amount of the second storage file, determine the space number of the block space used to store the second data block in the second storage file;

[0243] Based on the block space usage record of the third storage file and the first storage amount, determine the space number of the block space in the third storage file used to store the second data block.

[0244] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0245] The adjacency relationship between each data block to be stored is determined based on the sequence number corresponding to each data block to be stored.

[0246] Based on the adjacency relationship between each data block to be stored, determine the adjacent data blocks that are adjacent to each data block to be stored.

[0247] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, performs the following steps:

[0248] The data to be stored is split into at least one data block, and each data block is sorted according to its position in the data to be stored before splitting, so as to obtain the sorting number corresponding to each data block.

[0249] Based on the sequence number corresponding to each data block to be stored, determine the adjacent data blocks that are adjacent to each data block to be stored;

[0250] From each candidate storage file, determine the storage location of each data block to be stored, and based on the storage location of each data block to be stored, determine the storage location of each adjacent data block; wherein, the storage location includes the candidate storage file and the space number of the block space in the candidate storage file used to store the data block;

[0251] The storage locations of adjacent data blocks are used as supplementary storage information for each data block to be stored, and each data block to be stored and its supplementary storage information are stored in the storage location of each data block to be stored.

[0252] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0253] Perform a hash operation on the user key corresponding to the data to be stored and the data name of the data to be stored to obtain the hash operation message authentication code of the data to be stored.

[0254] The storage location of the first data block is determined based on the hash operation message authentication code;

[0255] The storage location of the second data block is determined based on the memory usage of each candidate storage file.

[0256] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0257] Extract the target field value of the hash operation message authentication code, and perform data type conversion on the target field value to obtain the integer data corresponding to the target field value;

[0258] Based on the integer data and the total number of files in each candidate storage file, determine the first storage file used to store the first data block from among the candidate storage files;

[0259] Based on the block space usage record of the first storage file, determine the space number of the block space used to store the first data block in the first storage file.

[0260] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0261] Store the space number of the block space used to store the first data block in the first storage file into the preset target storage file.

[0262] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0263] Based on the memory usage of each candidate storage file, a second storage file and a third storage file are determined from the candidate storage files to store the second data block; the second storage file is the file with the smallest memory usage among the candidate storage files, and the third storage file is the file with a memory usage that is only greater than that of the second storage file among the candidate storage files.

[0264] Based on the memory usage of the second storage file and the memory usage of the third storage file, determine the space number of the block space used to store the second data block in the second storage file, and the space number of the block space used to store the second data block in the third storage file.

[0265] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0266] The difference between the memory usage of the third storage file and the memory usage of the second storage file is calculated to obtain the memory usage difference.

[0267] Perform a difference operation on the difference between the total number of the second data blocks and the occupied amount to obtain the first difference operation result, and use the integer part of half of the first difference operation result as the first storage amount of the second data blocks in the third storage file;

[0268] The total number of the second data blocks is calculated by subtracting the first storage amount to obtain the second difference result. The second difference result is used as the second storage amount for storing the second data blocks in the second storage file.

[0269] Based on the block space usage record and the second storage amount of the second storage file, determine the space number of the block space used to store the second data block in the second storage file;

[0270] Based on the block space usage record of the third storage file and the first storage amount, determine the space number of the block space in the third storage file used to store the second data block.

[0271] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0272] The adjacency relationship between each data block to be stored is determined based on the sequence number corresponding to each data block to be stored.

[0273] Based on the adjacency relationship between each data block to be stored, determine the adjacent data blocks that are adjacent to each data block to be stored.

[0274] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data shall comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0275] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, data blocks, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The data blocks involved in the embodiments provided in this application may include at least one of relational data blocks and non-relational data blocks. Non-relational data blocks may include, but are not limited to, blockchain-based distributed data blocks. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0276] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0277] The above embodiments are merely illustrative of several implementation methods of this application, and their descriptions are relatively specific and detailed. However, they should not be construed as limiting the scope of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A data storage method, characterized in that, The method includes: The data to be stored is split into at least one data block, and each data block is sorted according to its position in the data to be stored before splitting, so as to obtain the sorting number corresponding to each data block. Based on the sequence number corresponding to each of the data blocks to be stored, determine the adjacent data blocks that are adjacent to each data block to be stored; From each candidate storage file, determine the storage location of each data block to be stored, and based on the storage location of each data block to be stored, determine the storage location of each adjacent data block; wherein, the storage location includes the candidate storage file and the space number of the block space in the candidate storage file used to store the data block; The storage location of each adjacent data block is used as supplementary storage information for each data block to be stored, and each data block to be stored and its supplementary storage information are stored in the storage location of each data block to be stored. Each data block to be stored includes a first data block and a second data block, wherein the first data block is the data block whose sequence number is the first in each of the data blocks to be stored, and the second data block is the data block other than the first data block in each of the data blocks to be stored; correspondingly, determining the storage location of each data block to be stored from each candidate storage file includes: performing a hash operation on the user key corresponding to the data to be stored and the data name of the data to be stored to obtain a hash operation message authentication code for the data to be stored; determining the storage location of the first data block based on the hash operation message authentication code; and determining the storage location of the second data block based on the memory usage of each candidate storage file; The step of determining the storage location of the second data block based on the memory usage of each candidate storage file includes: determining a second storage file and a third storage file for storing the second data block from each candidate storage file based on the memory usage of each candidate storage file; the second storage file is the file with the smallest memory usage among the candidate storage files, and the third storage file is the file whose memory usage among the candidate storage files is only greater than that of the second storage file; and determining the space number of the block space in the second storage file used to store the second data block, and the space number of the block space in the third storage file used to store the second data block, based on the memory usage of the second storage file and the memory usage of the third storage file.

2. The method according to claim 1, characterized in that, Determining the storage location of the first data block based on the hash operation message authentication code includes: Extract the target field value of the hash operation message authentication code, and perform data type conversion on the target field value to obtain the integer data corresponding to the target field value; Based on the integer data and the total number of files in each candidate storage file, a first storage file for storing the first data block is determined from each candidate storage file. Based on the block space usage record of the first storage file, determine the space number of the block space in the first storage file used to store the first data block.

3. The method according to claim 2, characterized in that, The method further includes: The space number of the block space used to store the first data block in the first storage file is stored in the preset target storage file.

4. The method according to claim 1, characterized in that, The step of determining the space number of the block space used to store the second data block in the second storage file and the space number of the block space used to store the second data block in the third storage file, based on the memory usage of the second storage file and the memory usage of the third storage file, includes: The memory usage of the third storage file and the memory usage of the second storage file are compared to obtain the memory usage difference. Perform a difference operation between the total number of the second data blocks and the difference in the occupied amount to obtain a first difference operation result, and use half of the integer part of the first difference operation result as the first storage amount of the second data blocks in the third storage file; The total number of the second data blocks is calculated by subtracting the first storage amount to obtain the second difference result. The second difference result is used as the second storage amount for storing the second data blocks in the second storage file. Based on the block space usage record of the second storage file and the second storage amount, determine the space number of the block space in the second storage file used to store the second data block; Based on the block space usage record of the third storage file and the first storage amount, determine the space number of the block space in the third storage file used to store the second data block.

5. The method according to claim 1, characterized in that, The step of determining the adjacent data blocks adjacent to each of the data blocks to be stored according to the sequence number corresponding to each of the data blocks to be stored includes: The adjacency relationship between the data blocks to be stored is determined based on the sequence number corresponding to each data block to be stored. Based on the adjacency relationship between each of the data blocks to be stored, the adjacent data blocks adjacent to each data block to be stored are determined.

6. A data storage device, characterized in that, The device includes: The first determining module is used to split the data to be stored into at least one data block to be stored, and sort each data block to be stored according to its position in the data to be stored before splitting, so as to obtain the sorting number corresponding to each data block to be stored. The second determining module is used to determine the adjacent data blocks that are adjacent to each of the data blocks to be stored according to the arrangement number corresponding to each of the data blocks to be stored; The third determining module is used to determine the storage location of each data block to be stored from each candidate storage file, and to determine the storage location of each adjacent data block based on the storage location of each data block to be stored. The storage module is used to use the storage location of each adjacent data block as supplementary storage information for each data block to be stored, and to store each data block to be stored and its supplementary storage information in the storage location of each data block to be stored. Each data block to be stored includes a first data block and a second data block. The first data block is the data block whose sequence number is the first in each of the data blocks to be stored, and the second data block is the data block other than the first data block in each of the data blocks to be stored. The third determining module includes: a first determining unit, used to perform a hash operation on the user key corresponding to the data to be stored and the data name of the data to be stored to obtain a hash operation message authentication code for the data to be stored; a second determining unit, used to determine the storage location of the first data block based on the hash operation message authentication code; and a third determining unit, used to determine the storage location of the second data block based on the memory usage of each candidate storage file. The third determining unit includes: a fourth determining subunit, configured to determine a second storage file and a third storage file for storing the second data block from each candidate storage file based on the memory usage of each candidate storage file; the second storage file is the file with the smallest memory usage among the candidate storage files, and the third storage file is the file whose memory usage among the candidate storage files is only greater than that of the second storage file; and a fifth determining subunit, configured to determine the space number of the block space in the second storage file used for storing the second data block, and the space number of the block space in the third storage file used for storing the second data block, based on the memory usage of the second storage file and the memory usage of the third storage file.

7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 5.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.

9. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Distributed large file storage system and file uploading and downloading method

    CN111049884A

  • Information storage method and device

    CN112965980A