File reading method, device and electronic device
By pre-storing the mapping relationship between file names, file handles, file units and object data in the distributed file storage service, and judging and reading file units with object data, the problem of low efficiency of empty file reading is solved, and faster file reading time is achieved.
Patent Information
- Application Number
- CN202210028391.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-11
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2042-01-11
AI Technical Summary
In the distributed file storage service, when there is a hollow part of the file to be read, it is still necessary to query the file unit object information of the hollow part when reading the file, resulting in a long time to read the file and low efficiency.
By prestoring the mapping relationship between file names and file handles and the mapping relationship between file units and object data in the server, it is determined whether each file unit has corresponding object data, and only file units with object data are read to avoid querying the file units of the empty part.
Saves time for file reading and improves file reading efficiency, especially when there are holes in the file.
Smart Images

Figure CN114356850B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of file storage, and in particular to a file reading method, device and electronic equipment. Background Art
[0002] Distributed file storage service is a fully managed, scalable, high-performance file storage product, generally composed of clients, gateways, metadata management modules, data nodes and other modules. Generally speaking, when reading a file, a distributed file storage service needs to read the object information of multiple file units corresponding to the file, obtain object data based on the object information, and combine the object data into the final file.
[0003] If there is a hole in the file to be read, the file unit of the hole in the file will not store object information. However, in the above-mentioned file reading method, even if there is a hole in the file to be read, it is still necessary to perform the step of querying the file unit object information of the hole in the file when reading the file. Only after the query fails, it is determined that the object information cannot be read. The file reading consumes a long time and the file reading efficiency is low. Summary of the invention
[0004] In view of this, an object of the present invention is to provide a file reading method, device and electronic device to save the time of file reading and improve the efficiency of file reading.
[0005] In a first aspect, an embodiment of the present invention provides a file reading method, which is applied to a server, and the server is communicatively connected with a client. The method includes: determining a file handle and multiple file units corresponding to a target file to be read by the client; for each file unit, determining whether the file unit has corresponding object data; if so, reading the file handle and the object data corresponding to the file unit; and sending the read object data to the client so that the client combines the file data into a target file.
[0006] In a preferred embodiment of the present invention, the above-mentioned server includes a name node, a metadata node and an object storage service.
[0007] In a preferred embodiment of the present invention, the above-mentioned step of determining the file handle and multiple file units corresponding to the target file to be read by the client includes: receiving the file name of the target file sent by the client; converting the file name into a file handle through a name node; and determining the multiple file units corresponding to the target file through a metadata node.
[0008] In a preferred embodiment of the present invention, the above-mentioned name node pre-stores a first mapping relationship between the file name and the file handle; the step of converting the file name to the file handle through the name node includes: determining the file handle corresponding to the file name based on the first mapping relationship through the name node.
[0009] In a preferred embodiment of the present invention, the above-mentioned step of determining multiple file units corresponding to the target file through the metadata node includes: determining information of multiple file units, wherein the information of the file units includes data offset information and data length information of the file units; determining multiple file units based on the information of the multiple file units through the metadata node.
[0010] In a preferred embodiment of the present invention, the Bloom filter of the above-mentioned server pre-stores a second mapping relationship between the file unit and the object data; the step of judging whether the file unit has the corresponding object data comprises: determining whether the file unit has the corresponding object data based on the second mapping relationship stored in the Bloom filter.
[0011] In a preferred embodiment of the present invention, after the above step of determining whether the file unit has corresponding object data, the method further comprises: if not, canceling the step of reading the file handle and the object data corresponding to the file unit.
[0012] In a preferred embodiment of the present invention, the above-mentioned metadata node pre-stores a third mapping relationship between file handles, file units and object information; the step of reading object data corresponding to file handles and file units includes: reading object information corresponding to file handles and file units based on the third mapping relationship through the metadata node; and reading object data from the object storage service based on the object information.
[0013] In a preferred embodiment of the present invention, after the above step of reading the object data corresponding to the file handle and the file unit, the method further includes: combining the read object data into a target file; and sending the target file to the client.
[0014] In the second aspect, an embodiment of the present invention also provides a file reading device, which is applied to a server, and the server is communicatively connected with a client. The device includes: a file handle and file unit determination module, which is used to determine the file handle and multiple file units corresponding to the target file to be read by the client; an object data judgment module, which is used to judge for each file unit whether the file unit has corresponding object data; an object data reading module, which is used to read the file handle and the object data corresponding to the file unit if so; and an object data sending module, which is used to send the read object data to the client, so that the client can combine the file data into a target file.
[0015] In a third aspect, an embodiment of the present invention further provides an electronic device, including a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the steps of the above-mentioned file reading method.
[0016] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the steps of the above-mentioned file reading method.
[0017] The embodiments of the present invention bring the following beneficial effects:
[0018] The present invention provides a file reading method, device and electronic device. For each file unit corresponding to the target file to be read, it is possible to determine whether the file unit has corresponding object data; read the object data of the file unit with the corresponding object data, and send the read object data to the client, which combines the file data into the target file. In this way, the step of reading the object data may not be performed for the file unit that does not have the corresponding object data, which can save the time of file reading and improve the efficiency of file reading.
[0019] Other features and advantages of the present disclosure 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 disclosure.
[0020] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] 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.
[0022] Figure 1 A flowchart of a file reading method provided by an embodiment of the present invention;
[0023] Figure 2 A flowchart of another file reading method provided by an embodiment of the present invention;
[0024] Figure 3 A schematic diagram of a server provided in an embodiment of the present invention;
[0025] Figure 4 A schematic diagram of the structure of a file reading device provided by an embodiment of the present invention;
[0026] Figure 5 A schematic diagram of the structure of another file reading device provided by an embodiment of the present invention;
[0027] Figure 6 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0028] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. 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.
[0029] Distributed file storage service is a fully managed, scalable, high-performance file storage product, generally composed of client, gateway, metadata management module, data node and other modules. At present, when reading a file, the distributed file storage service needs to read the object information of multiple file units corresponding to the file, obtain the object data based on the object information, and combine the object data into the final file.
[0030] In file operations, the file offset can be greater than the current length of the file. In this case, the next write to the file will extend the file and form a hole in the file. This is allowed. Bytes that are in the file but have not been written are set to 0.
[0031] If the offset is greater than the current length of the file, the next write operation will "expand" the file. This is called creating a "hole" in the file. All bytes that have not actually been written to the file are represented by repeated zeros. Whether a hole takes up disk space is determined by the file system.
[0032] If there is a hole in the file to be read, the file unit of the hole in the file will not store object information. However, in the above-mentioned file reading method, even if there is a hole in the file to be read, it is still necessary to perform the step of querying the file unit object information of the hole in the file when reading the file. Only after the query fails, it is determined that the object information cannot be read. The file reading consumes a long time and the file reading efficiency is low.
[0033] Based on this, the embodiments of the present invention provide a file reading method, device and electronic device, which specifically relate to a distributed file storage hole reading data optimization solution, and provide a performance optimization solution for reading file hole part data in distributed file storage.
[0034] To facilitate understanding of this embodiment, a file reading method disclosed in an embodiment of the present invention is first introduced in detail.
[0035] This embodiment provides a file reading method, which is applied to a server, and the server is connected to a client for communication. Figure 1 The flowchart of a file reading method shown in FIG. 1 comprises the following steps:
[0036] Step S100, determining a file handle and a plurality of file units corresponding to a target file to be read by a client.
[0037] The file that the user wants to read from the server can be called a target file. The user can send the file name of the target file to the server through the client, and the server can find the corresponding file handle and multiple file units based on the file name of the target file.
[0038] In file I / O (Input / Output), to read data from a file, the application first calls an operating system function and passes the file name and selects a path to the file to open the file. The function retrieves a sequence number, the file handle, which is the unique identification basis for the open file.
[0039] When storing files, the server in this embodiment can store them through multiple file units, and each file unit stores a part of the target file. For example, the target file can be divided according to the specified size, and the divided target files are stored in the file units respectively. Assuming that the specified size is 4MB and the target file is 14MB, the target file can be divided into 3 4MB file units and 1 2MB file unit, and stored separately.
[0040] The server in this embodiment may pre-store the correspondence between the file name, file handle and multiple file units. After obtaining the file name of the target file, the server may determine the corresponding file handle and multiple file units according to the above correspondence file name.
[0041] Step S102: for each file unit, determine whether the file unit has corresponding object data.
[0042] The server in this embodiment needs to determine whether each file unit has corresponding object data. Specifically, the server may pre-store a correspondence between the file unit and the object information of the object data. The server may determine whether each file unit has corresponding object information, that is, whether it has corresponding object data, through the above correspondence.
[0043] Step S104: if yes, read the object data corresponding to the file handle and the file unit.
[0044] If the file unit has corresponding object data, the corresponding object data can be read according to the file handle and the file unit; if the file unit does not have corresponding object data, the step of reading the file handle and the object data corresponding to the file unit is not performed. Through the above steps, the reading step is no longer performed for the file unit without object data, which can save the time of file reading and improve the efficiency of file reading.
[0045] Step S106: sending the read object data to the client, so that the client combines the file data into a target file.
[0046] After reading all the object data corresponding to the file units, the server may send the read object data to the client, and the client combines the file data into a target file.
[0047] A file reading method provided by an embodiment of the present invention can determine whether the file unit has corresponding object data for each file unit corresponding to the target file to be read; read the object data of the file unit with the corresponding object data, and send the read object data to the client, so that the client combines the file data into the target file. In this way, the step of reading the object data can be omitted for the file unit without the corresponding object data, which can save the time of file reading and improve the efficiency of file reading.
[0048] This embodiment provides another file reading method, which is implemented on the basis of the above embodiment; this embodiment focuses on describing the specific implementation method of determining whether a file unit has corresponding object data. Figure 2 The flowchart of another file reading method shown in FIG. 1 is a flowchart of another file reading method, and the file reading method in this embodiment includes the following steps:
[0049] Step S200, determining a file handle and a plurality of file units corresponding to a target file to be read by the client.
[0050] The distributed file storage service (KPFS) is an object-based storage service that provides file storage to the outside world. Users interact with the KPFS server through a KPFS client that supports the POSIX (Portable Operating System Interface of UNIX) standard or an NFS (Network File System) client to store, retrieve, and delete file data.
[0051] See also Figure 3 The schematic diagram of a server in this embodiment includes a name node, a metadata node and an object storage service. That is, the KPFS server mainly includes three modules, namely the name node (namenode), the metadata node (metanode) and the object storage service. Among them, the namenode constructs the file system directory tree structure and the mapping relationship between the file name and the file handle (inode). The metanode constructs the mapping relationship between the file handle and the object data. The object storage service stores the real data of the file in the form of objects, each object is an object, and the object data can be read according to the object information (object_id).
[0052] Specifically, when reading data, the user can convert the file name in the request into a file handle in the namenode, and obtain object information (also called object information) in the metanode based on the file handle, read data offset and length, and then read data from the object storage service based on the object information.
[0053] Currently, the way to store and read files in metanode is as follows: in metanode, files are divided into several file units with a certain length (for example, 4MB), and the file units are numbered (for example, cell_0, cell_1, cell_N). Metanode uses inode+cell_N as the key and object information (one cell can correspond to multiple objects) as the value to store file metadata. When the user's request to read data reaches metanode, metanode calculates the corresponding cell sequence according to the offset and length of the read request, and queries and reads the corresponding object information according to the cell sequence.
[0054] However, in the above reading method, when a file has a hole, the empty cell does not store object information. However, when reading the hole, the object information is still queried. The cell is identified as an empty cell only after the query fails. In this process, query is the main time-consuming point, which increases the time consumed for file reading and reduces the file reading efficiency.
[0055] Specifically, in an embodiment of the present invention, the file handle and multiple file units corresponding to the target file to be read by the client can be determined through the following steps: receiving the file name of the target file sent by the client; converting the file name into a file handle through a name node; and determining multiple file units corresponding to the target file through a metadata node.
[0056] After receiving a request to read a file, the server can determine the file name of the target file of the request, and can convert the file name into a file handle through the name node; and can determine multiple file units corresponding to the target file through the metadata node.
[0057] Specifically, the name node pre-stores a first mapping relationship between the file name and the file handle; the file handle corresponding to the file name can be determined through the name node based on the first mapping relationship.
[0058] For example, the first mapping relationship may include that the file name A corresponds to the file handle X. When the file name of the target file of the server is A, the name node may determine that the file handle corresponding to the file name A is X based on the first mapping relationship.
[0059] Specifically, the metadata node can determine multiple file units corresponding to the target file through the following steps: determine the information of multiple file units, wherein the information of the file units includes data offset information and data length information of the file units; determine the multiple file units based on the information of the multiple file units through the metadata node.
[0060] As mentioned above, the metadata node divides the file into several cells of a certain length (for example, 4MB) and numbers the cells (for example, cell_0, cell_1, cell_N). The metadata node uses inode+cell_N as the key and object information (one cell can correspond to multiple objects) as the value to store the file metadata.
[0061] Therefore, the metadata node can calculate the file unit information based on the data offset information and the data length information, and determine multiple file units based on the file unit information.
[0062] Step S202: for each file unit, determine whether the file unit has corresponding object data based on the second mapping relationship stored in the Bloom filter.
[0063] A Bloom filter is a very long binary vector and a series of random mapping functions. A Bloom filter can be used to retrieve whether an element is in a set. In an embodiment of the present invention, a Bloom filter can be added to the storage engine of the file unit and the object information. The file unit with object information is mapped to true in the Bloom filter, and the file unit without object information is likely to be mapped to false, thereby forming a second mapping relationship.
[0064] For example, the second mapping relationship stored in the Bloom filter may include: file unit T is mapped as true, therefore, for file unit T, file unit T determines that the mapping is true based on the second mapping relationship stored in the Bloom filter and has corresponding object data.
[0065] For another example, the second mapping relationship stored in the Bloom filter may include: file unit Y is mapped as false, therefore, for file unit Y, file unit Y determines that the mapping is false based on the second mapping relationship stored in the Bloom filter.
[0066] Step S204: if yes, read the object data corresponding to the file handle and the file unit.
[0067] When reading data, first query the Bloom filter to confirm whether the file unit has object data. If so, continue to query and read the object information in the storage engine. If not, return directly. This greatly reduces the query process during empty reads and helps improve reading performance. After the step of determining whether the file unit has corresponding object data, the method further includes: if not, cancel the step of reading the file handle and the object data corresponding to the file unit.
[0068] Specifically, the metadata node pre-stores a third mapping relationship between file handles, file units, and object information, and the object data corresponding to the file handles and file units can be read through the following steps: reading the object information corresponding to the file handles and file units based on the third mapping relationship through the metadata node; and reading the object data from the object storage service based on the object information.
[0069] As mentioned above, the metadata node uses inode+cell_N as the key and object information (one cell can correspond to multiple objects) as the value to store the metadata of the file, and a third mapping relationship can be established. After determining the file handle inode and the file unit cell_N, the object information corresponding to the key inode+cell_N can be determined according to the third mapping relationship. For example: Assuming that the file handle is inode P and the file unit cell_3, the value corresponding to the key when inode P+cell_3 is determined by the third mapping relationship, the value is used as the object information, and the object data is read based on the object information through the object storage service.
[0070] Step S206: sending the read object data to the client, so that the client combines the file data into a target file.
[0071] After determining all the object data, in addition to sending the read object data to the client so that the client combines the file data into a target file, there may also be a service to combine the object data, for example: combining the read object data into a target file; sending the target file to the client.
[0072] The server may combine the object data into a target file and send the target file to the client; or the server may directly send the object data to the client, and the client may combine the object data into the target file.
[0073] The above method provided by the embodiment of the present invention can determine whether each file unit corresponding to the target file to be read has corresponding object data; read the object data of the file unit with the corresponding object data, and send the read object data to the client, and the client combines the file data into the target file.
[0074] Specifically, whether a file unit has corresponding object data can be determined through the second mapping relationship stored in the Keelung filter. For a file unit with corresponding object data, the step of reading the object data can be executed, and for a file unit that does not have corresponding object data, the step of reading the object data may not be executed, thereby saving file reading time and improving file reading efficiency.
[0075] Corresponding to the above method embodiment, the embodiment of the present invention provides a file reading device, which is applied to a server, and the server is connected to a client for communication, see Figure 4 A structural schematic diagram of a file reading device is shown, the file reading device comprising:
[0076] A file handle and file unit determination module 41 is used to determine a file handle and a plurality of file units corresponding to a target file to be read by a client;
[0077] The object data determination module 42 is used to determine, for each file unit, whether the file unit has corresponding object data;
[0078] The object data reading module 43 is used to read the object data corresponding to the file handle and the file unit if yes;
[0079] The object data sending module 44 is used to send the read object data to the client, so that the client can combine the file data into a target file.
[0080] A file reading device provided by an embodiment of the present invention can determine whether the file unit has corresponding object data for each file unit corresponding to the target file to be read; read the object data of the file unit with the corresponding object data, and send the read object data to the client, which combines the file data into the target file. In this way, the step of reading the object data can be omitted for the file unit without the corresponding object data, which can save the time of file reading and improve the efficiency of file reading.
[0081] The above servers include name nodes, metadata nodes, and object storage services.
[0082] The above-mentioned file handle and file unit determination module is used to receive the file name of the target file sent by the client; convert the file name into a file handle through the name node; and determine multiple file units corresponding to the target file through the metadata node.
[0083] The name node stores a first mapping relationship between the file name and the file handle in advance; the file handle and file unit determination module is used to determine the file handle corresponding to the file name based on the first mapping relationship through the name node.
[0084] The above-mentioned file handle and file unit determination module are used to determine the information of multiple file units, wherein the information of the file unit includes data offset information and data length information of the file unit; and determine the multiple file units based on the information of the multiple file units through the metadata node.
[0085] The Bloom filter of the server pre-stores a second mapping relationship between the file unit and the object data; the object data judgment module is used to determine whether the file unit has corresponding object data based on the second mapping relationship stored in the Bloom filter.
[0086] The object data reading module is further used to cancel the step of reading the object data corresponding to the file handle and the file unit if no.
[0087] The metadata node pre-stores a third mapping relationship between the file handle, the file unit and the object information; the object data reading module is used to read the object information corresponding to the file handle and the file unit based on the third mapping relationship through the metadata node; and read the object data from the object storage service based on the object information.
[0088] See also Figure 5 The structural diagram of another file reading device shown in the figure further includes: a target file combination module 45, which is connected to the object data reading module 43, and the target file combination module 45 is used to combine the read object data into a target file; and send the target file to the client.
[0089] The file reading device provided in the embodiment of the present invention has the same implementation principle and technical effects as those of the aforementioned file reading method embodiment. For the sake of brief description, for matters not mentioned in the file reading device embodiment, reference may be made to the corresponding contents in the aforementioned file reading method embodiment.
[0090] The embodiment of the present invention also provides an electronic device for executing the above-mentioned file reading method; see Figure 6 A structural schematic diagram of an electronic device is shown, the electronic device includes a memory 100 and a processor 101, wherein the memory 100 is used to store one or more computer instructions, and the one or more computer instructions are executed by the processor 101 to implement the above-mentioned file reading method.
[0091] Further, Figure 6 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 .
[0092] The memory 100 may include a high-speed random access memory (RAM), and may also include a 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 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 Only 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.
[0093] 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 conjunction with the embodiments 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.
[0094] An embodiment of the present invention also provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the above-mentioned file reading method. The specific implementation can be found in the method embodiment, which will not be repeated here.
[0095] The computer program product of the file reading method, device and electronic device provided in the embodiments of the present invention includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the method in the previous method embodiment. The specific implementation can be found in the method embodiment and will not be repeated here.
[0096] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system and / or device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0097] In addition, in the description of the embodiments of the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0098] 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.
[0099] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.
[0100] 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 file reading method, characterized in that: Applied to a server, the server being in communication connection with a client, the method comprising: Determine a file handle and a plurality of file units corresponding to a target file to be read by the client; For each of the file units, determining whether the file unit has corresponding object data; If yes, read the file handle and the object data corresponding to the file unit; Sending the read object data to the client, so that the client combines the read object data into the target file; The Bloom filter of the server pre-stores a second mapping relationship between file units and object data; the step of judging whether the file unit has corresponding object data comprises: determining whether the file unit has corresponding object data based on the second mapping relationship stored in the Bloom filter.
2. The method according to claim 1, characterized in that The server includes a name node, a metadata node and an object storage service.
3. The method according to claim 2, characterized in that The step of determining the file handle and multiple file units corresponding to the target file to be read by the client includes: Receive the file name of the target file sent by the client; Converting the file name into a file handle via the name node; The plurality of file units corresponding to the target file are determined through the metadata node.
4. The method according to claim 3, characterized in that The name node pre-stores a first mapping relationship between the file name and the file handle; The step of converting the file name into a file handle through the name node comprises: The file handle corresponding to the file name is determined through the name node based on the first mapping relationship.
5. The method according to claim 3, characterized in that: The step of determining a plurality of file units corresponding to the target file through the metadata node comprises: Determine information of the plurality of file units, wherein the information of the file units includes data offset information and data length information of the file units; The plurality of file units are determined by the metadata node based on information of the plurality of file units.
6. The method according to claim 1, characterized in that After the step of determining whether the file unit has corresponding object data, the method further includes: If not, cancel the step of reading the object data corresponding to the file handle and the file unit.
7. The method according to claim 2, characterized in that: The metadata node pre-stores a third mapping relationship between the file handle, the file unit and the object information; The step of reading the file handle and the object data corresponding to the file unit comprises: Reading the object information corresponding to the file handle and the file unit through the metadata node based on the third mapping relationship; Object data is read from the object storage service based on the object information.
8. The method according to claim 1, characterized in that After the step of reading the file handle and the object data corresponding to the file unit, the method further includes: Combining the read object data into the target file; The target file is sent to the client.
9. A file reading device, characterized in that: Applied to a server, the server is connected to a client for communication, and the device comprises: A file handle and file unit determination module, used to determine a file handle and a plurality of file units corresponding to a target file to be read by the client; An object data determination module, used for determining, for each of the file units, whether the file unit has corresponding object data; an object data reading module, for reading the object data corresponding to the file handle and the file unit if yes; An object data sending module, used for sending the read object data to the client, so that the client combines the read object data into the target file; The Bloom filter of the server pre-stores a second mapping relationship between file units and object data; the object data judgment module is used to determine whether the file unit has corresponding object data based on the second mapping relationship stored in the Bloom filter.
10. An electronic device, characterized in that: The invention comprises a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the steps of the file reading method according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the steps of the file reading method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Caching method for distributed storage system
CN103595797A