Data storage method, data query method, device and electronic device

By converting the format of the key and value in the key-value pair to generate a target string and storing it, the problems of large system performance loss and high storage cost in the existing technology are solved, and low-cost and efficient data storage and query are achieved.

CN115114298BActive Publication Date: 2025-09-16BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210826527.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-14
Publication Date
2025-09-16
Estimated Expiration
2042-07-14

AI Technical Summary

Technical Problem

In the prior art, when a hash map data structure is used for data storage and query, there are problems of large system performance loss and high storage cost.

Method used

The key and value in the key-value pair to be stored are formatted separately, a target string is generated and stored, and the data storage and query methods are optimized by storing and querying the target string.

Benefits of technology

It reduces the storage cost of key-value pairs, optimizes system performance, and improves the efficiency and accuracy of data queries.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115114298B_ABST
    Figure CN115114298B_ABST
Patent Text Reader

Abstract

This application proposes a data storage method, a data query method, an apparatus, and an electronic device, wherein the method includes: performing a first format conversion on a character sequence of a key in a key-value pair to be stored to obtain a first string of key; performing a first format conversion on a value in the key-value pair to be stored to obtain a second string of value; generating a target string of the key-value pair to be stored based on the first string and the second string, and storing the target string. In this application, the storage cost of key-value pairs is reduced, the data storage method for key-value pairs and the operating performance of the system are optimized, the efficiency and accuracy of data queries are improved, and the data query method is optimized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing, and in particular to a data storage method, a data query method, a device, and an electronic device. Background Art

[0002] With the development of technology, data can be stored and queried in the form of key-value pairs. In related technologies, a hash map data structure can be used to store data, and related query operations can be performed on the stored key-value pairs according to the set query engine, which causes a certain degree of loss in system performance, large resource consumption, and high storage costs. Summary of the Invention

[0003] The present application aims to solve one of the technical problems in the related art at least to a certain extent.

[0004] To this end, the first aspect of the present application proposes a data storage method.

[0005] The second aspect of this application proposes a data query method

[0006] The third aspect of the present application also provides a data storage device.

[0007] The fourth aspect of the present application also proposes a data query device

[0008] In a fifth aspect, the present application proposes an electronic device.

[0009] In a sixth aspect, the present application proposes a computer-readable storage medium.

[0010] The seventh aspect of the present application proposes a computer program product.

[0011] In a first aspect, the present application proposes a data storage method, comprising: performing a first format conversion on a character sequence of a key in a key-value pair to be stored to obtain a first string of the key; performing a first format conversion on a value in the key-value pair to be stored to obtain a second string of the value; generating a target string of the key-value pair to be stored based on the first string and the second string, and storing the target string.

[0012] In addition, the data storage method proposed in the first aspect of the present application may also have the following additional technical features:

[0013] According to one embodiment of the present application, a first format conversion is performed on a character sequence of a key in a key-value pair to be stored to obtain a first string of the key, including: obtaining the first position number of each character in the key in the corresponding character table, and determining a first substring corresponding to the key according to the first position number of each character; obtaining the number of characters constituting the key, and determining a second substring of the key according to the number of characters; and concatenating the first subcharacter and the second substring in a first order to obtain the first string corresponding to the key.

[0014] According to one embodiment of the present application, the first substring corresponding to the key is obtained based on the first position number of each character, including: obtaining the first initial substring of the key, and determining the character position number in the first initial substring that matches the first position number as the second position number; marking the character at the position corresponding to the second position number as the first set value, marking the characters at the remaining positions as the second set value, and using the marked string as the first substring corresponding to the key.

[0015] According to one embodiment of the present application, obtaining the number of characters constituting the key and generating a second substring of the key based on the number of characters includes: obtaining the value of the number of characters and performing a first format conversion to obtain a string as the second substring of the key.

[0016] According to one embodiment of the present application, a first format conversion is performed on the value value in the key-value pair to be stored to obtain a second string of value, including: in response to the value of value being an integer, obtaining the string after the value is converted to the first format as the second string of value; in response to the value of value being a non-integer, converting the non-integer value of value to obtain an integer value corresponding to value, and obtaining the string after the integer value is converted to the first format as the second string of value.

[0017] According to one embodiment of the present application, a target string of key-value pairs to be stored is generated based on a first string and a second string, including: obtaining a string obtained by concatenating the first string and the second string in a second order as the target string of the key-value pairs to be stored.

[0018] According to one embodiment of the present application, a target string of a key-value pair to be stored is generated based on a first string and a second string, including: converting a string obtained by concatenating the first string and the second string in a second order into a second format, and using the string obtained by the conversion as the target string of the key-value pair to be stored.

[0019] According to one embodiment of the present application, the first format is binary and the second format is decimal.

[0020] According to an embodiment of the present application, storing the target string includes: storing the target string in a set storage area, and forming a corresponding key-value pair string set with other key-value pair strings to be stored in the set storage area.

[0021] According to an embodiment of the present application, a key is generated by combining characters in a character table, wherein among multiple first keys having the same number of characters, different characters must exist in the character sequences of any two first keys.

[0022] The second aspect of the present application proposes a data query method, which includes: obtaining a character sequence of a key to be queried, and performing a first format conversion on the character sequence to obtain a query string of the key to be queried; obtaining a target string that matches the query string in a key-value pair string set; and determining a target value corresponding to the key to be queried based on the target string.

[0023] In addition, the data query method proposed in the second aspect of this application may also have the following additional technical features:

[0024] According to one embodiment of the present application, a character sequence of a key to be queried is obtained, and a first format conversion is performed on the character sequence to obtain a query string of the key to be queried, including: obtaining the first position number of each character in the key to be queried in the character table, and obtaining a first substring of the key to be queried according to the first position number; obtaining a second substring corresponding to the key to be queried according to the number of characters in the key to be queried; and concatenating the first subcharacter and the second substring in a first order to obtain a query string corresponding to the key to be queried.

[0025] According to one embodiment of the present application, the first position number of each character in the key to be queried in the character table is obtained, and the first substring of the key to be queried is obtained according to the first position number, including: obtaining the initial substring of the key to be queried, and using the initial position number that matches the first position number in the initial character position number of the initial substring as the target position number; marking the character at the position corresponding to the target position number as a first set value, marking the characters at the remaining positions as a second set value, and using the marked character string as the first substring corresponding to the key to be queried.

[0026] According to one embodiment of the present application, the first sub-character and the second sub-string are concatenated in a first order to obtain a query string corresponding to the key to be queried, including: obtaining a string after the first sub-character and the second sub-string are concatenated in the first order as the query string of the key to be queried.

[0027] According to one embodiment of the present application, the first sub-character and the second sub-string are concatenated in a first order to obtain a query string corresponding to the key to be queried, including: converting the string obtained by concatenating the first sub-character and the second sub-string in the first order into a second format, and using the converted string as the query string corresponding to the key to be queried.

[0028] According to one embodiment of the present application, the first format is binary and the second format is decimal.

[0029] According to one embodiment of the present application, obtaining a target string that matches a query string in a key-value pair string set includes: obtaining a key string set in the key-value pair string set; and determining the key-value pair string in the key string set to which the string identical to the query string belongs as the target string.

[0030] According to one embodiment of the present application, determining the target value corresponding to the key to be queried based on the target string includes: obtaining a value string in the target string; converting the value string into a first format or a second format, and determining the converted value as the target value corresponding to the key to be queried.

[0031] The third aspect of the present application also proposes a data storage device, which includes: a first conversion module, used to perform a first format conversion on the character sequence of the key key in the key-value pair to be stored to obtain a first string of key; the first conversion module is also used to perform a first format conversion on the value value in the key-value pair to be stored to obtain a second string of value; a generation module is used to generate a target string of the key-value pair to be stored based on the first string and the second string, and store the target string.

[0032] In addition, the data storage device provided in the third aspect of the present application may also have the following additional technical features:

[0033] According to one embodiment of the present application, the first conversion module is also used to: obtain the first position number of each character in the key in the corresponding character table, and determine the first substring corresponding to the key based on the first position number of each character; obtain the number of characters that constitute the key, and determine the second substring of the key based on the number of characters; splice the first subcharacter and the second substring in the first order to obtain the first string corresponding to the key.

[0034] According to one embodiment of the present application, the first conversion module is also used to: obtain the first initial substring of the key, and determine the character position number in the first initial substring that matches the first position number as the second position number; mark the characters at the position corresponding to the second position number as the first set value, mark the characters at the remaining positions as the second set value, and use the marked string as the first substring corresponding to the key.

[0035] According to one embodiment of the present application, the first conversion module is further used to: obtain the value of the number of characters and perform first format conversion to obtain a string as the second substring of the key.

[0036] According to one embodiment of the present application, the first conversion module is also used to: in response to the value of value being an integer, obtain the string after value is converted to the first format as the second string of value; in response to the value of value being a non-integer, convert the non-integer value of value to obtain the integer value corresponding to value, and obtain the string after the integer value is converted to the first format as the second string of value.

[0037] According to one embodiment of the present application, the generation module is further used to: obtain a string obtained by concatenating the first string and the second string in a second order as a target string for storing the key-value pair.

[0038] According to one embodiment of the present application, the generation module is further used to: convert the string obtained by concatenating the first string and the second string in a second order into a second format, and use the string obtained by the conversion as the target string of the key-value pair to be stored.

[0039] According to one embodiment of the present application, the first format is binary and the second format is decimal.

[0040] According to one embodiment of the present application, the generating module is further configured to: store the target character string in a set storage area, and form a corresponding key-value pair character string set with other key-value pair character strings to be stored in the set storage area.

[0041] According to an embodiment of the present application, a key is generated by combining characters in a character table, wherein among multiple first keys having the same number of characters, different characters must exist in the character sequences of any two first keys.

[0042] The fourth aspect of the present application also proposes a data query device, which includes: a second conversion module, used to obtain a character sequence of the key to be queried, and perform a first format conversion on the character sequence to obtain a query string of the key to be queried; a query module, used to obtain a target string that matches the query string in a key-value pair string set; and a determination module, used to determine a target value corresponding to the key to be queried based on the target string.

[0043] In addition, the data query device proposed in the fourth aspect of this application may also have the following additional technical features:

[0044] According to one embodiment of the present application, the second conversion module is also used to: obtain the first position number of each character in the key to be queried in the character table, and obtain the first substring of the key to be queried based on the first position number; obtain the second substring corresponding to the key to be queried based on the number of characters in the key to be queried; and concatenate the first subcharacter and the second substring in a first order to obtain the query string corresponding to the key to be queried.

[0045] According to one embodiment of the present application, the second conversion module is also used to: obtain the initial substring of the key to be queried, and use the initial position number in the initial character position number of the initial substring that matches the first position number as the target position number; mark the characters at the position corresponding to the target position number as the first set value, mark the characters at the remaining positions as the second set value, and use the marked character string as the first substring corresponding to the key to be queried.

[0046] According to one embodiment of the present application, the second conversion module is further used to: obtain a string obtained by concatenating the first sub-character and the second sub-string in a first order as a query string for the key to be queried.

[0047] According to one embodiment of the present application, the second conversion module is further used to: convert the string obtained by concatenating the first sub-character and the second sub-string in the first order into a second format, and use the string obtained by the conversion as the query string corresponding to the key to be queried.

[0048] According to one embodiment of the present application, the first format is binary and the second format is decimal.

[0049] According to an embodiment of the present application, the query module is further configured to: obtain a key string set in the key-value pair string set; and determine the key-value pair string in the key string set to which the string identical to the query string belongs as the target string.

[0050] According to one embodiment of the present application, the determination module is further used to: obtain a value string in the target string; convert the value string into the first format or the second format, and determine the converted value as the target value corresponding to the key to be queried.

[0051] In the fifth aspect of the present application, an electronic device is proposed, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the data storage method proposed in the first aspect and the data query method proposed in the second aspect.

[0052] The fourth aspect of the present application proposes a computer-readable storage medium, wherein the computer instructions are used to enable the computer to execute the data storage method proposed in the first aspect and the data query method proposed in the second aspect.

[0053] In a fifth aspect, the present application proposes a computer program product, including a computer program, which, when executed by a processor, implements the data storage method proposed in the first aspect and the data query method proposed in the second aspect.

[0054] The data storage method, data query method, and device proposed in the present application respectively perform a first format conversion on the key and value in the key-value pair to be stored, respectively obtain a first character string corresponding to the key and a second character string corresponding to the value of the value, and then generate a target character string for the key-value pair to be stored, and store the target character string in a set storage area. Furthermore, based on the key-value pair string set in the storage area, the query character string of the key to be queried is compared with the character strings in the key-value pair string set, so as to obtain a target character string that matches the query character string, and obtain the target value corresponding to the key to be queried from the target character string. In the present application, the content and number of the character sequence of the key are simultaneously used as the identification information of the key, which strengthens the unique identification of the key. By storing the target character string, the storage of the key-value pair to be stored is realized, the storage space occupied by the key-value pair is reduced, the storage cost of the key-value pair is reduced, the data storage method of the key-value pair is optimized, the loss of system performance caused by the storage of the key-value pair is reduced, and the operating performance of the system is optimized. By using the query string corresponding to the key to be queried to query the key-value pair string set, the accuracy of obtaining the target string is improved, the efficiency and accuracy of the data query are improved, and the data query method is optimized.

[0055] It should be understood that the content described in this application is not intended to identify the key or important features of the embodiments of this application, nor is it intended to limit the scope of this application. Other features of this application will become easy to understand through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:

[0057] Figure 1 A flowchart of a data storage method according to an embodiment of the present application;

[0058] Figure 2 This is a flowchart of a data storage method according to another embodiment of the present application;

[0059] Figure 3 This is a flowchart of a data storage method according to another embodiment of the present application;

[0060] Figure 4 This is a flowchart of a data storage method according to another embodiment of the present application;

[0061] Figure 5 This is a flowchart of a data storage method according to another embodiment of the present application;

[0062] Figure 6 This is a flowchart of a data storage method according to another embodiment of the present application;

[0063] Figure 7 This is a flow chart of a data query method according to an embodiment of the present application;

[0064] Figure 8 This is a flow chart of a data query method according to another embodiment of the present application;

[0065] Figure 9 This is a flow chart of a data query method according to another embodiment of the present application;

[0066] Figure 10 This is a structural diagram of a data storage device according to an embodiment of the present application;

[0067] Figure 11 This is a structural diagram of a data query device according to an embodiment of the present application;

[0068] Figure 12 This is a schematic structural diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0069] The following describes in detail embodiments of the present application, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.

[0070] The data storage method, data query method, device, and electronic device according to the embodiments of the present application are described below with reference to the accompanying drawings.

[0071] Figure 1 This is a flow chart of a data storage method according to an embodiment of the present application. Figure 1 As shown, the method includes:

[0072] S101 , performing a first format conversion on a character sequence of a key in a key-value pair to be stored to obtain a first character string of the key.

[0073] In implementation, data that meets the set conditions can be stored in the form of key-value pairs, where the data with unique identification is used as the key in the key-value pair, and the data mapped by the key is used as the value in the key-value pair.

[0074] For example, if data A and data B meet the set conditions for storage as a key-value pair, where data A has unique identification, then data A can be used as the key in the key-value pair, and data B can be used as the value in the key-value pair.

[0075] It should be noted that there is a mapping relationship between the key and value in the key-value pair.

[0076] In some implementations, the character sequence included in the key and the character sequence included in the value of the key-value pair to be stored may be different types of characters. For example, the character sequence included in the key may be letters, symbols, or a combination of letters and symbols, and the character sequence included in the value may be numbers, words, or a combination of numbers and words.

[0077] Therefore, the key and value can be processed based on the set conversion method, and the key and value can be converted into strings stored in the same format, so that the key and value can be stored in the same string.

[0078] Optionally, the key can be converted to a set format, and the format can be determined as the first format for the key to be converted. Further, after the key is converted to the first format according to the first format, the obtained string can be used as the first string corresponding to the key in the first format.

[0079] For example, if the first format is set to hexadecimal format, the characters constituting the key can be converted into hexadecimal, the string corresponding to the key in hexadecimal can be obtained, and it can be determined as the first string obtained after the key is converted based on the first hexadecimal format.

[0080] S102: Perform a first format conversion on the value of the key-value pair to be stored to obtain a second character string of value.

[0081] In an embodiment of the present application, in order to ensure that the value value in the key-value pair to be stored can be stored in the same string as the key key, the value value can be converted into a set format based on the first format converted by the key key.

[0082] Furthermore, the value of value is converted into the first format, and the character string obtained after the conversion is used as the second character string obtained after the value of value is converted into the first format.

[0083] For example, if the first format for conversion of the key key is set to hexadecimal, the value of value value can be converted into hexadecimal, and the converted string of the value value value is obtained as the second string corresponding to the value value.

[0084] S103: Generate a target character string of a key-value pair to be stored according to the first character string and the second character string, and store the target character string.

[0085] In the embodiment of the present application, the first string and the second string are strings obtained after the key key and the value value in the key-value pair to be stored are converted based on the same first format. The first string and the second string can be integrated based on a setting method.

[0086] Optionally, the first character string and the second character string may be combined, and the character string obtained after the combination is used as a target character string for storing the key-value pair, and the target character string is stored in a set location.

[0087] Optionally, the first character string and the second character string may be further processed based on the setting method, and a target character string for storing the key-value pair may be determined according to the result of the data processing, and the target character string may be stored in a set location.

[0088] In some implementations, the target character strings may be stored based on a set order, which is not limited here.

[0089] The data storage method proposed in the present application performs a first format conversion on the key and value in the key-value pair to be stored, respectively, and obtains a first string corresponding to the key and a second string corresponding to the value of the value. Further, based on the obtained first and second strings, a target string corresponding to the key-value pair to be stored is obtained and stored. In the present application, by setting a format conversion, the key and value in the key-value pair to be stored are converted to the same target string. The storage of the key-value pair to be stored is achieved by storing the target string, which reduces the storage space occupied by the key-value pair, reduces the storage cost of the key-value pair, optimizes the data storage method of the key-value pair, reduces the loss of system performance caused by the storage of the key-value pair, and optimizes the operating performance of the system.

[0090] In the above embodiment, the first character string of the key in the key-value pair to be stored can be obtained by combining Figure 2 Further understanding, Figure 2 This is a flow chart of a data storage method according to another embodiment of the present application. Figure 2 As shown, the method includes:

[0091] S201 , obtaining the first position number of each character in the key in the corresponding character table, and determining the first substring corresponding to the key according to the first position number of each character.

[0092] In some implementations, to ensure unique identification of each key, a character sequence included in the key and the number of characters in the character sequence may be combined to serve as unique identification information for the key. The character sequence included in the key and the number of characters in the character sequence may be converted to a first format to generate a corresponding first character string.

[0093] Among them, the string obtained after the character sequence in the key is converted into the first format can be used as the first substring, and the string obtained after the number of characters corresponding to the character sequence in the key is converted into the first format can be used as the second substring. The first string of the key is generated by the first substring and the second substring.

[0094] In an embodiment of the present application, the key in the key-value pair to be stored has a set character table, and the character sequence constituting the key is generated by a combination of characters in the character table. The character sequence included in the key can be converted to a first format according to the set character table, thereby obtaining the first substring corresponding to the key.

[0095] Optionally, the number of positions of the first substring may be limited, and a blank string after the limited number may be determined as the first initial substring of the key key.

[0096] Furthermore, a character position number that matches the first position number may be determined from the position numbers of the first initial substring as the second position number.

[0097] In the embodiment of the present application, in the character table corresponding to the key, there is a corresponding character number for the position of each character. Since the key is generated by a combination of characters in the character table, each character in the character sequence that constitutes the key can determine its corresponding position number in the character table.

[0098] The position number of the character in the key key in the character table may be determined as the first position number of the key key.

[0099] For example, if the key is set to bbcc, then Figure 3 As can be seen from the character table shown, the position number of character b in the character table is 1, and the position number of character c in the character table is 2. The first position numbers corresponding to the key composed of bbcc are position number 1 and position number 2.

[0100] Correspondingly, in the first initial string of the key key, each position that can store a character has a corresponding position number, and the position number matching the first position number can be obtained from the position numbers of the first initial string as the second position number corresponding to the key key.

[0101] Optionally, the position number in the position number of the first initial substring that is the same as the first position number may be determined as the second position number.

[0102] For example, if key1 is set to cbcc, then according to Figure 3 It can be seen from the character table shown that the position number of character c in the character sequence included in the key key1 is 2 in the character table, and the position number of character b in the character table is 1. The first position number of the key key determines the position number 1 and the position number 2. The position numbers 1 and 2 in the first initial character string can be determined as the second position numbers that match the first position number.

[0103] Furthermore, the first substring corresponding to the key key is generated by marking the characters at the position corresponding to the second position number with relevant set values.

[0104] The character at the position corresponding to the second position number may be marked as the first set value, and the characters at the remaining positions may be marked as the second set value.

[0105] In some implementations, the first format of the key conversion may be set to a binary format. In this scenario, the first set value may be determined to be 1, and the second set value may be determined to be 0.

[0106] Furthermore, the characters at the positions corresponding to the second position number in the first initial substring are marked as 1, and the characters at the remaining positions are marked as 0, thereby generating a binary string corresponding to the character sequence of the key key and using it as the first substring of the key key.

[0107] For example, set the key to ccbfg, the first initial string is a 48-bit blank string, and then Figure 3 As can be seen from the character table shown, the first position number of character c is 2, the first position number of character b is 1, the first position number of character f is 5, and the first position number of character g is 6.

[0108] Then the second position numbers where the first initial character string matches the first position number are position number 1, position number 2, position number 5, and position number 6.

[0109] Optionally, the low bit of the first initial character string can be used as the starting bit, and starting from the low bit, the characters at position number 1, position number 2, position number 5, and position number 6 are marked as the first set value 1, and the characters at the remaining positions are marked as the second set value 0. Then, after binary conversion of the key composed of ccbfg, the binary substring obtained is 0000000000000000 000000000 000000000 000000000 01100110, and this string is used as the first substring corresponding to the key composed of ccbfg.

[0110] S202: Obtain the number of characters constituting the key, and determine a second substring of the key according to the number of characters.

[0111] In an embodiment of the present application, the key in the key-value pair to be stored exists in a set character table, and the character sequence constituting the key is generated by combining characters in the character table. The key that meets the set conditions and its mapped value can be converted into the first format.

[0112] The set condition that the key needs to meet may include that among multiple first keys with the same number of characters, the character sequences of any two first keys must contain different characters.

[0113] It can be understood that any two keys generated according to the character table with the same number of characters cannot coexist if they contain the same characters.

[0114] For example, set the key key to consist of the character sequence x1,x2,x3,...,x n Composition, of which

[0115] x i∈{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,0,1,2,3,4,5,6,7,8,9,_}.

[0116] Among them, key key1 is characters b and c in the character table, and a character sequence of 4 characters is composed of a set order. Then a character sequence of 4 characters composed of characters b and c based on other orders cannot coexist as key with key key1.

[0117] It can be understood that when key1 is cbcc, character sequences consisting of 4 characters, such as bccc and bbcc, consisting of the characters b and c, cannot coexist with key1 as other keys.

[0118] Therefore, the unique identification information of the key may include the number of characters included in the character sequence constituting the key.

[0119] Furthermore, the number of characters in the character sequence constituting the key key is obtained, the value of the number of characters is converted into a first format, and the character string obtained after the conversion is used as the second substring of the key key.

[0120] For example, for a key composed of the ccbfg character sequence, the value of the number of characters is 5. If the first format is set to binary, the value of the number of characters 5 can be converted into a binary string 00000101 and determined as the second substring of the key composed of the ccbfg character sequence.

[0121] S203: Concatenate the first sub-character and the second sub-character string in a first order to obtain a first character string corresponding to the key.

[0122] In implementation, the first substring and the second substring have a set concatenation order, and the concatenation order can be determined as the first order.

[0123] The first substring and the second substring are concatenated based on a set first order, and the concatenated string is the first string corresponding to the key key.

[0124] For example, based on the above example, the first substring of the key composed of the ccbfg character sequence is set to 00000000 00000000 00000000 00000000 01100110, and the second substring of the key is 00000101. Figure 4As shown, the first substring is concatenated with the second substring to obtain a binary string 00000101 00000000 00000000 00000000 00000000 000000000 0000000001100110. This binary string is the first string obtained after the key composed of the ccbfg character sequence is converted into binary format.

[0125] The data storage method proposed in the present application obtains a first substring after the character sequence in the key is converted to a first format, and a second substring after the value of the number of characters in the character sequence is converted to a first format. Further, the first substring and the second substring are spliced ​​based on a set first order to generate the first string of the key. In the present application, the character sequence in the key and the number of characters in the character sequence are converted to a first format, and the converted strings are combined to generate the first string of the key. At the same time, the content of the character sequence and the number of characters of the key are used as the identification information of the key, which strengthens the unique identification of the key, provides strong identification support for the subsequent data storage method of converting and combining the key and value into the same string for storage, and optimizes the storage method of key-value pairs.

[0126] In the above embodiment, the second character string of the value value in the key-value pair to be stored can be obtained by combining Figure 5 Further understanding, Figure 5 This is a flow chart of a data storage method according to another embodiment of the present application. Figure 5 As shown, the method includes:

[0127] S501 : Perform a first format conversion on the value of the key-value pair to be stored to obtain a second character string of value.

[0128] In some implementations, the value of a key-value pair to be stored may be a non-integer value. To convert the key and value of the key-value pair to a single string for storage, the value of the value may be identified and a setting method may be applied to the value identified as a non-integer value.

[0129] In a scenario where the value is an integer, in response to the value being an integer, a character string after the value is converted into the first format is obtained as the second character string of the value.

[0130] Optionally, for value whose value is an integer, it can be directly converted into the first format, so as to obtain the string corresponding to the value of value in the first format as the second string of value.

[0131] For example, if the value in the key-value pair to be stored is 5 and the first format is binary format, the value 5 can be converted into binary format to generate a string 00000101 of 5 in binary format, and this string is used as the second string of value.

[0132] Accordingly, in the scenario where the value of value is a non-integer, in response to the value of value being a non-integer, the non-integer value of value is converted to obtain the integer value corresponding to value, and the string after the integer value is converted to the first format is obtained as the second string of value.

[0133] In an embodiment of the present application, the non-integer value of value can be calculated based on a set algorithm to generate an integer value corresponding to the non-integer value of value, and the obtained integer value can be converted into a first format to generate a second string corresponding to value.

[0134] It should be noted that value can be a floating-point data type (float). When value is a float data type value, its corresponding value range is [-10, 10]. value can also be an int data type. When value is an int data type value, its corresponding value range is [0, 128]. This is not limited here.

[0135] For example, you can set the value of value to -3.7, and then calculate the value of value -3.7 based on the set algorithm to obtain the integer value corresponding to -3.7.

[0136] Optionally, you can convert the value -3.7 by multiplying it by 10 and rounding it to one decimal place or rounding it to the nearest integer, which is in the range [-128, 128] that can be represented by an 8-bit string. Furthermore, add 128 to each number in the range to generate the range [0, 256] where no negative numbers exist. This is used as the integer range obtained after the conversion calculation of the value -3.7.

[0137] It can be understood that -3.7 is calculated as -3.7 × 10 + 128, and the result of this calculation is 91. Then 91 is the integer value corresponding to the non-integer value of -3.7 calculated based on the set algorithm in this example.

[0138] Furthermore, the integer value corresponding to the non-integer value of value may be converted into the first format, and the character string obtained after the conversion may be used as the second character string of value.

[0139] For example, based on the above example, the non-integer value of value -3.7 corresponds to an integer value of 91. If the first format is set to binary, 91 is converted to binary format to obtain the binary string 01100110 of 91. This binary string can be determined as the second string of value.

[0140] The data storage method proposed in this application converts the value of the key-value pair to be stored into a first format, obtains a second string corresponding to the value, provides support for the subsequent conversion of the key key and value value in the key-value pair to be stored into the same string, and optimizes the storage method of the key-value pair.

[0141] In the above embodiment, the acquisition and storage of the target string of the key-value pair to be stored can be combined with Figure 6 Further understanding, Figure 6 This is a flow chart of a data storage method according to another embodiment of the present application. Figure 6 As shown, the method includes:

[0142] S601: Generate a target character string for storing key-value pairs according to a first character string and a second character string.

[0143] In an embodiment of the present application, the first character string and the second character string may be concatenated based on a set order, wherein the set concatenation order between the first character string and the second character string may be determined as a second order, and the first character string and the second character string may be concatenated in the second order.

[0144] Optionally, a string obtained by concatenating the first string and the second string in the second order may be obtained as a target string for storing the key-value pair.

[0145] The second order can be as follows Figure 4 As shown, the second character string can be concatenated with the first character string, and the concatenated character string is used as the target character string for storing the key-value pair.

[0146] For example, for the key-value pair ccbfg,-3.7 to be stored, the first format is set to binary. From the above example, we can see that the first string corresponding to the key in the key-value pair is 00000101 00000000 00000000 0000000000000000000000000 00000000 01100110, and the second string of the value is 01100110. Based on Figure 4 The second order shown concatenates the two, and the concatenated string is 00000101 000000000 00000000000000000000000000 000000000 0110011 01100110, which can be determined as the target string for storing the key-value pair ccbfg,-3.7.

[0147] In other implementations, the string obtained by concatenating the first string and the second string in the second order may be converted into a second format, and the string obtained by the conversion may be used as the target string of the key-value pair to be stored.

[0148] In an embodiment of the present application, the string obtained after the key-value pair to be stored is converted to the first format may have more characters than the set value. The string spliced ​​after the first format conversion can be converted to another set format and the format can be determined as the second format.

[0149] Furthermore, the string obtained by concatenating the first string and the second string in the second order may be converted into a second format, and the string obtained after the conversion into the second format may be determined as a target string for storing the key-value pair.

[0150] For example, if the second format is set to decimal, based on the above example, for the key-value pair to be stored ccbfg,-3.7, the corresponding first string and second string are based on Figure 4 After the second sequence concatenation shown, a binary string 00000101 00000000 00000000 00000000 00000000 00000000 011001101100110 is obtained. The binary string can be converted into decimal format to obtain a decimal string 360287970189665883. The decimal string can be determined as the target string corresponding to the key-value pair ccbfg,-3.7.

[0151] It should be noted that there are position limitations for the target string. In the scenario where the first format is binary format, the target string can be set to 64 bits. In the scenario where the second format is decimal format, the target string can be set to 18 character positions.

[0152] S602: Store the target character string into a set storage area, and form a corresponding key-value pair character string set with other key-value pair character strings to be stored in the set storage area.

[0153] In an embodiment of the present application, the target character string of the key-value pair to be stored can be stored in a set storage area.

[0154] In some implementations, it may be necessary to perform related storage processing on a large number of key-value pairs to be stored, and store the target string of each key-value pair to be stored in a predetermined storage area.

[0155] Optionally, the target character strings obtained based on the key-value pair storage method proposed in the embodiment of the present application can be stored in the same storage area.

[0156] Among them, the target strings stored in the storage area are all obtained based on the conversion of the same format. Therefore, the string set composed of the target strings stored in the storage area can be determined as the key-value pair string set corresponding to the key-value pairs to be stored.

[0157] The data storage method proposed in this application concatenates a first string and a second string based on a set concatenation order to generate a target string for a key-value pair to be stored. Furthermore, the target string is stored in a set storage area and, together with the target strings of other key-value pairs in the storage area, forms a corresponding set of key-value pair strings. In this application, the storage of the key-value pairs to be stored is achieved by storing the target string, thereby reducing the storage cost of the key-value pairs, avoiding the loss of system performance caused by the storage of key-value pairs, and optimizing the storage method for key-value pairs.

[0158] The data storage method proposed in the above embodiment can realize low-cost storage of key-value pairs and generate a corresponding key-value pair string set. Furthermore, related data query operations can be implemented based on the key-value pair string set. Figure 7 understand, Figure 7 This is a flow chart of a data query method according to an embodiment of the present application. Figure 7 As shown, the method includes:

[0159] S701: Obtain a character sequence of a key to be queried, and perform a first format conversion on the character sequence to obtain a query string of the key to be queried.

[0160] In the implementation, after the data is stored in the form of key-value pairs, the data query of the value in the key-value pair can be realized through the key with unique identification in the key-value pair.

[0161] In the embodiment of the present application, the key-value pair strings in the storage area are based on Figures 1 to 6 The related storage operations performed by the method proposed in the illustrated embodiment can therefore be implemented by performing corresponding processing on the query key through the data processing method performed during data storage, thereby realizing data query based on a key-value pair string set.

[0162] Optionally, the character sequence of the key to be queried may be converted into the first format, and the character string obtained after the conversion may be used as the query character string of the key to be queried.

[0163] S702: Obtain a target string that matches the query string in the key-value pair string set.

[0164] In an embodiment of the present application, the query string can be compared with the characters in the key-value pair string set. Based on the comparison result, the key-value pair string that matches the query string is determined from the key-value pair string set and is determined as the target string of the key to be queried.

[0165] Optionally, the key-value pair string set may be queried based on a binary query method, or other methods may be used, which are not limited here.

[0166] S703: Determine the target value corresponding to the key to be queried based on the target character string.

[0167] In the embodiment of the present application, a key-value pair string is determined as a target string of the key to be queried, which carries the value of the target value indicated by the key to be queried.

[0168] Furthermore, relevant data processing can be performed on the target string to obtain a string of a set format corresponding to the value of the target value indicated by the key to be queried, and the string is converted into the set format to obtain the value corresponding to the string.

[0169] The obtained value can be determined as the target value corresponding to the key to be queried.

[0170] The data query method proposed in this application compares the query string of the key to be queried with the strings in the key-value pair string set based on the key-value pair string set in the storage area, thereby obtaining a target string that matches the query string. Furthermore, the target value corresponding to the key to be queried is obtained from the target string. In this application, data is queried against the key-value pair string set using the query string corresponding to the key to be queried, thereby improving the accuracy of obtaining the target string, determining the target value of the key to be queried based on the target string, improving the efficiency and accuracy of data query, and optimizing the data query method.

[0171] In the above embodiment, the generation of the query string and the acquisition of the target value can be combined with Figure 8 Further understanding, Figure 8 This is a flow chart of a data query method according to another embodiment of the present application. Figure 8 As shown, the method includes:

[0172] S801: Obtain a character sequence of a key to be queried, and perform a first format conversion on the character sequence to obtain a query character string of the key to be queried.

[0173] In an embodiment of the present application, when storing the key to be stored in the key-value pair to be stored, the character sequence included in the key to be stored and the number of characters in the character sequence can be converted into the first format respectively, and the two substrings to be stored obtained after the conversion can be spliced ​​to generate a character string for storing the key to be stored.

[0174] Accordingly, the character sequence included in the key to be queried and the number of characters in the character sequence may be converted into the first format respectively, thereby obtaining a query character string of the key to be queried.

[0175] Optionally, the first position number of each character in the key to be queried in the character table is obtained, and the first substring of the key to be queried is obtained according to the first position number.

[0176] In implementation, based on the character table corresponding to the key to be queried, the position number of each character in the character sequence constituting the key to be queried in the character table can be obtained as the first position number of the key to be queried.

[0177] Still in use Figure 3 The character table shown in the figure sets the key to be queried as cbcc. Figure 3 It can be seen that the position number of character b in the character table is 1, and the position number of character c in the character table is 2. Therefore, the first position number corresponding to the key to be queried is position number 1 and position number 2.

[0178] Furthermore, an initial substring of the key to be queried is obtained, and an initial position number in the initial character position numbers of the initial substring that matches the first position number is used as the target position number.

[0179] The substring after the character sequence of the key to be queried is converted into the first format has a set position restriction, and the blank substring after the position restriction can be determined as the initial substring of the key to be queried.

[0180] In the embodiment of the present application, there is a set position number at the position where characters can be stored in the initial substring of the key to be queried, which can be determined as the initial position number of the initial substring.

[0181] A position number matching the first position number may be obtained from the initial position number and determined as the target position number.

[0182] Furthermore, the characters at the position corresponding to the target position number may be marked as a first set value, the characters at the remaining positions may be marked as a second set value, and the marked character string may be used as the first substring corresponding to the key to be queried.

[0183] Optionally, the values ​​of the first setting value and the second setting value may be determined based on the first format.

[0184] In a scenario where the first format is a binary format, the first setting value may be determined to be 1, and the second setting value may be determined to be 0.

[0185] Furthermore, the character at the target position number may be marked as 1, and the characters at the remaining positions may be marked as 0, thereby generating a first substring of the character sequence of the key to be queried for binary format conversion.

[0186] Accordingly, according to the number of characters in the key to be queried, the second substring corresponding to the key to be queried is obtained.

[0187] In an embodiment of the present application, the value of the number of characters in the character sequence included in the key to be queried can be obtained, and the value can be converted into a first format. The character string obtained after the conversion is the second substring of the key to be queried.

[0188] For example, assuming that the key to be queried is still composed of the character sequence ccbfg, in the scenario where the first format is binary format, Figure 3 From the character table shown, we can see that the first substring of the key to be queried is 00000000 0000000000000000000000000 00000000 0110011. The number of characters in the character sequence ccbfg that constitutes the key to be queried is 5. Converting it into binary format yields the binary string 01100110, which is the second substring of the key to be queried.

[0189] Furthermore, the first sub-character and the second sub-character string are concatenated in the first order to obtain a query string corresponding to the key to be queried.

[0190] In order to ensure that the first string of the key to be queried can accurately search for the corresponding target value in the key-value pair string set, the first substring and the second substring can be spliced ​​based on the first order.

[0191] As a possible implementation manner, a string obtained by concatenating the first sub-character and the second sub-character in a first order may be obtained as a query string for the key to be queried.

[0192] In the embodiment of the present application, the setting format of the query string of the key to be queried can be determined according to the setting format of the string in the key-value pair string set.

[0193] When the string in the key-value pair string set is a string in the first format, the first substring and the second substring may be concatenated based on a set order, and the concatenated string may be used as a query string for the key to be queried.

[0194] As another possible implementation, the string obtained by concatenating the first sub-character and the second sub-string in the first order is converted into the second format, and the string obtained by the conversion is used as the query string corresponding to the key to be queried.

[0195] In an embodiment of the present application, the string to be stored for the key-value pair may be a string that is converted to the second format after the first format conversion. In this scenario, the character obtained by concatenating the first sub-character and the second sub-string may be converted to the second format, and the string after the second format conversion may be determined as the query string of the key to be queried.

[0196] Optionally, the first format may be binary and the second format may be decimal.

[0197] S802: Obtain a target string that matches the query string in the key-value pair string set.

[0198] Furthermore, the key-value pair string set can be queried based on the set method, and then the target string that matches the query string can be obtained therefrom.

[0199] Here, a key string set in the key-value pair string set may be obtained, and the key-value pair string to which the string identical to the query string belongs in the key string set may be determined as the target string.

[0200] Optionally, a query may be performed based on a set method, such as a binary query method.

[0201] In an embodiment of the present application, the key-value pair strings in the key-value pair string set can be divided into key strings and value strings, wherein the string corresponding to the key key in the key-value pair corresponding to the key-value pair string can be determined as the key string, and the string corresponding to the value value can be determined as the value string.

[0202] Furthermore, a set consisting of key character strings in the key-value pair set may be determined as a key character string set.

[0203] Optionally, the query string may be compared with key strings in the key string set, a key string matching the query string may be determined based on the comparison result, and the key-value pair string to which the key string belongs may be determined as a target string matching the query string.

[0204] S803: Determine the target value corresponding to the key to be queried based on the target character string.

[0205] In the embodiment of the present application, since the key-value pair string can be divided into a key string and a value string, after determining the target string, the value string in the target string can be obtained.

[0206] Optionally, the key string can be filtered from the target string and the filtered string can be used as the value string.

[0207] Optionally, the key-value pair corresponding to the target string can be obtained to determine the value string therein.

[0208] Furthermore, the value character string is converted into the first format or the second format, and the converted value is determined as the target value corresponding to the key to be queried.

[0209] As a possible implementation method, when the target string is a key-value pair string stored based on the first format conversion, the obtained value string can be converted to the first format to obtain the value corresponding to the value string, and the value is determined as the value of the target value corresponding to the key to be queried.

[0210] As another possible implementation method, when the target string is a key-value pair string stored based on the second format conversion, the obtained value string can be converted to the second format to obtain the value corresponding to the value string, and the value is determined as the value of the target value corresponding to the key to be queried.

[0211] The data query method proposed in this application obtains a query string corresponding to a key to be queried, and based on the query string, obtains a matching target string from a set of key-value pair strings. Furthermore, the target value corresponding to the key to be queried is determined based on the target string. In this application, data is queried against a set of key-value pair strings using the query string corresponding to the key to be queried, thereby improving the accuracy of obtaining the target string and determining the target value of the key to be queried based on the target string. This improves the efficiency and accuracy of data queries and optimizes the data query method.

[0212] To better understand the above embodiments, Figure 9 , Figure 9 This is a flow chart of a data storage method and a data query method according to an embodiment of the present application. Figure 9 As shown, the method includes:

[0213] The key and value in the key-value pair to be stored are respectively converted to the first format, and the first string corresponding to the key and the second string corresponding to the value are respectively obtained. Furthermore, the first string and the second string are spliced ​​based on the set splicing order to generate the target string of the key-value pair to be stored, and the target string is stored in the set storage area to form a corresponding key-value pair string set with the target strings of other key-value pairs in the storage area. Furthermore, based on the key-value pair string set in the storage area, the query string of the key to be queried is compared with the strings in the key-value pair string set to obtain a target string that matches the query string. Furthermore, the target value corresponding to the key to be queried is obtained from the target string.

[0214] In this application, by setting a format conversion, the key and value in the key-value pair to be stored are converted to the same target string, wherein the content and number of characters of the key character sequence are used as the identification information of the key, thereby strengthening the unique identification of the key. By storing the target string, the key-value pair to be stored is stored, which reduces the storage space occupied by the key-value pair, reduces the storage cost of the key-value pair, optimizes the data storage method of the key-value pair, reduces the loss of system performance caused by the storage of the key-value pair, and optimizes the operating performance of the system. By performing data query on the key-value pair string set through the query string corresponding to the key to be queried, the accuracy of obtaining the target string is improved, the target value of the key to be queried is determined based on the target string, the efficiency and accuracy of data query are improved, and the data query method is optimized.

[0215] Corresponding to the data storage methods proposed in the above-mentioned embodiments, an embodiment of the present application also proposes a data storage device. Since the data storage device proposed in the embodiment of the present application corresponds to the data storage methods proposed in the above-mentioned embodiments, the implementation method of the above-mentioned data storage method is also applicable to the data storage device proposed in the embodiment of the present application and will not be described in detail in the following embodiments.

[0216] Figure 10 This is a structural diagram of a data storage device according to an embodiment of the present application. Figure 10 As shown, the data storage device 100 includes a first conversion module 11 and a generation module 12, wherein:

[0217] The first conversion module 11 is configured to perform a first format conversion on a character sequence of a key in a key-value pair to be stored, to obtain a first character string of the key; and

[0218] Perform a first format conversion on the value of the key-value pair to be stored to obtain a second string of value;

[0219] The generating module 12 is configured to generate a target character string of a key-value pair to be stored according to the first character string and the second character string, and store the target character string.

[0220] In an embodiment of the present application, the first conversion module 11 is also used to: obtain the first position number of each character in the key in the corresponding character table, and determine the first substring corresponding to the key based on the first position number of each character; obtain the number of characters that constitute the key, and determine the second substring of the key based on the number of characters; splice the first subcharacter and the second substring in the first order to obtain the first string corresponding to the key.

[0221] In an embodiment of the present application, the first conversion module 11 is also used to: obtain the first initial substring of the key, and determine the character position number in the first initial substring that matches the first position number as the second position number; mark the character at the position corresponding to the second position number as the first set value, mark the characters at the remaining positions as the second set value, and use the marked string as the first substring corresponding to the key.

[0222] In the embodiment of the present application, the first conversion module 11 is further configured to obtain a character string after performing first format conversion on the value of the number of characters as the second substring of the key.

[0223] In an embodiment of the present application, the first conversion module 11 is further used to: in response to the value of value being an integer, obtain the string after value is converted to the first format as the second string of value; in response to the value of value being a non-integer, convert the non-integer value of value to obtain an integer value corresponding to value, and obtain the string after the integer value is converted to the first format as the second string of value.

[0224] In the embodiment of the present application, the generating module 12 is further configured to obtain a string obtained by concatenating the first string and the second string in a second order as a target string for storing the key-value pair.

[0225] In the embodiment of the present application, the generation module 12 is further used to convert the string obtained by concatenating the first string and the second string in the second order into a second format, and use the string obtained by the conversion as the target string of the key-value pair to be stored.

[0226] In the embodiment of the present application, the first format is binary and the second format is decimal.

[0227] In the embodiment of the present application, the generating module 12 is further configured to store the target character string in a set storage area, and form a corresponding key-value pair character string set with other key-value pair character strings to be stored in the set storage area.

[0228] In the embodiment of the present application, the key is generated by combining characters in a character table, wherein among multiple first keys having the same number of characters, the character sequences of any two first keys must contain different characters.

[0229] The data storage device proposed in the present application performs a first format conversion on the key and value in the key-value pair to be stored, respectively, and obtains a first string corresponding to the key and a second string corresponding to the value of the value. Further, based on the obtained first and second strings, a target string corresponding to the key-value pair to be stored is obtained and stored. In the present application, by setting a format conversion, the key and value in the key-value pair to be stored are converted to the same target string, and the storage of the key-value pair to be stored is achieved by storing the target string, which reduces the storage space occupied by the key-value pair, reduces the storage cost of the key-value pair, optimizes the data storage method of the key-value pair, reduces the loss of system performance caused by the storage of the key-value pair, and optimizes the operating performance of the system.

[0230] Corresponding to the data query methods proposed in the above-mentioned embodiments, an embodiment of the present application also proposes a data query device. Since the data query device proposed in the embodiment of the present application corresponds to the data query methods proposed in the above-mentioned embodiments, the implementation method of the above-mentioned data query method is also applicable to the data query device proposed in the embodiment of the present application, and will not be described in detail in the following embodiments.

[0231] Figure 11 This is a structural diagram of a data storage device according to an embodiment of the present application. Figure 11 As shown, the data query device 200 includes a second conversion module 21, a query module 22, and a determination module 23, wherein:

[0232] The second conversion module 21 is used to obtain a character sequence of the key to be queried, and perform a first format conversion on the character sequence to obtain a query string of the key to be queried;

[0233] A query module 22 is used to obtain a target string matching the query string in the key-value pair string set;

[0234] The determination module 23 is used to determine the target value corresponding to the key to be queried based on the target character string.

[0235] In an embodiment of the present application, the second conversion module 21 is further used to: obtain the first position number of each character in the key to be queried in the character table, and obtain the first substring of the key to be queried based on the first position number; obtain the second substring corresponding to the key to be queried based on the number of characters in the key to be queried; and concatenate the first subcharacter and the second substring in a first order to obtain the query string corresponding to the key to be queried.

[0236] In an embodiment of the present application, the second conversion module 21 is also used to: obtain an initial substring of the key to be queried, and use the initial position number in the initial character position number of the initial substring that matches the first position number as the target position number; mark the characters at the position corresponding to the target position number as the first set value, mark the characters at the remaining positions as the second set value, and use the marked character string as the first substring corresponding to the key to be queried.

[0237] In the embodiment of the present application, the second conversion module 21 is further configured to obtain a string obtained by concatenating the first sub-character and the second sub-string in a first order as a query string for the key to be queried.

[0238] In the embodiment of the present application, the second conversion module 21 is further used to convert the string obtained by concatenating the first sub-character and the second sub-string in the first order into a second format, and use the string obtained by the conversion as the query string corresponding to the key to be queried.

[0239] In the embodiment of the present application, the first format is binary and the second format is decimal.

[0240] In the embodiment of the present application, the query module 22 is further configured to: obtain a key string set in the key-value pair string set; and determine the key-value pair string in the key string set that has the same string as the query string as the target string.

[0241] In the embodiment of the present application, the determination module 23 is further used to: obtain a value string in the target string; convert the value string into the first format or the second format, and determine the converted value as the target value corresponding to the key to be queried.

[0242] The data query device proposed in this application compares the query string of the key to be queried with the strings in the key-value pair string set based on the key-value pair string set in the storage area, thereby obtaining a target string that matches the query string. Furthermore, the target value corresponding to the key to be queried is obtained from the target string. In this application, the query string corresponding to the key to be queried performs data query on the key-value pair string set, thereby improving the accuracy of obtaining the target string, determining the target value of the key to be queried based on the target string, improving the efficiency and accuracy of data query, and optimizing the data query method.

[0243] To achieve the above embodiments, the present application also proposes an electronic device, a computer-readable storage medium, and a computer program product.

[0244] Figure 12 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. Figure 12 As shown, the device 1200 includes a memory 121, a processor 122, and a computer program stored in the memory 121 and executable on the processor 122. When the processor 122 executes the program instructions, the data storage method and the data query method proposed in the above embodiments are implemented.

[0245] The electronic device proposed in the present application performs a first format conversion on the key and value in the key-value pair to be stored, respectively, and obtains a first string corresponding to the key and a second string corresponding to the value of the value. Furthermore, the first string and the second string are spliced ​​based on a set splicing order to generate a target string of the key-value pair to be stored, and the target string is stored in a set storage area, forming a corresponding key-value pair string set with the target strings of other key-value pairs in the storage area. Furthermore, based on the key-value pair string set in the storage area, the query string of the key to be queried is compared with the strings in the key-value pair string set, so as to obtain a target string that matches the query string. Furthermore, the target value corresponding to the key to be queried is obtained from the target string. In this application, by setting a format conversion, the key and value in the key-value pair to be stored are converted to the same target string, wherein the content and number of characters of the key character sequence are used as the identification information of the key, thereby strengthening the unique identification of the key. By storing the target string, the key-value pair to be stored is stored, which reduces the storage space occupied by the key-value pair, reduces the storage cost of the key-value pair, optimizes the data storage method of the key-value pair, reduces the loss of system performance caused by the storage of the key-value pair, and optimizes the operating performance of the system. By performing data query on the key-value pair string set through the query string corresponding to the key to be queried, the accuracy of obtaining the target string is improved, the target value of the key to be queried is determined based on the target string, the efficiency and accuracy of data query are improved, and the data query method is optimized.

[0246] An embodiment of the present application proposes a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, the data storage method and the data query method proposed in the above embodiment are implemented.

[0247] The computer-readable storage medium of the embodiment of the present application performs a first format conversion on the key and value in the key-value pair to be stored, respectively, and obtains a first string corresponding to the key and a second string corresponding to the value of the value. Furthermore, the first string and the second string are spliced ​​based on a set splicing order to generate a target string for the key-value pair to be stored, and the target string is stored in a set storage area to form a corresponding key-value pair string set with the target strings of other key-value pairs in the storage area. Furthermore, based on the key-value pair string set in the storage area, the query string of the key to be queried is compared with the strings in the key-value pair string set to obtain a target string that matches the query string. Furthermore, the target value corresponding to the key to be queried is obtained from the target string. In this application, by setting a format conversion, the key and value in the key-value pair to be stored are converted to the same target string, wherein the content and number of characters of the key character sequence are used as the identification information of the key, thereby strengthening the unique identification of the key. By storing the target string, the key-value pair to be stored is stored, which reduces the storage space occupied by the key-value pair, reduces the storage cost of the key-value pair, optimizes the data storage method of the key-value pair, reduces the loss of system performance caused by the storage of the key-value pair, and optimizes the operating performance of the system. By performing data query on the key-value pair string set through the query string corresponding to the key to be queried, the accuracy of obtaining the target string is improved, the target value of the key to be queried is determined based on the target string, the efficiency and accuracy of data query are improved, and the data query method is optimized.

[0248] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art can combine and combine different embodiments or examples described in this specification and features of different embodiments or examples without contradiction.

[0249] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of the technical features being referred to. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of such features. Throughout the description of this application, "plurality" means at least two, for example, two, three, etc., unless otherwise specifically defined.

[0250] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code comprising one or more executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may be performed out of the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present application belong.

[0251] The logic and / or steps represented in the flowcharts or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing the logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (e.g., a computer-based system, a system including a processor, or other system that can fetch and execute instructions from an instruction execution system, apparatus, or device). For purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transport a program for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include the following: an electrical connection with one or more wires (electronic devices), a portable computer disk cartridge (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and programmable read-only memory (EPROM or flash memory), fiber optic devices, and a portable compact disc read-only memory (CDROM). Furthermore, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing it in another suitable manner if necessary, and then storing it in a computer memory.

[0252] It should be understood that various parts of the present application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented using hardware, as in another embodiment, any one of the following technologies known in the art or a combination thereof can be used to implement: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, an application-specific integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0253] Those skilled in the art will understand that all or part of the steps in the method of the above embodiment can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium. When the program is executed, it includes one or a combination of the steps of the method embodiment.

[0254] In addition, the functional units in the various embodiments of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into a module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.

[0255] The storage medium mentioned above may be a read-only memory, a magnetic disk, or an optical disk, etc. Although the embodiments of the present application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present application. Persons skilled in the art may make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present application.

[0256] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this application can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in this application can be achieved. This is not a limitation herein.

[0257] The above specific embodiments do not constitute a limitation on the scope of protection of this application. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this application shall be included within the scope of protection of this application.

Claims

1. A data storage method, characterized in that: include: Performing a first format conversion on the position number and the number of characters corresponding to the character sequence of the key key in the key-value pair to be stored, to obtain a first character string of the key, including: Obtaining a first position number of each character in the key in the corresponding character table, and determining a first substring corresponding to the key according to the first position number of each character; Obtaining the number of characters constituting the key, and determining a second substring of the key based on the number of characters; Concatenate the first sub-character and the second sub-character string in a first order to obtain the first character string corresponding to the key; Performing the first format conversion on the integer value corresponding to the value of value in the key-value pair to be stored to obtain a second character string of the value; generating a target string of the key-value pairs to be stored according to a concatenated string composed of the first string and the second string, and storing the target string; The first format is a digital format.

2. The method according to claim 1, characterized in that The step of obtaining the first substring corresponding to the key according to the first position number of each character includes: Obtain a first initial substring of the key, and determine a character position number in the first initial substring that matches the first position number as a second position number; The character at the position corresponding to the second position number is marked as the first set value, the characters at the remaining positions are marked as the second set value, and the marked character string is used as the first substring corresponding to the key.

3. The method according to claim 2, characterized in that The obtaining the number of characters constituting the key and generating a second substring of the key according to the number of characters includes: Obtain the value of the number of characters and convert the resulting string into the first format as the second substring of the key.

4. The method according to claim 3, characterized in that The performing the first format conversion on the integer value corresponding to the value value in the key-value pair to be stored to obtain the second character string of the value includes: In response to the value of the value being an integer, obtaining a character string after the value is converted into the first format as the second character string of the value; In response to the value of value being a non-integer, the non-integer value of value is converted to obtain an integer value corresponding to value, and a character string obtained by performing the first format conversion on the integer value is obtained as the second character string of value.

5. The method according to claim 4, characterized in that Generating the target string of the key-value pair to be stored according to the concatenated string composed of the first string and the second string includes: A string obtained by concatenating the first string and the second string in a second order is obtained as the target string of the key-value pair to be stored.

6. The method according to claim 4, characterized in that Generating the target string of the key-value pair to be stored according to the concatenated string composed of the first string and the second string includes: The string obtained by concatenating the first string and the second string in a second order is converted into a second format, and the string obtained by the conversion is used as the target string of the key-value pair to be stored, wherein the second format is one of the digital base formats, and the second format is different from the first format.

7. The method according to any one of claims 1 to 6, characterized in that The first format is binary, and the second format is decimal.

8. The method according to claim 1, characterized in that The storing of the target character string includes: The target character string is stored in a setting storage area, and forms a corresponding key-value pair character string set with other character strings of key-value pairs to be stored in the setting storage area.

9. The method according to claim 1, characterized in that The key is generated by combining characters in the character table, wherein among a plurality of first keys having the same number of characters, character sequences of any two of the first keys must contain different characters.

10. A data query method, characterized in that: The method comprises: Obtain a character sequence of the key to be queried, and perform a first format conversion on the position number and the number of characters corresponding to the character sequence to obtain a query string of the key to be queried, wherein the first format is a numeric format including: Obtaining a first position number of each character in the key to be queried in the character table, and obtaining a first substring of the key to be queried according to the first position number; Obtain a second substring corresponding to the key to be queried according to the number of characters in the key to be queried; Concatenate the first substring and the second substring in a first order to obtain the query string corresponding to the key to be queried; Obtaining a target string that matches the query string in a key-value pair string set, wherein the key-value pair string set is obtained based on a combination of target strings of key-value pairs to be stored in a set storage area; Determine the target value corresponding to the key to be queried based on the target string.

11. The method according to claim 10, characterized in that The obtaining of a first position number of each character in the key to be queried in the character table, and obtaining a first substring of the key to be queried according to the first position number, includes: Obtaining an initial substring of the key to be queried, and using an initial position number of the initial character position number of the initial substring that matches the first position number as a target position number; The character at the position corresponding to the target position number is marked as a first set value, the characters at the remaining positions are marked as a second set value, and the marked character string is used as the first substring corresponding to the key to be queried.

12. The method according to claim 11, characterized in that The step of concatenating the first sub-character and the second sub-character string in a first order to obtain the query string corresponding to the key to be queried includes: Obtain a string obtained by concatenating the first sub-characters and the second sub-character strings in the first order as the query string for the key to be queried.

13. The method according to claim 11, characterized in that The step of concatenating the first sub-character and the second sub-character string in a first order to obtain the query string corresponding to the key to be queried includes: The string obtained by concatenating the first sub-character and the second sub-string in the first order is converted into a second format, and the string obtained by the conversion is used as the query string corresponding to the key to be queried, wherein the second format is one of the digital base formats, and the second format is different from the first format.

14. The method according to any one of claims 10 to 13, characterized in that: The first format is binary, and the second format is decimal.

15. The method according to claim 14, characterized in that The step of obtaining a target string that matches the query string in the key-value pair string set includes: Obtaining a key string set in the key-value pair string set; The key-value pair string to which the string identical to the query string belongs in the key string set is determined as the target string.

16. The method according to claim 15, characterized in that Determining a target value corresponding to the key to be queried based on the target character string includes: Get the value string in the target string; The value character string is converted into the first format or the second format, and the converted value is determined as the target value corresponding to the key to be queried.

17. A data storage device, characterized in that: include: The first conversion module is configured to perform a first format conversion on the position number and the number of characters corresponding to the character sequence of the key key in the key-value pair to be stored, to obtain a first character string of the key, including: Obtaining a first position number of each character in the key in the corresponding character table, and determining a first substring corresponding to the key according to the first position number of each character; Obtaining the number of characters constituting the key, and determining a second substring of the key based on the number of characters; Concatenate the first sub-character and the second sub-character string in a first order to obtain the first character string corresponding to the key; The first conversion module is further configured to perform the first format conversion on the integer value corresponding to the value of value in the key-value pair to be stored, to obtain a second character string of the value; a generating module, configured to generate a target string of the key-value pairs to be stored according to a concatenated string composed of the first string and the second string, and store the target string; The first format is a digital format.

18. A data query device, characterized in that: The device comprises: The second conversion module is configured to obtain a character sequence of the key to be queried, and perform a first format conversion on the position number and the number of characters corresponding to the character sequence to obtain a query string of the key to be queried, wherein the first format is a numeric format including: Obtaining a first position number of each character in the key to be queried in the character table, and obtaining a first substring of the key to be queried according to the first position number; Obtain a second substring corresponding to the key to be queried according to the number of characters in the key to be queried; Concatenate the first substring and the second substring in a first order to obtain the query string corresponding to the key to be queried; A query module, configured to obtain a target string matching the query string from a key-value pair string set, wherein the key-value pair string set is obtained based on a combination of target strings of key-value pairs to be stored in a set storage area; A determination module is used to determine a target value corresponding to the key to be queried based on the target string.

19. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed 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 any one of claims 1-9 and 10-16.

20. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-9 and 10-16.

21. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 9 and 10 to 16.

Citation Information

Patent Citations

  • Data storage method, data query method, related devices and electronic equipment

    CN110321367A

  • Data query method, device and equipment and computer storage medium

    CN112269806A