CN117931058A - Data storage and query method, device, electronic equipment and storage medium - Google Patents

Data storage and query method, device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117931058A
CN117931058A CN202311589085.7A CN202311589085A CN117931058A CN 117931058 A CN117931058 A CN 117931058A CN 202311589085 A CN202311589085 A CN 202311589085A CN 117931058 A CN117931058 A CN 117931058A
Authority
CN
China
Prior art keywords
key
value pair
array
key value
storage
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311589085.7A
Other languages
Chinese (zh)
Inventor
淡伟栋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
CITIC Aibank Corp Ltd
Original Assignee
CITIC Aibank Corp Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by CITIC Aibank Corp Ltd filed Critical CITIC Aibank Corp Ltd
Priority to CN202311589085.7A priority Critical patent/CN117931058A/en
Publication of CN117931058A publication Critical patent/CN117931058A/en
Pending legal-status Critical Current

Links

Abstract

The present disclosure provides a data storage and query method, apparatus, electronic device, and storage medium. The method comprises the following steps: and acquiring a first key value pair and a second key value pair which are requested to be stored, wherein the first key value pair comprises a first keyword and first data, and the second key value pair comprises a second keyword and second data. The memory addresses of the first key-value pair and the second key-value pair in the first array are calculated based on the first key, the second key and the correlation function. And judging whether the storage addresses of the first key value pair and the second key value pair in the first array conflict or not. If the conflict occurs, a second array is created according to the storage address of the first array which generates the conflict. The memory addresses of the first key-value pair and the second key-value pair in the second array are calculated based on the first key, the second key, and the correlation function. And storing the first key value pair and the second key value pair into the second array according to the storage addresses of the first key value pair and the second key value pair in the second array.

Description

Data storage and query method, device, electronic equipment and storage medium
Technical Field
The embodiment of the disclosure relates to the technical field of computers, in particular to a data storage and query method, a device, electronic equipment and a storage medium.
Background
Key-value pairs are a common data structure that is commonly used to store data and can be accessed quickly through keywords.
In the prior art, when hash collision occurs when an array pair key value pair is used for storing, additional strategies need to be adopted for processing, for example, a linked list or a red-black tree and other data structures are used.
However, the method of using linked list or red-black tree may cause performance problems when large-scale data is stored and queried, and the data cannot be stored and queried quickly and efficiently.
Therefore, there is a need to propose a data storage and query method to solve at least one of the above technical problems.
Disclosure of Invention
The embodiment of the disclosure provides a data storage and query method, a data storage and query device, electronic equipment and a storage medium.
In a first aspect, the present disclosure provides a data storage method, including:
acquiring a first key value pair and a second key value pair which are requested to be stored, wherein the first key value pair comprises a first keyword and first data, and the second key value pair comprises a second keyword and second data;
Calculating the storage addresses of the first key value pair and the second key value pair in the first array based on the first key word, the second key word and the related function;
judging whether the storage addresses of the first key value pair and the second key value pair in the first array conflict or not;
if the conflict occurs, creating a second array according to the storage address of the first array in which the conflict occurs;
Calculating the storage addresses of the first key value pair and the second key value pair in the second array based on the first key word, the second key word and the related function;
And storing the first key value pair and the second key value pair into the second array according to the storage addresses of the first key value pair and the second key value pair in the second array.
In some alternative embodiments, creating the second array from the memory address of the conflicting first array includes:
Acquiring length information of a second group;
storing address information of the second array in the storage addresses in the first array where the conflict occurs;
a second array is created based on address information and length information of the second array.
In some alternative embodiments, calculating the memory addresses of the first key-value pair and the second key-value pair in the first array based on the first key, the second key, and the correlation function includes:
calculating a first memory address of the first key value pair in the first array based on the first key and the related function;
a second memory address of the second key-value pair in the first array is calculated based on the second key and the correlation function.
In some alternative embodiments, determining whether the memory addresses of the first key pair and the second key pair in the first array conflict includes:
Judging whether the storage address of the first key value pair in the first array is the same as the storage address of the second key value pair in the first array;
If the storage addresses are the same, determining that the storage addresses of the first key value pair and the second key value pair in the first array conflict.
In some alternative embodiments, calculating the memory addresses of the first key-value pair and the second key-value pair in the second array based on the first key, the second key, and the correlation function includes:
Calculating a third memory address of the first key value pair in the second array based on the first key and the related function;
a fourth memory address of the second key-value pair in the second array is calculated based on the second key and the correlation function.
In some alternative embodiments, storing the first key-value pair and the second key-value pair into the second array according to the storage addresses of the first key-value pair and the second key-value pair in the second array includes:
storing the first key value pair to a third storage address of the second array;
and storing the second key value pair to a fourth storage address of the second array.
In a second aspect, the present disclosure provides a data query method, including:
receiving a query request aiming at a target key value pair, wherein the query request comprises a target keyword;
calculating a storage address of the target key value pair in the first array based on the target key and the related function;
Determining whether the data stored in the storage address of the target key pair in the first array is address information of a second array;
If the target key value pair is the address information of the second array, calculating a target storage address of the target key value pair in the second array based on the target key words and the related functions;
the target key value pair is read from the target memory address.
In a third aspect, the present disclosure provides a data storage device comprising:
the device comprises an acquisition unit, a storage unit and a storage unit, wherein the acquisition unit is used for acquiring a first key value pair and a second key value pair which are requested to be stored, the first key value pair comprises a first keyword and first data, and the second key value pair comprises a second keyword and second data;
A first calculation unit configured to calculate a storage address of the first key value pair and the second key value pair in the first array based on the first key, the second key, and the correlation function;
a conflict judging unit, configured to judge whether a storage address of the first key value pair and a storage address of the second key value pair in the first array conflict;
The array creation unit is used for creating a second array according to the storage address of the first array which generates the conflict if the conflict occurs;
a second calculation unit configured to calculate a storage address of the first key value pair and the second key value pair in the second array based on the first key, the second key, and the correlation function;
And the key value pair storage unit is used for storing the first key value pair and the second key value pair into the second array according to the storage addresses of the first key value pair and the second key value pair in the second array.
In a fourth aspect, the present disclosure provides a data query apparatus, including:
a receiving unit, configured to receive a query request for a target key value pair, where the query request includes a target keyword;
A third calculation unit for calculating a storage address of the target key value pair in the first array based on the target key and the correlation function;
The determining unit is used for calculating a target storage address of the target key value pair in the second array based on the target key words and the related functions if the target key value pair is the address information of the second array;
The fourth calculation unit is used for calculating a target storage address of the target data in the second array based on the target key words and the related functions if the target key words and the related functions are the same;
and the reading unit is used for reading the target key value pair from the target storage address.
In a fifth aspect, the present disclosure provides an electronic device comprising:
One or more processors;
a storage device having one or more programs stored thereon,
The one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method as described in any implementation of the first and/or second aspects of the present disclosure.
In a sixth aspect, the present disclosure provides a computer readable storage medium having stored thereon a computer program, wherein the computer program, when executed by one or more processors, implements a method as described in any embodiment of the first and/or second aspects of the present disclosure.
The embodiment of the disclosure provides a data storage method, a device, an electronic device and a storage medium, wherein a first key value pair and a second key value pair which are required to be stored are obtained, the first key value pair comprises a first keyword and first data, and the second key value pair comprises a second keyword and second data. The memory addresses of the first key-value pair and the second key-value pair in the first array are calculated based on the first key, the second key and the correlation function. And judging whether the storage addresses of the first key value pair and the second key value pair in the first array conflict or not. If the conflict occurs, a second array is created according to the storage address of the first array which generates the conflict. The memory addresses of the first key-value pair and the second key-value pair in the second array are calculated based on the first key, the second key, and the correlation function. And storing the first key value pair and the second key value pair into the second array according to the storage addresses of the first key value pair and the second key value pair in the second array. When the key value pairs conflict in the storage process, a new array is created to store the key value pairs, so that the data can be stored quickly and efficiently.
Drawings
Other features, objects and advantages of the present disclosure will become more apparent upon reading of the detailed description of non-limiting embodiments made with reference to the following drawings. The drawings are only for purposes of illustrating particular embodiments and are not to be construed as limiting the invention. In the drawings:
FIG. 1 is a system architecture diagram of one embodiment of a data storage and querying system according to the present disclosure;
FIG. 2 is a flow chart of one embodiment of a data storage method according to the present disclosure;
FIG. 3 is a flow chart of one embodiment of a data query method according to the present disclosure;
FIG. 4 is a schematic structural view of one embodiment of a data storage device according to the present disclosure;
FIG. 5 is a schematic diagram of an embodiment of a data querying device according to the present disclosure;
Fig. 6 is a schematic diagram of a computer system suitable for use in implementing embodiments of the present disclosure.
Detailed Description
The present disclosure is described in further detail below with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be noted that, for convenience of description, only the portions related to the present invention are shown in the drawings.
It should be noted that, without conflict, the embodiments of the present disclosure and features of the embodiments may be combined with each other. The present disclosure will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
FIG. 1 illustrates an exemplary system architecture 100 in which embodiments of data storage and querying methods, apparatus, terminal devices, and storage media of the present disclosure may be applied.
As shown in fig. 1, a system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 is used as a medium to provide communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
The user may interact with the server 105 via the network 104 using the terminal devices 101, 102, 103 to receive or send messages or the like. Various communication client applications, such as a data storage and query class application, a voice interaction class application, a video conference class application, a short video social class application, a web browser application, a shopping class application, a search class application, an instant messaging tool, a mailbox client, social platform software, and the like, may be installed on the terminal devices 101, 102, 103.
The terminal devices 101, 102, 103 may be hardware or software. When the terminal devices 101, 102, 103 are hardware, various electronic devices with microphones and speakers may be available, including but not limited to smartphones, tablet computers, electronic book readers, MP3 players (Moving Picture Experts Group Audio Layer III, dynamic video expert compression standard audio plane 3), MP4 players (Moving Picture Experts Group Audio Layer IV, dynamic video expert compression standard audio plane 4), portable and desktop computers, and the like. When the terminal devices 101, 102, 103 are software, they can be installed in the above-listed electronic devices. It may be implemented as a plurality of software or software modules (e.g., a first key-value pair and a second key-value pair that are retrieved for storage) or as a single software or software module. The present invention is not particularly limited herein.
The server 105 may be a server providing various services, such as a background server processing the first key value pair and the second key value pair acquired and requested to be stored on the terminal devices 101, 102, 103. The background server can perform corresponding processing based on the first key value pair and the second key value pair which are acquired by the terminal equipment and are requested to be stored.
In some cases, the data storage and query methods provided by the present disclosure may be performed jointly by the terminal device 101, 102, 103 and the server 105, for example, the step of "obtaining the first key value pair and the second key value pair requested to be stored" may be performed by the terminal device 101, 102, 103, and the step of "calculating the storage address of the first key value pair and the second key value pair in the first array based on the first key word, the second key word, and the related function" may be performed by the server 105. The present disclosure is not limited in this regard. Accordingly, the data storage and querying means may also be provided in the terminal devices 101, 102, 103 and the server 105, respectively.
In some cases, the data storage and query method provided by the present disclosure may be executed by the server 105, and accordingly, the data storage and query apparatus may also be disposed in the server 105, where the system architecture 100 may not include the terminal devices 101, 102, 103.
In some cases, the data storage and query method provided by the present disclosure may be performed by the terminal devices 101, 102, 103, and accordingly, the data storage and query apparatus may also be disposed in the terminal devices 101, 102, 103, where the system architecture 100 may also not include the server 105.
The server 105 may be hardware or software. When the server 105 is hardware, it may be implemented as a distributed server cluster formed by a plurality of servers, or as a single server. When server 105 is software, it may be implemented as a plurality of software or software modules (e.g., to provide distributed services), or as a single software or software module. The present invention is not particularly limited herein.
It should be understood that the number of terminal devices, networks and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
With continued reference to fig. 2, fig. 2 illustrates a flow chart 200 of one embodiment of a data storage method according to the present disclosure, the data storage method illustrated in fig. 2 being applicable to the terminal device or server illustrated in fig. 1. The process 200 includes the steps of:
Step 201, a first key value pair and a second key value pair which are requested to be stored are obtained.
Key-value pairs (key-value) are a correspondence, and the key of each key-value pair corresponds to a value
In this embodiment, the first key-value pair includes a first key and first data, and the second key-value pair includes a second key and second data.
In this embodiment, the first data and the second data may be values in the key-value pair, and the first key and the second key may be keys in the key-value pair.
A hash table is a data structure that maps a set of keys to a finite and contiguous address space according to a set mapping function, and uses the "image" of the key in the address space as the storage location of the element in the table. The stored contents of the hash table are key-value pair (key-value) mappings.
The hash table may be stored by an array, which is a fixed length data structure storing the same data type, with elements in the array being stored in a continuous piece of memory space. The numerical numbers of the individual elements in the array may be referred to as subscripts.
The mapping function of the hash table may be a hash function, a value obtained by the hash function is referred to as a hash value, and a storage location obtained by the hash function is referred to as a hash address.
The key of different keywords in the key-value pair (key-value) can obtain the same hash value through the same hash function, or can obtain different hash values, that is, different keywords can obtain different hash addresses through the mapping of the hash function, or can obtain the same hash address.
The key (keyword) and value (value) types of the key-value pair may be the same or different, and may be a key and value of a String (String) type, a value of an Integer (inter) type, or the like, and are not particularly limited herein.
Step 202, calculating a memory address of the first key value pair and the second key value pair in the first array based on the first key, the second key and the related function.
Here, the first key-value pair and the second key-value pair may be stored by an array. The correlation function may be a hash function.
In some alternative embodiments, based on the first keyword, the second keyword and the related function, the subscript position of the first array corresponding to the first keyword and the second keyword may be obtained through calculation, and the storage addresses of the first key value pair and the second key value pair in the first array are obtained through the subscript position of the first array corresponding to the first keyword and the second keyword, so that the storage of the first key value pair and the second key value pair is realized.
In some alternative embodiments, a first memory address of a first key-value pair in a first array may be calculated based on a first key and a correlation function. A second memory address of the second key-value pair in the first array may be calculated based on the second key and the correlation function.
In this embodiment, the first keyword and the second keyword may be different keywords. And obtaining the subscript position of the first array corresponding to the first key through the first key and the related function, wherein the subscript position of the first array is the first storage address of the first key value pair in the first array. And obtaining the subscript position of the first array corresponding to the second key through the second key and the related function, wherein the subscript position of the first array is the second storage address of the second key value pair in the first array.
In this embodiment, the first memory address and the second memory address may be the same or different.
In step 203, it is determined whether the memory addresses of the first key pair and the second key pair in the first array conflict.
In some alternative embodiments, determining whether the first key pair and the second key pair conflict with each other in the memory address in the first array may be determining whether the first key pair and the second key pair have the same memory address in the first array, and if the memory addresses are the same, determining that the first key pair and the second key pair conflict with each other in the memory address in the first array.
That is, it is determined whether the subscript positions of the first key and the second key in the first numerical value are the same, and if so, the storage addresses of the first key pair in the first array and the storage addresses of the second key pair in the first array are the same, and it is determined that the storage addresses of the first key pair and the second key pair in the first array collide.
For example, the first array is an array of length 32, and the subscript of the corresponding array may range from 0 to 31. When the subscript positions of the first key and the second corresponding first array are 16, the first key value pair and the second key value pair are determined to conflict with each other in the storage address of the first array.
If a conflict occurs, a second array is created according to the memory address in the first array that has the conflict.
In some alternative embodiments, the second array is created according to the storage address in the first array where the conflict occurs, specifically, the length information of the second array is obtained first, then the address information of the second array is stored in the storage address in the first array where the conflict occurs, and finally, the second array is created based on the address information and the length information of the second array.
Here, the length of the second array may be the same as the length of the first array or may be different from the length of the first array.
For example, the first array may have a length of 32, and the second array may have a length of 16, 32, or other values, without limitation.
When a first key pair and a second key pair conflict at a storage address in a first array, a new array may be created for storing the key pair at which the storage conflict occurred, and address information of the new array may be stored at the storage address of the conflicting first array.
For example, when the subscript positions of the first key pair and the second key pair corresponding to the first array are both 16, a second array may be created, and the subscript positions of the first array are both 16 and may be used to store address information of the second array.
Step 205, calculating the memory address of the first key value pair and the second key value pair in the second array based on the first key, the second key and the correlation function.
After creating the new array, the memory addresses of the first key-value pair and the second key-value pair in the second array may be calculated based on the first key, the second key, and the correlation function. That is, the key-value pairs that would have generated the conflict are restored in the new array.
In some alternative embodiments, a third memory address of the first key-value pair in the second array may be calculated based on the first key and the correlation function. A fourth memory address of the second key-value pair in the second array may be calculated based on the second key and the correlation function.
Here, if the third memory address and the fourth memory address correspond to different subscript positions of the second array, then step 206 is continued. If the third storage address and the fourth storage address correspond to the same subscript position of the second array, a new array is continuously created at the position where the conflict is generated until different subscript positions of the first keyword and the second keyword array are calculated.
Step 206, storing the first key value pair and the second key value pair in the second array according to the storage addresses of the first key value pair and the second key value pair in the second array.
In some alternative embodiments, the first key-value pair may be stored to a third memory address of the second array. The second key-value pair may be stored to a fourth memory address of the second array.
The data storage method provided by the embodiment of the disclosure obtains a first key value pair and a second key value pair which are requested to be stored, wherein the first key value pair comprises a first keyword and first data, and the second key value pair comprises a second keyword and second data. The memory addresses of the first key-value pair and the second key-value pair in the first array are calculated based on the first key, the second key and the correlation function. And judging whether the storage addresses of the first key value pair and the second key value pair in the first array conflict or not. If the conflict occurs, a second array is created according to the storage address of the first array which generates the conflict. The memory addresses of the first key-value pair and the second key-value pair in the second array are calculated based on the first key, the second key, and the correlation function. And storing the first key value pair and the second key value pair into the second array according to the storage addresses of the first key value pair and the second key value pair in the second array. When the key value pairs conflict in the storage process, a new array is created to store the key value pairs, so that the data can be stored quickly and efficiently.
With continued reference to fig. 3, fig. 3 illustrates a flow chart 300 of one embodiment of a data query method according to the present disclosure, and the data storage method illustrated in fig. 3 is applicable to the terminal device or server illustrated in fig. 1. The process 300 includes the steps of:
step 301, a query request for a target key-value pair is received, the query request including a target key.
In this embodiment, the target key value pair includes a target keyword and target data.
Step 302, calculating a storage address of the target key value pair in the first array based on the target key and the correlation function.
Similarly, the memory address of the target key value pair in the first array may be calculated by the method shown in step 202.
Based on the target key words and the related functions, the subscript positions of the first array corresponding to the target key words can be calculated and obtained, and the storage addresses of the target key value pairs in the first array are obtained through the subscript positions of the first array corresponding to the target key words.
Step 303, determining whether the data stored in the storage address in the first array of target key pairs is address information of the second array.
In this embodiment, if it is determined that the data stored in the storage address of the target key pair in the first array is the address information of the second array, step 304 is continuously performed, and if it is determined that the data stored in the storage address of the target key pair in the first array is not the address information of the second array, it is directly determined that the address is the target storage address of the target key pair, and step 305 is continuously performed.
And step 304, if the target key value pair is the address information of the second array, calculating a target storage address of the target key value pair in the second array based on the target key and the related function.
In this embodiment, if the data stored in the storage address of the target key pair in the first array is the address information of the second array, the target key pair in the second array is calculated continuously through the target key and the related function, and it is determined whether the data stored in the target storage address is the address information of the array, if yes, step 304 is continuously executed until the data stored in the target storage address of the target key pair in the second array is not the address information of the array, and step 305 is executed.
Step 305, reading the target key value pair from the target memory address.
In the present embodiment, when the data stored in the target storage address is not the address information of the array, the target key value pair is read from the target storage address.
The data query method provided by the embodiment of the disclosure receives a query request aiming at a target key value pair, wherein the query request comprises a target keyword. The memory address of the target key value pair in the first array is calculated based on the target key and the correlation function. It is determined whether the target key value pair is address information of the second array for data stored in the storage address in the first array. And if the target key value pair is the address information of the second array, calculating a target storage address of the target key value pair in the second array based on the target key and the related function. The target key value pair is read from the target memory address. When the key value pairs conflict in the storage process, a new array pair is created to store the conflicting key value pairs, and similarly, when the key value pairs are queried, the key value pairs are queried based on the query mode of the array pair data, so that the data query efficiency can be improved.
With further reference to fig. 4, as an implementation of the method shown in the foregoing figures, the present disclosure provides an embodiment of a data storage device, where the embodiment of the device corresponds to the embodiment of the method shown in fig. 2, and the device may be specifically applied in various terminal devices.
As shown in fig. 4, the data storage device 400 of the present embodiment includes: an acquisition unit 401, a first calculation unit 402, a collision judgment unit 403, an array creation unit 404, a second calculation unit 405, and a key value pair storage unit 406. The obtaining unit 401 is configured to obtain a first key value pair and a second key value pair that are requested to be stored, where the first key value pair includes a first keyword and first data, and the second key value pair includes a second keyword and second data; a first calculation unit 402, configured to calculate, based on the first key, the second key, and the related function, a storage address of the first key pair and the second key pair in the first array; a conflict judging unit 403, configured to judge whether the storage addresses of the first key value pair and the second key value pair in the first array conflict; an array creation unit 404, configured to create a second array according to the storage address of the first array where the conflict occurs, if the conflict occurs; a second calculation unit 405, configured to calculate, based on the first key, the second key, and the related function, a storage address of the first key pair and the second key pair in the second array; and a key value pair storage unit 406, configured to store the first key value pair and the second key value pair into the second array according to the storage addresses of the first key value pair and the second key value pair in the second array.
In this embodiment, the specific processing of the obtaining unit 401, the first calculating unit 402, the conflict judging unit 403, the array creating unit 404, the second calculating unit 405, and the key value to the storing unit 406 and the technical effects thereof in the present embodiment may refer to the related descriptions of the steps 201 to 206 in the corresponding embodiment of fig. 2, and are not repeated herein.
In some alternative embodiments, the above-described array creation unit 404 may be further configured to:
Acquiring length information of a second group;
storing address information of the second array in the storage addresses in the first array where the conflict occurs;
a second array is created based on address information and length information of the second array.
In some alternative embodiments, the first computing unit 402 may be further configured to:
calculating a first memory address of the first key value pair in the first array based on the first key and the related function;
a second memory address of the second key-value pair in the first array is calculated based on the second key and the correlation function.
In some alternative embodiments, the conflict determination unit 403 may be further configured to:
Judging whether the storage address of the first key value pair in the first array is the same as the storage address of the second key value pair in the first array;
If the storage addresses are the same, determining that the storage addresses of the first key value pair and the second key value pair in the first array conflict.
In some alternative embodiments, the second computing unit 405 may be further configured to:
Calculating a third memory address of the first key value pair in the second array based on the first key and the related function;
a fourth memory address of the second key-value pair in the second array is calculated based on the second key and the correlation function.
In some alternative embodiments, the key-value pair storage unit 406 may be further configured to:
storing the first key value pair to a third storage address of the second array;
and storing the second key value pair to a fourth storage address of the second array.
It should be noted that, the implementation details and technical effects of each unit in the data storage device provided in the embodiments of the present disclosure may refer to the descriptions of other embodiments in the present disclosure, which are not described herein again.
With further reference to fig. 5, as an implementation of the method shown in the foregoing figures, the present disclosure provides an embodiment of a data query device, where an embodiment of the device corresponds to the embodiment of the method shown in fig. 3, and the device may be specifically applied to various terminal devices.
As shown in fig. 5, the data query device 500 of the present embodiment includes: a receiving unit 501, a third calculating unit 502, a determining unit 503, a fourth calculating unit 504, and a reading unit 505. Wherein, the receiving unit 501 is configured to receive a query request for a target key value pair, where the query request includes a target keyword; a third calculation unit 502, configured to calculate a storage address of the target key value pair in the first array based on the target key and the correlation function; a determining unit 503, configured to calculate, if the target key is the address information of the second array, a target storage address of the target key pair in the second array based on the target key and the correlation function; a fourth calculating unit 504, configured to calculate, if yes, a target storage address of the target data in the second array based on the target keyword and the correlation function; a reading unit 505 for reading the target key value pair from the target storage address.
In this embodiment, the specific processes of the receiving unit 501, the third calculating unit 502, the determining unit 503, the fourth calculating unit 504, and the reading unit 505 of the data query device and the technical effects thereof may refer to the relevant descriptions of the steps 301 to 305 in the corresponding embodiment of fig. 3, and are not repeated herein.
It should be noted that, the implementation details and technical effects of each unit in the data storage device provided in the embodiments of the present disclosure may refer to the descriptions of other embodiments in the present disclosure, which are not described herein again.
Referring now to FIG. 6, there is illustrated a schematic diagram of a computer system 600 suitable for use in implementing the terminal device of the present disclosure. The computer system 600 shown in fig. 6 is merely an example, and should not be construed as limiting the functionality and scope of use of embodiments of the present disclosure.
As shown in fig. 6, a computer system 600 may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 601, which may perform various suitable actions and processes in accordance with programs stored in a Read Only Memory (ROM) 602 or loaded from a storage device 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the computer system 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An input/output (I/O) interface 604 is also connected to bus 604.
In general, the following devices may be connected to the I/O interface 604: input devices 606 including, for example, a touch screen, touchpad, keyword pad, mouse, camera, microphone, etc.; an output device 607 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 608 including, for example, magnetic tape, hard disk, etc.; and a communication device 609. The communication means 609 may allow the computer system 600 to communicate with other devices wirelessly or by wire to exchange data. While fig. 6 illustrates a computer system 600 having electronic devices of various kinds, it is to be understood that not all illustrated devices are required to be implemented or provided. More or fewer devices may be implemented or provided instead.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network via communication means 609, or from storage means 608, or from ROM 602. The above-described functions defined in the methods of the embodiments of the present disclosure are performed when the computer program is executed by the processing means 601.
It should be noted that the computer readable medium described in the present disclosure may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this disclosure, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present disclosure, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
The computer readable medium may be contained in the electronic device; or may exist alone without being incorporated into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to implement a data storage and/or querying method as shown in the embodiments and alternative implementations of fig. 2 or 3.
Computer program code for carrying out operations of the present disclosure may be written in one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units involved in the embodiments described in the present disclosure may be implemented by means of software, or may be implemented by means of hardware. Where the name of the element does not constitute a limitation on the element itself in some cases, for example, the array creation unit may also be described as "an element for creating an array".
The foregoing description is only of the preferred embodiments of the present disclosure and description of the principles of the technology being employed. It will be appreciated by persons skilled in the art that the scope of the disclosure referred to in this disclosure is not limited to the specific combinations of features described above, but also covers other embodiments which may be formed by any combination of features described above or equivalents thereof without departing from the spirit of the disclosure. Such as those described above, are mutually substituted with the technical features having similar functions disclosed in the present disclosure (but not limited thereto).

Claims (11)

1. A method of data storage, the method comprising:
acquiring a first key value pair and a second key value pair which are requested to be stored, wherein the first key value pair comprises a first keyword and first data, and the second key value pair comprises a second keyword and second data;
calculating the storage addresses of the first key value pair and the second key value pair in the first array based on the first key word, the second key word and the related function;
Judging whether the storage addresses of the first key value pair and the second key value pair in the first array conflict or not;
If the conflict occurs, creating a second array according to the storage address of the first array which is in conflict;
Calculating the storage addresses of the first key value pair and the second key value pair in the second array based on the first key word, the second key word and the related function;
And storing the first key value pair and the second key value pair into the second array according to the storage addresses of the first key value pair and the second key value pair in the second array.
2. The method of claim 1, wherein the creating a second array from the memory addresses of the first array where the conflict occurs comprises:
Acquiring the length information of the second array;
Storing address information of the second array in the storage addresses in the first array where the conflict occurs;
the second array is created based on the address information and the length information of the second array.
3. The method of claim 1, wherein the computing the memory addresses of the first key-value pair and the second key-value pair in the first array based on the first key, the second key, and the correlation function comprises:
Calculating a first storage address of the first key value pair in the first array based on the first key and the correlation function;
and calculating a second storage address of the second key value pair in the first array based on the second key and the related function.
4. The method of claim 1, wherein the determining whether the first key pair and the second key pair conflict with each other at the memory address in the first array comprises:
judging whether the storage address of the first key value pair in the first array is the same as the storage address of the second key value pair in the first array;
And if the storage addresses are the same, determining that the first key value pair and the second key value pair conflict with each other in the storage addresses in the first array.
5. The method of claim 1, wherein calculating the memory addresses of the first key-value pair and the second key-value pair in the second array based on the first key, the second key, and the correlation function comprises:
Calculating a third memory address of the first key value pair in the second array based on the first key and the correlation function;
and calculating a fourth storage address of the second key value pair in the second array based on the second key and the related function.
6. The method of claim 5, wherein the storing the first key-value pair and the second key-value pair into the second array according to the memory addresses of the first key-value pair and the second key-value pair in the second array comprises:
Storing the first key-value pair to the third storage address of the second array;
storing the second key-value pair to the fourth memory address of the second array.
7. A method of querying data, the method comprising:
receiving a query request for a target key value pair, wherein the query request comprises a target keyword;
Calculating the storage address of the target key value pair in a first array based on the target key word and the related function;
determining whether the target key value pair is address information of a second array of data stored in a storage address in the first array;
If the target key value pair is the address information of the second array, calculating a target storage address of the target key value pair in the second array based on the target key word and the related function;
And reading the target key value pair from the target storage address.
8. A data storage device, comprising:
the device comprises an acquisition unit, a storage unit and a storage unit, wherein the acquisition unit is used for acquiring a first key value pair and a second key value pair which are requested to be stored, the first key value pair comprises a first keyword and first data, and the second key value pair comprises a second keyword and second data;
A first calculation unit configured to calculate a storage address of a first key value pair and a second key value pair in a first array based on the first key, the second key, and a correlation function;
A conflict judging unit, configured to judge whether a conflict occurs between the storage addresses of the first key value pair and the second key value pair in the first array;
The array creation unit is used for creating a second array according to the storage address of the first array which generates the conflict if the conflict occurs;
A second calculation unit configured to calculate a storage address of the first key-value pair and the second key-value pair in the second array based on the first key, the second key, and the correlation function;
And the key value pair storage unit is used for storing the first key value pair and the second key value pair into the second array according to the storage addresses of the first key value pair and the second key value pair in the second array.
9. A data query device, comprising:
a receiving unit, configured to receive a query request for a target key value pair, where the query request includes a target keyword;
A third calculation unit, configured to calculate a storage address of the target key value pair in the first array based on the target key and a correlation function;
the determining unit is used for calculating a target storage address of the target key value pair in the second array based on the target key word and the related function if the target key value pair is the address information of the second array;
a fourth calculation unit, configured to calculate, if yes, a target storage address of the target data in the second array based on the target keyword and the correlation function;
And the reading unit is used for reading the target key value pair from the target storage address.
10. An electronic device, comprising:
One or more processors;
a storage device having one or more programs stored thereon,
The one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method of any of claims 1-6 and/or 7.
11. A computer readable storage medium having stored thereon a computer program, wherein the computer program when executed by one or more processors implements the method of any of claims 1-6 and/or 7.
CN202311589085.7A 2023-11-27 2023-11-27 Data storage and query method, device, electronic equipment and storage medium Pending CN117931058A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311589085.7A CN117931058A (en) 2023-11-27 2023-11-27 Data storage and query method, device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311589085.7A CN117931058A (en) 2023-11-27 2023-11-27 Data storage and query method, device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117931058A true CN117931058A (en) 2024-04-26

Family

ID=90754528

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311589085.7A Pending CN117931058A (en) 2023-11-27 2023-11-27 Data storage and query method, device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117931058A (en)

Similar Documents

Publication Publication Date Title
CN110222775B (en) Image processing method, image processing device, electronic equipment and computer readable storage medium
CN111198859B (en) Data processing method, device, electronic equipment and computer readable storage medium
WO2020216204A1 (en) Information acquisition method and apparatus
JP7033165B2 (en) How and equipment to process information in parallel
CN111400625A (en) Page processing method and device, electronic equipment and computer readable storage medium
CN111459364A (en) Icon updating method and device and electronic equipment
WO2020199659A1 (en) Method and apparatus for determining push priority information
CN110198473B (en) Video processing method and device, electronic equipment and computer readable storage medium
CN115168362A (en) Data processing method and device, readable medium and electronic equipment
US20230385080A1 (en) Method and apparatus for presenting information on lock screen interface, terminal, and storage medium
CN111241137B (en) Data processing method, device, electronic equipment and storage medium
CN109614089B (en) Automatic generation method, device, equipment and storage medium of data access code
CN110765238A (en) Data encryption query method and device
CN110619101A (en) Method and apparatus for processing information
CN112100211B (en) Data storage method, apparatus, electronic device, and computer readable medium
CN111460020B (en) Method, device, electronic equipment and medium for resolving message
CN117931058A (en) Data storage and query method, device, electronic equipment and storage medium
CN111680754B (en) Image classification method, device, electronic equipment and computer readable storage medium
CN111274104B (en) Data processing method, device, electronic equipment and computer readable storage medium
CN110377654B (en) Data request processing method and device, electronic equipment and computer-readable storage medium
CN112799863A (en) Method and apparatus for outputting information
CN111580890A (en) Method, apparatus, electronic device, and computer-readable medium for processing features
CN116820354B (en) Data storage method, data storage device and data storage system
CN111597439A (en) Information processing method and device and electronic equipment
CN114513548B (en) Directional call information processing method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination