WO2020199760A1 - Data storage method, memory and server - Google Patents

Data storage method, memory and server Download PDF

Info

Publication number
WO2020199760A1
WO2020199760A1 PCT/CN2020/075170 CN2020075170W WO2020199760A1 WO 2020199760 A1 WO2020199760 A1 WO 2020199760A1 CN 2020075170 W CN2020075170 W CN 2020075170W WO 2020199760 A1 WO2020199760 A1 WO 2020199760A1
Authority
WO
WIPO (PCT)
Prior art keywords
value
storage
key
request
size
Prior art date
Application number
PCT/CN2020/075170
Other languages
French (fr)
Chinese (zh)
Inventor
閤先军
尹文波
王伶俐
邱云辉
任予琛
陈华
余博伟
Original Assignee
华为技术有限公司
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 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2020199760A1 publication Critical patent/WO2020199760A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/061Improving I/O performance
    • G06F3/0611Improving I/O performance in relation to response time
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device

Definitions

  • This application relates to the field of storage technology, and in particular to a data storage method, storage and server.
  • Key-value storage technology is a data access method that uses key pairs to store data. Each key corresponds to a value. Key-value storage technology is widely used in data centers. With the development of semiconductor technology, the cost of storage has dropped rapidly, and more and more high-performance storage has been applied to data centers, forming different types of key-value storage systems.
  • the key-value storage system has gradually developed from a system based on mechanical hard disks to a cache-type system that uses dynamic random access memory (DRAM) as a cache, and has developed to store all data including keys and values in DRAM A memory-based system as memory.
  • DRAM dynamic random access memory
  • the size of the value corresponding to the key is large, the data storage efficiency is low in the process of writing the value.
  • the value needs to be cached. Because the size of the value is large, a large cache space is required. In order to store the value completely in DRAM, the value needs to be stored The transmission process from the cache to the DRAM is started after the complete cache. The cache time and transmission time of this value are relatively long during the entire process, resulting in a large transmission delay and low data storage efficiency.
  • This application provides a data storage method, memory and server to solve the problem of low data storage efficiency of large-size data in the key-value storage system in the traditional technology.
  • the present application provides a data storage method.
  • the method includes: first, the key-value storage receives a key-value storage request, the key-value storage request includes a key and a first value, and the key and the first value are corresponding;
  • the key-value memory may divide the first storage space for storing the first value in the first memory, where the first memory may be a memory other than the key-value memory; if the first value is a large size Data; Exemplarily, the capacity of the data contained in the first value is greater than or equal to the first threshold, the key-value storage can perform data segmentation, divide the first value into multiple second values, and generate multiple secondary key-value stores Request, each secondary key value storage request can carry a key and one of the second values; the number of secondary key value storage requests is the same as the number of multiple second values obtained by dividing the first value.
  • the key-value storage can separately store the second value carried in each secondary key-value storage request according to the position order of the second value carried in each secondary key-value storage request in the first value.
  • the value is stored in the first storage space.
  • the capacity of the data contained in the first value can also be referred to as the size of the first value, which refers to the total size of the data contained in the first value, or the minimum storage space required to store the first value. the size of. For example, if the content contained in the first value is "0123456789", the capacity of the data contained in the first value is 10 bytes.
  • the key-value memory can be divided into multiple smaller second values, and the value of the smaller size can effectively shorten the time of data buffering and transmission, reduce the delay, and be more effective Improve the data storage efficiency of large-size data.
  • the key-value memory when the key-value memory divides the first value into multiple second values, it can be divided while caching; for example, the key-value memory can cache the first value (such as in the key-value memory).
  • the cached data In the process of caching the first value in the second memory), whenever the size of the cached data is less than or equal to the second threshold, the cached data is taken as the second value and carried in a secondary key value storage request until The first value cache is completed.
  • the cached data can be directly used as the second value and carried in a secondary key value storage request; in this case, each time The size of the second value carried in the level key value storage request is not necessarily the same.
  • the data division method may also be adopted after the cache is completed.
  • the key value storage may divide the first value into multiple second values, and the key value storage may divide the first value into N+1 second values, in which the order of division is Among the multiple second values arranged, the size of each of the first N second values can be equal to the second threshold, and the size of the N+1th second value can be less than or equal to the second threshold, and N is A positive integer greater than or equal to 1.
  • the key value storage may also set the second value to multiple second values.
  • the key value memory can set the second threshold value according to the size of the first value, which can segment the first value more flexibly.
  • a field may be set in the secondary key value storage request to indicate the relevant information of the second value carried, such as the size and offset of the second value.
  • a value offset may be included, and the value offset may indicate the position of the second value carried in the secondary key value storage request in the first value.
  • the key value storage can more conveniently determine the related information of the second value, which can make it convenient to determine that the second value carried in each secondary key value storage request is in the first value.
  • the key-value storage when the key-value storage stores the second value carried in each secondary key-value storage request to the first storage space, it needs to first determine the second value carried in each secondary key-value storage request.
  • the position order of the binary value in the first value; since the secondary key value storage request may include a value offset; the key value storage may determine the position order according to the value offset in each secondary key value storage request. For example, the position order is determined by comparing the magnitude of the value offset, and then the key value memory stores the second value in the first storage space according to the position order.
  • the key-value storage can determine the position sequence more conveniently by comparing the value offset in each secondary key-value storage request, improve data storage efficiency, and further ensure an efficient data storage process.
  • the second storage for the first value carried in one or more key-value storage requests can be configured in the first storage in advance. Space.
  • the key-value memory selects the first storage space from the second storage space, and the size of the first storage space may be equal to or greater than the size of the first value.
  • the key-value storage can pre-configure the second storage space before receiving the key-value storage request; it can also pre-configure the second storage space after receiving the key-value storage request and before storing the first value. In this case, the first 2.
  • the storage space can be equal to the size of the first value or greater than the size of the first value.
  • the key-value memory can select the first storage space from the pre-configured second storage space, and the first storage space can be determined more quickly, so that the first value can be stored in the first storage space faster, which can be realized Efficient data storage process.
  • the key-value memory allocates the first storage space for the first value, if there is not enough space in the second storage space to store the first value, that is, the amount of free space in the second storage space
  • the size is smaller than the size of the first value, and the key value storage may allocate the first storage space for the first value from the first storage.
  • the key value storage can select the first storage space from the first storage to store the first value, which can ensure that the first value can be stored in the first storage, and the efficiency of data storage can be guaranteed.
  • the key-value storage may further include a second storage, and after receiving the key-value storage request, the key-value storage may store the keys in the key-value storage request in the second storage; exemplary, the first 2.
  • a hash table can be stored in the storage, and the key value storage can update the hash table and add a hash table entry including the key; wherein the added hash table entry also includes the address of the first storage space.
  • the key value storage can update the hash table in time, and record the key and the corresponding first storage space address.
  • the key-value storage device determines that the storage of the first value has been completed, and stops the data storage operation ;
  • the secondary key value storage request includes the value size, which is used to indicate the size of the second value carried in the secondary key value storage request.
  • the key value storage device can accumulate the stored second value corresponding to the secondary key value storage request The value size, until the accumulated value is equal to the size of the first value, indicating that the first value has been stored.
  • the key value storage can determine that the first value has been stored in different ways, and can stop the data storage operation in time.
  • the present application provides a key-value memory, which has the function of the key-value memory in the first aspect and any one of the possible designs of the first aspect.
  • the function can be realized by hardware, or by hardware executing corresponding software.
  • the hardware or software includes one or more modules corresponding to the above-mentioned functions.
  • the structure of the device includes a receiving unit, a distributing unit, a dividing unit, and a storage unit. These units can perform the corresponding functions in the method example of the first aspect. For details, please refer to the detailed description in the method example. Do not repeat it.
  • the present application also provides a key value memory.
  • the structure of the key-value memory includes a processor and a memory, and the processor is configured to support the key-value memory to perform corresponding functions in the first aspect and any one of the possible design methods of the first aspect.
  • the memory is coupled with the processor, and it stores the program instructions and data necessary for the key-value memory.
  • the structure of the key-value memory also includes a transceiver for communicating with other devices.
  • this application provides a key-value storage server.
  • the key-value storage server includes a first storage and a key-value storage.
  • the first storage is a storage other than the key-value storage.
  • the key-value storage server is used to execute the first aspect. And the operation steps of the method provided in any one of the possible designs in the first aspect.
  • the present application also provides a computer-readable storage medium that stores instructions in the computer-readable storage medium, which when run on a computer, causes the computer to execute the methods of the above aspects.
  • the present application also provides a computer program product containing instructions, which when run on a computer, causes the computer to execute the methods of the above aspects.
  • the present application also provides a computer chip, which is connected to a memory, and the chip is used to read and execute a software program stored in the memory, and execute the methods of the above aspects.
  • Figure 1 is a schematic diagram of the architecture of a key-value storage system provided by this application.
  • FIG. 2 is a schematic structural diagram of a key-value storage server provided by this application.
  • FIG. 3 is a schematic diagram of a data storage method provided by this application.
  • FIG. 4 is a schematic diagram of a flow of data fragmentation and splicing provided by this application.
  • FIG. 5 is a schematic diagram of the format of a key-value storage request provided by this application.
  • FIG. 6 is a schematic diagram of another key-value storage request format provided by this application.
  • FIG. 7 is a schematic diagram of a first value segmentation provided by this application.
  • FIG. 8 is a schematic diagram of state switching of a state machine provided by this application.
  • FIG. 9 is a schematic structural diagram of a key value storage provided by this application.
  • FIG. 10 is a schematic structural diagram of another key value storage provided by this application.
  • This application provides a data storage method, memory and server to solve the problem of low data storage efficiency of large-size data in the key-value storage system in the traditional technology.
  • FIG. 1 a schematic diagram of a network architecture provided by an embodiment of this application, in which a plurality of application server key-value clients 101 and key-value storage servers (key-value servers) 102 are provided.
  • the application server key-value client 101 and the key-value storage server 102 interact through the network to send and receive information.
  • the embodiment of the present application does not limit the type of the network.
  • the transmission control protocol/Internet interconnection protocol transmission control protocol/ The wired transmission method of internet protocol (TCP/IP) can also be the wireless transmission method using wireless fidelity (Wifi).
  • the key-value storage server 102 may also be a key-value storage device composed of other hardware.
  • Each key-value storage server 102 can be provided with a memory 103, and the memory 103 can be used to store values.
  • the memory 103 can be a cache, flash memory (flash), or hard disk drive (HDD) in the key-value storage server. Or storage media such as solid-state drives (SSD).
  • the memory 103 may also be used to store a hash table for recording the correspondence between keys and values, and the storage location of the value, so that the hash table can be used in data processing to query the storage location of the specified value.
  • the hash table entries are the correspondence between the key and the address of the storage space where the value corresponding to the key is stored.
  • the storage of the value corresponding to the key can be retrieved through the hash table Address (the storage address is the address of the storage space in the memory 103).
  • the storage address of the value is determined by the hash table, and then the value is obtained from the memory 103; in the process of storing the value, the corresponding hash table entry needs to be added to the hash table to record the value The storage address.
  • the multiple key-value storage servers 102 shown in FIG. 1 can respectively receive key-value storage requests sent by different application server key-value clients 101 via the network in parallel. If the key-value storage request is a read request, the key-value storage server 102 may write the value carried in the key-value storage request into the memory 103. In addition, the key-value storage server 102 may also update the hash table and insert new hash table entries according to the key carried in the key-value storage request and the storage space allocated for the value in the memory 103.
  • the inserted hash table entry includes a key and a storage address; by hashing the key, the generated hash value is the index of the inserted hash table entry.
  • the key-value storage server 102 can read the corresponding value from the storage according to the key carried in the key-value storage request. Specifically, the key-value storage server 102 may perform a hash operation on the key carried in the key-value storage request to generate a hash value, query the corresponding hash table entry in the hash table through the hash value, and then compare the queried Whether the key in the hash table entry is consistent with the key carried in the key value storage request, if they are the same, read the value from the storage according to the storage address in the hash table entry and feed it back to the application server key value client 101.
  • multiple processing logics may be called in parallel to store different data in the same key-value storage server 102.
  • Each hash function corresponds to a set of processing logic, and the address of the storage space mapped by each processing logic corresponds to 4 buckets to form a set of buckets.
  • each key can correspond to 8 storage buckets for storing hash table entries; when updating the hash table entries, you can search the hash table entries stored in 8 storage buckets at the same time (keys pass a hash function
  • the hash table items stored in the mapped 4 buckets are a group of hash table items), find out the unoccupied buckets, and then use the polling mode to insert new hash table items; for each group of storage Buckets are inserted into the previous empty bucket first.
  • two groups can be inserted alternately.
  • a hash collision occurs, that is, when all 8 buckets corresponding to a key are occupied, a bucket is selected through preset rules, and some of the hash table entries are deleted to insert new hash table entries; for example, , Delete the earliest stored 10 hash table entries.
  • a polling mode can also be used to alternately delete the hash table entries in the two groups of buckets.
  • any application server key value client 101 can send a key to any key value storage server 102.
  • Value storage request may also communicate with the application server key-value client 101 through a key-value proxy (not shown in FIG. 1), and the key-value proxy is used to key the application server.
  • the key-value storage requests of the value client 101 are managed and scheduled, and distributed to different key-value storage servers. For example, the key-value agent can allocate key-value storage requests according to the current load of the key-value storage server.
  • the key-value proxy and the key-value storage server 102 can be deployed in one server, or can be deployed using a single server, or deployed in a cluster using multiple servers.
  • IP Internet protocol
  • the application server key-value client 101 can send a key-value storage request to the key-value proxy, and the key-value proxy is based on load balancing The algorithm distributes the key-value storage request to the key-value storage server 102.
  • variable-length key value storage method only involves the key hash operation, the hash table query, and the process of determining the hash table entry.
  • the embodiments of the present application are also applicable to variable-length key value storage methods.
  • additional fields are allowed in the key field.
  • variable-length keys are used to indicate different version numbers in scenarios such as data upgrades and snapshots. The value corresponding to the key will change to a certain extent.
  • the variable-length key is processed as follows: first perform a hash operation on the variable-length key, generate a hash value, query the hash table, and confirm Hash table entry.
  • the corresponding block address and the tree structure information stored in the block address are determined according to the hash table entry.
  • the parent node and the leaf node in the tree structure are determined according to the tree structure information, and the tree node may indicate the address of the storage space of the value corresponding to the variable-length key.
  • the tree structure may be a B-tree structure that identifies the size of the node, that is, in the tree structure, the value of the left leaf node is greater than the value of the parent node, and the value of the parent node is less than the value of the right leaf node.
  • the data storage methods provided in the embodiments of this application are all applicable. For ease of description, the following embodiments of this application only take fixed-length keys as an example for description.
  • the processor in the key-value storage server may be a central processing unit (CPU), an application specific integrated circuit (ASIC), and an on-site Field-programmable gate array (FPGA), artificial intelligence (AI) chip, system on chip (SoC) or complex programmable logic device (CPLD), of which,
  • the data required by the key-value storage server for example, the hash table and value, can be stored in the same memory or in different memories.
  • the hash table and value can be stored in the memory of the host.
  • the hash table can be stored in the memory of the host, and the value is stored in the flash memory.
  • the key-value storage server 201 is a key-value storage device constructed based on FPGA.
  • the key-value storage server 201 includes a key-value storage 202, The first storage 203; optionally, the key-value storage server 201 may also include a central processing unit 204.
  • the key value storage 202 includes a key value storage engine 205 and a second storage 206, and optionally, may also include a network offload engine (NOE) 207.
  • the second memory 206 may be a double data rate (DDR) memory, which may be specifically used to store a hash table.
  • DDR double data rate
  • the value is stored in the first memory 203.
  • the first memory 203 may be a memory in a host, and may be specifically implemented by a dynamic random access memory.
  • FPGA is a processing logic that uses hardware such as capacitors and resistors to implement specified functions.
  • the processing logic that implements specific functions in Figure 2 is named after the function name, for example, network offloading engine and key-value storage engine.
  • the key-value storage server 201 includes a central processing unit 204 and an FPGA-based key-value storage.
  • the same server including two or more types of processors it can also be called a heterogeneous server.
  • the network offloading engine 207 is used to receive the key-value storage request from the key-value client of the application server, process the key-value storage request based on the user datagram protocol (UDP), and send the processed key-value storage request to the key
  • the value storage engine 205 reduces the overhead incurred in the process of processing user datagram protocol messages by the CPU 204.
  • the CPU 204 can continue to complete the processing of the user datagram protocol.
  • the CPU 204 receives the key value storage request from the key value client of the application server, and based on the user data packet
  • the protocol processes the key-value storage request, and then sends the processed key-value storage request to the key-value storage engine 205.
  • the processing of the key-value storage request by the network offloading engine 207 in the key-value storage is taken as an example for description.
  • the specific processing process is to parse the message data, that is, to remove the header content of the protocol and obtain the payload data in the message.
  • the embodiment of the present application does not limit the process of the network offloading engine 207 or the CPU 204 processing the user data protocol message.
  • the key-value storage engine 205 is used to process the key-value storage request, for example, read the value from the first memory 203 according to the key in the key-value storage request or the value carried in the key-value storage request (corresponding to the value in the embodiment of this application).
  • the first key value of is written into the first memory 203.
  • the key-value storage engine 205 may add the value carried in the key-value storage request The first value is divided into multiple second values to generate multiple secondary key storage requests; where each secondary key value storage request carries a key and a second value; then, each secondary key value is stored separately The second value carried in the request is stored in the first memory 203.
  • the key-value memory 202 may also be connected to other processors, such as the CPU 204.
  • the key-value memory 202 may transfer the operation of data storage to the CPU 204.
  • the key-value storage 202 may directly forward the key-value storage request to the CUP 204; or after determining that the first value carried in the key-value storage request is greater than or equal to the first threshold, The key-value storage request is forwarded to CUP 204, and CUP 204 executes the data storage method provided in the embodiment of this application.
  • the structure of the key-value storage server shown in FIG. 2 is only an example, in which only one CPU and one key-value storage are shown. In fact, the embodiment of the present application does not limit the number of CPUs and key-value storages. One CPU or multiple key-value memories.
  • the key-value storage request can be forwarded between multiple key-value storages to cooperate with the data storage method provided in the embodiment of this application, and the data storage operation can also be selectively transferred to any CUP connected to the key-value storage device .
  • the embodiments of the present application do not limit the modules included in the key-value storage, the names of the modules, and the functions of each module. Any device that can implement the data storage method provided in the embodiments of the present application can be used as the key-value storage.
  • the method includes:
  • Step 301 The key-value storage receives a key-value storage request.
  • the key-value storage request carries a key and a first value, where the first value is a value corresponding to the key.
  • Step 302 The key value storage allocates a first storage space for the first value in the first storage.
  • a second storage space may be pre-configured in the first memory in the key-value storage for storing values.
  • the key-value storage allocates the storage space in the first storage for the first value, it may Priority is given to allocating storage space for the first value from the second storage space.
  • the size of the second storage space may be equal to or greater than the first value.
  • the second storage space may store the first value carried in one or more key-value storage requests.
  • the second storage space may be the storage space configured by the key-value storage from the first storage in advance after receiving the key-value storage request and before storing the first value carried in the key-value storage request,
  • the size of the second storage space may be equal to the first value or greater than the first value, so that the key value storage can flexibly allocate the first storage space for the first value from the second storage space.
  • the second storage space may be a storage space pre-configured by the key value storage from the first storage before the key value storage request is received. Since it is pre-configured before receiving the key-value storage request, the key-value storage can be pre-configured with a larger storage space as the second storage space, so that the key-value storage can store the first carried in multiple key-value storage key values. value.
  • the key-value memory can determine whether there is free space in the second storage space, and whether the free space can store the first value; if there is enough free space in the second storage space to store the first value , Select the free space from the second storage space as the first storage space.
  • the key value storage can be the first value from the first storage. Value allocation storage space.
  • the storage space allocated by the key-value storage for the first value from the first storage and the free space in the second storage space can be used to store the first value (such as storing one or Multiple second values). That is, the sum of the allocated storage space and the free space in the second storage space may be equal to the size of the first value.
  • the key value memory may also allocate a first storage space with a size equal to the size of the first value for the first value from the first storage.
  • the key value storage may also configure a third storage space from the first storage, and the third storage space is larger than The storage space required for the first value.
  • the third storage space may be a relatively large storage space such as 1G or 500M.
  • the third storage space can also be used to store the first value carried in the key-value storage request subsequently received by the key-value storage.
  • the key-value storage allocates the first value in the third storage space. The first storage space.
  • the key-value storage may not be configured with the second storage space in the first storage in advance, and when data storage is required, the first storage space is dynamically allocated in the first storage for the first value.
  • the key value storage may allocate the first storage space in the first storage according to the size of the first value.
  • the size of the first storage space is equal to the size of the storage space required for the first value as an example.
  • the embodiment of the present application does not limit the size of the first storage space.
  • the maximum threshold of the first value carried in the key-value storage request may be set. In other words, the maximum threshold is used to represent the maximum size of the value carried in the key-value storage request.
  • the key value storage allocates the first storage space in the first storage for the first value
  • the allocated first storage space may be equal to the maximum threshold.
  • the key-value memory stores the second value, it can store the second value in the allocated first storage space, and the storage location of the second value in the first storage space can be flexibly set, so that the way of storing the second value is more flexible .
  • the first storage space may be a continuous storage space or a discontinuous storage space, which is not limited in the embodiment of the present application.
  • Step 303 When the capacity of the data contained in the first value is greater than or equal to the first threshold, the key value store divides the first value into multiple second values, and generates multiple secondary key value storage requests, each secondary The key-value storage request carries the key and a second value.
  • the number of secondary key value storage requests is the same as the number of multiple second values obtained by dividing the first value.
  • the embodiment of the present application does not limit the sequence of step 302 and step 303, and can be performed simultaneously or sequentially.
  • the key value storage first caches the first value in the second storage. After that, the first value is transferred to the first memory, which will lead to a longer time for data storage.
  • the capacity of the data contained in the first value can also be referred to as the size of the first value, which refers to the total size of the data contained in the first value (size), or it can be said to refer to the storage space required to store the first value.
  • the size of the minimum storage space For example, if the content contained in the first value is "0123456789", the capacity of the data contained in the first value is 10 bytes.
  • the first threshold can be set here.
  • the first value is considered to be larger and belongs to large-size data; otherwise, the first value belongs to small-size data.
  • the specific value of the first threshold can be an empirical value, such as 1 mega (M), or it can be set according to specific scenarios and key-value storage performance. For example, in some key-value storage scenarios, the size of the value that needs to be stored in a period of time can be counted, and the first threshold can be determined according to the size of the value that needs to be stored in the statistics.
  • the storage efficiency of the key value memory is significantly slowed down, and 5M may be used as the first threshold.
  • the foregoing method of setting the threshold is only an example, and the embodiment of the present application does not limit the specific value and setting method of the threshold.
  • the embodiment of the present application proposes a method of data partitioning.
  • the first value is divided into multiple second values.
  • the second value is stored in the first memory in stages, and the key value memory is Complete the positive sequence, storage and merging process of multiple second values.
  • the embodiment of the present application does not limit the specific implementation of data segmentation, and any method that can finally divide the first value into multiple smaller second values is applicable to the embodiment of the present application.
  • FIG. 4 it is a schematic diagram of generating multiple secondary key value storage requests and merging after dividing the first value, which is divided into two different processes, the slicing process and the splicing process.
  • the key-value storage can divide the first value carried in the key-value storage request into multiple second values, and generate multiple secondary key-value storage requests.
  • Each secondary key-value storage request includes a message Header and a second value (the format of the secondary key value storage request will be explained later);
  • the splicing process is the process in which the key value storage reads the third value from the first storage, which can be seen as the inverse process of the sharding process.
  • the third threshold can be equal to the second threshold, or other values
  • the third threshold is 10M
  • the key value memory reads multiple fourth values from the first memory, and generates After multiple secondary key-value storage requests, multiple fourth values are combined into a third value, and the third value is carried in the key-value storage response that needs to be fed back to the key-value client of the application server.
  • FIG. 5 a schematic diagram of the format of a key-value storage request provided by an embodiment of the present application.
  • the key-value storage request includes two parts, one is a header and the other is a packet.
  • the message header carries some attribute information of keys and values.
  • the message header includes key identifier (k ID), type (type), key size (key size), value total size, value size, and value offset (value offset) ;
  • the data packet includes keys and values.
  • the key identifier is used to indicate the serial number of the key.
  • the type is used to indicate the operation type of the key-value storage request, for example, it can be insert (put), search (get), and delete (delete).
  • the insertion instruction key value storage request is a write request, and the value carried in the key value storage request (such as the first value in the embodiment of this application) needs to be stored in the first memory;
  • the search instruction key value storage request is read To fetch the request, the value corresponding to the key carried in the key-value storage request needs to be read from the first storage;
  • the deletion indicates that the value corresponding to the key carried in the key-value storage request needs to be deleted from the first storage.
  • the above three operation types are only examples, and the embodiments of the present application are not limited, and other operation types, such as update, may also exist.
  • the key size is used to indicate the size of the key carried in the key-value storage request.
  • the total value size is used to indicate the total size of the value carried in the key-value storage request (the corresponding key-value storage request is a write request, and the type is put), or the total size of the value obtained by the key-value storage request (the corresponding key-value storage request is Read request, the type is get), or the total size of the value deleted by the key value storage request (corresponding to the key storage request of type delete).
  • the value offset is used to indicate the offset of the value carried in the key value storage request (such as the second value in the embodiment of the present application) relative to the first position of the total value (corresponding to the first value in the embodiment of the present application).
  • the value offset may indicate the position of the second value in the first value. The larger the value offset, the lower the position of the second value in the first value.
  • the value size is used to indicate the size of the value (corresponding to the first value or the second value in the embodiment of the present application) carried in the key value storage request. Exemplarily, if the total length of a value is 2024, it is divided according to 1024. After the division, for the first value (such as the second value in the embodiment of this application), the value offset is 0 and the value size is 1024; The second value, the value offset is 1024, and the value size is 1000.
  • the format of a secondary key value storage request provided by the embodiment of the present application is similar to the key value storage request shown in FIG. 5, which can be referred to FIG. 5.
  • the secondary key value storage request can also be divided into two parts, one is the message header, and the other is the data packet.
  • the message header carries some attribute information of keys and values. Specifically, the message header includes key identifiers, types, key sizes, total value sizes, value sizes, and value offsets; data packets include keys and values.
  • the type of the key-value storage request is insert as an example, and correspondingly, the type in the secondary key-value storage request is also insert.
  • the total value size indicates the size of the value before data segmentation, that is, the size of the first value carried in the key value storage request.
  • the value size indicates the size of the value carried in the secondary key value storage request (corresponding to the second value in the embodiment of the present application).
  • the value offset indicates the offset position of the value carried in the secondary key value storage request (such as the second value in the embodiment of this application) in the value (corresponding to the first value in the embodiment of this application) in the key value storage request.
  • the value offset in the secondary key value storage request may be 0, indicating that the second value carried in the secondary key value storage request is divided from the starting position of the second value in the first value of.
  • the value offsets in the secondary key value storage requests that carry different second values are different, and the value offsets can reflect the position order of the second value in the first value.
  • the type may also indicate whether the key value storage request is a key value storage request before data segmentation or a secondary key value storage request formed after data segmentation.
  • an identification bit can be added to the type to indicate whether the key-value storage request is a key-value storage request before data segmentation or a secondary key-value storage request.
  • a field can be added to the key-value storage request as a slice, which is used to indicate whether the request is a key-value storage request before data segmentation or a secondary key. Value storage request.
  • the fragment has the first value (such as null), it indicates that the request is a key-value storage request before data segmentation, and when the fragment has the second value (such as 1), it indicates that the request is a secondary key-value storage request.
  • the key value memory can divide the first value into five second values, and the size of each second value is 1M. In this way, five secondary key value storage requests can be generated. Each secondary key value storage request carries a second value.
  • the value size is 1M, Indicates that the size of the second value carried is 1M, and the value offset can be set to 0, indicating that the second value is divided from the starting position of the first value; for the secondary key value storage that carries the second second value
  • the size of the value in the request is 1M
  • the size of the second value carried in the instruction is 1M
  • the value offset can be set to 1M, indicating that the second value is segmented from the 1M position of the first value.
  • the secondary key value storage request may set a field to indicate the order of the carried second value in the first value more intuitively.
  • a fragment field can be used.
  • 1 indicates that the key-value storage request is a secondary key-value storage request, and the second value carried in the secondary key-value storage request is the first value after the first value is split.
  • Binary value indicates that the key value storage request is a secondary key value storage request, and the second value carried in the secondary key value storage request is a second value whose position order is second after the first value is divided.
  • the above indication of using the fragment field is only an example, for example, other fields may be added, which is not limited in the embodiment of the present application.
  • the value in the data packet in the secondary key-value storage request is part of the value in the key-value storage request.
  • the value in the data packet in the secondary key-value storage request is the second value
  • the key-value storage The value in the data packet in the request is the first value.
  • the key identifier, type, key size, and total value of the message header in the secondary key-value storage request are the same as the content of the corresponding field in the key-value storage request.
  • the key and key value in the data packet in the secondary key-value storage request The keys in the storage request are the same.
  • Method 1 In the process of caching the first value, partition while caching.
  • the key value storage may first buffer the first value.
  • the caching process when the size of the cached data reaches the second threshold, the cached data is taken as a second value, and a corresponding secondary key value storage request is generated.
  • the value size field can be set to the size of the second value
  • the value offset is the position of the second value in the first value, indicating the offset of the second value relative to the first value of the first value.
  • the second value carried in the secondary key value storage request can be stored in the first storage space allocated for the first value, because the second value is only a part of the first value , The second value only takes up part of the storage space.
  • the key-value storage will continue to cache the remaining first value, when the size of the cached data reaches the second threshold (the previously cached data has been carried in the secondary key-value storage request, in this case, The size of the cached data starts from 0), the cached data is used as a second value; the corresponding secondary key request is generated, and the same operation as before is performed, including setting the secondary storage key request, and setting the secondary key
  • the second value carried in the value storage request is stored in the first storage space allocated for the first value; when the second value is stored, because a second value is already stored in the first storage space allocated for the first value. Value, the second value carried in the secondary key value storage request is stored in the storage space after the stored second value to achieve sequential storage.
  • the above process is looped until the first value is cached. It should be noted that when the first value is cached in the final stage, the first value may be cached, but the cached data does not reach the second threshold. In this case, the key-value storage may directly use the cached data as a second value, generate a corresponding secondary key request, and store the second value in the secondary storage key request into the first storage. In this case, it can be found that the sizes of the divided second values are not completely the same, and there may be a second value whose size is smaller than the second threshold.
  • step 303 and step 304 are performed alternately, and this method is only an example.
  • the operation of storing the second value can be executed after the first value is cached and all secondary key value storage requests (step 303) are generated, which is not limited in this embodiment of the application.
  • the key-value memory may adopt a state machine control mode.
  • Fig. 8 is a schematic diagram of a state machine provided by an embodiment of the application.
  • the finite state machine can be set in 6 states, namely, idle state (IDLE), waiting command (WAIT_CMD), and waiting descriptor (WAIT_DSC) , Wait for data (WAIT_DATA), generate descriptor (GEN_DSC), complete (FINISH) state, the state transition diagram is shown in Figure 8.
  • IDLE idle state
  • WAIT_CMD waiting command
  • WAIT_DSC waiting descriptor
  • WAIT_DATA Wait for data
  • G_DSC generate descriptor
  • complete complete
  • IDLE state When the first value is received, jump to WAIT_CMD state; otherwise, keep in IDLE state.
  • WAIT_CMD state Waiting to receive insert command. In this state, if the type of the key-value storage request is parsed by the key-value store, it will jump to the IDLE state, and the first value received is invalid and discarded; if the type of the key-value storage request is parsed, it will jump to WAIT_DSC State; otherwise, keep in WAIT_CMD state.
  • WAIT_DSC state waiting for receiving card to host (card to host, C2H) descriptor.
  • the C2H descriptor is used to indicate the size of the first value and the first storage space allocated by the key value storage for the first value. After the key value storage receives the key value storage request and allocates the first storage space for the first value, it may generate the C2H descriptor.
  • the key value memory determines the C2H descriptor, it jumps to the WAIT_DATA state; otherwise, it remains in the WAIT_DSC state.
  • WAIT_DATA state Waiting for the first value to be buffered to one frame (taking the second threshold as one frame as an example). When the first value buffer reaches one frame, the buffered data is used as the second value.
  • the first value is cached for one frame, and the first value has not been cached, that is, it is not the last frame, jump to the GEN_DSC state; when the last frame of the first value is cached, jump to the FINISH state; otherwise , Remain in the WAIT_DATA state; here, taking the size of the second value as one frame as an example, the embodiment of the present application does not limit the size of the second value.
  • GEN_DSC state Generate C2H fragment descriptor.
  • the key value memory can start a data transfer and transfer the second value to the first storage space.
  • the C2H fragment descriptor is used to indicate the size of the second value, the storage address of the second value, or the source address of the second value, etc., where the source address of the second value is the address of the key value memory cache second value, such as the key
  • the value memory caches the address of the second value in the second memory; it should be noted that caching the second value here means that when the key value memory caches the first value, the cached data is used as the second value.
  • the key value memory may store the second value carried in the corresponding secondary key value storage request in the first storage space according to the information indicated by the C2H fragment descriptor.
  • the storage address indication of the second value is a storage space for storing the second value.
  • the key value memory may determine the location of the storage space in the first storage space according to the size of the second value and the position of the second value in the first value, and determine the storage address of the second value.
  • the storage space for storing the second value is one frame from the starting position in the first storage space
  • the storage space can then determine the storage address of the second value; if the second value currently cached in the key-value memory is the third frame of the first value, the storage space used to store the second value is 3M in the first storage space
  • the storage space starting from the position and the size is one frame, and then the storage address of the second value is determined.
  • the corresponding secondary key value storage request is generated, and then it jumps to the WAIT_DATA state; otherwise, it remains in the GEN_DSC state.
  • FINISH state Generate the last piece of C2H fragment descriptor (that is, cache the last frame of the first value, and generate the last second value), marking the completion of the cache operation of the first value.
  • the first value When the first value is completely transmitted, it jumps to the IDLE state; otherwise, it remains in the FINISH state.
  • the embodiment of the present application is not a specific value of the second threshold, but may be an empirical value, or may be set according to a specific scenario, and the embodiment of the present application is not limited.
  • Method 2 After the first value is cached, segmentation is performed.
  • the key value memory can also divide the first value into multiple second values after fully buffering the first value.
  • the key-value storage may evenly divide the first value into a plurality of second values with the same size.
  • the second value is less than the second threshold.
  • the key-value memory may also randomly divide the first value, and the size of each second value after division is different.
  • each secondary key value storage request carries one of the second values
  • the message in each secondary key value storage request The value offset in the header indicates the position of the second value carried in the first value.
  • Step 304 The key-value storage stores the second value carried in each secondary key-value storage request to the first storage according to the order in which the second value carried in each secondary key-value storage request is located in the first value space.
  • the key value storage may store the second value carried in the secondary key value storage request in the order of the position of the second value in the first value, in the order from front to back in the order of position.
  • the position of the second value carried in the secondary key value storage request in the first value can be determined according to the value offset in the header of each secondary key value storage request, and each secondary key value can be The value offsets in the message header in the value storage request are sorted in order of magnitude, from small to large, and the second value carried in the corresponding secondary key value storage request is sequentially stored in the first storage space.
  • the key value storage when the key value storage stores the second value carried in the secondary key value storage request.
  • the storage position of the second value in the first storage space may be determined according to the position of the second value in the first value.
  • the second value is stored in the storage location in the first storage space, and the location of the second value in the first value can be determined by the value offset in the message header of the secondary key value storage request.
  • the value offset in the header of the secondary key value storage request is 0, it indicates that the second value carried in the secondary key value storage request is located at the beginning of the first value, and the second value is in the first value.
  • the storage location of a storage space is a storage space with a size of a second value starting from the starting point of the storage space.
  • the value offset in the message header of the secondary key value storage request is 1M, which indicates that the second value carried in the secondary key value storage request starts at the 1M position of the first value, and the second value is in the first storage space
  • the storage location starts from the location corresponding to the 1M data that is stored empty, and the size is the second value size storage space.
  • the key value storage After storing the second value in all secondary key value storage requests in the first storage space, the key value storage ends the data storage operation.
  • the key value memory judges whether the total size of the second value stored in the first storage space is consistent with the size of the first value, and determines whether the first value is stored through the judgment result; if the key value memory can query the first storage space For the stored second value, if the total size of the stored second value is consistent with the size of the first value, it is determined that the storage of the first value is completed.
  • the key value storage may accumulate the key value size in the header of each stored secondary key value storage request to generate an accumulated value until the accumulated value is equal to the total size of the key value. Determine whether the storage of the first value is complete, and end the data storage operation.
  • the embodiment of the application also provides a key-value memory for executing the method of the key-value memory in the above-mentioned method embodiment.
  • the device includes a receiving unit 901, a distributing unit 902, a dividing unit 903, and a storage unit 904:
  • the receiving unit 901 is configured to receive a key-value storage request.
  • the key-value storage request includes a key and a first value, where the key corresponds to the first value.
  • the allocating unit 902 is configured to allocate a first storage space for the first value in the first storage, and the first storage is a storage other than the key value storage.
  • the dividing unit 903 is configured to divide the first value into multiple second values when the total length of the first value is greater than or equal to the first threshold, and generate multiple secondary key value storage requests, each secondary key value
  • the storage request carries the key and a second value, and the number of secondary key value storage requests is the same as the number of multiple second values obtained by dividing the first value.
  • the storage unit 904 is configured to store the second value carried in each secondary key value storage request in the first storage according to the position order of the second value carried in each secondary key value storage request in the first value space.
  • the dividing unit 903 when it divides the first value into multiple second values, it may divide while buffering.
  • the dividing unit 903 in the process of caching the first value, the dividing unit 903 may use the cached data as the second value whenever the size of the cached data is equal to the second threshold, and carry the second value in a secondary key. In the value storage request, until the first value cache is completed.
  • the remaining data size of the last first value is less than the second threshold, you can directly use the cached data as the second value and carry it in a secondary key value storage request; in this case ,
  • the size of the second value carried in each secondary key value storage request may not be exactly the same.
  • the dividing unit 903 when the dividing unit 903 divides the first value into multiple second values, it may also use a method of data division after the buffering is completed; for example, the dividing unit 903 may perform data division after the first value is buffered.
  • the first value is divided into multiple second values; for example, the dividing unit 903 may divide the first value into N+1 second values, and among the multiple second values arranged in the order of division, the first N second values
  • the size of can be equal to the second threshold, the last second value, that is, the size of the N+1th second value can be less than or equal to the second threshold, and N is a positive integer greater than or equal to 1.
  • the dividing unit 903 may also set the second values to be multiple second values.
  • the secondary key value storage request may include some fields for indicating related information of the second value carried, such as the size and offset of the second value.
  • a value offset may be included, and the value offset may indicate the position of the second value carried in the secondary key value storage request in the first value.
  • the storage unit 904 stores the second value carried in each secondary key value storage request to the first value in the order of the second value carried in each secondary key value storage request.
  • the position order needs to be determined first, and then the second value is stored; for example, the storage unit 904 may determine each secondary key value storage request according to the value offset in each secondary key value storage request The position order of the second value carried in the first value in the first value; after that, the second value is stored in the first storage space according to the position order.
  • the second storage for the first value carried in one or more key value storage requests may be pre-configured in the first storage.
  • Storage space The storage unit 904 may allocate the first storage space for the first value from the second storage space.
  • the size of the first storage space may be equal to or greater than the first value.
  • the storage unit 904 may pre-configure the second storage space before the receiving unit 901 receives the key-value storage request; it may also pre-configure the second storage space after the receiving unit 901 receives the key-value storage request and before the storage unit 904 stores the first value.
  • the size of the second storage space can be equal to or greater than the size of the first value.
  • the storage unit 904 when the storage unit 904 allocates storage space for the first value in the first storage, if the size of the free space in the second storage space is less than the size of the first value, the storage unit 904 may not store the first value.
  • the first storage space is allocated for the first value from the first storage.
  • the storage unit 904 may also determine whether the first value has been stored; for example, when the total size of the second value stored in the first storage space is equal to the size of the first value, the storage unit 904 may determine The storage of the first value has been completed.
  • the storage unit 904 may accumulate the secondary key value corresponding to the stored second value Store the size of the requested value until the accumulated value is equal to the size of the first value, and it is determined that the first value has been stored.
  • the division of units in the embodiments of the present application is illustrative, and is only a logical function division, and there may be other division methods in actual implementation.
  • the functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
  • the above-mentioned integrated unit can be implemented in the form of hardware or software functional unit.
  • the foregoing embodiments can be implemented in whole or in part by software, hardware, firmware or any other combination.
  • the above-mentioned embodiments may be implemented in the form of a computer program product in whole or in part.
  • the computer program product includes one or more computer instructions.
  • the computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices.
  • the computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium.
  • the computer instructions may be transmitted from a website, computer, server, or data center.
  • the computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or a data center that includes one or more sets of available media.
  • the usable medium may be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium.
  • the semiconductor medium may be a solid state drive (SSD).
  • FIG. 10 is a schematic diagram of a key value storage 1000 according to an embodiment of the application.
  • the key value storage 1000 includes a processor 1001 and a memory 1002.
  • the key value storage 1000 may further include a communication interface 1003.
  • the number of the memory 1002 and the communication interface 1003 does not constitute a limitation to the embodiment of the present application, and can be configured arbitrarily according to business requirements during specific implementation.
  • the memory 1002 may be a volatile memory, such as a random access memory; the memory may also be a nonvolatile memory, such as a read-only memory, flash memory, hard disk drive (HDD) or solid-state drive (SSD) Or the memory 1002 is any other medium that can be used to carry or store desired program codes in the form of instructions or data structures and that can be accessed by a computer, but is not limited thereto.
  • the memory 1002 may be a combination of the above-mentioned memories.
  • the memory 1002 may be the second memory in the foregoing method embodiment.
  • connection medium between the foregoing processor 1001 and the memory 1002 is not limited in the embodiment of the present application.
  • the processor 1001 may be a CPU, and the processor 1001 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate array (FPGA) or other programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, artificial intelligence chips, chips on a chip, etc.
  • the general-purpose processor may be a microprocessor or any conventional processor. It has a data transceiver function and can communicate with other devices.
  • an independent data transceiver module such as a communication interface 1003, can be used to send and receive data; when the processor 1001 communicates with other devices, it can Data transmission is performed through the communication interface 1003, such as receiving a key-value storage request from an application server key-value client.
  • the processor 1001 in FIG. 10 can call the computer-executed instructions stored in the memory 1002, so that the key-value memory can execute the key-value memory execution in any of the foregoing method embodiments. The steps of the method.
  • the processor 1001 of the key-value storage in FIG. 10 may implement the functions of the key-value storage engine 205 and the network offloading engine 207 in FIG. 2.
  • the functions/implementation processes of the receiving unit, the allocation unit, the dividing unit, and the storage unit in FIG. 9 can all be implemented by the processor 1001 in FIG. 10 calling the computer execution instructions stored in the memory 1002.
  • the function/implementation process of the allocation unit, the division unit, and the storage unit in FIG. 9 can be implemented by the processor 1001 in FIG. 10 calling the computer execution instructions stored in the memory 1002, and the function/implementation of the receiving unit in FIG. 9
  • the process can be implemented through the communication interface 1003 in FIG. 10.
  • the embodiment of the present application also provides a key-value storage server.
  • the structure of the key-value storage server can be seen in FIG. 2.
  • the key-value storage server may include a key-value storage and a first storage;
  • the memory is a memory other than the key value memory;
  • the key value memory is used to execute the method executed by the key value memory in the foregoing method embodiment, and the first memory is used to store the first value; optionally, it may also include a central processing unit.
  • the disclosed system, device, and method may be implemented in other ways.
  • the device embodiments described above are only illustrative.
  • the division of the units is only a logical function division, and there may be other divisions in actual implementation, for example, multiple units or components can be combined or It can be integrated into another system, or some features can be ignored or not implemented.
  • the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.

Abstract

A data storage method, a memory and a server. The specific method comprises: a key-value memory receiving a key-value storage request, the key-value storage request comprising a key and a first value; when the first value is large-size data, the key-value memory segmenting the first value into a plurality of second values, and generating a plurality of secondary key-value storage requests, each secondary key-value storage request carrying the key and one of the second values; then, according to the position sequence, in the first value, of the second value carried in each secondary key-value storage request, storing in a first storage space the second value carried in each secondary key-value storage request, thereby solving the problem of low data storage efficiency of large-size data in a key-value storage system.

Description

数据存储方法、存储器和服务器Data storage method, storage and server 技术领域Technical field
本申请涉及存储技术领域,尤其涉及一种数据存储方法、存储器和服务器。This application relates to the field of storage technology, and in particular to a data storage method, storage and server.
背景技术Background technique
键值(key-value)存储技术是利用键对存储数据的数据存取方式,每个键(key)对应一个值(value),键值存储技术在数据中心中有广泛的应用。随着半导体技术的发展,存储器的成本快速下降,越来越多的高性能的存储器被应用到数据中心,形成了不同类型的键值存储系统。Key-value storage technology is a data access method that uses key pairs to store data. Each key corresponds to a value. Key-value storage technology is widely used in data centers. With the development of semiconductor technology, the cost of storage has dropped rapidly, and more and more high-performance storage has been applied to data centers, forming different types of key-value storage systems.
键值存储系统从开始的基于机械硬盘的系统逐步发展到利用动态随机存取存储器(dynamic random access memory,DRAM)作缓存的缓存型系统,发展到将包括键和值的所有数据都存储于DRAM作为内存的内存型系统。The key-value storage system has gradually developed from a system based on mechanical hard disks to a cache-type system that uses dynamic random access memory (DRAM) as a cache, and has developed to store all data including keys and values in DRAM A memory-based system as memory.
但是,对于键对应的值的大小较大的情况下,在写入该值的过程中,数据存储效率较低。以一个值的写入过程为例,首先,需要先缓存该值,由于该值的大小较大,需要较大的缓存空间,且为了能够将该值完整的存储至DRAM中,需要在该值完全缓存之后,才启动由缓存至DRAM的传输过程,整个处理过程中该值的缓存时间和传输时间均相对较长,产生较大的传输时延,数据存储效率低。However, when the size of the value corresponding to the key is large, the data storage efficiency is low in the process of writing the value. Take the writing process of a value as an example. First of all, the value needs to be cached. Because the size of the value is large, a large cache space is required. In order to store the value completely in DRAM, the value needs to be stored The transmission process from the cache to the DRAM is started after the complete cache. The cache time and transmission time of this value are relatively long during the entire process, resulting in a large transmission delay and low data storage efficiency.
发明内容Summary of the invention
本申请提供一种数据存储方法、存储器和服务器,用以解决传统技术中键值存储系统中大尺寸数据的数据存储效率低的问题。This application provides a data storage method, memory and server to solve the problem of low data storage efficiency of large-size data in the key-value storage system in the traditional technology.
第一方面,本申请提供了一种数据存储方法,该方法包括:首先,键值存储器接收键值存储请求,键值存储请求中包括键和第一值,键与第一值是对应的;为了存储第一值,键值存储器可以在第一存储器中划分用于存储第一值的第一存储空间,其中,第一存储器可以是键值存储器之外的存储器;若第一值为大尺寸数据;示例性的,第一值所包含数据的容量大于或等于第一阈值,键值存储器可以进行数据分割,将第一值分割为多个第二值,并生成多个次级键值存储请求,每个次级键值存储请求中可以携带键和其中一个第二值;次级键值存储请求的数量与第一值分割获得的多个第二值的个数是相同的。在存储第一值时,键值存储器可以依据每个次级键值存储请求中携带的第二值在第一值中的位置顺序,分别将每个次级键值存储请求中携带的第二值存储至第一存储空间。其中,第一值所包含数据的容量也可以称为第一值的大小,是指第一值中所包含数据的总大小,也可以说是指存储第一值所需存储空间的最小存储空间的大小。例如,第一值中包含内容为“0123456789”,则第一值所包含数据的容量为10字节。In a first aspect, the present application provides a data storage method. The method includes: first, the key-value storage receives a key-value storage request, the key-value storage request includes a key and a first value, and the key and the first value are corresponding; In order to store the first value, the key-value memory may divide the first storage space for storing the first value in the first memory, where the first memory may be a memory other than the key-value memory; if the first value is a large size Data; Exemplarily, the capacity of the data contained in the first value is greater than or equal to the first threshold, the key-value storage can perform data segmentation, divide the first value into multiple second values, and generate multiple secondary key-value stores Request, each secondary key value storage request can carry a key and one of the second values; the number of secondary key value storage requests is the same as the number of multiple second values obtained by dividing the first value. When storing the first value, the key-value storage can separately store the second value carried in each secondary key-value storage request according to the position order of the second value carried in each secondary key-value storage request in the first value. The value is stored in the first storage space. Among them, the capacity of the data contained in the first value can also be referred to as the size of the first value, which refers to the total size of the data contained in the first value, or the minimum storage space required to store the first value. the size of. For example, if the content contained in the first value is "0123456789", the capacity of the data contained in the first value is 10 bytes.
通过上述方法,对于大尺寸数据,键值存储器可以进行数据分割,分割为多个较小的第二值,值的尺寸较小,可以有效缩短数据缓存和传输的时间,减小时延,进一步有效提高大尺寸数据的数据存储效率。Through the above method, for large-size data, the key-value memory can be divided into multiple smaller second values, and the value of the smaller size can effectively shorten the time of data buffering and transmission, reduce the delay, and be more effective Improve the data storage efficiency of large-size data.
在一种可能的设计中,键值存储器在将第一值分割为多个第二值时,可以边缓存边分 割;示例性的,键值存储器在缓存第一值(如在键值存储器中的第二存储器缓存第一值)的过程中,每当缓存的数据的大小小于或等于第二阈值时,将缓存的数据作为第二值,并携带在一个次级键值存储请求中,直至第一值缓存完成。当第一值的缓存的最后阶段,最后缓存的数据大小小于第二阈值,可以直接将缓存的数据作为第二值,携带在一个次级键值存储请求中;这种情况下,每个次级键值存储请求中携带的第二值的大小不一定完全相同。In a possible design, when the key-value memory divides the first value into multiple second values, it can be divided while caching; for example, the key-value memory can cache the first value (such as in the key-value memory). In the process of caching the first value in the second memory), whenever the size of the cached data is less than or equal to the second threshold, the cached data is taken as the second value and carried in a secondary key value storage request until The first value cache is completed. When the final stage of the first value of the cache, the size of the last cached data is less than the second threshold, the cached data can be directly used as the second value and carried in a secondary key value storage request; in this case, each time The size of the second value carried in the level key value storage request is not necessarily the same.
通过上述方法,采用边缓存边分割的方式,可以在缓存的过程中,同时完成数据分割的操作,能够较快的进行数据分割,进而可以尽快进行数据存储,进一步,可以提升数据存储效率。Through the above method, the method of partitioning while caching is adopted, and the operation of data partitioning can be completed at the same time during the caching process, data partitioning can be performed faster, data storage can be performed as soon as possible, and data storage efficiency can be improved.
在一种可能的设计中,键值存储器在将第一值分割为多个第二值时,也可以采用缓存完成后再进行数据分割的方式。示例性的,键值存储器在第一值缓存完成后,可以将第一值分割为多个第二值,键值存储器可以将第一值分割为N+1个第二值,其中按照分割顺序排列的多个第二值中,前N个第二值中每个第二值的大小均可以等于第二阈值,第N+1个第二值的大小可以小于或等于第二阈值,N为大于或等于1的正整数。示例性的,键值存储器也可以将第二值均为多个第二值。In a possible design, when the key-value memory divides the first value into a plurality of second values, the data division method may also be adopted after the cache is completed. Exemplarily, after the first value cache is completed, the key value storage may divide the first value into multiple second values, and the key value storage may divide the first value into N+1 second values, in which the order of division is Among the multiple second values arranged, the size of each of the first N second values can be equal to the second threshold, and the size of the N+1th second value can be less than or equal to the second threshold, and N is A positive integer greater than or equal to 1. Exemplarily, the key value storage may also set the second value to multiple second values.
通过上述方法,采用先缓存后分割的方式,键值存储器可以依据第一值的大小设置第二阈值,能够更加灵活的对第一值进行分割。Through the above method, the method of caching first and then segmentation is adopted, and the key value memory can set the second threshold value according to the size of the first value, which can segment the first value more flexibly.
在一种可能的设计中,次级键值存储请求中可以设置字段,用于指示携带的第二值的相关信息,如第二值的大小、偏移量等。示例性的,可以包括值偏置,通过值偏置可以指示次级键值存储请求中携带的第二值在第一值中的位置。In a possible design, a field may be set in the secondary key value storage request to indicate the relevant information of the second value carried, such as the size and offset of the second value. Exemplarily, a value offset may be included, and the value offset may indicate the position of the second value carried in the secondary key value storage request in the first value.
通过上述方法,通过设置相应字段,键值存储器可以更加方便的确定出第二值的相关信息,能够使得后续方便的确定出每个次级键值存储请求中携带的第二值在第一值中的位置顺序。Through the above method, by setting the corresponding fields, the key value storage can more conveniently determine the related information of the second value, which can make it convenient to determine that the second value carried in each secondary key value storage request is in the first value. The order of positions in.
在一种可能的设计中,键值存储器在将每个次级键值存储请求中携带的第二值存储至第一存储空间时,需要先确定每个次级键值存储请求中携带的第二值在第一值中的位置顺序;由于次级键值存储请求中可以包括值偏置;键值存储器可根据每个次级键值存储请求中的值偏置,确定该位置顺序。例如通过值偏置的大小比较确定位置顺序,之后键值存储器再根据位置顺序,将第二值存储至第一存储空间。In a possible design, when the key-value storage stores the second value carried in each secondary key-value storage request to the first storage space, it needs to first determine the second value carried in each secondary key-value storage request. The position order of the binary value in the first value; since the secondary key value storage request may include a value offset; the key value storage may determine the position order according to the value offset in each secondary key value storage request. For example, the position order is determined by comparing the magnitude of the value offset, and then the key value memory stores the second value in the first storage space according to the position order.
通过上述方法,键值存储器通过比较每个次级键值存储请求中的值偏置可以较为便捷的确定出位置顺序,提升数据存储效率,进一步保证高效的数据存储过程。Through the above method, the key-value storage can determine the position sequence more conveniently by comparing the value offset in each secondary key-value storage request, improve data storage efficiency, and further ensure an efficient data storage process.
在一种可能的设计中,键值存储器为第一值分配第一存储空间时,可以预先在第一存储器中配置用于一个或多个键值存储请求中携带的第一值的第二存储空间,键值存储器从第二存储空间选择第一存储空间,第一存储空间的大小可以等于或大于第一值的大小。键值存储器可以在接收到键值存储请求前预先配置第二存储空间;也可以在接收到携带键值存储请求之后,存储第一值之前,预先配置第二存储空间,这种情况下,第二存储空间可以等于第一值的大小,也可以大于第一值的大小。In a possible design, when the key-value storage allocates the first storage space for the first value, the second storage for the first value carried in one or more key-value storage requests can be configured in the first storage in advance. Space. The key-value memory selects the first storage space from the second storage space, and the size of the first storage space may be equal to or greater than the size of the first value. The key-value storage can pre-configure the second storage space before receiving the key-value storage request; it can also pre-configure the second storage space after receiving the key-value storage request and before storing the first value. In this case, the first 2. The storage space can be equal to the size of the first value or greater than the size of the first value.
通过上述方法,键值存储器可以从预先配置的第二存储空间中选择第一存储空间,可以更加快速的确定第一存储空间,使得第一值可以较快存储至第一存储空间中,可以实现 高效的数据存储过程。Through the above method, the key-value memory can select the first storage space from the pre-configured second storage space, and the first storage space can be determined more quickly, so that the first value can be stored in the first storage space faster, which can be realized Efficient data storage process.
在一种可能的设计中,键值存储器为第一值分配第一存储空间时,若第二存储空间中没有足够的空间存储第一值,也就是说,第二存储空间中的空闲空间的大小小于第一值的大小,键值存储器可以从第一存储器中为第一值分配第一存储空间。In a possible design, when the key-value memory allocates the first storage space for the first value, if there is not enough space in the second storage space to store the first value, that is, the amount of free space in the second storage space The size is smaller than the size of the first value, and the key value storage may allocate the first storage space for the first value from the first storage.
通过上述方法,键值存储器可以从第一存储器选择第一存储空间存储第一值,可以保证第一值可以存储至第一存储器中,可以保证数据存储的效率。Through the above method, the key value storage can select the first storage space from the first storage to store the first value, which can ensure that the first value can be stored in the first storage, and the efficiency of data storage can be guaranteed.
在一种可能的设计中,键值存储器中还可以包括第二存储器,键值存储器接收键值存储请求后,可以将键值存储请求中的键保存在第二存储器中;示例性的,第二存储器中可以存储哈希表,键值存储器可以更新哈希表,添加包括键的哈希表项;其中,添加的哈希表项中还包括第一存储空间的地址。In a possible design, the key-value storage may further include a second storage, and after receiving the key-value storage request, the key-value storage may store the keys in the key-value storage request in the second storage; exemplary, the first 2. A hash table can be stored in the storage, and the key value storage can update the hash table and add a hash table entry including the key; wherein the added hash table entry also includes the address of the first storage space.
通过上述方法,键值存储器可以及时的更新哈希表,记录键与对应的第一存储空间地址。Through the above method, the key value storage can update the hash table in time, and record the key and the corresponding first storage space address.
在一种可能的设计中,在第一存储空间中已存储的第二值的总大小等于第一值的大小的情况下,键值存储装置确定已完成第一值的存储,停止数据存储操作;次级键值存储请求包括值大小,用于指示次级键值存储请求中携带的第二值的大小,键值存储装置可以累加已存储的第二值对应的次级键值存储请求中值大小,直至累加值等于第一值的大小,表征第一值已存储完成。In a possible design, when the total size of the second value stored in the first storage space is equal to the size of the first value, the key-value storage device determines that the storage of the first value has been completed, and stops the data storage operation ; The secondary key value storage request includes the value size, which is used to indicate the size of the second value carried in the secondary key value storage request. The key value storage device can accumulate the stored second value corresponding to the secondary key value storage request The value size, until the accumulated value is equal to the size of the first value, indicating that the first value has been stored.
通过上述方法,键值存储器可以通过不同的方式确定第一值已完成存储,可以及时停止数据存储操作。Through the above method, the key value storage can determine that the first value has been stored in different ways, and can stop the data storage operation in time.
第二方面,本申请提供了一种键值存储器,键值存储器具有实现第一方面及第一方面任意一种可能的设计中键值存储器所实现的功能。功能可以通过硬件实现,也可以通过硬件执行相应的软件实现。硬件或软件包括一个或多个与上述功能相对应的模块。在一个可能的设计中,装置的结构中包括接收单元、分配单元、分割单元以及存储单元,这些单元可以执行上述第一方面方法示例中的相应功能,具体参见方法示例中的详细描述,此处不做赘述。In the second aspect, the present application provides a key-value memory, which has the function of the key-value memory in the first aspect and any one of the possible designs of the first aspect. The function can be realized by hardware, or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above-mentioned functions. In a possible design, the structure of the device includes a receiving unit, a distributing unit, a dividing unit, and a storage unit. These units can perform the corresponding functions in the method example of the first aspect. For details, please refer to the detailed description in the method example. Do not repeat it.
第三方面,本申请还提供了一种键值存储器,有益效果可以参见第一方面及第一方面任意一种可能的设计的描述此处不再赘述。键值存储器的结构中包括处理器和存储器,处理器被配置为支持键值存储器执行上述第一方面及第一方面任意一种可能的设计的方法中相应的功能。存储器与处理器耦合,其保存键值存储器必要的程序指令和数据。键值存储器的结构中还包括收发器,用于与其他设备进行通信。In the third aspect, the present application also provides a key value memory. For beneficial effects, please refer to the description of the first aspect and any possible design of the first aspect, which will not be repeated here. The structure of the key-value memory includes a processor and a memory, and the processor is configured to support the key-value memory to perform corresponding functions in the first aspect and any one of the possible design methods of the first aspect. The memory is coupled with the processor, and it stores the program instructions and data necessary for the key-value memory. The structure of the key-value memory also includes a transceiver for communicating with other devices.
第四方面,本申请提供了一种键值存储服务器,键值存储服务器包括第一存储器和键值存储器,第一存储器是键值存储器之外的存储器,键值存储服务器用于执行第一方面及第一方面任意一种可能的设计中任意设计提供的方法的操作步骤。In a fourth aspect, this application provides a key-value storage server. The key-value storage server includes a first storage and a key-value storage. The first storage is a storage other than the key-value storage. The key-value storage server is used to execute the first aspect. And the operation steps of the method provided in any one of the possible designs in the first aspect.
第五方面,本申请还提供一种计算机可读存储介质,计算机可读存储介质中存储有指令,当其在计算机上运行时,使得计算机执行上述各方面的方法。In a fifth aspect, the present application also provides a computer-readable storage medium that stores instructions in the computer-readable storage medium, which when run on a computer, causes the computer to execute the methods of the above aspects.
第六方面,本申请还提供一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行上述各方面的方法。In a sixth aspect, the present application also provides a computer program product containing instructions, which when run on a computer, causes the computer to execute the methods of the above aspects.
第七方面,本申请还提供一种计算机芯片,芯片与存储器相连,芯片用于读取并执行 存储器中存储的软件程序,执行上述各方面的方法。In a seventh aspect, the present application also provides a computer chip, which is connected to a memory, and the chip is used to read and execute a software program stored in the memory, and execute the methods of the above aspects.
附图说明Description of the drawings
图1为本申请提供的一种键值存储系统的架构示意图;Figure 1 is a schematic diagram of the architecture of a key-value storage system provided by this application;
图2为本申请提供的一种键值存储服务器的结构示意图;Figure 2 is a schematic structural diagram of a key-value storage server provided by this application;
图3为本申请提供的一种数据存储方法的示意图;FIG. 3 is a schematic diagram of a data storage method provided by this application;
图4为本申请提供的一种数据分片和拼接的流程示意图;FIG. 4 is a schematic diagram of a flow of data fragmentation and splicing provided by this application;
图5为本申请提供的一种键值存储请求的格式示意图;FIG. 5 is a schematic diagram of the format of a key-value storage request provided by this application;
图6为本申请提供的另一种键值存储请求的格式示意图;Figure 6 is a schematic diagram of another key-value storage request format provided by this application;
图7为本申请提供的一种第一值的分割示意图;FIG. 7 is a schematic diagram of a first value segmentation provided by this application;
图8为本申请提供的一种状态机的状态切换示意图;FIG. 8 is a schematic diagram of state switching of a state machine provided by this application;
图9为本申请提供的一种键值存储器的结构示意图;FIG. 9 is a schematic structural diagram of a key value storage provided by this application;
图10为本申请提供的另一种键值存储器的结构示意图。FIG. 10 is a schematic structural diagram of another key value storage provided by this application.
具体实施方式detailed description
本申请提供了一种数据存储方法、存储器和服务器,用以解决传统技术中键值存储系统中大尺寸数据的数据存储效率低的问题。This application provides a data storage method, memory and server to solve the problem of low data storage efficiency of large-size data in the key-value storage system in the traditional technology.
如图1所示,为本申请实施例提供的一种网络架构示意图,其中多个应用服务器键值客户端(application server key-value client)101和键值存储服务器(key-value server)102。应用服务器键值客户端101与键值存储服务器102之间通过网络进行交互,收发信息,本申请实施例并不限定网络的类型,例如可以是采用传输控制协议/因特网互联协议(transmission control protocol/internet protocol,TCP/IP)的有线传输方式,也可以是采用无线保真(Wifi)的无线传输方式。作为一种可能的实施例,键值存储服务器102也可以是由其他硬件组成的键值存储装置。As shown in FIG. 1, a schematic diagram of a network architecture provided by an embodiment of this application, in which a plurality of application server key-value clients 101 and key-value storage servers (key-value servers) 102 are provided. The application server key-value client 101 and the key-value storage server 102 interact through the network to send and receive information. The embodiment of the present application does not limit the type of the network. For example, the transmission control protocol/Internet interconnection protocol (transmission control protocol/ The wired transmission method of internet protocol (TCP/IP) can also be the wireless transmission method using wireless fidelity (Wifi). As a possible embodiment, the key-value storage server 102 may also be a key-value storage device composed of other hardware.
每个键值存储服务器102中可以设置存储器103,该存储器103可以用于存储值(value),存储器103可以是键值存储服务器中的缓存、闪存(flash),硬盘(hard disk drive,HDD)或固态硬盘(solid-state drive,SSD)等存储介质。示例性的,存储器103中还可以用于存储哈希表,用于记录键和值的对应关系,以及值的存储位置,以便于数据处理中利用哈希表查询到指定值所在存储位置。哈希表中存储有多个哈希表项,哈希表项为键与该键对应的值存储的存储空间的地址之间的对应关系,通过哈希表可以检索到键对应的值的存储地址(存储地址为在存储器103中的存储空间的地址)。在值的读取过程中,通过哈希表确定值的存储地址,进而,从存储器103获取值;在值的存储过程中,需要在哈希表中增加相应的哈希表项,以记录值的存储地址。Each key-value storage server 102 can be provided with a memory 103, and the memory 103 can be used to store values. The memory 103 can be a cache, flash memory (flash), or hard disk drive (HDD) in the key-value storage server. Or storage media such as solid-state drives (SSD). Exemplarily, the memory 103 may also be used to store a hash table for recording the correspondence between keys and values, and the storage location of the value, so that the hash table can be used in data processing to query the storage location of the specified value. There are multiple hash table entries stored in the hash table. The hash table entries are the correspondence between the key and the address of the storage space where the value corresponding to the key is stored. The storage of the value corresponding to the key can be retrieved through the hash table Address (the storage address is the address of the storage space in the memory 103). In the process of reading the value, the storage address of the value is determined by the hash table, and then the value is obtained from the memory 103; in the process of storing the value, the corresponding hash table entry needs to be added to the hash table to record the value The storage address.
图1所示的多个键值存储服务器102可以并行通过网络分别接收不同应用服务器键值客户端101发送的键值存储请求。若键值存储请求为读取请求,键值存储服务器102可以将键值存储请求中携带的值写入该存储器103。另外,键值存储服务器102还可以根据键值存储请求中携带的键以及为该值分配的在该存储器103中的存储空间,更新哈希表,插入新的哈希表项。插入的哈希表项包括键和存储地址;通过对键进行哈希运算,生成的哈希值为插入的哈希表项的索引。若键值存储请求为写入请求,键值存储服务器102可以根 据键值存储请求中携带的键从该存储器中读取对应的值。具体的,键值存储服务器102可以对键值存储请求中携带的键进行哈希运算,生成哈希值,通过哈希值查询哈希表中对应的哈希表项,进而比对查询到的哈希表项中的键与键值存储请求中携带的键是否一致,若一致,根据该哈希表项中的存储地址,从该存储器中读取值,并反馈给应用服务器键值客户端101。The multiple key-value storage servers 102 shown in FIG. 1 can respectively receive key-value storage requests sent by different application server key-value clients 101 via the network in parallel. If the key-value storage request is a read request, the key-value storage server 102 may write the value carried in the key-value storage request into the memory 103. In addition, the key-value storage server 102 may also update the hash table and insert new hash table entries according to the key carried in the key-value storage request and the storage space allocated for the value in the memory 103. The inserted hash table entry includes a key and a storage address; by hashing the key, the generated hash value is the index of the inserted hash table entry. If the key-value storage request is a write request, the key-value storage server 102 can read the corresponding value from the storage according to the key carried in the key-value storage request. Specifically, the key-value storage server 102 may perform a hash operation on the key carried in the key-value storage request to generate a hash value, query the corresponding hash table entry in the hash table through the hash value, and then compare the queried Whether the key in the hash table entry is consistent with the key carried in the key value storage request, if they are the same, read the value from the storage according to the storage address in the hash table entry and feed it back to the application server key value client 101.
作为一个可能的实施例,为了提升键值存储系统的存储效率,在同一个键值存储服务器102中可以并行调用多个处理逻辑存储不同的数据。例如,同时调用两个哈希函数进行哈希运算,每个哈希函数对应一组处理逻辑,每个处理逻辑映射的存储空间的地址可以对应4个存储桶(bucket),构成一组存储桶,也即每一个键可以对应8个存储桶,用于存储哈希表项;在更新哈希表项时,可以同时搜索8个存储桶中存储的哈希表项(键通过一个哈希函数映射的4个存储桶中存储的哈希表项为一组哈希表项),找出未被占用的存储桶,然后采用轮询的模式插入新的哈希表项;对于每一组存储桶,优先插入前面的空桶,在插入新的哈希表项时,可以两组交替插入。也就是说,在第一次插入哈希表项,选用其中一组存储桶中的一个存储桶,在第二次插入哈希表项,选用另一组存储桶中的一个存储桶。当出现哈希碰撞的情况时,即一个键对应的8个存储桶全部被占用时,通过预置规则选择一个存储桶,删除其中的部分哈希表项以插入新的哈希表项;例如,删除最早存储的10个哈希表项。在删除已有哈希表项时,也可以采用轮询模式,依次交替删除两组存储桶中的哈希表项。也就是说,在第一次删除哈希表项时,删除其中一组存储桶的一个存储桶中的哈希表项,在第二次删除哈希表项,删除另一组存储桶的一个存储桶中的哈希表项。As a possible embodiment, in order to improve the storage efficiency of the key-value storage system, multiple processing logics may be called in parallel to store different data in the same key-value storage server 102. For example, call two hash functions to perform hash operations at the same time. Each hash function corresponds to a set of processing logic, and the address of the storage space mapped by each processing logic corresponds to 4 buckets to form a set of buckets. , That is, each key can correspond to 8 storage buckets for storing hash table entries; when updating the hash table entries, you can search the hash table entries stored in 8 storage buckets at the same time (keys pass a hash function The hash table items stored in the mapped 4 buckets are a group of hash table items), find out the unoccupied buckets, and then use the polling mode to insert new hash table items; for each group of storage Buckets are inserted into the previous empty bucket first. When inserting new hash table entries, two groups can be inserted alternately. That is to say, when inserting a hash table entry for the first time, one of the buckets in one group is selected, and when inserting a hash table entry for the second time, one of the storage buckets in another group is selected. When a hash collision occurs, that is, when all 8 buckets corresponding to a key are occupied, a bucket is selected through preset rules, and some of the hash table entries are deleted to insert new hash table entries; for example, , Delete the earliest stored 10 hash table entries. When deleting an existing hash table entry, a polling mode can also be used to alternately delete the hash table entries in the two groups of buckets. In other words, when deleting a hash table entry for the first time, delete the hash table entry in one bucket of one group of buckets, and delete the hash table entry for the second time, and delete one of the other group of buckets. The hash table entry in the bucket.
在如图1所示的网络架构中,存在多个应用服务器键值客户端101和多个键值存储服务器102,任一个应用服务器键值客户端101可以向任一个键值存储服务器102发送键值存储请求。作为一个可能的实施例,多个键值存储服务器102也可以通过键值代理(proxy)(图1中未示出)与应用服务器键值客户端101通信,键值代理用于对应用服务器键值客户端101的键值存储请求进行管理和调度,分发给不同键值存储服务器。例如,键值代理可以按照键值存储服务器的当前负载情况分配键值存储请求。键值代理和键值存储服务器102可以部署在一个服务器中,也可以利用单独服务器部署,或者利用多个服务器以集群的形式部署。当以键值代理以集群形式部署时,对外可呈现一个互联网协议(internet protocol,IP)地址,应用服务器键值客户端101可以把键值存储请求发送给键值代理,键值代理根据负载均衡算法将键值存储请求分发给键值存储服务器102。In the network architecture shown in FIG. 1, there are multiple application server key value clients 101 and multiple key value storage servers 102, and any application server key value client 101 can send a key to any key value storage server 102. Value storage request. As a possible embodiment, multiple key-value storage servers 102 may also communicate with the application server key-value client 101 through a key-value proxy (not shown in FIG. 1), and the key-value proxy is used to key the application server. The key-value storage requests of the value client 101 are managed and scheduled, and distributed to different key-value storage servers. For example, the key-value agent can allocate key-value storage requests according to the current load of the key-value storage server. The key-value proxy and the key-value storage server 102 can be deployed in one server, or can be deployed using a single server, or deployed in a cluster using multiple servers. When a key-value proxy is deployed in the form of a cluster, an Internet protocol (IP) address can be presented to the outside. The application server key-value client 101 can send a key-value storage request to the key-value proxy, and the key-value proxy is based on load balancing The algorithm distributes the key-value storage request to the key-value storage server 102.
需要说明的是,在上述说明中,仅是以定长键值存储方式进行说明,其中仅涉及键进行哈希运算,查询哈希表,以及确定哈希表项的处理过程。本申请实施例还适用于变长键值存储方式。对于变长键,键的字段中允许添加额外字段,例如,在数据升级、快照等场景中利用变长键指示不同的版本号。键对应的值存在会发生一定的改变,以键值存储请求为写入请求为例,变长键处理如下:先对变长键进行哈希运算,生成哈希值,查询哈希表,确定哈希表项。之后,根据哈希表项确定对应的块(block)地址,以及该块地址中存储的树结构信息。根据该树结构信息确定树结构中父节点和叶子节点,该树节点可以指示变长键对应的值的存储空间的地址。其中,树结构可以为标识节点大小的B树结构,即在树结构中,左叶子节点的值大于父节点的值,且父节点的值小于右叶子节点的值。对于不同类 型的键,本申请实施例提供的数据存储方式均适用,为便于描述,本申请的以下实施例仅是以定长键为例进行说明。It should be noted that in the above description, only the fixed-length key value storage method is used for the description, which only involves the key hash operation, the hash table query, and the process of determining the hash table entry. The embodiments of the present application are also applicable to variable-length key value storage methods. For variable-length keys, additional fields are allowed in the key field. For example, variable-length keys are used to indicate different version numbers in scenarios such as data upgrades and snapshots. The value corresponding to the key will change to a certain extent. Taking the key-value storage request as a write request as an example, the variable-length key is processed as follows: first perform a hash operation on the variable-length key, generate a hash value, query the hash table, and confirm Hash table entry. After that, the corresponding block address and the tree structure information stored in the block address are determined according to the hash table entry. The parent node and the leaf node in the tree structure are determined according to the tree structure information, and the tree node may indicate the address of the storage space of the value corresponding to the variable-length key. The tree structure may be a B-tree structure that identifies the size of the node, that is, in the tree structure, the value of the left leaf node is greater than the value of the parent node, and the value of the parent node is less than the value of the right leaf node. For different types of keys, the data storage methods provided in the embodiments of this application are all applicable. For ease of description, the following embodiments of this application only take fixed-length keys as an example for description.
本申请实施例并不限定键值存储服务器的结构,例如键值存储服务器中的处理器可以是中央处埋器(central processing unit,CPU)、专用集成电路(application specific integrated circuit,ASIC)、现场可编程门阵列(field-programmable gate array,FPGA)、人工智能(artificial intelligence,AI)芯片、片上系统(system on chip,SoC)或复杂可编程逻辑器件(complex programmable logic device,CPLD),其中,键值存储服务器所需的数据,例如,哈希表和值,可以存储在同一个存储器中,也可以存储在不同的存储器中,例如,哈希表和值可以都存储于主机的内存中,又例如,哈希表可以存储于主机的内存中,值存储于闪存中,上述仅是举例,本申请实施例并不限定哈希表和值的存储位置。The embodiment of the present application does not limit the structure of the key-value storage server. For example, the processor in the key-value storage server may be a central processing unit (CPU), an application specific integrated circuit (ASIC), and an on-site Field-programmable gate array (FPGA), artificial intelligence (AI) chip, system on chip (SoC) or complex programmable logic device (CPLD), of which, The data required by the key-value storage server, for example, the hash table and value, can be stored in the same memory or in different memories. For example, the hash table and value can be stored in the memory of the host. For another example, the hash table can be stored in the memory of the host, and the value is stored in the flash memory. The foregoing is only an example, and the embodiment of the present application does not limit the storage location of the hash table and the value.
如图2所示,为本申请实施例提供的一种键值存储服务器的结构示意图,该键值存储服务器201是基于FPGA构建的键值存储装置,键值存储服务器201包括键值存储器202、第一存储器203;可选的,键值存储服务器201还可以包括中央处理器204。As shown in FIG. 2, a schematic structural diagram of a key-value storage server provided by an embodiment of this application. The key-value storage server 201 is a key-value storage device constructed based on FPGA. The key-value storage server 201 includes a key-value storage 202, The first storage 203; optionally, the key-value storage server 201 may also include a central processing unit 204.
键值存储器202包括键值存储引擎205和第二存储器206,可选的,还可以包括网络卸载引擎(network offload engine,NOE)207。第二存储器206可以是双倍速率(double data rate,DDR)存储器,具体可以用于存储哈希表,在如图2所示的键值存储服务器,将值存储于第一存储器203中,该第一存储器203可以是主机(host)中的内存,具体可以利用动态随机存取存储器实现。The key value storage 202 includes a key value storage engine 205 and a second storage 206, and optionally, may also include a network offload engine (NOE) 207. The second memory 206 may be a double data rate (DDR) memory, which may be specifically used to store a hash table. In the key-value storage server shown in FIG. 2, the value is stored in the first memory 203. The first memory 203 may be a memory in a host, and may be specifically implemented by a dynamic random access memory.
值得说明的是,FPGA是利用电容、电阻等硬件搭建的实现指定功能的处理逻辑,为了便于描述,将图2中实现具体功能的处理逻辑以功能名称命名,例如,网络卸载引擎和键值存储引擎。另外,如图2所示键值存储服务器201中包括中央处理器204和基于FPGA的键值存储器,而对于同一服务器中包括两种或两种以上类型的处理器也可以称为异构服务器。It is worth noting that FPGA is a processing logic that uses hardware such as capacitors and resistors to implement specified functions. For ease of description, the processing logic that implements specific functions in Figure 2 is named after the function name, for example, network offloading engine and key-value storage engine. In addition, as shown in FIG. 2, the key-value storage server 201 includes a central processing unit 204 and an FPGA-based key-value storage. For the same server including two or more types of processors, it can also be called a heterogeneous server.
网络卸载引擎207用于接收来自应用服务器键值客户端的键值存储请求,基于用户数据报协议(user datagram protocol,UDP)对键值存储请求进行处理,将处理后的键值存储请求发送给键值存储引擎205,以此减少CPU204处理用户数据报协议报文过程中所产生的开销。可选的,在CPU204的处理能力较强时,也可以由CPU204继续完成用户数据报协议的处理过程,此时,由CPU204接收来自应用服务器键值客户端的键值存储请求,并基于用户数据包协议对键值存储请求进行处理,再将处理后的键值存储请求发送给键值存储引擎205。为了便于描述,本申请实施例的以下描述中,以键值存储器中网络卸载引擎207对键值存储请求进行处理为例进行说明。The network offloading engine 207 is used to receive the key-value storage request from the key-value client of the application server, process the key-value storage request based on the user datagram protocol (UDP), and send the processed key-value storage request to the key The value storage engine 205 reduces the overhead incurred in the process of processing user datagram protocol messages by the CPU 204. Optionally, when the processing capability of the CPU 204 is strong, the CPU 204 can continue to complete the processing of the user datagram protocol. At this time, the CPU 204 receives the key value storage request from the key value client of the application server, and based on the user data packet The protocol processes the key-value storage request, and then sends the processed key-value storage request to the key-value storage engine 205. For ease of description, in the following description of the embodiments of the present application, the processing of the key-value storage request by the network offloading engine 207 in the key-value storage is taken as an example for description.
值得说明的是,无论由网络卸载引擎207还是CPU204对用户数据报协议报文进行处理,其具体处理过程均为解析报文数据,即去除协议的报文头内容,获取报文中净荷数据的内容,本申请实施例对于网络卸载引擎207或CPU204处理用户数据协议报文的过程不做限定。It is worth noting that whether the user datagram protocol message is processed by the network offloading engine 207 or the CPU204, the specific processing process is to parse the message data, that is, to remove the header content of the protocol and obtain the payload data in the message. The embodiment of the present application does not limit the process of the network offloading engine 207 or the CPU 204 processing the user data protocol message.
键值存储引擎205用于对键值存储请求进行处理,例如根据键值存储请求中的键从第一存储器203中读取值或将键值存储请求中携带的值(对应本申请实施例中的第一键值)写入第一存储器203中。在本申请实施例中,键值存储引擎205在将第一值写入第一存储 器203前,若第一值大于或等于第一阈值,键值存储引擎205可以将键值存储请求中携带的第一值分割为多个第二值,生成多个次级键存请求;其中每个次级键值存储请求中携带有键以及一个第二值;然后,分别将每一个次级键值存储请求中携带的第二值存储到第一存储器203中。The key-value storage engine 205 is used to process the key-value storage request, for example, read the value from the first memory 203 according to the key in the key-value storage request or the value carried in the key-value storage request (corresponding to the value in the embodiment of this application). The first key value of) is written into the first memory 203. In this embodiment of the present application, before the key-value storage engine 205 writes the first value into the first memory 203, if the first value is greater than or equal to the first threshold, the key-value storage engine 205 may add the value carried in the key-value storage request The first value is divided into multiple second values to generate multiple secondary key storage requests; where each secondary key value storage request carries a key and a second value; then, each secondary key value is stored separately The second value carried in the request is stored in the first memory 203.
如图2所示,键值存储器202还可以与其他处理器,如与CPU204连接,在本申请实施例中,键值存储器202可以将数据存储的操作移交至CUP204。示例性的,键值存储器202在接收到键值存储请求后,可以直接将键值存储请求转发给CUP204;也可以在确定键值存储请求中携带的第一值大于或等于第一阈值后,将键值存储请求转发给CUP204,由CUP204执行本申请实施例提供的数据存储方法。As shown in FIG. 2, the key-value memory 202 may also be connected to other processors, such as the CPU 204. In the embodiment of the present application, the key-value memory 202 may transfer the operation of data storage to the CPU 204. Exemplarily, after receiving the key-value storage request, the key-value storage 202 may directly forward the key-value storage request to the CUP 204; or after determining that the first value carried in the key-value storage request is greater than or equal to the first threshold, The key-value storage request is forwarded to CUP 204, and CUP 204 executes the data storage method provided in the embodiment of this application.
如图2所示的键值存储服务器的结构仅为举例,其中仅示出一个CPU和一个键值存储器,事实上,本申请实施例,并不限定CPU和键值存储器的数量,可以存在多个CPU或多个键值存储器。多个键值存储器之间可以转发键值存储请求,以配合完成本申请实施例提供的数据存储方法,还可以选择性的将数据存储的操作移交至与键值存储器装置连接的任一CUP上。本申请实施例也不限定键值存储器中包括的模块、模块的名称以及各个模块的作用,凡是可以实现本申请实施例提供的数据存储方法的装置均可以作为键值存储器。The structure of the key-value storage server shown in FIG. 2 is only an example, in which only one CPU and one key-value storage are shown. In fact, the embodiment of the present application does not limit the number of CPUs and key-value storages. One CPU or multiple key-value memories. The key-value storage request can be forwarded between multiple key-value storages to cooperate with the data storage method provided in the embodiment of this application, and the data storage operation can also be selectively transferred to any CUP connected to the key-value storage device . The embodiments of the present application do not limit the modules included in the key-value storage, the names of the modules, and the functions of each module. Any device that can implement the data storage method provided in the embodiments of the present application can be used as the key-value storage.
下面结合附图,基于如图2所示的键值存储器,对本申请实施例提出的一种数据存储方法进行说明,如图3所示,该方法包括:The following describes a data storage method proposed in an embodiment of the present application based on the key-value storage shown in FIG. 2 with reference to the accompanying drawings. As shown in FIG. 3, the method includes:
步骤301:键值存储器接收键值存储请求,键值存储请求中携带有键和第一值,其中,第一值为键对应的值。Step 301: The key-value storage receives a key-value storage request. The key-value storage request carries a key and a first value, where the first value is a value corresponding to the key.
步骤302:键值存储器在第一存储器中为第一值分配第一存储空间。Step 302: The key value storage allocates a first storage space for the first value in the first storage.
作为一种可能的实施方式,键值存储器中可以预先在第一存储器中配置第二存储空间,用于存储值,键值存储器在为第一值分配在第一存储器中的存储空间时,可以优先从第二存储空间中为第一值分配存储空间。该第二存储空间的大小可以等于或大于第一值,示例性的,该第二存储空间可以存储一个或多个键值存储请求中携带的第一值。As a possible implementation manner, a second storage space may be pre-configured in the first memory in the key-value storage for storing values. When the key-value storage allocates the storage space in the first storage for the first value, it may Priority is given to allocating storage space for the first value from the second storage space. The size of the second storage space may be equal to or greater than the first value. Exemplarily, the second storage space may store the first value carried in one or more key-value storage requests.
对于第二存储空间,该第二存储空间可以是在接收到键值存储请求后,存储该键值存储请求中携带的第一值之前,键值存储器预先从第一存储器中配置的存储空间,第二存储空间的大小可以等于该第一值,也可以大于第一值,以便于键值存储器可以灵活的从第二存储空间中为第一值分配第一存储空间。For the second storage space, the second storage space may be the storage space configured by the key-value storage from the first storage in advance after receiving the key-value storage request and before storing the first value carried in the key-value storage request, The size of the second storage space may be equal to the first value or greater than the first value, so that the key value storage can flexibly allocate the first storage space for the first value from the second storage space.
作为一种可能的实施方式,该第二存储空间可以是在接收到键值存储请求之前,键值存储器预先从第一存储器中配置的存储空间。由于是在接收键值存储请求之前预配置的,键值存储器可以预配置一个较大的存储空间作为第二存储空间,以使得键值存储器可以存储多个键值存储键值中携带的第一值。As a possible implementation manner, the second storage space may be a storage space pre-configured by the key value storage from the first storage before the key value storage request is received. Since it is pre-configured before receiving the key-value storage request, the key-value storage can be pre-configured with a larger storage space as the second storage space, so that the key-value storage can store the first carried in multiple key-value storage key values. value.
键值存储器接收到键值存储请求后,可以确定第二存储空间是否存在空闲空间,且空闲空间是否可以存储第一值;在第二存储空间中存在足够的空闲空间存储第一值的情况下,从第二存储空间中选择空闲空间作为第一存储空间。After receiving the key-value storage request, the key-value memory can determine whether there is free space in the second storage space, and whether the free space can store the first value; if there is enough free space in the second storage space to store the first value , Select the free space from the second storage space as the first storage space.
若第二存储空间中没有足够的空闲空间存储第一值,也就是说,第二存储空间中的空闲空间小于第一值所需的存储空间,键值存储器可以从第一存储器中为第一值分配存储空间。If there is not enough free space in the second storage space to store the first value, that is, the free space in the second storage space is less than the storage space required by the first value, the key value storage can be the first value from the first storage. Value allocation storage space.
为了有效的利用第二存储空间中的存储空间,键值存储器从第一存储器中为第一值分配的存储空间和第二存储空间中的空闲空间均可用于存储第一值(如存储一个或多个第二值)。也就是说,分配的存储空间与第二存储空间中的空闲空间的总和可以等于第一值的大小。当然,键值存储器也可以从第一存储器中为第一值分配存储空间的大小等于第一值的大小的第一存储空间。In order to effectively use the storage space in the second storage space, the storage space allocated by the key-value storage for the first value from the first storage and the free space in the second storage space can be used to store the first value (such as storing one or Multiple second values). That is, the sum of the allocated storage space and the free space in the second storage space may be equal to the size of the first value. Of course, the key value memory may also allocate a first storage space with a size equal to the size of the first value for the first value from the first storage.
作为另一种可能的实施方式,在第二存储空间中没有足够的空间存储第一值键值存储器的情况下,键值存储器还可以从第一存储器配置第三存储空间,第三存储空间大于第一值所需的存储空间。示例性的,第三存储空间可以为1G或500M等较大的存储空间。第三存储空间除了可以用于存储第一值,还可以用于存储键值存储器后续接收到的键值存储请求中携带的第一值,键值存储器在第三存储空间中为第一值分配第一存储空间。As another possible implementation manner, when there is not enough space in the second storage space to store the first value key value storage, the key value storage may also configure a third storage space from the first storage, and the third storage space is larger than The storage space required for the first value. Exemplarily, the third storage space may be a relatively large storage space such as 1G or 500M. In addition to storing the first value, the third storage space can also be used to store the first value carried in the key-value storage request subsequently received by the key-value storage. The key-value storage allocates the first value in the third storage space. The first storage space.
应需理解的是,键值存储器也可以不预先在第一存储器中配置第二存储空间,在需要进行数据存储时,动态的在第一存储器中为第一值分配第一存储空间。示例性的,键值存储器可以根据第一值的大小,在第一存储器中分配第一存储空间。It should be understood that the key-value storage may not be configured with the second storage space in the first storage in advance, and when data storage is required, the first storage space is dynamically allocated in the first storage for the first value. Exemplarily, the key value storage may allocate the first storage space in the first storage according to the size of the first value.
在上述说明中,以第一存储空间的大小等于第一值所需的存储空间的大小为例。本申请实施例并不限定第一存储空间的大小。示例性的,可以设置键值存储请求中携带的第一值的最大阈值。也就是说,最大阈值用于表征键值存储请求中所携带的值的最大尺寸。键值存储器在为第一值分配的在第一存储器中的第一存储空间时,分配的第一存储空间可以等于最大阈值。键值存储器在存储第二值时,可以将第二值存储在分配的第一存储空间中,第二值在第一存储空间中的存储位置可以灵活设置,这样存储第二值的方式更加灵活。另外,第一存储空间可以是连续的存储空间,也可以是不连续的存储空间,本申请实施例并不限定。In the above description, the size of the first storage space is equal to the size of the storage space required for the first value as an example. The embodiment of the present application does not limit the size of the first storage space. Exemplarily, the maximum threshold of the first value carried in the key-value storage request may be set. In other words, the maximum threshold is used to represent the maximum size of the value carried in the key-value storage request. When the key value storage allocates the first storage space in the first storage for the first value, the allocated first storage space may be equal to the maximum threshold. When the key-value memory stores the second value, it can store the second value in the allocated first storage space, and the storage location of the second value in the first storage space can be flexibly set, so that the way of storing the second value is more flexible . In addition, the first storage space may be a continuous storage space or a discontinuous storage space, which is not limited in the embodiment of the present application.
步骤303:当第一值所包含数据的容量大于或等于第一阈值时,键值存储器将第一值分割为多个第二值,并生成多个次级键值存储请求,每个次级键值存储请求中携带键和一个第二值。次级键值存储请求的数量与第一值分割获得的多个第二值的个数相同。Step 303: When the capacity of the data contained in the first value is greater than or equal to the first threshold, the key value store divides the first value into multiple second values, and generates multiple secondary key value storage requests, each secondary The key-value storage request carries the key and a second value. The number of secondary key value storage requests is the same as the number of multiple second values obtained by dividing the first value.
本申请实施例并不限定步骤302和步骤303的先后顺序,可以同时执行,也可以先后执行。The embodiment of the present application does not limit the sequence of step 302 and step 303, and can be performed simultaneously or sequentially.
对于第一值所包含数据的容量较大的情况下,如果直接进行数据存储,需要先在键值存储器中缓存第一值。示例性的,键值存储器先在第二存储器中缓存第一值。之后再将第一值传输至第一存储器,这样会导致数据存储的时间较长。其中,第一值所包含数据的容量也可以称为第一值的大小,是指第一值中所包含数据的总大小(size),也可以说是指存储第一值所需存储空间的最小存储空间的大小。例如,第一值中包含内容为“0123456789”,则第一值所包含数据的容量为10字节。When the capacity of the data contained in the first value is large, if the data is stored directly, the first value needs to be cached in the key value storage first. Exemplarily, the key value storage first caches the first value in the second storage. After that, the first value is transferred to the first memory, which will lead to a longer time for data storage. Among them, the capacity of the data contained in the first value can also be referred to as the size of the first value, which refers to the total size of the data contained in the first value (size), or it can be said to refer to the storage space required to store the first value. The size of the minimum storage space. For example, if the content contained in the first value is "0123456789", the capacity of the data contained in the first value is 10 bytes.
这里可以设置第一阈值,当第一值大于或等于第一阈值,则认为第一值的较大,属于大尺寸数据;否则,第一值属于小尺寸数据,对于小尺寸数据,可以按照传统的键值存储方式进行数据存储;第一阈值的具体数值可以是经验值,如1兆(M),也可以是按照具体场景以及键值存储器性能设置的。例如,在一些键值存储场景中,可以统计一段时间内,需要存储的值的大小,根据统计的需要存储的值的大小确定第一阈值。示例性的,当存储的值的大小集中在3M到10M,且发现值大于5M时,键值存储器的存储效率明显减慢, 则可以将5M作为第一阈值。上述设置阈值的方式仅是举例,本申请实施例并不限定阈值的具体数值以及设置方式。The first threshold can be set here. When the first value is greater than or equal to the first threshold, the first value is considered to be larger and belongs to large-size data; otherwise, the first value belongs to small-size data. For small-size data, you can follow the traditional The data is stored in the key-value storage mode of the first threshold; the specific value of the first threshold can be an empirical value, such as 1 mega (M), or it can be set according to specific scenarios and key-value storage performance. For example, in some key-value storage scenarios, the size of the value that needs to be stored in a period of time can be counted, and the first threshold can be determined according to the size of the value that needs to be stored in the statistics. Exemplarily, when the size of the stored value is concentrated in 3M to 10M, and the value is found to be greater than 5M, the storage efficiency of the key value memory is significantly slowed down, and 5M may be used as the first threshold. The foregoing method of setting the threshold is only an example, and the embodiment of the present application does not limit the specific value and setting method of the threshold.
为了提高大尺寸数据的存储效率,本申请实施例提出了数据分割的方式,将第一值分割为多个第二值的方式,分次将第二值存储至第一存储器,由键值存储器完成多个第二值的正序、存储以及合并过程。本申请实施例并不限定数据分割的具体实现方式,凡是最终可以将第一值分割为多个较小的第二值的方式均适用于本申请实施例。In order to improve the storage efficiency of large-size data, the embodiment of the present application proposes a method of data partitioning. The first value is divided into multiple second values. The second value is stored in the first memory in stages, and the key value memory is Complete the positive sequence, storage and merging process of multiple second values. The embodiment of the present application does not limit the specific implementation of data segmentation, and any method that can finally divide the first value into multiple smaller second values is applicable to the embodiment of the present application.
如图4所示,为对第一值分割后生成多个次级键值存储请求以及合并的示意图,分为两个不同的过程,分片过程和拼接过程。分片过程中,键值存储器将键值存储请求中携带的第一值可以分为多个第二值,生成多个次级键值存储请求,每个次级键值存储请求中包括报文头以及一个第二值(次级键值存储请求的格式之后会进行说明);拼接过程为键值存储器从第一存储器中读取第三值的过程,可以看做分片过程的逆过程,若第三值大于第三阈值(第三阈值可以等于第二阈值,也可以为其他数值),如第三阈值为10M,键值存储器从第一存储器中,读取多个第四值,生成多个次级键值存储请求,之后将多个第四值合成为第三值,将第三值携带在需要反馈给应用服务器键值客户端的键值存储响应中。As shown in FIG. 4, it is a schematic diagram of generating multiple secondary key value storage requests and merging after dividing the first value, which is divided into two different processes, the slicing process and the splicing process. During the sharding process, the key-value storage can divide the first value carried in the key-value storage request into multiple second values, and generate multiple secondary key-value storage requests. Each secondary key-value storage request includes a message Header and a second value (the format of the secondary key value storage request will be explained later); the splicing process is the process in which the key value storage reads the third value from the first storage, which can be seen as the inverse process of the sharding process. If the third value is greater than the third threshold (the third threshold can be equal to the second threshold, or other values), for example, the third threshold is 10M, the key value memory reads multiple fourth values from the first memory, and generates After multiple secondary key-value storage requests, multiple fourth values are combined into a third value, and the third value is carried in the key-value storage response that needs to be fed back to the key-value client of the application server.
为了更好的解释本申请实施例的技术方案,首先,对键值存储请求的格式进行说明,如图5所示,为本申请实施例提供的一种键值存储请求的格式示意图。In order to better explain the technical solutions of the embodiments of the present application, first, the format of the key-value storage request is described. As shown in FIG. 5, a schematic diagram of the format of a key-value storage request provided by an embodiment of the present application.
键值存储请求包括两部分,一部分为报文头(header),一部分为数据包(packet)。其中,报文头携带键和值的一些属性信息。具体的,报文头中包括键标识(k ID)、类型(type)、键大小(key size)、值总大小(value total size)、值大小(value size)、值偏置(value offset);数据包包括键和值。The key-value storage request includes two parts, one is a header and the other is a packet. Among them, the message header carries some attribute information of keys and values. Specifically, the message header includes key identifier (k ID), type (type), key size (key size), value total size, value size, and value offset (value offset) ; The data packet includes keys and values.
键标识用于指示键的序列号。类型用于指示键值存储请求的操作类型,例如可以为插入(put)、查找(get)以及删除(delete)。其中,插入指示键值存储请求为写入请求,需要将键值存储请求中携带的值(如本申请实施例中的第一值)存储到第一存储器中;查找指示键值存储请求为读取请求,需要从第一存储器中读取与键值存储请求中携带的键对应的值;删除指示需要从第一存储器中删除与键值存储请求中携带的键对应的值。上述三种操作类型仅是举例,本申请实施例并不限定,还可以存在其他操作类型,如更新(update)等。The key identifier is used to indicate the serial number of the key. The type is used to indicate the operation type of the key-value storage request, for example, it can be insert (put), search (get), and delete (delete). Wherein, the insertion instruction key value storage request is a write request, and the value carried in the key value storage request (such as the first value in the embodiment of this application) needs to be stored in the first memory; the search instruction key value storage request is read To fetch the request, the value corresponding to the key carried in the key-value storage request needs to be read from the first storage; the deletion indicates that the value corresponding to the key carried in the key-value storage request needs to be deleted from the first storage. The above three operation types are only examples, and the embodiments of the present application are not limited, and other operation types, such as update, may also exist.
键大小用于指示键值存储请求中携带的键的大小。值总大小用于指示键值存储请求中携带值的总大小(对应键值存储请求为写入请求,类型为put)、或键值存储请求获取的值的总大小(对应键值存储请求为读取请求,类型为get)、或键值存储请求删除的value的总大小(对应类型为delete的键存请求)。The key size is used to indicate the size of the key carried in the key-value storage request. The total value size is used to indicate the total size of the value carried in the key-value storage request (the corresponding key-value storage request is a write request, and the type is put), or the total size of the value obtained by the key-value storage request (the corresponding key-value storage request is Read request, the type is get), or the total size of the value deleted by the key value storage request (corresponding to the key storage request of type delete).
值偏置用于指示键值存储请求中携带值(如本申请实施例中的第二值)相对于总值(对应本申请实施例中的第一值)首位的偏移量。在本申请实施例中,值偏置可以指示第二值在第一值的位置。值偏置越大,表明第二值在第一值中的位置越靠后。The value offset is used to indicate the offset of the value carried in the key value storage request (such as the second value in the embodiment of the present application) relative to the first position of the total value (corresponding to the first value in the embodiment of the present application). In the embodiment of the present application, the value offset may indicate the position of the second value in the first value. The larger the value offset, the lower the position of the second value in the first value.
值大小用于指示该键值存储请求中携带的值(对应本申请实施例中的第一值或第二值)的大小。示例性的,如果一个值的总长度为2024,按照1024来分割,分割后,对于第一个值(如本申请实施例中的第二值),值偏置为0,值大小为1024;第二个值,值偏置为1024,值大小为1000。The value size is used to indicate the size of the value (corresponding to the first value or the second value in the embodiment of the present application) carried in the key value storage request. Exemplarily, if the total length of a value is 2024, it is divided according to 1024. After the division, for the first value (such as the second value in the embodiment of this application), the value offset is 0 and the value size is 1024; The second value, the value offset is 1024, and the value size is 1000.
本申请实施例提供的一种次级键值存储请求的格式与图5所示的键值存储请求类似可以参见图5。次级键值存储请求也可以分为两部分,一部分为报文头,一部分为数据包(packet)。报文头携带键和值的一些属性信息,具体的,报文头中包括键标识、类型、键大小、值总大小、值大小、值偏置(value offset);数据包包括键和值。The format of a secondary key value storage request provided by the embodiment of the present application is similar to the key value storage request shown in FIG. 5, which can be referred to FIG. 5. The secondary key value storage request can also be divided into two parts, one is the message header, and the other is the data packet. The message header carries some attribute information of keys and values. Specifically, the message header includes key identifiers, types, key sizes, total value sizes, value sizes, and value offsets; data packets include keys and values.
在本申请实施例中以键值存储请求的类型为插入为例,相应的,次级键值存储请求中的类型也为插入。值总大小指示的是数据分割前的值的大小,也就是键值存储请求中携带的第一值的大小。值大小指示次级键值存储请求携带的值的大小(对应本申请实施例中第二值)。值偏置指示次级键值存储请求携带的值(如本申请实施例中的第二值)在键值存储请求中值(对应本申请实施例中的第一值)的偏移位置。在本申请实施例中,通常次级键值存储请求中的值偏置可以为0,表明次级键值存储请求携带的第二值是从第二值在第一值中的起始位置分割的。携带有不同的第二值的次级键值存储请求中的值偏置是不同的,值偏置可以反映出第二值在第一值中的位置顺序。In the embodiment of the present application, the type of the key-value storage request is insert as an example, and correspondingly, the type in the secondary key-value storage request is also insert. The total value size indicates the size of the value before data segmentation, that is, the size of the first value carried in the key value storage request. The value size indicates the size of the value carried in the secondary key value storage request (corresponding to the second value in the embodiment of the present application). The value offset indicates the offset position of the value carried in the secondary key value storage request (such as the second value in the embodiment of this application) in the value (corresponding to the first value in the embodiment of this application) in the key value storage request. In the embodiment of this application, usually the value offset in the secondary key value storage request may be 0, indicating that the second value carried in the secondary key value storage request is divided from the starting position of the second value in the first value of. The value offsets in the secondary key value storage requests that carry different second values are different, and the value offsets can reflect the position order of the second value in the first value.
需要说明的是,类型还可以指示键值存储请求为数据分割前的键值存储请求还是数据分割之后,形成的次级键值存储请求。示例性的,类型中可以增加一个标识位,用于指示键值存储请求为数据分割前的键值存储请求还是次级键值存储请求。It should be noted that the type may also indicate whether the key value storage request is a key value storage request before data segmentation or a secondary key value storage request formed after data segmentation. Exemplarily, an identification bit can be added to the type to indicate whether the key-value storage request is a key-value storage request before data segmentation or a secondary key-value storage request.
作为另一种可能的实施方式,如图6所示,键值存储请求中还可以增加一个字段为片段(slice),片段用于指示该请求为数据分割前的键值存储请求还是次级键值存储请求。当片段为第一值(如为null)时,指示该请求为数据分割前的键值存储请求,当片段为第二值(如为1)时,指示该请求为次级键值存储请求。As another possible implementation, as shown in Figure 6, a field can be added to the key-value storage request as a slice, which is used to indicate whether the request is a key-value storage request before data segmentation or a secondary key. Value storage request. When the fragment has the first value (such as null), it indicates that the request is a key-value storage request before data segmentation, and when the fragment has the second value (such as 1), it indicates that the request is a secondary key-value storage request.
如图7所示,以第一值为5M为例,键值存储器可以将第一值分为五个第二值,每个第二值的大小为1M。这样可以生成五个次级键值存储请求,每个次级键值存储请求中携带一个第二值,对于携带有第一个第二值的次级键值存储请求中的值大小为1M,指示携带的第二值的大小为1M,值偏置可以设置为0,指示第二值从第一值的起始位置分割出的;对于携带有第二个第二值的次级键值存储请求中的值大小为1M,指示携带的第二值的大小为1M,值偏置可以设置为1M,指示第二值是从第一值的1M位置为起始分割出的。As shown in FIG. 7, taking the first value of 5M as an example, the key value memory can divide the first value into five second values, and the size of each second value is 1M. In this way, five secondary key value storage requests can be generated. Each secondary key value storage request carries a second value. For the secondary key value storage request carrying the first second value, the value size is 1M, Indicates that the size of the second value carried is 1M, and the value offset can be set to 0, indicating that the second value is divided from the starting position of the first value; for the secondary key value storage that carries the second second value The size of the value in the request is 1M, the size of the second value carried in the instruction is 1M, and the value offset can be set to 1M, indicating that the second value is segmented from the 1M position of the first value.
作为一种可能的实施方式,次级键值存储请求可以设置字段更加直观的用于指示携带的第二值在第一值的顺序。示例性的,可以利用片段字段,例如用1指示键值存储请求为次级键值存储请求,次级键值存储请求携带的第二值为第一值分割之后的位置顺序为第一的第二值;用2指示键值存储请求为次级键值存储请求,次级键值存储请求携带的第二值为第一值分割之后的位置顺序为第二的第二值。上述利用片段字段指示仅是举例,例如还可以增加其他字段,本申请实施例并不限定。As a possible implementation manner, the secondary key value storage request may set a field to indicate the order of the carried second value in the first value more intuitively. Exemplarily, a fragment field can be used. For example, 1 indicates that the key-value storage request is a secondary key-value storage request, and the second value carried in the secondary key-value storage request is the first value after the first value is split. Binary value; Use 2 to indicate that the key value storage request is a secondary key value storage request, and the second value carried in the secondary key value storage request is a second value whose position order is second after the first value is divided. The above indication of using the fragment field is only an example, for example, other fields may be added, which is not limited in the embodiment of the present application.
次级键值存储请求中数据包中的值为键值存储请求中的值的一部分,在本申请实施例中,次级键值存储请求中数据包中的值为第二值,键值存储请求中数据包中的值为第一值。The value in the data packet in the secondary key-value storage request is part of the value in the key-value storage request. In this embodiment of the application, the value in the data packet in the secondary key-value storage request is the second value, and the key-value storage The value in the data packet in the request is the first value.
次级键值存储请求中报文头的键标识、类型、键大小、值总大小与键值存储请求中的对应字段的内容相同,次级键值存储请求中数据包中的键与键值存储请求中的键相同。The key identifier, type, key size, and total value of the message header in the secondary key-value storage request are the same as the content of the corresponding field in the key-value storage request. The key and key value in the data packet in the secondary key-value storage request The keys in the storage request are the same.
本申请实施例提供了两种不同的数据分割方式,下面分别进行介绍:The embodiments of this application provide two different data segmentation methods, which will be introduced separately as follows:
方式一、在缓存第一值的过程中,边缓存边分割。Method 1: In the process of caching the first value, partition while caching.
键值存储器在接收到第一值后,可以先缓存第一值。在缓存的过程中,当缓存的数据 大小达到第二阈值时,将缓存的数据作为一个第二值,并生成对应的次级键值存储请求。在生成次级键值存储请求时,需要在次级键值存储请求中携带已缓存的数据(也就是第二值),并设置次级键值存储请求的报文头中各个字段。示例性的,可以将值大小字段设置为第二值的大小,值偏置为第二值在第一值中的位置,指示第二值相对于第一值首位的偏移,设置方式可见前述描述,此处不再赘述。After receiving the first value, the key value storage may first buffer the first value. In the caching process, when the size of the cached data reaches the second threshold, the cached data is taken as a second value, and a corresponding secondary key value storage request is generated. When generating a secondary key value storage request, it is necessary to carry the cached data (that is, the second value) in the secondary key value storage request, and set various fields in the header of the secondary key value storage request. Exemplarily, the value size field can be set to the size of the second value, and the value offset is the position of the second value in the first value, indicating the offset of the second value relative to the first value of the first value. The setting method can be seen in the foregoing Description, not repeat them here.
生成了次级键值存储请求后,可以将次级键值存储请求中携带的第二值,存储在为第一值分配的第一存储空间中,由于第二值只是第一值中的一部分,第二值只占用其中一部分存储空间。After the secondary key value storage request is generated, the second value carried in the secondary key value storage request can be stored in the first storage space allocated for the first value, because the second value is only a part of the first value , The second value only takes up part of the storage space.
然后,键值存储器仍会继续缓存剩余的第一值,在缓存的数据的大小达到第二阈值的情况下(之前缓存的数据已携带在次级键值存储请求中,在这种情况下,缓存的数据大小是从0开始的),将缓存的数据作为一个第二值;生成对应的次级键请求,执行与之前相同的操作,包括设置次级存储键请求,以及在将次级键值存储请求中携带的第二值,存储在为第一值分配的第一存储空间中;在存储第二值时,由于之前在为第一值分配的第一存储空间已存储有一个第二值,则将次级键值存储请求中携带的第二值存储在已存储的第二值之后的存储空间中,以实现按顺序存储。Then, the key-value storage will continue to cache the remaining first value, when the size of the cached data reaches the second threshold (the previously cached data has been carried in the secondary key-value storage request, in this case, The size of the cached data starts from 0), the cached data is used as a second value; the corresponding secondary key request is generated, and the same operation as before is performed, including setting the secondary storage key request, and setting the secondary key The second value carried in the value storage request is stored in the first storage space allocated for the first value; when the second value is stored, because a second value is already stored in the first storage space allocated for the first value. Value, the second value carried in the secondary key value storage request is stored in the storage space after the stored second value to achieve sequential storage.
循环上述过程,直至将第一值缓存完成,需要说明的是,当处于缓存第一值的最后阶段,可能存在第一值缓存完成,但缓存的数据未达到第二阈值的情况。在这种情况下,键值存储器可以直接将缓存的数据作为一个第二值,生成对应的次级键请求,并将次级存储键请求中的第二值存储至第一存储器中。在这种情况下,可以发现分割的多个第二值的大小并不完全相同,可能存在一个第二值的大小小于第二阈值。The above process is looped until the first value is cached. It should be noted that when the first value is cached in the final stage, the first value may be cached, but the cached data does not reach the second threshold. In this case, the key-value storage may directly use the cached data as a second value, generate a corresponding secondary key request, and store the second value in the secondary storage key request into the first storage. In this case, it can be found that the sizes of the divided second values are not completely the same, and there may be a second value whose size is smaller than the second threshold.
在上述说明中,键值存储器接收第一值和分割第一值的过程并行执行,即键值存储器在缓存第一值的过程中,进行数据分割,同时完成第二值的存储过程,也就是说,步骤303和步骤304是交替执行的,这种方式仅是举例。在具体实施过程中,第二值存储的操作(步骤304)可以在将第一值缓存完成,生成了所有次级键值存储请求(步骤303)后再执行,本申请实施例并不限定。In the above description, the process of receiving the first value and dividing the first value by the key-value memory is performed in parallel, that is, the key-value memory performs data division during the process of caching the first value and completes the storage process of the second value at the same time, that is In other words, step 303 and step 304 are performed alternately, and this method is only an example. In the specific implementation process, the operation of storing the second value (step 304) can be executed after the first value is cached and all secondary key value storage requests (step 303) are generated, which is not limited in this embodiment of the application.
作为一种可能的实施方式,为了实现边缓存边分割的方式,键值存储器可以采用状态机控制的方式。As a possible implementation manner, in order to implement a cache-side partition mode, the key-value memory may adopt a state machine control mode.
图8为本申请实施例提供的一种状态机的示意图,如图所示,有限状态机可以设置6种状态,分别为空闲态(IDLE)、等待命令(WAIT_CMD)、等待描述符(WAIT_DSC)、等待数据(WAIT_DATA)、生成描述符(GEN_DSC)、完成(FINISH)状态,状态转换图如图8所示,各个状态的描述和切换可参见如下内容:Fig. 8 is a schematic diagram of a state machine provided by an embodiment of the application. As shown in the figure, the finite state machine can be set in 6 states, namely, idle state (IDLE), waiting command (WAIT_CMD), and waiting descriptor (WAIT_DSC) , Wait for data (WAIT_DATA), generate descriptor (GEN_DSC), complete (FINISH) state, the state transition diagram is shown in Figure 8. The description and switching of each state can be seen as follows:
IDLE状态:当接收到第一值时,跳转到WAIT_CMD状态;否则,保持在IDLE状态。IDLE state: When the first value is received, jump to WAIT_CMD state; otherwise, keep in IDLE state.
WAIT_CMD状态:等待接收插入指令。在这个状态下,若键值存储器解析键值存储请求中的类型错误时,跳转为IDLE状态,接收到第一值无效并丢弃;若解析键值存储请求的类型为插入,跳转为WAIT_DSC状态;否则,保持在WAIT_CMD状态。WAIT_CMD state: Waiting to receive insert command. In this state, if the type of the key-value storage request is parsed by the key-value store, it will jump to the IDLE state, and the first value received is invalid and discarded; if the type of the key-value storage request is parsed, it will jump to WAIT_DSC State; otherwise, keep in WAIT_CMD state.
WAIT_DSC状态:等待接收卡到主机(card to host,C2H)描述符。C2H描述符用于指示第一值的大小、键值存储器为第一值分配的第一存储空间。键值存储器在接收到键值存储请求并为第一值分配了第一存储空间后,可以生成C2H描述符。WAIT_DSC state: waiting for receiving card to host (card to host, C2H) descriptor. The C2H descriptor is used to indicate the size of the first value and the first storage space allocated by the key value storage for the first value. After the key value storage receives the key value storage request and allocates the first storage space for the first value, it may generate the C2H descriptor.
当键值存储器确定了C2H描述符后,跳转为WAIT_DATA状态;否则,保持在WAIT_DSC状态。When the key value memory determines the C2H descriptor, it jumps to the WAIT_DATA state; otherwise, it remains in the WAIT_DSC state.
WAIT_DATA状态:等待第一值缓存到一帧(以第二阈值为一帧为例)。当第一值缓存达到一帧,将缓存的数据作为第二值。当第一值缓存到一帧,且第一值并未缓存完成,也就是不是最后一帧,跳转到GEN_DSC状态;当第一值的最后一帧数据缓存完成,跳转到FINISH状态;否则,保持在WAIT_DATA状态;这里以第二值的大小为一帧为例,本申请实施例并不限定第二值的大小。WAIT_DATA state: Waiting for the first value to be buffered to one frame (taking the second threshold as one frame as an example). When the first value buffer reaches one frame, the buffered data is used as the second value. When the first value is cached for one frame, and the first value has not been cached, that is, it is not the last frame, jump to the GEN_DSC state; when the last frame of the first value is cached, jump to the FINISH state; otherwise , Remain in the WAIT_DATA state; here, taking the size of the second value as one frame as an example, the embodiment of the present application does not limit the size of the second value.
GEN_DSC状态:生成C2H分片描述符。键值存储器可以启动一次数据传输,将第二值传输至第一存储空间。GEN_DSC state: Generate C2H fragment descriptor. The key value memory can start a data transfer and transfer the second value to the first storage space.
C2H分片描述符用于指示第二值的大小、第二值的存储地址或第二值的源地址等,其中,第二值的源地址为键值存储器缓存第二值的地址,如键值存储器在第二存储器中缓存第二值的地址;需要说明的是,这里缓存第二值是指键值存储器在缓存第一值时,将缓存的数据作为第二值。键值存储器可以根据C2H分片描述符指示的信息,将对应的次级键值存储请求中携带的第二值存储在第一存储空间中。The C2H fragment descriptor is used to indicate the size of the second value, the storage address of the second value, or the source address of the second value, etc., where the source address of the second value is the address of the key value memory cache second value, such as the key The value memory caches the address of the second value in the second memory; it should be noted that caching the second value here means that when the key value memory caches the first value, the cached data is used as the second value. The key value memory may store the second value carried in the corresponding secondary key value storage request in the first storage space according to the information indicated by the C2H fragment descriptor.
需要说明的是,第二值的存储地址指示是用于存储第二值的存储空间。键值存储器可以根据第二值的大小以及第二值在第一值中的位置,确定该存储空间在第一存储空间的位置,并确定第二值的存储地址。示例性的,若键值存储器当前缓存所的第二值为第一值的第一帧,则用于存储第二值的存储空间是第一存储空间中起始位置起、大小为一帧的存储空间,进而可以确定第二值的存储地址;若键值存储器当前缓存所的第二值为第一值的第三帧,则用于存储第二值的存储空间是第一存储空间中3M位置起、大小为一帧的存储空间,进而确定第二值的存储地址。It should be noted that the storage address indication of the second value is a storage space for storing the second value. The key value memory may determine the location of the storage space in the first storage space according to the size of the second value and the position of the second value in the first value, and determine the storage address of the second value. Exemplarily, if the second value currently cached in the key-value memory is the first frame of the first value, the storage space for storing the second value is one frame from the starting position in the first storage space The storage space can then determine the storage address of the second value; if the second value currently cached in the key-value memory is the third frame of the first value, the storage space used to store the second value is 3M in the first storage space The storage space starting from the position and the size is one frame, and then the storage address of the second value is determined.
在这个状态下,生成对应的次级键值存储请求,之后跳转到WAIT_DATA状态;否则,保持在GEN_DSC状态。In this state, the corresponding secondary key value storage request is generated, and then it jumps to the WAIT_DATA state; otherwise, it remains in the GEN_DSC state.
FINISH状态:生成最后一片C2H分片描述符(也就是缓存第一值的最后一帧,产生最后一个第二值),标志第一值的缓存操作完成。当第一值完全传输后,跳转到IDLE状态;否则,保持在FINISH状态。FINISH state: Generate the last piece of C2H fragment descriptor (that is, cache the last frame of the first value, and generate the last second value), marking the completion of the cache operation of the first value. When the first value is completely transmitted, it jumps to the IDLE state; otherwise, it remains in the FINISH state.
需要说明的是,本申请实施例并不第二阈值的具体数值,可以是一个经验值,也可以是根据具体场景设置的,本申请实施例并不限定。It should be noted that the embodiment of the present application is not a specific value of the second threshold, but may be an empirical value, or may be set according to a specific scenario, and the embodiment of the present application is not limited.
方式二、第一值缓存完成后,再做分割。Method 2: After the first value is cached, segmentation is performed.
键值存储器也可以在将第一值完全缓存后,再对第一值进行分割,分割为多个第二值。示例性的,键值存储器可以将第一值平均分为多个大小相同的第二值。也可以设置第二阈值,将第一值分割为第二阈值大小的第二值,这种情况下,由于第一值的大小并不一定是第二阈值的整数倍,可能存在其中一个或多个第二值小于第二阈值的情况。The key value memory can also divide the first value into multiple second values after fully buffering the first value. Exemplarily, the key-value storage may evenly divide the first value into a plurality of second values with the same size. You can also set a second threshold to divide the first value into a second value of the second threshold. In this case, since the size of the first value is not necessarily an integer multiple of the second threshold, one or more of them may exist. The second value is less than the second threshold.
上述分割方式仅是举例,本申请实施例并不限定分割的方式,例如键值存储器还可以对第一值进行随机分割,分割后的每个第二值的大小不同。The foregoing division method is only an example, and the embodiment of the present application does not limit the division method. For example, the key-value memory may also randomly divide the first value, and the size of each second value after division is different.
完成了第一值的分割后,可以生成多个次级键值存储请求,其中每个次级键值存储请求中携带有其中一个第二值,每个次级键值存储请求中的报文头中的值偏置指示携带的第二值在第一值的位置。After the division of the first value is completed, multiple secondary key value storage requests can be generated, where each secondary key value storage request carries one of the second values, and the message in each secondary key value storage request The value offset in the header indicates the position of the second value carried in the first value.
步骤304:键值存储器按照每个次级键值存储请求中携带的第二值在第一值中的位置顺序,将每个次级键值存储请求中携带的第二值存储至第一存储空间。Step 304: The key-value storage stores the second value carried in each secondary key-value storage request to the first storage according to the order in which the second value carried in each secondary key-value storage request is located in the first value space.
作为一种可能的实施方式,在存储第二值时,键值存储器可以按照次级键值存储请求中携带的第二值在第一值的位置顺序,按照位置顺序从前到后的顺序存储。示例性的,根据每个次级键值存储请求报文头中的值偏置可以确定出次级键值存储请求中携带的第二值在第一值的位置,可以对每个次级键值存储请求中的报文头中的值偏置按照大小顺序排序,从小到大,依次将对应的次级键值存储请求中携带第二值存至第一存储空间。As a possible implementation manner, when storing the second value, the key value storage may store the second value carried in the secondary key value storage request in the order of the position of the second value in the first value, in the order from front to back in the order of position. Exemplarily, the position of the second value carried in the secondary key value storage request in the first value can be determined according to the value offset in the header of each secondary key value storage request, and each secondary key value can be The value offsets in the message header in the value storage request are sorted in order of magnitude, from small to large, and the second value carried in the corresponding secondary key value storage request is sequentially stored in the first storage space.
作为另一种可能的实施方式,键值存储器在存储次级键值存储请求中携带的第二值时。可以根据第二值在第一值的位置确定第二值在第一存储空间中的存储位置。将第二值存储在第一存储空间中的存储位置,第二值在第一值的位置可以通过次级键值存储请求的报文头中的值偏置确定。As another possible implementation manner, when the key value storage stores the second value carried in the secondary key value storage request. The storage position of the second value in the first storage space may be determined according to the position of the second value in the first value. The second value is stored in the storage location in the first storage space, and the location of the second value in the first value can be determined by the value offset in the message header of the secondary key value storage request.
示例性的,次级键值存储请求的报文头中的值偏置为0,则表明次级键值存储请求中携带的第二值位于第一值的起始位置,第二值在第一存储空间存储位置为存储空间的起始点开始的、大小为第二值大小的存储空间。Exemplarily, if the value offset in the header of the secondary key value storage request is 0, it indicates that the second value carried in the secondary key value storage request is located at the beginning of the first value, and the second value is in the first value. The storage location of a storage space is a storage space with a size of a second value starting from the starting point of the storage space.
次级键值存储请求的报文头中的值偏置为1M,则表明次级键值存储请求中携带的第二值起始于第一值的1M位置,第二值在第一存储空间存储位置为存储空的1M数据对应的位置开始、大小为第二值大小存储空间。The value offset in the message header of the secondary key value storage request is 1M, which indicates that the second value carried in the secondary key value storage request starts at the 1M position of the first value, and the second value is in the first storage space The storage location starts from the location corresponding to the 1M data that is stored empty, and the size is the second value size storage space.
键值存储器在将所有次级键值存储请求中的第二值存储在第一存储空间后,结束数据存储操作。After storing the second value in all secondary key value storage requests in the first storage space, the key value storage ends the data storage operation.
键值存储器判断第一存储空间中已存储的第二值的总大小与第一值的大小是否一致,通过判断结果来确定第一值是否存储完成;若键值存储器可以查询第一存储空间中已存储的第二值,若已存储的第二值的总大小与第一值的大小一致,则确定第一值存储完成。The key value memory judges whether the total size of the second value stored in the first storage space is consistent with the size of the first value, and determines whether the first value is stored through the judgment result; if the key value memory can query the first storage space For the stored second value, if the total size of the stored second value is consistent with the size of the first value, it is determined that the storage of the first value is completed.
作为另一种可能的实施方式,键值存储器可以对已存储的每个次级键值存储请求中报文头中的键值大小进行累加,生成累加值,直至累加值等于键值总大小,确定第一值是否存储完成,结束数据存储操作。As another possible implementation manner, the key value storage may accumulate the key value size in the header of each stored secondary key value storage request to generate an accumulated value until the accumulated value is equal to the total size of the key value. Determine whether the storage of the first value is complete, and end the data storage operation.
基于与方法实施例同一发明构思,本申请实施例还提供了一种键值存储器,用于执行上述方法实施例中键值存储器执行的方法,相关特征可参见上述方法实施例,此处不再赘述,如图9所示,该装置包括接收单元901、分配单元902、分割单元903以及存储单元904:Based on the same inventive concept as the method embodiment, the embodiment of the application also provides a key-value memory for executing the method of the key-value memory in the above-mentioned method embodiment. For related features, please refer to the above-mentioned method embodiment. To repeat, as shown in FIG. 9, the device includes a receiving unit 901, a distributing unit 902, a dividing unit 903, and a storage unit 904:
接收单元901,用于接收键值存储请求,键值存储请求中包括键和第一值,其中,键与第一值对应。The receiving unit 901 is configured to receive a key-value storage request. The key-value storage request includes a key and a first value, where the key corresponds to the first value.
分配单元902,用于在第一存储器中为第一值分配第一存储空间,第一存储器是键值存储器之外的存储器。The allocating unit 902 is configured to allocate a first storage space for the first value in the first storage, and the first storage is a storage other than the key value storage.
分割单元903,用于当第一值的总长度大于或等于第一阈值时,将第一值分割为多个第二值,并生成多个次级键值存储请求,每个次级键值存储请求中携带键和一个第二值,次级键值存储请求的数量与第一值分割获得的多个第二值的个数相同。The dividing unit 903 is configured to divide the first value into multiple second values when the total length of the first value is greater than or equal to the first threshold, and generate multiple secondary key value storage requests, each secondary key value The storage request carries the key and a second value, and the number of secondary key value storage requests is the same as the number of multiple second values obtained by dividing the first value.
存储单元904,用于按照每个次级键值存储请求中携带的第二值在第一值中的位置顺 序,将每个次级键值存储请求中携带的第二值存储至第一存储空间。The storage unit 904 is configured to store the second value carried in each secondary key value storage request in the first storage according to the position order of the second value carried in each secondary key value storage request in the first value space.
可选的,分割单元903在将第一值分割为多个第二值时,可以边缓存边分割。示例性的,分割单元903可以在缓存第一值的过程中,每当缓存的数据的大小等于第二阈值时,将缓存的数据作为第二值,并将第二值携带在一个次级键值存储请求中,直至第一值缓存完成。当处于第一值的缓存的最后阶段,最后第一值的剩余数据大小小于第二阈值,可以直接将缓存的数据作为第二值,携带在一个次级键值存储请求中;这种情况下,每个次级键值存储请求中携带的第二值的大小不一定完全相同。Optionally, when the dividing unit 903 divides the first value into multiple second values, it may divide while buffering. Exemplarily, in the process of caching the first value, the dividing unit 903 may use the cached data as the second value whenever the size of the cached data is equal to the second threshold, and carry the second value in a secondary key. In the value storage request, until the first value cache is completed. When in the final stage of the first value cache, the remaining data size of the last first value is less than the second threshold, you can directly use the cached data as the second value and carry it in a secondary key value storage request; in this case , The size of the second value carried in each secondary key value storage request may not be exactly the same.
可选的,分割单元903在将第一值分割为多个第二值时,也可以采用缓存完成后再进行数据分割的方式;示例性的,分割单元903在第一值缓存完成后,可以将第一值分割为多个第二值;例如,分割单元903可以将第一值分割为N+1个第二值,按照分割顺序排列的多个第二值中,前N个第二值的大小可以等于第二阈值,最后一个第二值,也就是第N+1个第二值的大小可以小于或等于第二阈值,N为大于或等于1的正整数。示例性的,分割单元903也可以将第二值均为多个第二值。Optionally, when the dividing unit 903 divides the first value into multiple second values, it may also use a method of data division after the buffering is completed; for example, the dividing unit 903 may perform data division after the first value is buffered. The first value is divided into multiple second values; for example, the dividing unit 903 may divide the first value into N+1 second values, and among the multiple second values arranged in the order of division, the first N second values The size of can be equal to the second threshold, the last second value, that is, the size of the N+1th second value can be less than or equal to the second threshold, and N is a positive integer greater than or equal to 1. Exemplarily, the dividing unit 903 may also set the second values to be multiple second values.
可选的,次级键值存储请求中可以包括一些字段,用于指示携带的第二值的相关信息,如第二值的大小、偏移量等。示例性的,可以包括值偏置,通过值偏置可以指示次级键值存储请求中携带的第二值在第一值中的位置。Optionally, the secondary key value storage request may include some fields for indicating related information of the second value carried, such as the size and offset of the second value. Exemplarily, a value offset may be included, and the value offset may indicate the position of the second value carried in the secondary key value storage request in the first value.
可选的,存储单元904在按照每个次级键值存储请求中携带的第二值在第一值中的位置顺序,将每个次级键值存储请求中携带的第二值存储至第一存储空间时,需要先确定位置顺序,之后再存储第二值;示例性的,存储单元904可以根据每个次级键值存储请求中的值偏置,确定每个次级键值存储请求中携带的第二值在第一值中的位置顺序;之后,根据位置顺序,将第二值存储至第一存储空间。Optionally, the storage unit 904 stores the second value carried in each secondary key value storage request to the first value in the order of the second value carried in each secondary key value storage request. For a storage space, the position order needs to be determined first, and then the second value is stored; for example, the storage unit 904 may determine each secondary key value storage request according to the value offset in each secondary key value storage request The position order of the second value carried in the first value in the first value; after that, the second value is stored in the first storage space according to the position order.
可选的,存储单元904在第一存储器中为第一值分配第一存储空间时,可以预先在第一存储器中配置用于一个或多个键值存储请求中携带的第一值的第二存储空间,存储单元904可以从第二存储空间中为第一值分配第一存储空间,第一存储空间的大小可以等于第一值的大小,也可以大于第一值的大小。存储单元904可以在接收单元901接收到键值存储请求前预先配置第二存储空间;也可以在接收单元901接收到携带键值存储请求之后,存储单元904存储第一值之前,预先配置第二存储空间,这种情况下,第二存储空间的可以等于第一值的大小,也可以大于第一值的大小。Optionally, when the storage unit 904 allocates the first storage space for the first value in the first storage, the second storage for the first value carried in one or more key value storage requests may be pre-configured in the first storage. Storage space. The storage unit 904 may allocate the first storage space for the first value from the second storage space. The size of the first storage space may be equal to or greater than the first value. The storage unit 904 may pre-configure the second storage space before the receiving unit 901 receives the key-value storage request; it may also pre-configure the second storage space after the receiving unit 901 receives the key-value storage request and before the storage unit 904 stores the first value. Storage space. In this case, the size of the second storage space can be equal to or greater than the size of the first value.
可选的,存储单元904在第一存储器中为第一值分配存储空间时,若在第二存储空间中的空闲空间的大小小于第一值的大小,不能存储第一值,存储单元904可以从第一存储器中为第一值分配第一存储空间。Optionally, when the storage unit 904 allocates storage space for the first value in the first storage, if the size of the free space in the second storage space is less than the size of the first value, the storage unit 904 may not store the first value. The first storage space is allocated for the first value from the first storage.
可选的,存储单元904还可以确定第一值是否已完成存储;示例性的,当第一存储空间中已存储的第二值的总大小等于第一值的大小时,存储单元904可以确定已完成第一值的存储。Optionally, the storage unit 904 may also determine whether the first value has been stored; for example, when the total size of the second value stored in the first storage space is equal to the size of the first value, the storage unit 904 may determine The storage of the first value has been completed.
可选的,若次级键值存储请求包括值大小,用于指示次级键值存储请求中携带的第二值的大小;存储单元904可以累加已存储的第二值对应的次级键值存储请求中值大小,直至累加值等于第一值的大小,确定第一值已存储完成。Optionally, if the secondary key value storage request includes a value size, it is used to indicate the size of the second value carried in the secondary key value storage request; the storage unit 904 may accumulate the secondary key value corresponding to the stored second value Store the size of the requested value until the accumulated value is equal to the size of the first value, and it is determined that the first value has been stored.
需要说明的是,本申请实施例中对单元的划分是示意性的,仅仅为一种逻辑功能划分, 实际实现时可以有另外的划分方式。在本申请的实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。It should be noted that the division of units in the embodiments of the present application is illustrative, and is only a logical function division, and there may be other division methods in actual implementation. The functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or software functional unit.
上述实施例,可以全部或部分地通过软件、硬件、固件或其他任意组合来实现。当使用软件实现时,上述实施例可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载或执行所述计算机程序指令时,全部或部分地产生按照本发明实施例所述的流程或功能。所述计算机可以为通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集合的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质。半导体介质可以是固态硬盘(solid state drive,SSD)。The foregoing embodiments can be implemented in whole or in part by software, hardware, firmware or any other combination. When implemented by software, the above-mentioned embodiments may be implemented in the form of a computer program product in whole or in part. The computer program product includes one or more computer instructions. When the computer program instructions are loaded or executed on a computer, the processes or functions described in the embodiments of the present invention are generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website, computer, server, or data center. Transmission to another website site, computer, server or data center via wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.). The computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or a data center that includes one or more sets of available media. The usable medium may be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium. The semiconductor medium may be a solid state drive (SSD).
图10为本申请实施例提供的一种键值存储器1000的示意图,如图所示,键值存储器1000包括处理器1001、存储器1002。可选的,键值存储器1000还可以包括通信接口1003。其中,存储器1002和通信接口1003的个数并不构成对本申请实施例的限定,具体实施时,可以根据业务需求任意配置。FIG. 10 is a schematic diagram of a key value storage 1000 according to an embodiment of the application. As shown in the figure, the key value storage 1000 includes a processor 1001 and a memory 1002. Optionally, the key value storage 1000 may further include a communication interface 1003. Among them, the number of the memory 1002 and the communication interface 1003 does not constitute a limitation to the embodiment of the present application, and can be configured arbitrarily according to business requirements during specific implementation.
存储器1002可以是易失性存储器,例如随机存取存储器;存储器也可以是非易失性存储器,例如只读存储器,闪存,硬盘(hard disk drive,HDD)或固态硬盘(solid-state drive,SSD)、或者存储器1002是能够用于携带或存储具有指令或数据结构形式的期望的程序代码并能够由计算机存取的任何其他介质,但不限于此。存储器1002可以是上述存储器的组合。存储器1002可以是上述方法实施例中的第二存储器。The memory 1002 may be a volatile memory, such as a random access memory; the memory may also be a nonvolatile memory, such as a read-only memory, flash memory, hard disk drive (HDD) or solid-state drive (SSD) Or the memory 1002 is any other medium that can be used to carry or store desired program codes in the form of instructions or data structures and that can be accessed by a computer, but is not limited thereto. The memory 1002 may be a combination of the above-mentioned memories. The memory 1002 may be the second memory in the foregoing method embodiment.
本申请实施例中不限定上述处理器1001以及存储器1002之间的具体连接介质。The specific connection medium between the foregoing processor 1001 and the memory 1002 is not limited in the embodiment of the present application.
处理器1001可以为CPU,该处理器1001还可以是其他通用处理器、数字信号处理器(DSP)、专用集成电路(ASIC)、现场可编程门阵列(FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件、人工智能芯片、片上芯片等。通用处理器可以是微处理器或者是任何常规的处理器等。具有数据收发功能,能够与其他设备进行通信,在如图10装置中,也可以设置独立的数据收发模块,例如通信接口1003,用于收发数据;处理器1001在与其他设备进行通信时,可以通过通信接口1003进行数据传输,如从应用服务器键值客户端接收键值存储请求。The processor 1001 may be a CPU, and the processor 1001 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate array (FPGA) or other programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, artificial intelligence chips, chips on a chip, etc. The general-purpose processor may be a microprocessor or any conventional processor. It has a data transceiver function and can communicate with other devices. In the device shown in Figure 10, an independent data transceiver module, such as a communication interface 1003, can be used to send and receive data; when the processor 1001 communicates with other devices, it can Data transmission is performed through the communication interface 1003, such as receiving a key-value storage request from an application server key-value client.
当键值存储器采用图10所示的形式时,图10中的处理器1001可以通过调用存储器1002中存储的计算机执行指令,使得键值存储器可以执行上述任一方法实施例中的键值存储器执行的方法的操作步骤。When the key-value memory adopts the form shown in FIG. 10, the processor 1001 in FIG. 10 can call the computer-executed instructions stored in the memory 1002, so that the key-value memory can execute the key-value memory execution in any of the foregoing method embodiments. The steps of the method.
可选的,图10中键值存储器的处理器1001可以实现图2中键值存储引擎205和网络卸载引擎207的功能。Optionally, the processor 1001 of the key-value storage in FIG. 10 may implement the functions of the key-value storage engine 205 and the network offloading engine 207 in FIG. 2.
图9中的接收单元、分配单元、分割单元以及存储单元的功能/实现过程均可以通过图 10中的处理器1001调用存储器1002中存储的计算机执行指令来实现。或者,图9中的分配单元、分割单元以及存储单元的功能/实现过程可以通过图10中的处理器1001调用存储器1002中存储的计算机执行指令来实现,图9中的接收单元的功能/实现过程可以通过图10中的通信接口1003来实现。The functions/implementation processes of the receiving unit, the allocation unit, the dividing unit, and the storage unit in FIG. 9 can all be implemented by the processor 1001 in FIG. 10 calling the computer execution instructions stored in the memory 1002. Alternatively, the function/implementation process of the allocation unit, the division unit, and the storage unit in FIG. 9 can be implemented by the processor 1001 in FIG. 10 calling the computer execution instructions stored in the memory 1002, and the function/implementation of the receiving unit in FIG. 9 The process can be implemented through the communication interface 1003 in FIG. 10.
基于与方法实施例同一发明构思,本申请实施例还提供了一种键值存储服务器,键值存储服务器的结构可以参见图2,键值存储服务器可以包括键值存储器和第一存储器;第一存储器是键值存储器之外的存储器;键值存储器用于执行上述方法实施例中键值存储器执行的方法,第一存储器用于存储第一值;可选的,还可以包括中央处理器。Based on the same inventive concept as the method embodiment, the embodiment of the present application also provides a key-value storage server. The structure of the key-value storage server can be seen in FIG. 2. The key-value storage server may include a key-value storage and a first storage; The memory is a memory other than the key value memory; the key value memory is used to execute the method executed by the key value memory in the foregoing method embodiment, and the first memory is used to store the first value; optionally, it may also include a central processing unit.
在本申请所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed system, device, and method may be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the units is only a logical function division, and there may be other divisions in actual implementation, for example, multiple units or components can be combined or It can be integrated into another system, or some features can be ignored or not implemented. In addition, the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
以上所述,仅为本发明的具体实施方式。熟悉本技术领域的技术人员根据本发明提供的具体实施方式,可想到变化或替换,都应涵盖在本发明的保护范围之内。The above are only specific embodiments of the present invention. Those skilled in the art can think of changes or substitutions according to the specific implementation manners provided by the present invention, which should all fall within the protection scope of the present invention.

Claims (17)

  1. 一种数据存储方法,其特征在于,该方法包括:A data storage method, characterized in that the method includes:
    键值存储器接收键值存储请求,所述键值存储请求中携带有键和第一值,其中,所述键与所述第一值对应;The key value storage receives a key value storage request, where the key value storage request carries a key and a first value, wherein the key corresponds to the first value;
    所述键值存储器在第一存储器中为所述第一值分配第一存储空间,所述第一存储器是所述键值存储器之外的存储器;The key value storage allocates a first storage space for the first value in the first storage, and the first storage is a storage other than the key value storage;
    当所述第一值所包含数据的容量大于或等于第一阈值时,所述键值存储器将所述第一值分割为多个第二值,并生成多个次级键值存储请求,每个次级键值存储请求中携带所述键和一个所述第二值,所述次级键值存储请求的数量与所述第一值分割获得的所述多个第二值的个数相同;When the capacity of the data contained in the first value is greater than or equal to the first threshold, the key value storage divides the first value into multiple second values, and generates multiple secondary key value storage requests, each A secondary key value storage request carries the key and one of the second values, and the number of secondary key value storage requests is the same as the number of the multiple second values obtained by dividing the first value ;
    所述键值存储器按照每个次级键值存储请求中携带的第二值在所述第一值中的位置顺序,将所述每个次级键值存储请求中携带的第二值存储至所述第一存储空间。The key-value storage device stores the second value carried in each secondary key-value storage request in the order of the position in the first value of each secondary key-value storage request to The first storage space.
  2. 如权利要求1所述的方法,其特征在于,所述键值存储器将所述第一值分割为多个第二值,包括:8. The method of claim 1, wherein the key-value storage partitioning the first value into a plurality of second values comprises:
    所述键值存储器在缓存所述第一值的过程中,每当缓存的数据的大小等于第二阈值时,将所述缓存的数据作为所述第二值,将所述第二值携带在一个所述次级键值存储请求中,直至所述第一值缓存完成。When the key value memory is in the process of caching the first value, whenever the size of the cached data is equal to the second threshold, it uses the cached data as the second value, and carries the second value in In one of the secondary key value storage requests, until the first value cache is completed.
  3. 如权利要求1所述的方法,其特征在于,所述键值存储器将所述第一值分割为多个第二值,包括:8. The method of claim 1, wherein the key-value storage partitioning the first value into a plurality of second values comprises:
    所述键值存储器在所述第一值缓存完成后,将所述第一值分割为多个所述第二值,其中,所述第一值的按照分割顺序排列的多个所述第二值中,前N个第二值的大小等于所述第二阈值,第N+1个第二值的大小小于或等于所述第二阈值,N为大于或等于1的正整数。After the first value cache is completed, the key value memory divides the first value into a plurality of the second values, wherein the plurality of second values of the first value are arranged in the order of division. Among the values, the magnitude of the first N second values is equal to the second threshold, the magnitude of the N+1th second value is less than or equal to the second threshold, and N is a positive integer greater than or equal to 1.
  4. 如权利要求1所述的方法,其特征在于,所述次级键值存储请求包括值偏置,所述值偏置用于指示次级键值存储请求中携带的所述第二值在所述第一值中的位置。The method according to claim 1, wherein the secondary key value storage request includes a value offset, and the value offset is used to indicate that the second value carried in the secondary key value storage request is The position in the first value.
  5. 如权利要求1或4所述的方法,其特征在于,所述键值存储器按照每个次级键值存储请求中携带的第二值在所述第一值中的位置顺序,将所述每个次级键值存储请求中携带的第二值存储至所述第一存储空间,包括:The method according to claim 1 or 4, characterized in that the key-value storage stores the order of the second value carried in each secondary key-value storage request in the first value. The storage of the second value carried in a secondary key value storage request in the first storage space includes:
    所述键值存储器根据每个次级键值存储请求中的值偏置,确定每个次级键值存储请求中携带的第二值在所述第一值中的位置顺序;The key value storage determines the position sequence of the second value carried in each secondary key value storage request in the first value according to the value offset in each secondary key value storage request;
    所述键值存储器根据所述位置顺序,将所述第二值存储至所述第一存储空间。The key value storage stores the second value in the first storage space according to the position sequence.
  6. 如权利要求1所述的方法,其特征在于,所述键值存储器在第一存储器中为所述第一值分配第一存储空间,包括:The method according to claim 1, wherein the key value storage allocating a first storage space for the first value in the first storage, comprising:
    所述键值存储器从第二存储空间中为所述第一值分配所述第一存储空间,所述第二存储空间为所述第一存储器中预配置的用于存储多个所述键值存储请求中携带的第一值,所述第一存储空间的大小等于所述第一值的大小。The key value storage allocates the first storage space for the first value from a second storage space, and the second storage space is pre-configured in the first storage for storing a plurality of the key values For storing the first value carried in the request, the size of the first storage space is equal to the size of the first value.
  7. 如权利要求6所述的方法,其特征在于,所述键值存储器在第一存储器中为所述第一值分配第一存储空间,包括:The method according to claim 6, wherein the key value storage allocating a first storage space for the first value in the first storage, comprising:
    所述键值存储器在所述第二存储空间中的空闲空间的大小小于所述第一值的大小的情况下,从所述第一存储器中为所述第一值分配所述第一存储空间。When the size of the free space in the second storage space of the key value storage is smaller than the size of the first value, the first storage space is allocated from the first storage for the first value .
  8. 如权利要求1或6所述的方法,其特征在于,所述方法还包括:The method of claim 1 or 6, wherein the method further comprises:
    当所述第一存储空间中已存储的第二值的总大小等于所述第一值的大小时,所述键值存储装置确定已完成所述第一值的存储。When the total size of the second value stored in the first storage space is equal to the size of the first value, the key value storage device determines that the storage of the first value has been completed.
  9. 一种键值存储器,其特征在于,所述键值存储器包括接收单元、分配单元、分割单元以及存储单元:A key-value storage is characterized in that the key-value storage includes a receiving unit, a distribution unit, a dividing unit, and a storage unit:
    所述接收单元,用于接收键值存储请求,所述键值存储请求中携带有键和第一值,其中,所述键与所述第一值对应;The receiving unit is configured to receive a key-value storage request, where the key-value storage request carries a key and a first value, wherein the key corresponds to the first value;
    所述分配单元,用于在第一存储器中为所述第一值分配第一存储空间,所述第一存储器是所述键值存储器之外的存储器;The allocating unit is configured to allocate a first storage space for the first value in a first storage, where the first storage is a storage other than the key value storage;
    所述分割单元,用于当所述第一值所包含数据的容量大于或等于第一阈值时,将所述第一值分割为多个第二值,并生成多个次级键值存储请求,每个次级键值存储请求中携带所述键和一个所述第二值,所述次级键值存储请求的数量与所述第一值分割获得的所述多个第二值的个数相同;The dividing unit is configured to divide the first value into multiple second values when the capacity of the data contained in the first value is greater than or equal to the first threshold value, and generate multiple secondary key value storage requests Each secondary key value storage request carries the key and one of the second values, and the number of secondary key value storage requests is divided by the number of the second values obtained by dividing the first value. The same number
    所述存储单元,用于按照每个次级键值存储请求中携带的第二值在所述第一值中的位置顺序,将所述每个次级键值存储请求中携带的第二值存储至所述第一存储空间。The storage unit is configured to store the second value carried in each secondary key value storage request in the order of the position of the second value carried in each secondary key value storage request in the first value Stored in the first storage space.
  10. 如权利要求9所述的键值存储器,其特征在于,所述分割单元在将所述第一值分割为多个第二值时,具体用于:9. The key-value storage of claim 9, wherein when the dividing unit divides the first value into a plurality of second values, it is specifically configured to:
    在缓存所述第一值的过程中,每当缓存的数据的大小等于第二阈值时,将所述缓存的数据作为所述第二值,将所述第二值携带在一个所述次级键值存储请求中,直至所述第一值缓存完成。In the process of caching the first value, whenever the size of the cached data is equal to the second threshold, the cached data is used as the second value, and the second value is carried in one of the secondary In the key-value storage request, until the first value cache is completed.
  11. 如权利要求9所述的键值存储器,其特征在于,所述分割单元在将所述第一值分割为多个第二值时,具体用于:9. The key-value storage of claim 9, wherein when the dividing unit divides the first value into a plurality of second values, it is specifically configured to:
    在所述第一值缓存完成后,将所述第一值分割为多个所述第二值,其中,所述第一值的按照分割顺序排列的多个所述第二值中,前N个第二值的大小等于所述第二阈值,第N+1个第二值的大小小于或等于所述第二阈值,N为大于或等于1的正整数。After the first value is cached, the first value is divided into a plurality of the second values, wherein, among the plurality of second values of the first value arranged in the order of division, the first N The size of the second value is equal to the second threshold, the size of the N+1th second value is less than or equal to the second threshold, and N is a positive integer greater than or equal to 1.
  12. 如权利要求9所述的键值存储器,其特征在于,所述次级键值存储请求包括值偏置,所述值偏置用于指示次级键值存储请求中携带的所述第二值在所述第一值中的位置。The key value storage according to claim 9, wherein the secondary key value storage request includes a value offset, and the value offset is used to indicate the second value carried in the secondary key value storage request The position in the first value.
  13. 如权利要求9或12所述的键值存储器,其特征在于,所述存储单元在按照每个次级键值存储请求中携带的第二值在所述第一值中的位置顺序,将所述每个次级键值存储请求中携带的第二值存储至所述第一存储空间时,具体用于:The key-value storage according to claim 9 or 12, wherein the storage unit stores the second value in the first value according to the order of the second value carried in each secondary key-value storage request. When the second value carried in each secondary key value storage request is stored in the first storage space, it is specifically used for:
    根据每个次级键值存储请求中的值偏置,确定每个次级键值存储请求中携带的第二值在所述第一值中的位置顺序;According to the value offset in each secondary key value storage request, determine the position sequence of the second value carried in each secondary key value storage request in the first value;
    根据所述位置顺序,将所述第二值存储至所述第一存储空间。According to the position sequence, the second value is stored in the first storage space.
  14. 如权利要求9所述的键值存储器,其特征在于,所述存储单元在第一存储器中为所述第一值分配第一存储空间时,具体用于:9. The key-value storage of claim 9, wherein when the storage unit allocates the first storage space for the first value in the first storage, it is specifically used for:
    从第二存储空间中为所述第一值分配所述第一存储空间,所述第一存储空间为所述第一存储器中预配置的用于存储多个所述键值存储请求中携带的第一值,所述第一存储空间 的大小等于所述第一值的大小。Allocate the first storage space for the first value from the second storage space, where the first storage space is pre-configured in the first storage for storing multiple key-value storage requests carried The first value, the size of the first storage space is equal to the size of the first value.
  15. 如权利要求14所述的键值存储器,其特征在于,所述存储单元在第一存储器中为所述第一值分配存储空间时,具体用于:The key-value storage according to claim 14, wherein when the storage unit allocates storage space for the first value in the first storage, it is specifically used for:
    在所述第二存储空间中的空闲空间的大小小于所述第一值的大小的情况下,从所述第一存储器中为所述第一值分配所述第一存储空间。When the size of the free space in the second storage space is smaller than the size of the first value, the first storage space is allocated for the first value from the first memory.
  16. 如权利要求9或14所述的键值存储器,其特征在于,所述存储单元还用于:The key-value storage according to claim 9 or 14, wherein the storage unit is further used for:
    当所述第一存储空间中已存储的第二值的总大小等于所述第一值的大小时,确定已完成所述第一值的存储。When the total size of the second value stored in the first storage space is equal to the size of the first value, it is determined that the storage of the first value has been completed.
  17. 一种键值存储服务器,其特征在于,所述键值存储服务器包括第一存储器和键值存储器,所述第一存储器是所述键值存储器之外的存储器,所述键值存储器用于执行如权利要求1~8任一所述的方法。A key-value storage server, wherein the key-value storage server includes a first storage and a key-value storage, the first storage is a storage other than the key-value storage, and the key-value storage is used to execute The method according to any one of claims 1-8.
PCT/CN2020/075170 2019-03-29 2020-02-14 Data storage method, memory and server WO2020199760A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910252054.XA CN110083307A (en) 2019-03-29 2019-03-29 Date storage method, memory and server
CN201910252054.X 2019-03-29

Publications (1)

Publication Number Publication Date
WO2020199760A1 true WO2020199760A1 (en) 2020-10-08

Family

ID=67413914

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/075170 WO2020199760A1 (en) 2019-03-29 2020-02-14 Data storage method, memory and server

Country Status (2)

Country Link
CN (1) CN110083307A (en)
WO (1) WO2020199760A1 (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110083307A (en) * 2019-03-29 2019-08-02 华为技术有限公司 Date storage method, memory and server
CN111177025B (en) * 2019-12-30 2022-05-17 深圳云天励飞技术股份有限公司 Data storage method and device and terminal equipment
CN112511450B (en) * 2020-11-02 2022-05-31 杭州迪普信息技术有限公司 Flow control equipment and method
CN113742555A (en) * 2021-09-10 2021-12-03 北京锐安科技有限公司 Hotspot detection method, device, detection server, hotspot detection system and medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120284317A1 (en) * 2011-04-26 2012-11-08 Dalton Michael W Scalable Distributed Metadata File System using Key-Value Stores
CN102971732A (en) * 2010-07-02 2013-03-13 华为技术有限公司 System architecture for integrated hierarchical query processing for key/value stores
CN106155586A (en) * 2016-05-31 2016-11-23 华为技术有限公司 A kind of storage method, server and storage control
CN110083307A (en) * 2019-03-29 2019-08-02 华为技术有限公司 Date storage method, memory and server

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102971732A (en) * 2010-07-02 2013-03-13 华为技术有限公司 System architecture for integrated hierarchical query processing for key/value stores
US20120284317A1 (en) * 2011-04-26 2012-11-08 Dalton Michael W Scalable Distributed Metadata File System using Key-Value Stores
CN106155586A (en) * 2016-05-31 2016-11-23 华为技术有限公司 A kind of storage method, server and storage control
CN110083307A (en) * 2019-03-29 2019-08-02 华为技术有限公司 Date storage method, memory and server

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
CHU, XING: "Non-official translation: Redis Big Key Partition Scheme", 27 August 2017 (2017-08-27), Retrieved from the Internet <URL:https://blog.csdn.net/foreverling/article/details/77612060> DOI: 20200423145148Y *

Also Published As

Publication number Publication date
CN110083307A (en) 2019-08-02

Similar Documents

Publication Publication Date Title
WO2020199760A1 (en) Data storage method, memory and server
US11467975B2 (en) Data processing method and NVMe storage device
US20160132541A1 (en) Efficient implementations for mapreduce systems
CN110555001B (en) Data processing method, device, terminal and medium
JP6757808B2 (en) Systems and methods for managing and supporting Virtual Host Bus Adapters (vHBAs) on Infiniband (IB), and systems and methods for supporting efficient use of buffers using a single external memory interface.
US9304939B2 (en) Method and multi-core communication processor for replacing data in system cache
CN109388590B (en) Dynamic cache block management method and device for improving multichannel DMA (direct memory access) access performance
EP4318251A1 (en) Data access system and method, and device and network card
US9307024B2 (en) Efficient storage of small random changes to data on disk
US20200364080A1 (en) Interrupt processing method and apparatus and server
US20230289343A1 (en) Allocating partitions for executing operations of a query
US11226778B2 (en) Method, apparatus and computer program product for managing metadata migration
CN111125011B (en) File processing method, system and related equipment
WO2017177400A1 (en) Data processing method and system
WO2019201091A1 (en) Data processing method and device, and computer readable storage medium
US9747226B2 (en) Packet processing system, method and device to optimize packet buffer space
CN117312201B (en) Data transmission method and device, accelerator equipment, host and storage medium
CN116665727B (en) Write I/O aggregation method, apparatus, storage device and storage medium
WO2022222523A1 (en) Log management method and apparatus
US20230105067A1 (en) Metadata Processing Method in Storage Device, and Related Device
CN115904211A (en) Storage system, data processing method and related equipment
CN117666921A (en) Data processing method, accelerator and computing device
CN117917649A (en) Data processing method, device, chip and computer readable storage medium
CN117349232A (en) Data access method, device and system
KR101485246B1 (en) A design of extended ring buffer

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20783720

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20783720

Country of ref document: EP

Kind code of ref document: A1