Data storage method, device, equipment and storage medium

By separating the key and value in key-value pairs and generating unique identifiers, the write amplification problem in key-value storage is solved, thus improving storage performance.

CN116383333BActive Publication Date: 2026-01-02BAIDU ONLINE NETWORK TECH (BEIJIBG) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310465247.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-26
Publication Date
2026-01-02
Estimated Expiration
2043-04-26

AI Technical Summary

Technical Problem

Existing key-value storage methods suffer from write amplification when writing data, which leads to a significant degrade in storage performance.

Method used

The key and value in the key-value pair corresponding to the target data to be stored are separated, and a unique identifier is generated for it. The correspondence between the key and the identifier is established. The identifier, key, value and correspondence are pre-written into the log using the RAFT algorithm. When the application accesses the data, the key and identifier are written to the application to look up the value.

Benefits of technology

It reduces the amount of data written when storing data, lowers write amplification, and improves storage performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116383333B_ABST
    Figure CN116383333B_ABST
Patent Text Reader

Abstract

The present disclosure provides a data storage method, device, equipment and storage medium, relates to the technical field of data processing, in particular to the technical field of data storage, data separation, data reading and the like, and can be applied to the scene of storing unstructured data such as text, picture, audio and video. The specific implementation scheme comprises the following steps: separating the key and the value in the target key-value pair corresponding to the target data to obtain a target key and a target value; generating unique identification information for the target key-value pair, establishing a first correspondence relationship between the target key and the identification information and a second correspondence relationship between the identification information and the target value; prewriting the identification information, the target key, the target value, the first correspondence relationship and the second correspondence relationship into a log; and when the application side accesses the target data, writing the target key, the identification information and the first correspondence relationship into the application side. The present disclosure can reduce the data write amount when storing data, reduce write amplification, and improve storage performance.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the technical field of data processing, in particular to the technical field of data storage, data separation, data reading, and the like, and can be applied to the scene of storing unstructured data such as text, picture, audio and video, and in particular to a data storage method and device, equipment and storage medium. BACKGROUND

[0002] Key-value (KV) storage is a storage method in a NoSQL database. The NoSQL database refers to a database that is not a relational database and can store unstructured data such as text, picture, audio and video. In the KV storage method, data can be organized, indexed and stored in the form of key-value (KV) pairs.

[0003] Currently, in the KV storage method, when storing data (i.e. key-value pairs) in a database, the key-value pairs can be pre-written into a log through a RAFT algorithm. When accessing data, the application side can write the key-value pairs pre-written in the log into the application side through the RAFT algorithm.

[0004] However, in the current KV storage method, the actual write amount corresponding to the data is much larger than the size of the data itself, causing write amplification and seriously affecting the storage performance. SUMMARY

[0005] The present disclosure provides a data storage method, device, equipment and storage medium, which can reduce the data write amount when storing data, reduce write amplification and improve storage performance.

[0006] According to a first aspect of the present disclosure, a data storage method is provided, the method comprising: separating a key and a value in a target key-value pair corresponding to target data to be stored to obtain a target key and a target value; generating unique identification information for the target key-value pair, and establishing a first correspondence relationship between the target key and the identification information and a second correspondence relationship between the identification information and the target value; pre-writing the identification information, the target key, the target value, and the first and second correspondence relationships into a log; and when an application side accesses the target data, writing the target key, the identification information, and the first correspondence relationship into the application side, and the identification information is used by the application side to find the target value from the log.

[0007] According to a second aspect of the present disclosure, a data storage method is provided, the method comprising:

[0008] The unique identification information is generated for a target key-value pair corresponding to target data to be stored, and the target key-value pair and the identification information are pre-written in a log; when the application side accesses the target data, a target key and a target value are obtained by separating a key and a value in the target key-value pair, and a first correspondence relationship between the target key and the identification information is established; the target key, the identification information, and the first correspondence relationship are written to the application side, and the identification information is used by the application side to find the target value from the log.

[0009] According to a third aspect of the present disclosure, a data storage device is provided, the device comprising: a separation unit, a generation unit, a pre-writing unit, and a writing unit.

[0010] The separation unit is configured to separate a key and a value in a target key-value pair corresponding to target data to be stored, to obtain a target key and a target value; the generation unit is configured to generate unique identification information for the target key-value pair, and to establish a first correspondence relationship between the target key and the identification information, and a second correspondence relationship between the identification information and the target value; the pre-writing unit is configured to pre-write the identification information, the target key, the target value, and the first and second correspondence relationships into a log; and the writing unit is configured to write the target key, the identification information, and the first correspondence relationship to the application side when the application side accesses the target data, and the identification information is used by the application side to find the target value from the log.

[0011] According to a fourth aspect of the present disclosure, a data storage device is provided, the device comprising: a generation unit, a separation unit, and a writing unit.

[0012] The generation unit is configured to generate unique identification information for a target key-value pair corresponding to target data to be stored, and to pre-write the target key-value pair and the identification information into a log; the separation unit is configured to separate a key and a value in the target key-value pair when an application side accesses the target data, to obtain a target key and a target value, and to establish a first correspondence relationship between the target key and the identification information; and the writing unit is configured to write the target key, the identification information, and the first correspondence relationship to the application side, and the identification information is used by the application side to find the target value from the log.

[0013] According to a fifth aspect of the present disclosure, an electronic device is provided, comprising: at least one processor; and a memory connected with the at least one processor in communication; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method of the first aspect or the second aspect.

[0014] According to a sixth aspect of the present disclosure, a non-transitory computer readable storage medium storing computer instructions is provided, the computer instructions being used to cause a computer to perform the method of the first aspect or the second aspect.

[0015] According to a seventh aspect of the present disclosure, there is provided a computer program product comprising a computer program which, when executed by a processor, implements the method according to the first aspect or the second aspect.

[0016] It should be understood that nothing in this section is intended to limit the scope of the embodiments of the present disclosure. Other aspects of the present disclosure will become apparent to those of ordinary skill in the art upon reviewing the description below in conjunction with the accompanying figures. BRIEF DESCRIPTION OF DRAWINGS

[0017] The accompanying drawings are included to provide a further understanding of the present scheme, and are incorporated in and constitute a part of this specification. In the drawings:

[0018] Figure 1 A flowchart of a data storage method according to an embodiment of the present disclosure is provided.

[0019] Figure 2 An implementation flowchart of S102 according to an embodiment of the present disclosure is provided.

[0020] Figure 3 Another flowchart of a data storage method according to an embodiment of the present disclosure is provided.

[0021] Figure 4 A principle diagram of a data storage method according to an embodiment of the present disclosure is provided.

[0022] Figure 5 A composition diagram of a data storage device according to an embodiment of the present disclosure is provided.

[0023] Figure 6 Another composition diagram of a data storage device according to an embodiment of the present disclosure is provided.

[0024] Figure 7 A schematic block diagram of an example electronic device 700 that can be used to implement embodiments of the present disclosure is provided. DETAILED DESCRIPTION

[0025] Exemplary embodiments of the present disclosure are described herein with reference to the accompanying drawings, which are included to provide a further understanding of the present scheme and are incorporated in and constitute a part of this specification. Embodiments of the present disclosure described herein should be considered in a descriptive sense only and not for purposes of limitation. Therefore, various modifications and changes can be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, it should be understood that the description and specific examples, while indicating preferred embodiments of the application, are given by way of illustration only and not by way of limitation. Thus, the scope of the present disclosure should not be limited by the examples described herein, but should be given the broadest interpretation of the appended claims and their equivalents.

[0026] It should be understood that in the embodiments of the present disclosure, the character " / " generally represents that the associated objects before and after are in an "or" relationship. The terms "first", "second", etc. are only for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features.

[0027] Key-value (KV) storage is a storage method in a NoSQL database. NoSQL database generally refers to a non-relational database, which can store text, pictures, audio and video, and other unstructured data. In the KV storage method, data can be organized, indexed and stored in the form of key-value (KV) pairs.

[0028] For example, the full name of the NoSQL database can be not only structured query language (NoSQL). There are many types of NoSQL databases, and there is no relationship between data and data, which is very easy to expand and has very high read and write performance.

[0029] Currently, when the KV storage method stores data (i.e. key-value pairs) in the database, it can prewrite the key-value pairs to the log through the RAFT algorithm. When the application side accesses the data, the key-value pairs prewritten in the log can be written to the application side through the RAFT algorithm.

[0030] For example, the KV storage method stores data in the form of key-value pairs in the database. Currently, when the KV storage method stores data (i.e. key-value pairs) in the database, it can prewrite the key-value pairs to the log (such as RAFT log) for storage through the RAFT algorithm. RAFT is a simple, convenient and easy-to-understand distributed algorithm that mainly solves the consistency problem in distributed systems. When the application side accesses the data, the key-value pairs prewritten in the log can be written to the application side through the RAFT algorithm. The application side can be an application program or a server on the application side.

[0031] However, in the current KV storage method, the actual write amount corresponding to the data far exceeds the size of the data itself, causing write amplification and seriously affecting the storage performance.

[0032] For example, in the current KV storage method, the RAFT-based write mechanism first prewrites the log, and when the application side accesses the data, the prewritten log is written to the application side again. In this way, the data is written twice, resulting in a physical data amount that is several times the amount of data written, which affects the storage performance.

[0033] In this background art, the present disclosure provides a data storage method, which can reduce the amount of data writing when storing data, reduce write amplification, and improve storage performance.

[0034] Exemplarily, the execution subject of the data storage method can be a computer or a server, or can also be other devices with data processing capabilities. The execution subject of the method is not limited herein.

[0035] For example, the execution subject of the data storage method can be a computer or a server deployed with a storage system or a database. Alternatively, the execution subject of the data storage method can also be a storage system, or a software module for managing or maintaining a storage system or a database.

[0036] In some embodiments, the server can be a single server, or can also be a server cluster composed of multiple servers. In some implementations, the server cluster can also be a distributed cluster. The specific implementation of the server is not limited in the present disclosure.

[0037] Figure 1 A flowchart of the data storage method provided by the embodiments of the present disclosure is shown in FIG. 1. Figure 1 As shown in FIG. 1, the method can include S101-S104.

[0038] S101, separate the key and the value in the target key-value pair corresponding to the target data to be stored, to obtain a target key and a target value.

[0039] Exemplarily, in the KV storage mode, data can be organized, indexed and stored in the form of key-value (KV) pairs. The key and the value in the target key-value pair corresponding to the target data to be stored can be separated to obtain a target key and a target value.

[0040] For example, the key and the value in the target key-value pair corresponding to the target data to be stored can be separated to obtain a target key key and a target value value.

[0041] S102, generate unique identification information for the target key-value pair, and establish a first correspondence relationship between the target key and the identification information, and a second correspondence relationship between the identification information and the target value.

[0042] Exemplarily, the unique identification information can be generated for the target key-value pair, a first correspondence relationship between the target key and the identification information, and a second correspondence relationship between the identification information and the target value. The target key and the identification information in the target key-value pair are the same, the identification information can be used as a new value of the target key, and the identification information can also be used as a new key of the target value. The identification information used as the new value of the target key has a correspondence relationship with the target key, which can be referred to as the first correspondence relationship. The identification information used as the new key of the target value has a correspondence relationship with the target value, which can be referred to as the second correspondence relationship.

[0043] For example, assuming that the target key of the target key-value pair is k, the target value is v, and the identification information is 1, 1 can be used as a new value of k, and 1 can also be used as a new key of v.

[0044] S103, prewrite the identification information, the target key, the target value, and the first correspondence relationship and the second correspondence relationship into the log.

[0045] Exemplarily, the unique identification information generated for the target key-value pair, the separated target key, the target value, and the first correspondence relationship between the target key and the identification information and the second correspondence relationship between the identification information and the target value can be prewritten into the log by the RAFT algorithm.

[0046] S104, when the application side accesses the target data, write the target key, the identification information, and the first correspondence relationship into the application side, and the identification information is used by the application side to find the target value from the log.

[0047] Exemplarily, when the application side accesses the target data, the target key, the identification information, and the first correspondence relationship between the target key and the identification information can be written into the application side by the RAFT algorithm. The user can find the unique identification information corresponding to the target key according to the first correspondence relationship of the target key written into the application side, and then find the target value corresponding to the unique identification information from the prewritten log according to the unique identification information. The application side can be an application software or a server.

[0048] For example, assuming that the target key is k, the identification information is 1, and the target value is v, when the application side accesses the target data, the target key k, the identification information 1, and the first correspondence relationship between the target key k and the identification information 1 can be written into the application side. The user can find the identification information 1 corresponding to the target key k according to the target key k written into the application side and the first correspondence relationship between the target key k and the identification information 1, and then find the target value v corresponding to the identification information 1 in the prewritten log according to the identification information 1.

[0049] The disclosure separates the key and the value in the target key-value pair corresponding to the target data to be stored to obtain a target key and a target value; generates unique identification information for the target key-value pair, and establishes a first correspondence relationship between the target key and the identification information and a second correspondence relationship between the identification information and the target value; prewrites the identification information, the target key, the target value, and the first and second correspondence relationships into a log; when the target data is accessed by an application side, the target key, the identification information, and the first correspondence relationship are written to the application side, and the identification information is used by the application side to find the target value from the log, which can reduce the data write amount when storing data, reduce write amplification, and improve storage performance.

[0050] In some embodiments, the above-mentioned generation of unique identification information for the target key-value pair can include:

[0051] At the target time, a timestamp is generated for the target key-value pair as identification information of the target key-value pair.

[0052] For example, at the target time, unique identification information can be generated for the target key-value pair, and the generated unique identification information can be in the form of a timestamp.

[0053] For example, assuming that the target key-value pair is X, a timestamp 1 can be generated for the target key-value pair X, and this timestamp 1 is the unique identification information of the target key-value pair X.

[0054] The embodiment can greatly reduce the amount of data written and reduce write amplification by generating a timestamp for the target key-value pair at the target time as unique identification information of the target key-value pair.

[0055] In some embodiments, the above-mentioned target time is before the time when the key and the value in the target key-value pair are separated; or the target time is the time when the key and the value in the target key-value pair are separated; or the target time is after the time when the key and the value in the target key-value pair are separated.

[0056] For example, the timestamp can be generated for the target key-value pair at the same time when the key and the value in the target key-value pair are separated, or the timestamp can be generated for the target key-value pair before the key and the value in the target key-value pair are separated, or the timestamp can be generated for the target key-value pair after the key and the value in the target key-value pair are separated.

[0057] The embodiment can improve the flexibility of the timestamp generation time and the efficiency of data storage by limiting the target time to be the time when the key and the value in the target key-value pair are separated, or before the time when the key and the value in the target key-value pair are separated, or after the time when the key and the value in the target key-value pair are separated.

[0058] In some embodiments, the unique identification information generated for the target key-value pair can include:

[0059] According to a preset numbering rule, a unique number corresponding to the target key-value pair is determined as the identification information of the target key-value pair.

[0060] For example, the unique identification information generated for the target key-value pair can be a unique number corresponding to the target key-value pair determined according to a preset numbering rule. The form of the unique identification information can be various, which is not limited herein.

[0061] For example, according to a preset numbering rule, a unique number ① corresponding to the target key-value pair X can be generated, and the number ① is the unique identification information of the target key-value pair X.

[0062] According to the preset numbering rule, the unique number corresponding to the target key-value pair is determined, which can improve the richness of the identification information and improve the flexibility of generating the identification information.

[0063] Figure 2 An implementation flowchart of S102 provided by the embodiments of the present disclosure is shown in FIG. 2. Figure 2 As shown in FIG. 2, in some embodiments, the steps of establishing the first correspondence relationship between the target keyword and the identification information and the second correspondence relationship between the identification information and the target value in S102 can include S201-S202.

[0064] S201, taking the identification information as a new value corresponding to the target keyword to obtain a first key-value pair, and the first key-value pair is used to represent the first correspondence relationship.

[0065] For example, the unique identification information generated can be taken as a new value corresponding to the target keyword to obtain a new key-value pair, and the new key-value pair is the first key-value pair, which is used to indicate the first correspondence relationship between the target keyword and the unique identification information.

[0066] For example, assuming that the target keyword of the target key-value pair is k, the target value is v, and the generated unique identification information is X, the identification information X can be taken as a new value of the target keyword k to obtain a first key-value pair, and the first key-value pair is used to indicate the first correspondence relationship between the target keyword k and the identification information X.

[0067] S202, taking the identification information as a new keyword corresponding to the target value to obtain a second key-value pair, and the second key-value pair is used to represent the second correspondence relationship.

[0068] For example, the unique identification information generated can be taken as a new keyword corresponding to the target value to obtain a new key-value pair, and the new key-value pair is the second key-value pair, which is used to indicate the second correspondence relationship between the target value and the unique identification information.

[0069] For example, assuming that the target key of the target key-value pair is k, the target value is v, and the generated unique identification information is X, the identification information X can be taken as a new key of the target value v to obtain a second key-value pair, and the second key-value pair is used to indicate a second correspondence relationship between the identification information X and the target value v.

[0070] In this embodiment, S103 can include prewriting the first key-value pair and the second key-value pair into a log. The step of writing the target key, the identification information, and the first correspondence relationship into the application side in S104 can include writing the first key-value pair into the application side.

[0071] For example, assuming that the target key of the target key-value pair is k, the target value is v, and the generated unique identification information is X, the identification information X can be taken as a new key of the target value v to obtain a second key-value pair, and the second key-value pair is used to indicate a second correspondence relationship between the identification information X and the target value v.

[0072] For example, assuming that the target key of the target key-value pair is k, the target value is v, and the generated unique identification information is X, the identification information X can be taken as a new key of the target value v to obtain a second key-value pair, and the second key-value pair is used to indicate a second correspondence relationship between the identification information X and the target value v.

[0073] The embodiment obtains the first key-value pair by taking the identification information as a new value corresponding to the target key, obtains the second key-value pair by taking the identification information as a new key corresponding to the target value, prewrites the first key-value pair and the second key-value pair into the log, and writes the first key-value pair into the application side, thereby further reducing the data volume of the written data, reducing the write amplification, and further improving the storage performance.

[0074] The embodiment of the present disclosure also provides a data storage method, and the execution subject of the data storage method can refer to the foregoing embodiments, which will not be described herein again. Figure 3 Another flowchart of the data storage method provided by the embodiment of the present disclosure is shown in FIG. 3. Figure 3 As shown in FIG. 3, the method can include S301-S303.

[0075] S301, generating unique identification information for a target key-value pair of target data to be stored, and prewriting the target key-value pair and the identification information into a log.

[0076] For example, unique identification information can be generated for the target key-value pair, and the target key-value pair and the unique identification information generated for the target key-value pair can be prewritten into the log by using the RAFT algorithm.

[0077] For example, assuming that the target key-value pair is X and the unique identification information is y, the target key-value pair X and the unique identification information y can be pre-written into the log by the RAFT algorithm.

[0078] S302, when the application side accesses the target data, the key and the value in the target key-value pair are separated to obtain the target key and the target value, and a first correspondence between the target key and the identification information is established.

[0079] For example, when the application side accesses the target data, the key and the value in the target key-value pair corresponding to the target data can be separated to obtain the target key and the target value, and a first correspondence between the target key and the unique identification information generated for the target key-value pair is established.

[0080] For example, assuming that the target key of the target key-value pair is k, the target value is v, and the identification information is 1, when the application side accesses the target data, the target key k and the target value v of the target key-value pair are separated, and the identification information 1 can be used as the new value of the target key k.

[0081] S303, the target key, the identification information, and the first correspondence are written to the application side, and the identification information is used by the application side to find the target value from the log.

[0082] For example, the target key of the target key-value pair, the unique identification information generated for the target key-value pair, and the first correspondence between the target key and the unique identification information generated for the target key-value pair can be written to the application side, and the user can find the unique identification information corresponding to the target key according to the target key written to the application side through the first correspondence, and then find the target value corresponding to the unique identification information from the pre-written log according to the unique identification information.

[0083] For example, assuming that the target key is k, the identification information is 1, and the target value is v, the target key k, the identification information 1, and the first correspondence between the target key k and the identification information 1 can be written to the application side, and the user can find the identification information 1 corresponding to the target key k according to the target key k written to the application side and the first correspondence between k and the identification information 1, and then find the target value v corresponding to the identification information 1 in the pre-written log according to the identification information 1.

[0084] Similar to the embodiments shown in the above Figure 1 , the embodiments shown in the above Figure 3In the embodiment, the unique identification information of the target key-value pair to be stored is generated, and the target key-value pair and the identification information are pre-written into the log. When the target data is accessed by the application side, the key and the value in the target key-value pair are separated to obtain the target key and the target value, and a first correspondence between the target key and the identification information is established. The target key, the identification information, and the first correspondence are written into the application side, so that the data write amount during storage of data is reduced, the write amplification is reduced, and the storage performance is improved.

[0085] In some embodiments, the unique identification information of the target key-value pair to be stored can include: generating a timestamp of the target key-value pair as the identification information of the target key-value pair at a target time.

[0086] For example, at the target time, the unique identification information of the target key-value pair can be generated in the form of a timestamp.

[0087] For example, assuming that the target key-value pair is X, a timestamp 1 can be generated for the target key-value pair X, and the timestamp 1 is the unique identification information of the target key-value pair X.

[0088] In the embodiment, the timestamp of the target key-value pair is generated at the target time as the unique identification information of the target key-value pair, so that the data amount of writing is further reduced, and the write amplification is reduced.

[0089] In some embodiments, the target time can be before the target key-value pair is pre-written into the log, or the target time is the time when the target key-value pair is pre-written into the log.

[0090] For example, the time when the unique identification information of the target key-value pair is generated can be before the target key-value pair is pre-written into the log, or the unique identification information of the target key-value pair can be generated at the same time when the target key-value pair is pre-written into the log.

[0091] In the embodiment, the time when the unique identification information of the target key-value pair is generated can be before the target key-value pair is pre-written into the log, or the unique identification information of the target key-value pair can be generated at the same time when the target key-value pair is pre-written into the log, so that the flexibility of the time when the unique identification information is generated is improved, and the efficiency of data storage is improved.

[0092] In some embodiments, the unique identification information of the target key-value pair to be stored can include: determining a unique number corresponding to the target key-value pair as the identification information of the target key-value pair according to a preset numbering rule.

[0093] Exemplarily, the unique identification information generated for the target key-value pair can be a unique number corresponding to the target key-value pair determined according to a preset numbering rule. The form of the unique identification information can be various, which is not limited herein.

[0094] For example, a unique number ① corresponding to the target key-value pair X can be generated according to a preset numbering rule, and the number ① is the unique identification information of the target key-value pair X.

[0095] According to the preset numbering rule, the unique number corresponding to the target key-value pair is determined in this embodiment, which can improve the richness of the identification information and improve the flexibility of generating the identification information.

[0096] In some embodiments, the S302 can include obtaining a first key-value pair by taking the identification information as a new value corresponding to the target keyword, and the first key-value pair is used to represent the first correspondence relationship.

[0097] Exemplarily, the generated unique identification information can be taken as a new value corresponding to the target keyword to obtain a new key-value pair, and the new key-value pair is the first key-value pair, which is used to indicate the first correspondence relationship between the target keyword and the unique identification information.

[0098] For example, assuming that the target keyword of the target key-value pair is k, the target value is v, and the generated unique identification information is X, the identification information X can be taken as a new value of the target keyword k to obtain a first key-value pair, and the first key-value pair is used to indicate the first correspondence relationship between the target keyword k and the identification information X.

[0099] In this embodiment, the S303 can include writing the first key-value pair to the application side.

[0100] Exemplarily, the first key-value pair composed of the identification information and the target keyword can be written to the application side through the RAFT algorithm.

[0101] For example, assuming that the target keyword of the target key-value pair is k, the target value is v, and the generated unique identification information is X, a first key-value pair composed of the target keyword k and the identification information X can be obtained, and the first key-value pair is written to the application side.

[0102] In this embodiment, the identification information is taken as a new value corresponding to the target keyword to obtain a first key-value pair, and the first key-value pair is written to the application side, which further reduces the data writing amount when storing data and reduces the write amplification.

[0103] The principle of the data storage method provided in the embodiments of the present disclosure will be described exemplarily. Figure 4 The principle of the data storage method provided in the embodiments of the present disclosure will be described exemplarily.

[0104] Figure 4 The principle of the data storage method provided in the embodiments of the present disclosure will be described exemplarily. As shown in FIG. 1, the data storage method provided in the embodiments of the present disclosure includes the following steps.Figure 4 As shown, the key and value in the target key-value pairs corresponding to the target data are separated to obtain the target key k and the target value v. A timestamp 1 can be generated for target key-value pair 1, timestamp 3 for target key-value pair 2, timestamp 5 for target key-value pair 3, and timestamp 7 for target key-value pair 4. All the key, value, and timestamps of all target key-value pairs are pre-written into the log. When the application accesses the target data, timestamp 1 is used as the new value of the target key of target key-value pair 1 to obtain key-value pair 1, timestamp 3 is used as the new value of the target key of target key-value pair 2 to obtain key-value pair 2, and timestamp 5 is used as the new value of the target key of target key-value pair 3 to obtain key-value pair v. For key 3, use timestamp 7 as the new key of the target key-value pair 4 to obtain key-value pair 4; use timestamp 1 as the new key of the target value of target key-value pair 1 to obtain key-value pair 5; use timestamp 3 as the new key of the target value of target key-value pair 2 to obtain key-value pair 6; use timestamp 5 as the new key of the target value of target key-value pair 3 to obtain key-value pair 7; use timestamp 7 as the new key of the target value of target key-value pair 4 to obtain the eighth key-value pair; write key-value pair 1, key-value pair 2, key-value pair 3, and key-value pair 4 to the application side. When reading, the corresponding timestamp can be read according to the target key written to the application side, and then the target value of the target key-value pair can be indexed by the timestamp.

[0105] In an exemplary embodiment, this disclosure also provides a data storage device that can be used to implement the aforementioned... Figures 1 to 2 The data storage method described in the illustrated embodiment.

[0106] Figure 5 This is a schematic diagram illustrating the composition of a data storage device provided in an embodiment of this disclosure. For example... Figure 5 As shown, the device may include: a separation unit 501, a generation unit 502, a pre-write unit 503, and a writing unit 504.

[0107] The separation unit 501 is used to separate the key and value in the target key-value pair corresponding to the target data to be stored, so as to obtain the target key and the target value.

[0108] The generation unit 502 is used to generate unique identification information for target key-value pairs, and establish a first correspondence between target keywords and identification information, and a second correspondence between identification information and target values.

[0109] The pre-write unit 503 is used to pre-write the identification information, target keyword, target value, and first and second correspondence into the log.

[0110] The writing unit 504 is used to write the target keyword, identification information and the first correspondence to the application side when the application side accesses the target data. The identification information is used by the application side to find the target value from the log.

[0111] Optionally, the generating unit 502 is specifically configured to generate a timestamp as the identification information of the target key-value pair at a target time point for the target key-value pair.

[0112] Optionally, the target time point is before a time point at which the key and the value in the target key-value pair are separated; or, the target time point is the time point at which the key and the value in the target key-value pair are separated; or, the target time point is after the time point at which the key and the value in the target key-value pair are separated.

[0113] Optionally, the generating unit 502 is specifically configured to determine a unique number corresponding to the target key-value pair as the identification information of the target key-value pair according to a preset numbering rule.

[0114] Optionally, the generating unit 502 is specifically configured to obtain a first key-value pair by taking the identification information as a new value corresponding to the target key, and the first key-value pair is used to represent a first correspondence relationship; obtain a second key-value pair by taking the identification information as a new key corresponding to the target value, and the second key-value pair is used to represent a second correspondence relationship; the prewriting unit 503 is specifically configured to prewrite the first key-value pair and the second key-value pair into the log; and the writing unit 504 is specifically configured to write the first key-value pair into the application side.

[0115] In an example embodiment, the present disclosure also provides a data storage device, which can be used to implement the data storage method described in the foregoing Figure 3 example embodiments.

[0116] Figure 6 Another constituent schematic diagram of the data storage device provided by the present disclosure is shown in FIG. 6. As shown in FIG. 6, the device can include a generating unit 601, a separating unit 602, and a writing unit 603. Figure 6

[0117] The generating unit 601 is configured to generate unique identification information for a target key-value pair corresponding to target data to be stored, and prewrite the target key-value pair and the identification information into a log.

[0118] The separating unit 602 is configured to separate a key and a value in the target key-value pair to obtain a target key and a target value, and establish a first correspondence relationship between the target key and the identification information when an application side accesses the target data.

[0119] The writing unit 603 is configured to write the target key, the identification information, and the first correspondence relationship into the application side, and the identification information is used by the application side to find the target value from the log.

[0120] Optionally, the generating unit 601 is specifically configured to generate a timestamp as the identification information of the target key-value pair at a target time point for the target key-value pair. ​

[0121] Optionally, the target time is before the time when the target key-value pair is pre-written into the log; or the target time is the time when the target key-value pair is pre-written into the log.

[0122] Optionally, the generation unit 601 is specifically configured to determine, according to a preset numbering rule, a unique number corresponding to the target key-value pair as the identification information of the target key-value pair.

[0123] Optionally, the generation unit 601 is specifically configured to obtain a first key-value pair by taking the identification information as a new value corresponding to the target key, and the first key-value pair is used to represent the first correspondence; and the writing unit 603 is specifically configured to write the first key-value pair into the application side.

[0124] In the technical solution of the present disclosure, the acquisition, storage and application of user personal information comply with relevant laws and regulations and do not violate public order and good customs.

[0125] According to the embodiments of the present disclosure, the present disclosure further provides an electronic device, a readable storage medium, and a computer program product.

[0126] In the example embodiments, the electronic device comprises at least one processor, and a memory connected in communication with the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method as described in the above embodiments.

[0127] In the example embodiments, the readable storage medium can be a non-transitory computer readable storage medium storing computer instructions for causing a computer to perform the method according to the above embodiments.

[0128] In the example embodiments, the computer program product comprises a computer program, which, when executed by a processor, implements the method according to the above embodiments.

[0129] Figure 7 A schematic block diagram of an example electronic device 700 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptops, desktops, tablets, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular telephones, smartphones, wearable devices, and other similar computing devices. The components shown here, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit the implementations of the present disclosure described and / or claimed in this document.

[0130] AsFigure 7 As shown, the electronic device 700 includes a computing unit 701 that can perform various appropriate actions and processes in accordance with a computer program stored in a read-only memory (ROM) 702 or a computer program loaded into a random access memory (RAM) 703 from a storage unit 708. Various programs and data required for the operation of the electronic device 700 can also be stored in the RAM 703. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other through a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.

[0131] A plurality of components in the electronic device 700 are connected to the I / O interface 705, including: an input unit 706, such as a keyboard, a mouse, and the like; an output unit 707, such as various types of displays, a speaker, and the like; a storage unit 708, such as a magnetic disk, an optical disk, and the like; and a communication unit 709, such as a network card, a modem, a wireless communication transceiver, and the like. The communication unit 709 allows the electronic device 700 to exchange information / data with other devices through a computer network, such as the Internet, and / or various telecommunication networks.

[0132] The computing unit 701 can be various general-purpose and / or special-purpose processing components having processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, and the like. The computing unit 701 performs various methods and processes described above, such as the data storage method. For example, in some embodiments, the data storage method can be implemented as a computer software program that is tangibly embodied in a machine-readable medium, such as the storage unit 708. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 700 via the ROM 702 and / or the communication unit 709. When the computer program is loaded into the RAM 703 and executed by the computing unit 701, one or more steps of the data storage method described above can be performed. Alternatively, in other embodiments, the computing unit 701 can be configured to perform the data storage method by any other appropriate means, such as by means of firmware.

[0133] The various embodiments of the systems and techniques described above can be implemented in digital electronic circuitry, integrated circuitry, a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on a chip (SOC), a load programmable logic device (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.

[0134] Program code for carrying out methods of the present disclosure can be written in any combination of one or more programming languages. The program code can be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the program code, when executed by the processor or controller, produces the functions / operations specified in the flowcharts and / or the block diagrams. The program code can be executed entirely on a machine, partially on a machine, partially on a machine as a stand-alone software package, or entirely on a remote machine or server.

[0135] In the context of the present disclosure, a machine-readable medium can be a tangible medium that contains or stores a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include but is not limited to an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of the machine-readable storage medium will include one or more lines of electrical connections, portable computer disks, hard disk drives, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or Flash memory), optical fibers, portable compact disc read-only memories (CD-ROMs), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0136] To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the computer. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.

[0137] The systems and techniques described here can be implemented in a computing system that includes a back end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front end component (e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), and the Internet.

[0138] The computer system can include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server is generally established by computer programs running on the respective computers and having a client-server relationship to each other. The servers can be cloud servers, servers of a distributed system, or servers combined with a blockchain.

[0139] It should be understood that the various forms of flow shown above can be re-ordered, added to, or deleted from without departing from the scope of the present disclosure. For example, the steps recited in the present disclosure can be performed in parallel, in series, or in a different order, without departing from the desired results of the technology disclosed in the present disclosure, which are not limited herein.

[0140] The specific embodiments described above are not intended to be limiting, and persons skilled in the art will appreciate that various modifications, combinations, sub-combinations and alternatives can be made to the specific embodiments without departing from the spirit and scope of the disclosure. Any modifications, equivalent substitutions, improvements, and the like, made within the spirit and principles of the disclosure, are intended to be included in the scope of the disclosure.

Claims

1. A data storage method, comprising: separating a key and a value in a target key-value pair corresponding to target data to be stored, to obtain a target key and a target value; generating unique identification information for the target key-value pair, and establishing a first correspondence relationship between the target key and the identification information, and a second correspondence relationship between the identification information and the target value; prewriting the identification information, the target key, the target value, and the first and second correspondence relationships into a log; when an application side accesses the target data, writing the target key, the identification information, and the first correspondence relationship to the application side, the identification information being used by the application side to find the target value from the log. 2.The method of claim 1, wherein the generating unique identification information for the target key-value pair comprises: generating a time stamp at a target time as the identification information for the target key-value pair. 3.The method of claim 2, wherein the target time is before the separating of the key and the value in the target key-value pair. 4.The method of claim 1, wherein the generating unique identification information for the target key-value pair comprises: determining a unique number corresponding to the target key-value pair as the identification information for the target key-value pair according to a preset numbering rule. 5.The method of any one of claims 1-4, wherein the establishing the first correspondence relationship between the target key and the identification information, and the second correspondence relationship between the identification information and the target value comprises: taking the identification information as a new value corresponding to the target key to obtain a first key-value pair, the first key-value pair being used to represent the first correspondence relationship; taking the identification information as a new key corresponding to the target value to obtain a second key-value pair, the second key-value pair being used to represent the second correspondence relationship. 6.A data storage method, comprising: generating unique identification information for a target key-value pair corresponding to target data to be stored, and prewriting the target key-value pair and the identification information into a log; when an application side accesses the target data, separating a key and a value in the target key-value pair to obtain a target key and a target value, and establishing a first correspondence relationship between the target key and the identification information. ​ ​ ​ ​ ​ ​ write the target keyword, the identification information and the first corresponding relationship to the application side, the identification information being used by the application side to find the target value from the log.

7. The method of claim 6, wherein the generating of the unique identification information corresponding to the target key-value pair of the target data to be stored comprises: generating a time stamp as the identification information of the target key-value pair at a target time.

8. The method of claim 7, wherein the target time is before a time when the target key-value pair is pre-written into the log.

9. The method of claim 6, wherein the generating of the unique identification information corresponding to the target key-value pair of the target data to be stored comprises: determining a unique number corresponding to the target key-value pair as the identification information of the target key-value pair according to a preset numbering rule.

10. The method of any one of claims 6-9, wherein the establishing of the first corresponding relationship between the target keyword and the identification information comprises: taking the identification information as a new value corresponding to the target keyword to obtain a first key-value pair, the first key-value pair being used to represent the first corresponding relationship.

11. A data storage apparatus, comprising: a separation unit configured to separate a keyword and a value in a target key-value pair corresponding to target data to be stored to obtain a target keyword and a target value; a generation unit configured to generate unique identification information for the target key-value pair, and to establish a first corresponding relationship between the target keyword and the identification information and a second corresponding relationship between the identification information and the target value; a pre-writing unit configured to pre-write the identification information, the target keyword, the target value, and the first corresponding relationship and the second corresponding relationship into a log; and a writing unit configured to write the target keyword, the identification information and the first corresponding relationship to an application side when the application side accesses the target data, the identification information being used by the application side to find the target value from the log.

12. The apparatus of claim 11, wherein the generation unit is specifically configured to generate a time stamp as the identification information of the target key-value pair at a target time.

13. The apparatus of claim 12, wherein the target time is before a time when the keyword and the value in the target key-value pair are separated.

14. The apparatus of any one of claims 11-13, wherein the generation unit is specifically configured to take the identification information as a new value corresponding to the target keyword to obtain a first key-value pair, the first key-value pair being used to represent the first corresponding relationship. ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ The identification information is taken as a new key corresponding to the target value, to obtain a second key-value pair, the second key-value pair being used to represent the second correspondence relationship; The pre-writing unit is specifically configured to: pre-write the first key-value pair and the second key-value pair into a log; The writing unit is specifically configured to: write the first key-value pair into the application side.

15. A data storage apparatus, the apparatus comprising: a generating unit configured to generate unique identification information for a target key-value pair corresponding to target data to be stored, and pre-write the target key-value pair and the identification information into a log; a separating unit configured to separate a key and a value in the target key-value pair to obtain a target key and a target value, and establish a first correspondence relationship between the target key and the identification information, when an application side accesses the target data; a writing unit configured to write the target key, the identification information, and the first correspondence relationship into the application side, the identification information being used by the application side to find the target value from the log.

16. The apparatus of claim 15, the generating unit is specifically configured to: generate a time stamp as identification information of the target key-value pair, at a target time.

17. The apparatus of claim 15 or 16, the generating unit is specifically configured to: take the identification information as a new value corresponding to the target key, to obtain a first key-value pair, the first key-value pair being used to represent the first correspondence relationship; The writing unit is specifically configured to: write the first key-value pair into the application side.

18. An electronic device, comprising: at least one processor; and a memory connected with the at least one processor in communication; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-5 or the method of any one of claims 6-10.

19. A non-transitory computer-readable storage medium storing computer instructions, the computer instructions being used to cause a computer to perform the method of any one of claims 1-5 or the method of any one of claims 6-10.

20. A computer program product comprising a computer program, the computer program, when executed by a processor, implementing the method of any one of claims 1-5 or the method of any one of claims 6-10.

Citation Information

Patent Citations

  • Data management system employing a hash-based and tree-based key-value data structure

    CN109977111A

  • Data Storage and Query Method

    US20140222778A1