Data processing method, device and electronic device
By pre-stored object data in the memory cache and directly accessing the objects in the memory cache, the problem of increased data access latency after object storage is mapped to block storage in the TGT gateway is solved, achieving a more efficient data access speed.
Patent Information
- Application Number
- CN202110293380.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-18
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2041-03-18
AI Technical Summary
In the TGT gateway, after object storage is mapped to block storage, the client's data access latency increases and the access speed decreases. This is mainly because each request needs to be converted through the HTTP protocol, which causes the data access latency to increase.
By pre-stored data of multiple objects in the memory cache, the objects in the memory cache can be directly accessed according to the data access request to avoid converting the request into an HTTP request, thus reducing the data access delay.
It improves data access speed, reduces data access delay, and improves the efficiency of data reading and writing.
Smart Images

Figure CN113010455B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data interaction, and in particular to a data processing method, device and electronic equipment. Background Art
[0002] In the TGT gateway, object storage is mapped to block storage, and block storage services are provided to the outside. In the related art, after object storage is mapped to block storage through TGT, the client accesses data by requesting access to data (for example, reading and writing data) according to the data offset and data length. The backend uses object storage, and each object is a block of a fixed size. Every time the client sends a request to access data, it will be converted into an HTTP request in the backend, and data will be requested from the object storage through the HTTP request. However, each request to access data is converted through the HTTP protocol, which will increase the data access delay and reduce the access speed. Summary of the invention
[0003] The object of the present invention is to provide a data processing method, device and electronic device to improve data access speed.
[0004] In a first aspect, the present invention provides a data processing method, which includes: if a data access request is received, determining a target object that the data access request needs to access, and a target linked list to which the target object belongs; querying whether the target object exists in a preset memory cache based on the target linked list; wherein the memory cache contains multiple linked lists; each linked list contains at least one object, which is used to store a specified amount of data; if the target object exists in the memory cache, accessing the target object in the memory cache based on the data access request.
[0005] In an optional implementation, if the linked list includes multiple objects, the multiple objects are sorted and stored in order of last access time; when the number of objects in the linked list reaches a preset number threshold, the object with the earliest last access time is deleted.
[0006] In an optional embodiment, the above-mentioned data access request carries an access starting position and an access length; if the data access request is received, the step of determining the target object that the data access request needs to access, and the target linked list to which the target object belongs, includes: if a data access request is received, extracting the access starting position and the access length from the data access request; determining the object identification of the target object to be accessed based on the access starting position, the access length and a preset device identification; performing a hash operation on the object identification of the target object to obtain a hash value; the hash value represents the linked list identification of the linked list to which the target object belongs; and determining the target linked list described by the target object based on the linked list identification.
[0007] In an optional embodiment, the above-mentioned data access request includes a data read request, which carries a read start position and a read length; the memory cache includes a write cache and a read cache; the above-mentioned step of querying whether the target object exists in the preset memory cache based on the target linked list includes: determining the object identifier of the target object based on the read start position and the read length; querying whether there is a target object corresponding to the object identifier in the target linked list of the read cache; if the target object exists in the memory cache, the step of accessing the target object in the memory cache based on the data access request includes: if the target object exists in the read cache, based on the object stored in the write cache, performing data reading processing on the target object according to the read start position and the read length.
[0008] In an optional implementation, the method further includes: if the target object does not exist in the read cache, reading the target object from a preset object storage; wherein the object storage includes a plurality of objects, each object storing pre-saved specified data.
[0009] In an optional embodiment, the above-mentioned step of performing data reading processing on the target object according to the read start position and the read length based on the object stored in the write cache includes: querying whether the target object exists in the write cache; if the target object exists in the write cache, determining whether the data contained in the target object in the write cache are all dirty data; if they are all dirty data, reading the target object from the write cache; if they are not all dirty data, reading the target object from the object storage and the write cache respectively, and merging the data contained in the read target object; wherein the object storage contains multiple objects, each object stores pre-saved specified data; if the target object does not exist in the write cache, reading the target object from the object storage.
[0010] In an optional embodiment, after the above step of reading the target object from the object storage, the method further includes: reading a specified number of objects subsequent to the target object from the object storage; and caching the specified number of objects into the read cache.
[0011] In an optional embodiment, the step of caching a specified number of objects into the read cache includes: determining a specified number of empty objects of data to be loaded from the read cache; and saving the specified number of objects read from the object storage into the empty objects.
[0012] In an optional embodiment, the above method also includes: determining whether the last object in the target linked list storing a specified number of objects in the read cache has not been read within a specified time; if not, deleting the last object from the read cache.
[0013] In an optional embodiment, the above-mentioned data access request includes a data write request, which carries the data to be written, the write starting position and the write length for the target object; the memory cache includes a write cache and a read cache; the above-mentioned step of querying whether the target object exists in the preset memory cache based on the target linked list includes: determining the object identifier of the target object based on the write starting position and the write length; querying whether there is a target object corresponding to the object identifier in the target linked list of the write cache; if the target object exists in the memory cache, the step of accessing the target object in the memory cache based on the data access request includes: if the target object exists in the write cache, merging the data to be written with the data contained in the target object in the write cache, and writing the merged target object into the write cache.
[0014] In an optional implementation, the method further includes: if the target object does not exist in the write cache, writing the data to be written into an empty object in the write cache.
[0015] In an optional implementation, the step of merging the data to be written with the data contained in the target object in the write cache includes: updating the data at the position corresponding to the data to be written in the target object in the write cache to the data to be written.
[0016] In an optional implementation, the method further includes: for each linked list in the write cache, starting from the last object in the current linked list, determining whether the data contained in the current object are all dirty data; if they are all dirty data, uploading the current object to the object storage; wherein the object storage contains multiple objects, each object storing pre-saved specified data; if they are not all dirty data, requesting the current object from the object storage, merging the data of the requested current object with the data of the current object in the write cache, and uploading the merged current object to the object storage.
[0017] In an optional implementation, the method further includes: determining whether the read cache contains the specified object currently uploaded to the object storage; if the specified object is contained, deleting the specified object from the read cache; if the specified object is not contained, deleting the specified object from the write cache.
[0018] In a second aspect, the present invention provides a data processing device, which includes: a request receiving module, which is used to determine the target object that the data access request needs to access and the target linked list to which the target object belongs if a data access request is received; an object query module, which is used to query whether the target object exists in a preset memory cache based on the target linked list; wherein the memory cache contains multiple linked lists; each linked list contains at least one object, which is used to store a specified amount of data; a data processing module, which is used to access the target object in the memory cache based on the data access request if the target object exists in the memory cache.
[0019] In a third aspect, the present invention provides an electronic device, comprising a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the data processing method described in any one of the aforementioned embodiments.
[0020] In a fourth aspect, the present invention provides a machine-readable storage medium storing machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the data processing method described in any one of the aforementioned implementations.
[0021] The embodiments of the present invention bring the following beneficial effects:
[0022] The present invention provides a data processing method, device and electronic device. If a data access request is received, the target object that the data access request needs to access and the target linked list to which the target object belongs are determined; then, based on the target linked list, a query is made as to whether the target object exists in a preset memory cache; if the target object exists in the memory cache, the target object in the memory cache is accessed based on the data access request. In this method, data of multiple objects are pre-stored in the memory cache in the form of a linked list. When accessing the data of the target object, if the target object exists in the memory cache, the target object in the memory cache is directly accessed. Since the access to the object in the memory cache does not require converting the data access request into an HTTP request to access the object, the data access delay is reduced and the data access speed is improved.
[0023] Other features and advantages of the present invention will be set forth in the following description, or some features and advantages may be inferred or unambiguously determined from the description, or may be learned by implementing the above-mentioned technology of the present invention.
[0024] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are specifically listed below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0026] Figure 1 A flowchart of a data processing method provided by an embodiment of the present invention;
[0027] Figure 2 A flowchart of another data processing method provided by an embodiment of the present invention;
[0028] Figure 3 A schematic diagram of the structure of a memory cache provided by an embodiment of the present invention;
[0029] Figure 4 A flowchart of another data processing method provided by an embodiment of the present invention;
[0030] Figure 5 A flowchart of another data processing method provided by an embodiment of the present invention;
[0031] Figure 6 A schematic diagram of the structure of a data processing device provided by an embodiment of the present invention;
[0032] Figure 7 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0033] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0034] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0035] In the TGT (Linux SCSI target framework) gateway, in order to reduce costs and facilitate storage, object storage is mapped to block storage, and block storage services are provided to the outside world. Block storage is a block-level data storage method, usually used in cloud environments; object storage is an unstructured data storage method, and usually requires the use of the HTTP (Hyper Text Transfer Protocol) interface to access the object. Specifically, in order to map object storage to block storage, the entire block device needs to be divided into blocks of fixed size, and each block corresponds to an object.
[0036] In the related art, after object storage is mapped to block storage through TGT, the client accesses data by requesting access to data (such as reading and writing data) according to data offset and data length. The backend uses object storage. Since access to the object storage service requires an HTTP interface, each time the client sends a request to access data, it will be converted into an HTTP request on the backend, and the object in the object storage will be accessed through the HTTP request. However, each request to access data is converted through the HTTP protocol, which will increase the data access latency and reduce the access speed.
[0037] Based on the above problems, the embodiments of the present invention provide a data processing method, device and electronic device. The technology can be applied to data access scenarios after object storage is mapped to block storage, especially in data reading and data writing scenarios. In order to facilitate understanding of the embodiments of the present invention, a data processing method disclosed in the embodiments of the present invention is first described in detail. Figure 1 As shown, the method comprises the following steps:
[0038] Step S102: If a data access request is received, determine the target object that the data access request needs to access and the target linked list to which the target object belongs.
[0039] The above data access request may be sent by a user through a terminal device, which may be a mobile terminal (e.g., a mobile phone, a tablet computer, etc.) or a computer. The above data access request may be a request to read data, or a request to write data or modify data, etc. In a specific implementation, the above data access request usually carries access parameters, which may include an access start position and an access length, etc. The target object to be accessed may be determined through the access parameters, and then the target linked list to which the target object belongs may be determined through the target object and the block device corresponding to the target object. The block device corresponding to the target object is also the device that stores the block data corresponding to the target object.
[0040] Step S104, querying whether the target object exists in the preset memory cache based on the target linked list; wherein the memory cache includes a plurality of linked lists; each linked list includes at least one object, and the object is used to store a specified amount of data.
[0041] The above-mentioned memory cache can be a preset high-speed buffer memory cache, or it can be other caches, which are specifically set according to user needs. The memory cache is used to cache data in objects, and the memory cache contains multiple linked lists, each of which contains at least one object, and each object is used to store a specified amount of data, which can be set according to user needs, for example, 1000M or 500M, etc.; not every object in the memory cache necessarily stores data, and there may be empty objects (that is, objects without data), which can be filled according to data access requests or pre-reading strategies, etc.
[0042] In the specific implementation, when querying the target object in the memory cache, the target linked list of the memory cache can be searched according to the object identifier of the target object; the object identifier can be calculated according to the access parameters carried in the data access request and the device identifier of the block device corresponding to the target object, and the specific calculation method can be arbitrarily set by the user.
[0043] Step S106: If the target object exists in the memory cache, access the target object in the memory cache based on the data access request.
[0044] If the target object is found in the target linked list of the memory cache, it means that the data of the target object is stored in the memory cache, and then the target object in the memory cache is accessed to read, modify and write the data in the target object according to the access parameters in the data access request. In the specific implementation, since the target object in the memory cache does not need to be converted into an HTTP request, the time for data access can be reduced.
[0045] A data processing method provided by an embodiment of the present invention determines the target object that needs to be accessed by the data access request and the target linked list to which the target object belongs if a data access request is received; then queries whether the target object exists in a preset memory cache based on the target linked list; if the target object exists in the memory cache, accesses the target object in the memory cache based on the data access request. In this method, data of multiple objects are pre-stored in the memory cache in the form of a linked list. When accessing the data of the target object, if the target object exists in the memory cache, the target object in the memory cache is directly accessed. Since accessing the object in the memory cache does not require converting the data access request into an HTTP request to access the object, the data access delay is reduced and the data access speed is improved.
[0046] The embodiment of the present invention also provides another data processing method, which is implemented on the basis of the method of the above embodiment; the method focuses on describing the specific process of determining the target object to be accessed by the data access request and the target linked list to which the target object belongs if a data access request is received (implemented by the following steps S202-S208); Figure 2 As shown, the method comprises the following steps:
[0047] Step S202: If a data access request is received, extract an access start position and an access length from the data access request.
[0048] The access start position is used to indicate the position corresponding to the starting point of the target object that the data access request needs to access, and the access length is used for the size of the data that needs to be accessed.
[0049] Step S204: determining the object identifier of the target object to be accessed according to the access start position, the access length and the preset device identifier.
[0050] The above-mentioned preset device identification refers to the identification of the block device storing the data block corresponding to the target object. In specific implementation, the device identification of the block device corresponding to each object is pre-stored in a specified position. The identification of the data block can be obtained according to the access start position and access length in the data access request, and then the object identification of the target object to be accessed can be obtained according to the identification of the data block and the device identification of the block device corresponding to the data block. Specifically, the access start position and the access length can be hashed to obtain the identification of the data block, and then the identification of the data block and the device identification can be hashed to obtain the object identification of the target object.
[0051] Step S206, performing a hash operation on the object identifier of the target object to obtain a hash value; the hash value represents the linked list identifier of the linked list to which the target object belongs.
[0052] In the specific implementation, the object identifier of the target object is hashed to obtain a hash value, which is the linked list identifier of the linked list to which the target object belongs. The linked list identifier uniquely corresponds to a linked list, and the linked list includes at least one object. In order to facilitate the understanding of the memory cache in the example of the present invention, Figure 3 A schematic diagram of the structure of a memory cache is given. Figure 3 The memory cache in contains n linked lists, each of which corresponds to a linked list identifier (equivalent to Figure 3 key in ) and at least one object (the object is equivalent to Figure 3 An entry in a table represents an object), and each object has a unique object identifier; Figure 3The key1, key2, ..., keyn in the list represent the linked list identifiers corresponding to the n linked lists respectively. The objects in each linked list can be sorted according to a preset sorting rule, for example, according to the number of uses, usage time, etc.
[0053] In some embodiments, if the linked list of the memory cache includes multiple objects, the multiple objects can be sorted and stored in the order of the last access time; when the number of objects in the linked list reaches a preset number threshold, the object with the earliest last access time is deleted, that is, the last object in the linked list is deleted. In this way, the objects in the linked list can be managed, making the objects stored in the linked list more valuable.
[0054] Step S208, determining the target linked list of the target object based on the linked list identifier.
[0055] Step S210, querying whether the target object exists in the preset memory cache based on the target linked list.
[0056] In the specific implementation, the object identifier can be queried in the target linked list of the memory cache according to the object identifier of the target object. If the object identifier exists, it means that the target object exists in the memory cache; if the object identifier does not exist, it means that the target object does not exist in the memory cache.
[0057] Step S212: If the target object exists in the memory cache, access the target object in the memory cache based on the data access request.
[0058] The above data processing method can temporarily store the data that may be accessed in the memory cache in advance. If the data to be accessed exists in the memory cache, the data can be accessed directly from the memory cache without having to request the data through HTTP every time the data is accessed, which reduces the latency of data requests and improves the data access speed.
[0059] The embodiment of the present invention also provides another data processing method, which is implemented on the basis of the method of the above embodiment; the method focuses on describing the specific process of querying whether the target object exists in the preset memory cache based on the target linked list when the data access request is a data read request and the memory cache includes a write cache and a read cache (implemented by the following steps S404-S406), and if the target object exists in the memory cache, the specific process of accessing the target object in the memory cache based on the data access request (implemented by the following step S408); Figure 4 As shown, the method comprises the following steps:
[0060] Step S402: if a data read request is received, determine the target object that the data read request needs to access and the target linked list to which the target object belongs; wherein the data read request carries a read start position and a read length.
[0061] Step S404: determining the object identifier of the target object based on the reading start position and the reading length.
[0062] Specifically, a hash operation may be performed on the read start position and the read length to obtain an identifier of the data block, and then a hash operation is performed on the identifier of the data block and a device identifier of a block device storing the data block to obtain an object identifier of the target object.
[0063] Step S406, query whether there is a target object corresponding to the object identifier in the target linked list of the read cache; if yes, execute step S408, otherwise, execute step S410.
[0064] In a specific implementation, the memory cache includes a write cache and a read cache. The data storage structure of the write cache and the read cache is the same, but the stored objects and data may be different. For example, the structure of the write cache and the read cache can be Figure 3 The structure shown is that the read cache contains multiple linked lists, each linked list contains at least one object, and each object user stores a specified amount of data. Similarly, the write cache also contains multiple linked lists.
[0065] Step S408: Based on the object stored in the write cache, data reading processing is performed on the target object according to the reading start position and the reading length.
[0066] If the target object corresponding to the above object identifier exists in the target linked list of the read cache, it is necessary to check whether the target object is stored in the write cache, and determine whether the data in the target object has been modified based on the target object stored in the write cache. If it has been modified, the target object will be read based on the modified data, so that the data in the accurate target object can be read. In specific implementation, the above step S408 can be implemented through the following steps 10-14:
[0067] Step 10, query whether the target object exists in the write cache; if so, execute step 11, otherwise, execute step 14.
[0068] The data stored in the objects of the write cache are the data written by the user at historical moments, and each object in the write cache stores a dirty data index, which is used to identify whether the data in the object has been written, that is, to indicate which data in the object has been modified.
[0069] Step 11, determining whether the data contained in the target object in the write cache are all dirty data; if they are all dirty data, executing step 12, otherwise, executing step 13.
[0070] According to the dirty data index of the target object in the write cache, it can be determined whether the data contained in the target object in the write cache are all dirty data.
[0071] Step 12: Read the target object from the write cache.
[0072] If the data contained in the target object in the write cache are all dirty data, it means that the data contained in the target object in the read cache have been modified. Therefore, it is necessary to read the target object from the write cache and return the data contained in the target object to the user who sent the data read request.
[0073] Step 13, read the target object from the object storage and the write cache respectively, and merge the data contained in the read target object; wherein the object storage contains multiple objects, and each object stores pre-saved specified data.
[0074] If the data contained in the target object in the write cache are not all dirty data, that is, there is data that is not dirty data in the data contained in the target object, it means that there is unmodified data in the data contained in the target object in the read cache. Therefore, it is necessary to read the target object from the write cache and the object storage respectively, and merge the data in the target object in the write cache with the data in the target object in the object storage (that is, replace the data at the storage location corresponding to the data in the target object in the write cache in the target object in the object storage with the data in the target object in the write cache), and return the target object after the data is merged to the user who sent the data read request.
[0075] The above object storage contains multiple objects, each of which stores pre-saved specified data, which is data in pre-divided data blocks. In specific implementation, in order to map the object storage to block storage, the entire block device is pre-divided into blocks of fixed size, and each block corresponds to an object, which is also the object contained in the object storage. Among them, the write cache and the read cache contain a part of the objects in the object storage.
[0076] Step 14: Read the target object from the object storage.
[0077] If the target object does not exist in the write cache, the target object needs to be read from the object storage and returned to the user.
[0078] In some embodiments, after step 14, it is necessary to read a specified number of objects subsequent to the target object from the object storage; and cache the specified number of objects in the read cache. It can also be understood that if the target object does not exist in the write cache, it is necessary to read the target object from the object storage, and pre-read a specified number of objects subsequent to the target object in the object storage, and cache the read specified number of objects in the read cache, so that the next time a data read request for the specified number of objects is received, the object is directly read from the read cache. The above-mentioned specified number can be set according to user needs, for example, it can be set to 3 or 4, etc.
[0079] In a specific implementation, the above method of caching a specified number of objects in the read cache can be implemented through the following steps 20-21:
[0080] Step 20: Determine a specified number of empty objects of the data to be loaded from the read cache.
[0081] Step 21, save the specified number of objects read from the object storage to the empty object.
[0082] For example, the specified number of objects read from the object storage is 3, and it is necessary to determine 3 empty objects to be loaded from the read cache, and then fill the data in these 3 objects into the 3 empty objects respectively. In some embodiments, after filling the data into the empty objects in the read cache, it will be detected whether the filled empty objects have been used within the specified time (that is, check whether it has timed out). If it has not been used, the object in the read cache will be deleted, thereby avoiding the pre-read data from occupying too many memory cache resources; if it has been used, the object position will be sorted on the linked list to which the object belongs according to the usage time. The above-mentioned specified time can be set according to user needs, and can be set to 10s or 15s, etc.
[0083] Step S410: read the target object from a preset object storage.
[0084] If the target object corresponding to the above object identifier does not exist in the target linked list of the read cache, the target object needs to be read from the object storage, that is, the data read request needs to be converted into an HTTP request, and then the target object is requested from the object storage, and the target object is returned to the user who sent the data read request.
[0085] In some embodiments, after step S410, a specified number of objects subsequent to the target object can be pre-read from the object storage and cached in the read cache so that the next time a data read request for the specified number of objects is received, the object can be read directly from the read cache.
[0086] In a specific implementation, multiple objects in any linked list in the read cache can be sorted and stored in the order of the last access time, that is, the earlier the last access time of the object, the later the sorting. The embodiment of the present invention needs to manage the objects in the read cache in real time, that is, to determine in real time whether the last object in the target linked list of a specified number of objects stored in the read cache has not been read within a specified time; if it has not been read, delete the last object from the read cache.
[0087] The above data processing method, when reading a target object, if the target object exists in the read cache, will perform data reading processing on the target object in the write cache based on the object stored in the write cache. This can reduce the number of times the object is requested from the object storage, avoid converting the data read request into the HTTP request to read the object, thereby reducing the data reading delay and improving the data reading speed.
[0088] The embodiment of the present invention also provides another data processing method, which is implemented on the basis of the method of the above embodiment; the method focuses on describing the specific process of querying whether the target object exists in the preset memory cache based on the target linked list when the data access request is a data write request (implemented by the following steps S504-S506), and if the target object exists in the memory cache, the specific process of accessing the target object in the memory cache based on the data access request (implemented by the following step S508); Figure 5 As shown, the method comprises the following steps:
[0089] Step S502, if a data write request is received, determine the target object that the data write request needs to access and the target linked list to which the target object belongs; wherein the data write request carries the data to be written for the target object, the write start position and the write length.
[0090] Step S504: determining the object identifier of the target object based on the write start position and the write length.
[0091] Specifically, a hash operation may be performed on the write start position and the write length to obtain an identifier of the data block to be accessed, and then a hash operation is performed on the identifier of the data block and the device identifier of the block device storing the data block to obtain an object identifier of the target object.
[0092] Step S506, query whether there is a target object corresponding to the object identifier in the target linked list of the write cache; if yes, execute step S508, otherwise, execute step S510.
[0093] Step S508: merge the data to be written with the data contained in the target object in the write cache, and write the target object after the data is merged into the write cache.
[0094] If the target object corresponding to the above object identifier is found in the target linked list of the write cache, it means that the data in the target object has been modified at the historical moment, and the data to be written in the data write request can be directly merged with the data contained in the target object in the write cache, and the target object after the data merger is written into the write cache. In specific implementation, the above step S508 can be implemented by the following steps 30-31:
[0095] Step 30: Update the data at the position corresponding to the data to be written in the target object in the write cache to the data to be written.
[0096] Step 31, writing the updated target object into the write cache.
[0097] For example, the write starting position of the data to be written is the starting position of the target object, and the write length is 100M. Then the 100M data starting from the starting position in the target object in the write cache is deleted, and the data to be written is written to the position where the data is deleted to obtain the updated target object; then the updated target object is written to the write cache.
[0098] Step S510, writing the data to be written into an empty object in the write cache.
[0099] If the target object corresponding to the above object identifier does not exist in the target linked list of the write cache, it is necessary to fill the data to be written into the empty object of the write cache according to the write parameters indicated by the data write request. The empty object can be the empty object corresponding to the target linked list in the write cache.
[0100] In some embodiments, it is also necessary to manage objects written into the write cache so as to write the data in the write cache into the object storage and process part of the data in the read cache to avoid dirty data in the read cache. Specifically, the management process of the write cache is as follows:
[0101] Step 40, for each linked list in the write cache, starting from the last object in the current linked list, determine whether the data contained in the current object are all dirty data; if they are all dirty data, execute step 41; if not, execute step 42.
[0102] Step 41, upload the current object to the object storage, and execute step 43.
[0103] Step 42 , request the current object from the object storage, merge the data of the requested current object with the data of the current object in the write cache, upload the merged data of the current object to the object storage, and execute step 43 .
[0104] If the data contained in the current object is all dirty data, it means that the data contained in the current object in the write cache has been modified by the user, and the current object in the write cache can be directly written to the object storage. If the data contained in the current object is not all dirty data, it means that only part of the data in the current object has been modified in the write cache, so it is necessary to request the current object from the object storage, and merge the data of the requested current object with the data of the current object in the write cache (that is, replace the data in the storage location corresponding to the data in the current object in the write cache in the requested current object with the data in the current object in the write cache), and upload the merged current object to the object storage.
[0105] Step 43 , determining whether the read cache contains the specified object currently uploaded to the object storage; if the specified object is contained, executing step 44 , otherwise, executing step 45 .
[0106] Step 44: Delete the specified object from the read cache.
[0107] Step 45: Delete the specified object from the write cache.
[0108] The above-mentioned specified object can be the current object currently uploaded to the object storage, that is, after the current object is uploaded to the object storage, it will be detected whether the current object exists in the read cache. If it exists, it means that the data of the current object contained in the read cache has been modified, that is, the data of the current object contained in the read cache is incorrect, and the current object in the read cache needs to be deleted; if it does not exist, it means that when a data read request is received, the data will be read directly from the object storage, and it will not be detected whether the current object exists in the write cache. Therefore, in order to save cache memory controls, the current object needs to be deleted from the write cache.
[0109] The above data processing method, when writing data to a target object, if the target object exists in the write cache, merges the data to be written with the data contained in the target object in the write cache, and writes the merged target object into the write cache. Since writing data to the write cache does not require converting the data write request into an HTTP request to write the data, the data writing delay is reduced and the data writing speed is improved; at the same time, this method is simple to implement in engineering and easy to maintain.
[0110] Corresponding to the above method embodiment, the embodiment of the present invention provides a data processing device, such as Figure 6 As shown, the device comprises:
[0111] The request receiving module 60 is used to determine the target object that needs to be accessed by the data access request and the target linked list to which the target object belongs if a data access request is received.
[0112] The object query module 61 is used to query whether a target object exists in a preset memory cache based on a target linked list; wherein the memory cache contains multiple linked lists; each linked list contains at least one object, and the object is used to store a specified amount of data.
[0113] The data processing module 62 is configured to access the target object in the memory cache based on the data access request if the target object exists in the memory cache.
[0114] The above-mentioned data processing device, if receiving a data access request, determines the target object that the data access request needs to access, and the target linked list to which the target object belongs; then queries whether the target object exists in the preset memory cache based on the target linked list; if the target object exists in the memory cache, accesses the target object in the memory cache based on the data access request. In this method, the memory cache pre-stores data of multiple objects in the form of a linked list. When accessing the data of the target object, if the target object exists in the memory cache, the target object in the memory cache is directly accessed. Since accessing the object in the memory cache does not require converting the data access request into an HTTP request to access the object, the data access delay is reduced and the data access speed is improved.
[0115] Specifically, if the linked list includes multiple objects, the multiple objects are sorted and stored in the order of the last access time; when the number of objects in the linked list reaches a preset number threshold, the object with the earliest last access time is deleted.
[0116] Furthermore, the above-mentioned data access request carries an access starting position and an access length; the above-mentioned request receiving module 60 is used to: if a data access request is received, extract the access starting position and the access length from the data access request; determine the object identification of the target object to be accessed according to the access starting position, the access length and the preset device identification; perform a hash operation on the object identification of the target object to obtain a hash value; the hash value represents the list identification of the list to which the target object belongs; based on the list identification, determine the target list of the target object.
[0117] Furthermore, the above-mentioned data access request includes a data read request, which carries a read start position and a read length; the memory cache includes a write cache and a read cache; the above-mentioned object query module 61 is used to: determine the object identifier of the target object based on the read start position and the read length; in the target linked list of the read cache, query whether there is a target object corresponding to the object identifier; the above-mentioned data processing module 62 is used to: if the target object exists in the read cache, based on the object stored in the write cache, perform data reading processing on the target object according to the read start position and the read length.
[0118] Furthermore, the data processing module 62 is also used to: if the target object does not exist in the read cache, read the target object from a preset object storage; wherein the object storage includes a plurality of objects, each object stores pre-saved specified data.
[0119] Specifically, the above-mentioned data processing module 62 is also used to: query whether the target object exists in the write cache; if the target object exists in the write cache, determine whether the data contained in the target object in the write cache are all dirty data; if they are all dirty data, read the target object from the write cache; if they are not all dirty data, read the target object from the object storage and the write cache respectively, and merge the data contained in the read target object; wherein the object storage contains multiple objects, each object stores pre-saved specified data; if the target object does not exist in the write cache, read the target object from the object storage.
[0120] Furthermore, the above-mentioned device also includes a read management module, which is used to: after reading the target object from the object storage, read a specified number of objects subsequent to the target object from the object storage; and cache the specified number of objects in the read cache.
[0121] Specifically, the read management module is further used to: determine a specified number of empty objects of the data to be loaded from the read cache; and save the specified number of objects read from the object storage to the empty objects.
[0122] Furthermore, the above-mentioned read management module is also used to: determine whether the last object in the target linked list storing a specified number of objects in the read cache has not been read within a specified time; if not, delete the last object from the read cache.
[0123] In a specific implementation, the data access request includes a data write request, which carries the data to be written, the write start position and the write length for the target object; the memory cache includes a write cache and a read cache; the object query module 61 is used to: determine the object identifier of the target object based on the write start position and the write length; query whether there is a target object corresponding to the object identifier in the target linked list of the write cache; the data processing module 62 is used to: if the target object exists in the write cache, merge the data to be written with the data contained in the target object in the write cache, and write the merged target object into the write cache.
[0124] Furthermore, the data processing module 62 is further configured to: if the target object does not exist in the write cache, write the data to be written into an empty object in the write cache.
[0125] Furthermore, the data processing module 62 is also used to update the data at the position corresponding to the data to be written in the target object in the write cache to the data to be written when merging data.
[0126] Furthermore, the above-mentioned device also includes a write management module, which is used to: for each linked list in the write cache, starting from the last object of the current linked list, determine whether the data contained in the current object are all dirty data; if they are all dirty data, upload the current object to the object storage; wherein the object storage contains multiple objects, each object stores pre-saved specified data; if they are not all dirty data, request the current object from the object storage, merge the data of the requested current object with the data of the current object in the write cache, and upload the current object after the merged data to the object storage.
[0127] Specifically, the method further includes: determining whether the read cache contains the specified object currently uploaded to the object storage; if the specified object is contained, deleting the specified object from the read cache; if the specified object is not contained, deleting the specified object from the write cache.
[0128] The data processing device provided in the embodiment of the present invention has the same implementation principle and technical effects as those of the aforementioned method embodiment. For the sake of brief description, for matters not mentioned in the device embodiment, reference may be made to the corresponding contents in the aforementioned method embodiment.
[0129] The embodiment of the present invention further provides an electronic device, see Figure 7 As shown, the electronic device includes a processor 101 and a memory 100. The memory 100 stores machine executable instructions that can be executed by the processor 101. The processor 101 executes the machine executable instructions to implement the above data processing method.
[0130] Further, Figure 7 The electronic device shown further includes a bus 102 and a communication interface 103 , and the processor 101 , the communication interface 103 and the memory 100 are connected via the bus 102 .
[0131] The memory 100 may include a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 103 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used. The bus 102 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0132] The processor 101 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 101. The above processor 101 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiment of the present invention can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 100, and the processor 101 reads the information in the memory 100 and completes the steps of the method of the above embodiment in combination with its hardware.
[0133] An embodiment of the present invention also provides a machine-readable storage medium, which stores machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the above-mentioned data processing method. The specific implementation can be found in the method embodiment, which will not be repeated here.
[0134] The computer program products of the data processing methods, devices, and electronic devices provided in the embodiments of the present invention include a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the methods described in the previous method embodiments. The specific implementation can be found in the method embodiments, which will not be repeated here.
[0135] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, electronic device, or network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0136] Finally, it should be noted that the above-described embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims
1. A data processing method, characterized in that: Applied to a data access scenario after object storage is mapped to block storage, the method includes: If a data access request is received, determining a target object that the data access request needs to access, and a target linked list to which the target object belongs; Based on the target linked list, query whether the target object exists in a preset memory cache; wherein the memory cache includes a plurality of linked lists; each of the linked lists includes at least one object, and the object is used to store a specified amount of data; If the target object exists in the memory cache, accessing the target object in the memory cache based on the data access request; The data access request includes a data read request, which carries a read start position and a read length; the memory cache includes a write cache and a read cache; the step of querying whether the target object exists in the preset memory cache based on the target linked list includes: determining the object identifier of the target object based on the read start position and the read length; querying whether there is a target object corresponding to the object identifier in the target linked list of the read cache; if the target object exists in the memory cache, the step of accessing the target object in the memory cache based on the data access request includes: if the target object exists in the read cache, based on the object stored in the write cache, performing data reading processing on the target object according to the read start position and the read length.
2. The method according to claim 1, characterized in that: If the linked list includes multiple objects, the multiple objects are sorted and stored in the order of the last access time; when the number of objects in the linked list reaches a preset number threshold, the object with the earliest last access time is deleted.
3. The method according to claim 1, characterized in that The data access request carries an access start position and an access length; The step of determining, if a data access request is received, a target object to be accessed by the data access request and a target linked list to which the target object belongs comprises: If the data access request is received, extracting the access start position and the access length from the data access request; Determining the object identification of the target object to be accessed according to the access starting position, the access length and a preset device identification; Performing a hash operation on the object identifier of the target object to obtain a hash value; the hash value represents the linked list identifier of the linked list to which the target object belongs; Based on the linked list identifier, a target linked list of the target object is determined.
4. The method according to claim 1, characterized in that: The method further comprises: If the target object does not exist in the read cache, the target object is read from a preset object storage; wherein the object storage includes a plurality of objects, each of which stores pre-saved specified data.
5. The method according to claim 1, characterized in that The step of performing data reading processing on the target object according to the read start position and the read length based on the object stored in the write cache includes: Querying whether the target object exists in the write cache; If the target object exists in the write cache, determining whether the data contained in the target object in the write cache are all dirty data; If all are dirty data, read the target object from the write cache; If not all of the data are dirty data, the target object is read from the object storage and the write cache respectively, and the data contained in the read target object is merged; wherein the object storage contains a plurality of objects, and each of the objects stores pre-saved specified data; If the target object does not exist in the write cache, the target object is read from the object storage.
6. The method according to claim 5, characterized in that After the step of reading the target object from the object storage, the method further includes: Reading a specified number of objects subsequent to the target object from the object storage; Cache the specified number of objects in the read cache.
7. The method according to claim 6, characterized in that The step of caching the specified number of objects in the read cache includes: Determining a specified number of empty objects of data to be loaded from the read cache; The specified number of objects read from the object store are saved to the empty object.
8. The method according to claim 6 or 7, characterized in that: The method further comprises: Determine whether the last object in the target linked list storing the specified number of objects in the read cache has not been read within a specified time; If it has not been read, the last object is deleted from the read cache.
9. The method according to claim 1, characterized in that: The data access request includes a data write request, wherein the data write request carries the data to be written, the write start position and the write length for the target object; The memory cache includes a write cache and a read cache; The step of querying whether the target object exists in a preset memory cache based on the target linked list includes: Determining an object identifier of a target object based on the write start position and the write length; In the target linked list of the write cache, query whether there is a target object corresponding to the object identifier; The step of accessing the target object in the memory cache based on the data access request if the target object exists in the memory cache comprises: If the target object exists in the write cache, the data to be written is merged with the data included in the target object in the write cache, and the target object after the data is merged is written into the write cache.
10. The method according to claim 9, characterized in that The method further comprises: If the target object does not exist in the write cache, the data to be written is written into an empty object in the write cache.
11. The method according to claim 9, characterized in that The step of merging the data to be written with the data contained in the target object in the write cache includes: The data at the position corresponding to the data to be written in the target object in the write cache is updated to the data to be written.
12. The method according to claim 9, characterized in that The method further comprises: For each linked list in the write cache, starting from the last object in the current linked list, determine whether the data contained in the current object are all dirty data; If all of them are dirty data, uploading the current object to an object storage; wherein the object storage contains a plurality of objects, each of which stores pre-saved specified data; If not all of the data are dirty data, the current object is requested from the object storage, the requested data of the current object is merged with the data of the current object in the write cache, and the merged current object is uploaded to the object storage.
13. The method according to claim 12, characterized in that The method further comprises: Determining whether the read cache contains a specified object currently uploaded to the object storage; If the specified object is contained, deleting the specified object from the read cache; If the specified object is not included, the specified object is deleted from the write cache.
14. A data processing device, characterized in that: Applied to a data access scenario after object storage is mapped to block storage, the device includes: A request receiving module, configured to, if a data access request is received, determine a target object that the data access request needs to access, and a target linked list to which the target object belongs; An object query module, used for querying whether the target object exists in a preset memory cache based on the target linked list; wherein the memory cache contains a plurality of linked lists; each of the linked lists contains at least one object, and the object is used to store a specified amount of data; A data processing module, configured to access the target object in the memory cache based on the data access request if the target object exists in the memory cache; The data access request includes a data read request, which carries a read start position and a read length; the memory cache includes a write cache and a read cache; the object query module is used to determine the object identifier of the target object based on the read start position and the read length; in the target linked list of the read cache, query whether there is a target object corresponding to the object identifier; if the target object exists in the memory cache, the step of accessing the target object in the memory cache based on the data access request includes: if the target object exists in the read cache, based on the object stored in the write cache, data reading processing is performed on the target object according to the read start position and the read length.
15. An electronic device, characterized in that: The electronic device includes a processor and a memory, the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the data processing method according to any one of claims 1 to 13.
16. A machine-readable storage medium, characterized in that: The machine-readable storage medium stores machine-executable instructions, and when the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the data processing method according to any one of claims 1 to 13.
