File handle coding method and device, equipment, storage medium and program product
By generating file handles using variable-length encoding, the problem of file description in complex distributed systems that traditional encoding methods cannot meet is solved, thereby improving file access efficiency and system performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-08
- Publication Date
- 2026-03-13
AI Technical Summary
Traditional fixed-length encoding methods cannot meet the requirements for describing files in complex distributed systems, resulting in low file access efficiency. This is especially true in complex distributed storage systems where information in file handles is limited, affecting access speed and system resource utilization.
By employing a variable-length encoding method, a file handle is generated by determining the file's basic metadata and advanced feature version number. This method utilizes bitmaps and encoded data to include more information within a limited length range, thereby improving file access performance.
It saves space while improving file access efficiency, reducing invalid updates, and optimizing system performance.
Smart Images

Figure CN121658435A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of file handle technology, and in particular to a file handle encoding method, apparatus, device, storage medium, and program product. Background Technology
[0002] The Network File System (NFS) protocol allows NFS clients to access a distributed file system connected to an NFS server over a network, much like accessing local storage. In NFS, a file handle is generated by the NFS server using fixed-length encoding based on the file's basic metadata. It is a fixed-length identifier used to uniquely identify a file, and its maximum length is typically limited to 32 bytes, 48 bytes, or 64 bytes depending on the protocol version. NFS clients can query file handles and cache them locally. When they need to read, write, delete, or access metadata about a file, they can include the file handle in the communication message. The NFS server parses the file handle to obtain the basic metadata information, thus locating the file.
[0003] In traditional technologies, NFS servers can connect to local file systems, distributed file systems, and object storage. When the NFS server is a local file system or a relatively simple distributed storage implementation, the identifier used to uniquely identify files is generally short, usually not exceeding the maximum length limited by the NFS protocol.
[0004] However, traditional fixed-length encoding methods cannot meet the requirements for file description in complex distributed systems. When the backend storage connected to the NFS server is a relatively complex distributed storage, more information may need to be included in the file handle in order to speed up access. However, due to the limitation on the file handle length of the NFS protocol itself, the information that can be included in the file handle is limited, which may increase the file access time and affect the file access efficiency. Summary of the Invention
[0005] Therefore, it is necessary to provide a file handle encoding method, apparatus, computer device, computer-readable storage medium, and computer program product that can improve file access efficiency in response to the above-mentioned technical problems.
[0006] On one hand, this application provides a file handle encoding method, comprising: determining basic metadata corresponding to a file; determining the version number of a target advanced feature of the file; performing a first encoding on the basic metadata to obtain first encoded data, and performing a second encoding on the version number of the target advanced feature of the file to obtain second encoded data corresponding to the target advanced feature, wherein the first encoding and / or the second encoding is a variable-length encoding; and generating a file handle of the file based on the first encoded data and the second encoded data corresponding to the target advanced feature.
[0007] In this embodiment, the basic metadata corresponding to the file is determined, the version number of the target advanced feature of the file is determined, the basic metadata is first encoded to obtain first encoded data, and the version number of the target advanced feature of the file is second encoded to obtain second encoded data corresponding to the target advanced feature. The first encoding and / or the second encoding are variable-length encodings. A file handle of the file is generated based on the first encoded data and the second encoded data corresponding to the target advanced feature. Introducing variable-length encoding in the process of generating the file handle can include as much information as possible in the file handle within a limited length, thereby saving space and improving file access performance.
[0008] In an exemplary embodiment, generating a file handle for the file based on the first encoded data and the second encoded data corresponding to the target advanced feature includes: generating a bitmap based on the advanced features of the file, wherein each advanced feature corresponds to a different bit in the bitmap, the target advanced feature belongs to the plurality of advanced features, the bit in the bitmap corresponding to the advanced feature of the file takes a first preset value, and the remaining bits in the bitmap take a second preset value; and generating a file handle for the file based on the first encoded data, the second encoded data corresponding to the target advanced feature, and the bitmap.
[0009] In this embodiment, a bitmap can be used to indicate which advanced features a file has in the file handle, instead of using a preset version number in the file handle to indicate advanced features that the file does not have, thus reducing the number of bits occupied by advanced features in the file handle.
[0010] In an exemplary embodiment, the file has at least two target high-level features. Generating a file handle for the file based on the first encoded data, the second encoded data corresponding to the target high-level features, and the bitmap includes: generating a file handle for the file based on the first encoded data, the second encoded data corresponding to the at least two target high-level features respectively, and the bitmap; wherein the second encoded data in the file handle is arranged according to the position of the corresponding bit in the bitmap.
[0011] In this embodiment, since the second encoded data in the file handle is arranged in the bitmap according to the position of the corresponding bit of the target high-level feature, the correspondence between the second encoded data and the target high-level feature can be clearly defined by combining the bitmap, which makes it easier to parse the version number corresponding to the target high-level feature.
[0012] In an exemplary embodiment, the step of performing a second encoding on the version number of the target advanced feature of the file to obtain the second encoded data corresponding to the target advanced feature includes: converting the version number of the target advanced feature of the file into corresponding binary data; if the binary data corresponding to the version number is greater than a numerical threshold, inserting a continuation marker into the binary data corresponding to the version number at intervals from low to high bits according to the target length, and inserting an end marker before the first bit of the binary data corresponding to the version number to obtain the second encoded data corresponding to the target advanced feature.
[0013] In this embodiment, a continuation marker is inserted into the binary data corresponding to the version number in the order from low bit to high bit, and an end marker is inserted before the first bit of the binary data corresponding to the version number, to obtain the second encoded data corresponding to the target advanced feature. The binary data belonging to the same value can be clearly identified by the continuation marker and the end marker, thus realizing variable length encoding.
[0014] In an exemplary embodiment, the method further includes: if the binary data corresponding to the version number is less than or equal to the numerical threshold, adding an end marker before the first digit of the binary data corresponding to the version number to obtain the second encoded data corresponding to the target advanced feature.
[0015] In this embodiment, when the binary data corresponding to the version number is less than or equal to the numerical threshold, an end marker is directly added before the first digit of the binary data corresponding to the version number, which can quickly obtain the second encoded data corresponding to the target advanced feature.
[0016] In an exemplary embodiment, adding an end marker before the first bit of the binary data corresponding to the version number includes: adding at least one end marker before the first bit of the binary data corresponding to the version number; wherein the length between adjacent markers in the second encoded data is the target length, and the marker is an end marker or a continuation marker.
[0017] In this embodiment, by adding at least one end marker before the first bit of the binary data corresponding to the version number, the length between adjacent markers in the second encoded data is the target length, so the length of each unit in the second encoded data = target length + 1, thus parsing can be performed according to a fixed length, providing conditions for parsing.
[0018] In an exemplary embodiment, the method further includes: if the file does not possess any advanced features, using the first encoded data as a file handle for the file, wherein the first encoding is a variable-length encoding.
[0019] In this embodiment, when the file does not have any advanced features, the first encoded data obtained by first encoding the basic metadata is used as the file handle. Compared with fixed-length encoding, this allows the basic metadata to contain more useful information.
[0020] On the other hand, this application also provides a file handle encoding device, including: a data determination module, used to determine basic metadata corresponding to a file; a version number determination module, used to determine the version number of a target advanced feature of the file; an encoding module, used to perform a first encoding on the basic metadata to obtain first encoded data, and perform a second encoding on the version number of the target advanced feature of the file to obtain second encoded data corresponding to the target advanced feature, wherein the first encoding and / or the second encoding are variable-length encodings; and a handle generation module, used to generate a file handle of the file based on the first encoded data and the second encoded data corresponding to the target advanced feature.
[0021] On the other hand, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described file handle encoding method.
[0022] On the other hand, this application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps in the above-described file handle encoding method.
[0023] On the other hand, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps in the above-described file handle encoding method.
[0024] The aforementioned file handle encoding method, apparatus, computer device, computer-readable storage medium, and computer program product determine the basic metadata corresponding to the file, determine the version number of the target advanced features of the file, perform a first encoding on the basic metadata to obtain first encoded data, and perform a second encoding on the version number of the target advanced features of the file to obtain second encoded data corresponding to the target advanced features. The first encoding and / or the second encoding are variable-length encodings. A file handle is generated based on the first encoded data and the second encoded data corresponding to the target advanced features. Introducing variable-length encoding in the process of generating the file handle allows for the inclusion of more information within a limited length range in the file handle, thereby saving space while improving file access performance. Attached Figure Description
[0025] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0026] Figure 1 This is a diagram illustrating the application environment of a file handle encoding method in one embodiment;
[0027] Figure 2 This is a flowchart illustrating a file handle encoding method in one embodiment;
[0028] Figure 3 This is a schematic diagram of the component handle structure in one embodiment;
[0029] Figure 4 This is a schematic diagram of a variable-length encoded binary representation of a number in one embodiment;
[0030] Figure 5 This is a structural block diagram of a file handle encoding device in one embodiment;
[0031] Figure 6 This is an internal structural diagram of a computer device in one embodiment;
[0032] Figure 7 This is a diagram of the internal structure of a computer device in another embodiment. Detailed Implementation
[0033] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0034] It should be noted that the terms "first," "second," etc., used in this application can be used to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from the second element. The terms "comprising" and "having," and any variations thereof, used in this application, are intended to cover non-exclusive inclusion. The term "multiple" used in this application refers to two or more. The term "and / or" used in this application refers to one of the embodiments, or any combination of multiple embodiments.
[0035] The file handle encoding method provided in this application embodiment can be applied to, for example... Figure 1In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104, or it can be located in the cloud or on other network servers. Server 104 can be a backend server of an NFS storage system.
[0036] Specifically, server 104 determines the basic metadata corresponding to the file and the version number of the advanced features the file possesses; it performs a first encoding on the basic metadata to obtain first encoded data, and performs a second encoding on the version number of the target advanced feature of the file to obtain second encoded data corresponding to the target advanced feature. The first encoding and / or the second encoding are variable-length encodings. Based on the first encoded data and the second encoded data corresponding to the target advanced feature, a file handle is generated. Server 104 can then transmit the file handle to terminal 102.
[0037] Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, drones, low-altitude aircraft, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, and projection equipment. Portable wearable devices can include smartwatches, smart bracelets, and head-mounted displays. Head-mounted displays can be virtual reality (VR) devices, augmented reality (AR) devices, and smart glasses. Server 104 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services.
[0038] In one exemplary embodiment, such as Figure 2 As shown, a file handle encoding method is provided, which can be executed by a terminal or server, and can be applied to... Figure 1 Taking server 104 as an example, the following steps are included:
[0039] Step 202: Determine the basic metadata corresponding to the file.
[0040] The basic metadata includes, but is not limited to, the inode number, the node ID where the inode resides, and / or the disk ID where the inode resides. Basic metadata may also include storage location and file identifier. A file's inode is used to store the file's metadata.
[0041] Step 204: Determine the version number of the target advanced features that the file has.
[0042] Advanced features, also known as advanced functionalities, include, but are not limited to, QoS (Quality of Service), directory QoS, and snapshots. For each advanced feature, the same file with the same ino number may have multiple versions; the NFS client's cached file handles need to be able to distinguish which version of the file it represents. A target advanced feature refers to the advanced features a file possesses; a file can have at least one advanced feature. If a file has the snapshot advanced feature, it means that the file handle represents a file accessed via a snapshot. If a file has the QoS advanced feature, it means that the file handle represents a file controlled by QoS rate limiting rules.
[0043] Step 206: Perform a first encoding on the basic metadata to obtain first encoded data, and perform a second encoding on the version number of the target advanced feature of the file to obtain second encoded data corresponding to the target advanced feature. The first encoding and / or the second encoding are variable-length encodings.
[0044] The characteristics of variable-length encoding include: the total number of bits required for a number increases as the number grows. Compared to encoding methods where each number occupies a fixed number of bits, such as 64 bits, smaller numbers require fewer than 64 bits. This allows for less restriction on the length of basic metadata and the number of advanced features, enabling file handles to contain more information and improving file access efficiency.
[0045] For example, when the server receives information from the client / terminal, it compares the version number of the advanced features in the file handle with the latest local version number. If the version number has changed, it means that there have been changes such as the addition or deletion of advanced features in the system, and the relevant metadata of the file's advanced features needs to be updated. Otherwise, if there is no change, it means that there have been no changes to the advanced features, and the NFS client cached data can be trusted, thereby reducing the number of times the backend distributed storage is accessed and improving file access efficiency.
[0046] For example, the first encoding is a fixed-length encoding, and the second encoding is a variable-length encoding. Alternatively, both the first and second encodings are variable-length encodings. Alternatively, the first encoding is a variable-length encoding, and the second encoding is a fixed-length encoding. Obtaining the first encoded data by performing variable-length encoding on the basic metadata includes: converting each element in the basic metadata into its corresponding binary data; for each element's corresponding binary data, if the binary data is greater than a numerical threshold, inserting a continuation marker in the binary data at target length intervals from low to high bits, and inserting an end marker before the first bit of the binary data to obtain the encoding value corresponding to that element; and combining the encoding values corresponding to each element in the basic metadata to form the first encoded data.
[0047] For example, suppose the file handle is encoded in a fixed-length format as follows:
[0048] struct FileHandle {
[0049] long ino; / / ino symbol
[0050] long nodeid; / / ID of the node where the inode is located
[0051] long diskid; / / Disk ID where the inode is located
[0052] long snap_ver; / / Snapshot version number
[0053] long qos_ver; / / QoS version number (user / volume-level quality of service version number)
[0054] long sysqos_ver; / / Sysqos version number (system-level quality of service version number)
[0055] }; / / Total size: 48 bytes
[0056] The `long` data type occupies 8 bytes and has 6 member variables, totaling 6 × 8 = 48 bytes. Therefore, if encoded with a fixed length, it will always occupy 48 bytes regardless of the value of each member variable. However, with variable-length encoding, all fields will occupy varying amounts of storage space based on their size. For example, if all values are 1, each field will occupy 8 bits, for a total of 48 bits = 6 bytes < 48 bytes. This compresses the space used.
[0057] In the above file handle encoding method, the basic metadata corresponding to the file is determined, the version number of the target advanced feature of the file is determined, the basic metadata is first encoded to obtain first encoded data, and the version number of the target advanced feature is second encoded to obtain second encoded data corresponding to the target advanced feature. The first encoding and / or the second encoding is variable-length encoding. The file handle is generated based on the first encoded data and the second encoded data corresponding to the target advanced feature. Introducing variable-length encoding in the process of generating the file handle can include as much information as possible within a limited length, thereby saving space and improving file access performance.
[0058] In a typical NFS system, a file handle is generated by the NFS server and serves as a unique file descriptor for communication between the NFS server and NFS clients. For example, a file handle generated by server 104 is used for communication between server 104 and terminal 102. Variable-length encoding is a type of compression encoding, a technique used to reduce data storage space. In NFS, the file handle is generated by the NFS server using fixed-length encoding based on the file's basic metadata information. It is a fixed-length identifier used to uniquely identify the file, and its maximum length is typically limited to 32 bytes, 48 bytes, or 64 bytes depending on the protocol version. NFS clients can query file handles and cache them locally. When they need to read, write, delete, or access file metadata, they can include the cached file handle in the communication message. The NFS server parses the file handle carried in the communication message to obtain the basic metadata, thus locating the file based on the basic metadata. NFS servers can connect to local file systems, distributed file systems, object storage, etc. When the NFS server is a local file system or a relatively simple distributed storage implementation, the identifier used to uniquely identify a file is generally short, usually not exceeding the maximum length limited by the NFS protocol. When the distributed storage system is more complex, such as having many advanced features, in order to cache file metadata, it is necessary to cache the metadata state of these advanced features (e.g., the version number of the advanced feature) at the time the file is accessed. This reduces the time spent retrieving advanced features on subsequent accesses, thereby improving file access efficiency.
[0059] Traditional fixed-length encoding methods are insufficient for describing files in complex distributed systems. This is because when describing the advanced functional states at the time of file retrieval, especially when the backend storage connected to by the NFS server is a complex distributed storage system with numerous advanced features, storing each advanced feature's information in the file handle at its original fixed length, along with the basic metadata, would exceed the NFS protocol's inherent limitations. While discarding the storage of some advanced feature version numbers allows for retrieving these features based on the basic metadata during file access, accessing unsaved advanced features would be extremely slow and resource-intensive. Alternatively, unifying version numbers for advanced features would only require storing one version number in the file handle, but changes to one advanced feature could affect unrelated features, resulting in numerous invalid updates during file access and further slowing down the system. For example, in scenarios involving both QoS and snapshots, if the two version numbers are not consistent (the QoS version number differs from the snapshot version number), two copies need to be stored in the file handle to represent different versions. If the two version numbers are consistent, only one copy needs to be stored in the file handle to uniquely identify the file's version. However, a problem arises when the snapshot version number increments by 1. In the storage system, many caches corresponding to this increment must be invalidated to prevent access to outdated data. If version numbers are managed separately, only the snapshot cache is invalidated when the snapshot version changes, and only the QoS cache is invalidated when the QoS version changes. If version numbers are managed uniformly, both the snapshot and QoS caches must be invalidated when only the snapshot version changes, even though the QoS hasn't changed, resulting in the invalidation of valid caches—a waste for the system. This application, however, can store as much file metadata information as possible within a limited length while maintaining file access efficiency.
[0060] In an exemplary embodiment, generating a file handle for a file based on first encoded data and second encoded data corresponding to a target advanced feature includes: generating a bitmap based on the advanced features of the file, wherein each advanced feature corresponds to a different bit in the bitmap, the target advanced feature belongs to multiple advanced features, the bit in the bitmap corresponding to the advanced feature of the file takes a first preset value, and the remaining bits in the bitmap take a second preset value; and generating a file handle for the file based on the first encoded data, the second encoded data corresponding to the target advanced feature, and the bitmap.
[0061] These advanced features can be, for example, two or more advanced features. The first preset value and the second preset value are either 0 or 1, and the first preset value and the second preset value are different; for example, the first preset value is 1 and the second preset value is 0, or the first preset value is 0 and the second preset value is 1. The first preset value represents that the file has the corresponding advanced feature, and the second preset value represents that the file does not have the corresponding advanced feature.
[0062] The length of the bitmap can be set according to actual needs. For example, the length of the bitmap can be the same as the number of advanced features, such as 10 bits. Each bit in the bitmap takes the value of a first preset value, such as 1, or a second preset value, such as 0. Each bit represents the presence or absence of an advanced feature. For example, if the bit value is 1, it means that the advanced feature corresponding to that bit exists; if the bit value is 0, it means that the advanced feature corresponding to that bit does not exist. For example, if the bit value corresponding to the snapshot advanced feature is 1, it means that the file handle represents a file obtained from a snapshot. Similarly, if the bit value corresponding to the QoS advanced feature is 1, it means that the file handle represents a file controlled by QoS rate limiting rules. For example, if the bitmap is "1000010000", it means that the file has the advanced features corresponding to the 1st and 6th bits, and the file does not have the advanced features corresponding to the remaining bits.
[0063] For example, the first encoded data, the second encoded data corresponding to the target high-level characteristics, and the bitmap can be combined to form the file handle of the file.
[0064] For example, when there are at least two target advanced features, the first encoded data, the second encoded data corresponding to the at least two target advanced features, and the bitmap can be used to form the file handle of the file.
[0065] Bitmaps reserve one bit in contiguous space for each optional advanced feature to indicate whether the advanced feature information exists in the file handle. If it exists, the corresponding advanced feature information is in the file handle; otherwise, it is not. Bitmaps allow for more storage space for basic metadata in simple file scenarios. In complex file scenarios with multiple advanced features configured, space saved for non-existent advanced features can be used for currently used features, increasing the representation range of existing advanced features. For example, in a simple file scenario, if all advanced features are absent and all bits are 0, then the version numbers of these advanced features do not need to be stored. Figure 3 The space saved by the intermediate and advanced features 1 and advanced features 2 can be used to store longer basic metadata. For example, when all versions exist, the original ino can only occupy a maximum of 32 bits, but now it can occupy 64 bits. The range of supported information such as location information or parent directory ino information in basic metadata can be expanded.
[0066] In this embodiment, a bitmap can be used to indicate which advanced features a file has in the file handle, instead of using a preset version number, such as 0, to represent advanced features that the file does not have. For example, in the fixed-length encoding format of the file handle mentioned above, if an 8-bit bitmap marker is added, if the file only has a snapshot version number, and the QoS version number and sysqos version number are both 0 (i.e., it does not have QoS and sysqos), then it only needs to occupy 3B (basic metadata ino, inodeid, diskid) + 1B (snap version number snap_ver) + 1B (bitmap) = 5B, further reducing the space and further compressing the number of bits occupied by advanced features in the file handle.
[0067] The version number indicates whether an advanced feature has been updated. If it has, the advanced feature entry point applicable to that file may also have been updated. If it hasn't been updated, it means there have been no additions or deletions to the advanced feature, and the advanced feature entry point applicable to that file will not be updated. Therefore, it can be accessed using the File Handle in the NFS client cache, reducing invalid updates. Understanding advanced feature entry points includes, for example, the snapshot advanced feature. Typically, a root directory or other directory is selected, and a marker is set on it. Newly created subdirectories and subfiles under this directory will have snapshot functionality, and modifications will be saved as snapshots. The selected root directory or other directory is called the snapshot advanced feature entry point. When a new directory is selected as the snapshot advanced feature entry point or a snapshot function on an old directory is deleted, the corresponding advanced feature version number will increment by 1. If the client finds that the cached version number is smaller than the latest version number, it means the cache is not up-to-date and will invalidate the cache and update to the latest version.
[0068] Since the advanced features configured on each file may differ, or they may be all present or none present, a fixed bit in the file handle is used to indicate whether the file has a certain advanced feature information: 1 for presence and 0 for absence. When an advanced feature is absent, the saved space can be used for variable-length encoding of the existing advanced features, allowing them to support larger numbers.
[0069] Assume that version numbers occupy a maximum of 16 bits, and inode numbers occupy a maximum of 48 bits. After a considerable period, there might be scenarios where not all fields can be stored. In such cases, version numbers for some advanced features can be discarded. If the discarded version numbers miss in the NFS server cache, all of them will need to be searched. Since current storage space cannot accommodate the maximum length of all advanced features, and both version numbers and inode numbers increase in size over time, their storage requirements also increase. When both reach large values, discarding some version numbers for advanced features ensures that critical information is preserved intact. For example, an inode number might be 1 at system deployment, requiring only 8 bits, but after 10 years, it might be 123456, requiring 24 bits, thus increasing storage space.
[0070] In an exemplary embodiment, the file has at least two target high-level features. Based on the first encoded data, the second encoded data corresponding to the target high-level features, and the bitmap, a file handle of the file is generated, including: generating a file handle of the file based on the first encoded data, the second encoded data corresponding to the at least two target high-level features respectively, and the bitmap; wherein, the second encoded data in the file handle is arranged according to the position of the bit corresponding to the target high-level feature in the bitmap.
[0071] In this case, the earlier the corresponding bit of the target high-level feature is in the bitmap, the earlier the second encoded data of the target high-level feature is in the file handle.
[0072] For example, a file handle can be formed by first encoded data, second encoded data corresponding to at least two target high-level features, and a bitmap. For instance, if there are two target high-level features, S1 and S2, and the bit corresponding to S1 precedes the bit corresponding to S2, then the file handle can be "first encoded data concatenated with the second encoded data corresponding to S1 concatenated with the encoded data of S2 concatenated with the bitmap".
[0073] In this embodiment, since the second encoded data in the file handle is arranged in the bitmap according to the position of the corresponding bit of the target high-level feature, the correspondence between the second encoded data and the target high-level feature can be clearly defined by combining the bitmap, which makes it easier to parse the version number corresponding to the target high-level feature.
[0074] In an exemplary embodiment, the second encoding of the version number of the target advanced feature of the file to obtain the second encoded data corresponding to the target advanced feature includes: converting the version number of the target advanced feature of the file into corresponding binary data; if the binary data corresponding to the version number is greater than a numerical threshold, inserting a continuation marker in the binary data corresponding to the version number at intervals from low to high bits according to the target length, and inserting an end marker before the first bit of the binary data corresponding to the version number to obtain the second encoded data corresponding to the target advanced feature.
[0075] The version number is identified numerically. The target length can be set according to actual needs, for example, a target length of 7. The numerical threshold is the maximum value that binary data of the target length can represent. Taking a target length of 7 as an example, the maximum value represented by binary data of length 7 is 127. The continuation marker and the end marker are two different markers. A continuation marker is inserted every target length interval. Therefore, the length of the binary segment from one marker to the next marker is equal to the target length + 1. The binary segment from one marker to the next marker can be considered as a unit, and the length of each unit is the target length + 1. If the target length is 7, then the length of each unit is 8, thus each unit occupies 8 bits.
[0076] Since the length of the binary data corresponding to the version number may not be an integer multiple of the target length, at least one end marker must be inserted before the first bit of the binary data corresponding to the version number so that the length of the binary segment from the first end marker to the first continuation marker is equal to the target length + 1.
[0077] For example, the continuation marker and the end marker are either 0 or 1. For instance, the continuation marker is 1 and the end marker is 0, or the continuation marker is 0 and the end marker is 1. The continuation and end markers are used to resolve the file handle, clearly indicating whether further resolution of the next unit is necessary. Figure 4 The diagram shows the binary representation of the number 6666 after variable-length encoding. The binary form of the number 6666 is "01101000001010". A continuation marker of 1 is added before the lower 7 bits of the number, and an end marker of 0 is added before the higher 7 bits of the data (i.e., before the first bit). This gives the binary representation of the number 6666 after variable-length encoding.
[0078] Exemplarily, during parsing, if the first bit of the next unit is an end marker, it indicates that the binary digits belonging to the same value end here, and the binary digits belonging to the same value can be converted into data in the required form; if the first bit of the next unit is a continuation marker, continue to read the next unit to gradually obtain the complete binary digits of the same value. It can be understood that before converting the binary digits belonging to the same value into data in the required form, the continuation marker and the end marker need to be deleted. For example, if the target length is 7, each unit occupies 8 bits, that is, taking 8 bits as a unit, the highest bit indicates whether there is a next 8-bit to be parsed. If the value of the highest bit is 1, it means that the next 8-bit needs to be parsed; if the highest bit is 0, it means that there is no need to parse the next 8-bit. When the number < 128, it occupies 8 bits; when the number < 32768, it occupies 16 bits; when the number <8388608>, it occupies 24 bits, and so on. If the number increments by 1 every day, a 16-bit number can represent the number 32768 and can be used for 89 years; a 48-bit number can be consumed at a rate of 100,000 per second and can be used for 44 years. Since the variable-length encoded number itself has a marker indicating whether the next 8 bits need to be parsed, the length of the variable-length encoded number can be automatically parsed out without reserving additional space to store the number length.
[0079] In this embodiment, continuation markers are inserted into the binary data corresponding to the version number at intervals of the target length in the order from the low bit to the high bit, and an end marker is inserted before the first bit of the binary data corresponding to the version number to obtain the second encoded data corresponding to the target advanced feature. The binary digits belonging to the same value can be clearly identified through the continuation marker and the end marker, realizing variable-length encoding.
[0080] In an exemplary embodiment, the method further includes: when the binary data corresponding to the version number is less than or equal to a numerical threshold, adding an end marker before the first bit of the binary data corresponding to the version number to obtain the second encoded data corresponding to the target advanced feature.
[0081] Exemplarily, taking the target length of 7 (i.e., the numerical threshold of 127) as an example, when the binary data corresponding to the version number is less than or equal to 127, the length of the binary data corresponding to the version number is less than or equal to 7. Therefore, at least one end marker is added before the first bit of the binary data corresponding to the version number to obtain binary data of unit length, and the binary data of unit length is the second encoded data corresponding to the target advanced feature. Here, the unit length = target length + 1.
[0082] In this embodiment, when the binary data corresponding to the version number is less than or equal to the numerical threshold, directly adding an end marker before the first bit of the binary data corresponding to the version number can quickly obtain the second encoded data corresponding to the target advanced feature.
[0083] In an exemplary embodiment, adding an end marker before the beginning of the binary data corresponding to the version number includes: adding at least one end marker before the beginning of the binary data corresponding to the version number; wherein the length between adjacent markers in the second encoded data is the target length, and the marker is an end marker or a continuation marker.
[0084] By adding at least one end marker before the first bit of the binary data corresponding to the version number, the distance between the first bit of the second encoded data and the first continuation marker can be the target length, so that the length of each unit in the second encoded data is equal to the target length + 1.
[0085] In this embodiment, by adding at least one end marker before the first bit of the binary data corresponding to the version number, the length between adjacent markers in the second encoded data is the target length, so the length of each unit in the second encoded data = target length + 1, thus parsing can be performed according to a fixed length, providing conditions for parsing.
[0086] In an exemplary embodiment, the method further includes: using first encoded data as a file handle for a file when the file does not possess any advanced features, wherein the first encoding is a variable-length encoding.
[0087] For example, if the file does not have any advanced features, the basic metadata is variable-length encoded to obtain first encoded data, and the first encoded data is used as the file handle of the file.
[0088] In this embodiment, when the file does not have any advanced features, the first encoded data obtained by first encoding the basic metadata is used as the file handle. Compared with fixed-length encoding, this allows the basic metadata to contain more useful information.
[0089] The file handle encoding method provided in this application introduces variable-length encoding into the file handle, which saves space while maximizing file access performance. By setting bit identifiers (i.e., one bit in the bitmap) for different advanced functions in the file handle to indicate the presence of advanced functions, space is further saved, by at least 25%. In the initial stages of system operation, due to the small number of bits, the space saved can far exceed 25%. The variable-length encoding in this application can also be replaced with other compression encoding methods, such as differential compression or snappy compression algorithms.
[0090] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps. It is understood that the steps in different embodiments can be freely combined as needed, and all non-contradictory solutions formed by such combinations are within the scope of protection of this application.
[0091] Based on the same inventive concept, this application also provides a file handle encoding apparatus for implementing the file handle encoding method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more file handle encoding apparatus embodiments provided below can be found in the limitations of the file handle encoding method described above, and will not be repeated here.
[0092] In one exemplary embodiment, such as Figure 5 As shown, a file handle encoding device is provided, including: a data determination module 502, a version number determination module 504, an encoding module 506, and a handle generation module 508, wherein:
[0093] The data determination module 502 is used to determine the basic metadata corresponding to the file.
[0094] Version number determination module 504 is used to determine the version number of the target advanced features of a file.
[0095] Encoding module 506 is used to perform a first encoding on basic metadata to obtain first encoded data, and to perform a second encoding on the version number of the target advanced feature of the file to obtain second encoded data corresponding to the target advanced feature. The first encoding and / or the second encoding are variable-length encodings.
[0096] The handle generation module 508 is used to generate a file handle for a file based on the first encoded data and the second encoded data corresponding to the target advanced characteristics.
[0097] In some embodiments, the handle generation module 508 is further configured to generate a bitmap based on the advanced features of the file, wherein each advanced feature corresponds to a different bit in the bitmap, the target advanced feature belongs to multiple advanced features, the bit in the bitmap corresponding to the advanced feature of the file takes a first preset value, and the other bits in the bitmap take a second preset value; and generate a file handle of the file based on the first encoded data, the second encoded data corresponding to the target advanced feature, and the bitmap.
[0098] In some embodiments, the file has at least two advanced features. The handle generation module 508 is further configured to generate a file handle for the file based on the first encoded data, the second encoded data corresponding to the at least two target advanced features, and a bitmap. The second encoded data in the file handle is arranged according to the position of the corresponding bit in the bitmap.
[0099] In some embodiments, the encoding module 506 is further configured to convert the version number of the target advanced feature of the file into corresponding binary data; if the binary data corresponding to the version number is greater than a numerical threshold, insert a continuation marker in the binary data corresponding to the version number at intervals from low to high bits according to the target length, and insert an end marker before the first bit of the binary data corresponding to the version number to obtain the second encoded data corresponding to the target advanced feature.
[0100] In some embodiments, the encoding module 506 is further configured to add an end marker before the first bit of the binary data corresponding to the version number when the binary data corresponding to the version number is less than or equal to a numerical threshold, so as to obtain the second encoded data corresponding to the target advanced feature.
[0101] In some embodiments, the encoding module 506 is further configured to add at least one end marker before the first bit of the binary data corresponding to the version number; wherein the length between adjacent markers in the second encoded data is the target length, and the marker is an end marker or a continuation marker.
[0102] In some embodiments, the encoding module 506 is further configured to use the first encoded data as the file handle of the file when the file does not have any advanced features, wherein the first encoding is a variable-length encoding.
[0103] Each module in the aforementioned file handle encoding device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.
[0104] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 6 As shown, the computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores the operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage medium. The database stores at least a portion of the data involved in the file handle encoding method. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a file handle encoding method.
[0105] In one exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 7 As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, Near Field Communication (NFC), or other technologies. When the computer program is executed by the processor, it implements a file handle encoding method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0106] Those skilled in the art will understand that Figure 6 and Figure 7The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0107] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.
[0108] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps in the above method embodiments.
[0109] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0110] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0111] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0112] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0113] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A file handle encoding method, characterized in that, The method includes: Determine the basic metadata corresponding to the file; Determine the version number of the target advanced features that the file has; The basic metadata is first encoded to obtain first encoded data, and the version number of the target advanced feature of the file is second encoded to obtain second encoded data corresponding to the target advanced feature, wherein the first encoding and / or the second encoding are variable length encodings; A file handle for the file is generated based on the first encoded data and the second encoded data corresponding to the target advanced features.
2. The method according to claim 1, characterized in that, The step of generating a file handle for the file based on the first encoded data and the second encoded data corresponding to the target high-level feature includes: A bitmap is generated based on the advanced features of the file. Each advanced feature corresponds to a different bit in the bitmap. The target advanced feature belongs to the advanced features. The bit in the bitmap corresponding to the advanced feature of the file takes a first preset value, and the other bits in the bitmap take a second preset value. Based on the first encoded data, the second encoded data corresponding to the target advanced feature, and the bitmap, a file handle for the file is generated.
3. The method according to claim 2, characterized in that, The file has at least two target high-level features. Generating a file handle for the file based on the first encoded data, the second encoded data corresponding to the target high-level features, and the bitmap includes: Based on the first encoded data, the second encoded data corresponding to the at least two target high-level features respectively, and the bitmap, a file handle for the file is generated; The second encoded data in the file handle is arranged in the bitmap according to the position of the corresponding bit of the target high-level feature.
4. The method according to any one of claims 1 to 3, characterized in that, The step of performing a second encoding on the version number of the target advanced feature of the file to obtain the second encoded data corresponding to the target advanced feature includes: Convert the version number of the target advanced features of the file into the corresponding binary data; If the binary data corresponding to the version number is greater than the numerical threshold, a continuation marker is inserted into the binary data corresponding to the version number in the order from low bit to high bit, with an interval of the target length, and an end marker is inserted before the first bit of the binary data corresponding to the version number, to obtain the second encoded data corresponding to the target advanced feature.
5. The method according to claim 4, characterized in that, The method further includes: If the binary data corresponding to the version number is less than or equal to the numerical threshold, an end marker is added before the first digit of the binary data corresponding to the version number to obtain the second encoded data corresponding to the target advanced feature.
6. The method according to claim 5, characterized in that, Adding an end marker before the first element of the binary data corresponding to the version number includes: Add at least one end marker before the first element of the binary data corresponding to the version number; In the second encoded data, the length between adjacent markers is the target length, and the marker is an end marker or a continuation marker.
7. The method according to any one of claims 1 to 3, characterized in that, The method further includes: If the file does not possess any advanced features, the first encoded data is used as the file handle of the file, wherein the first encoding is a variable-length encoding.
8. A file handle encoding device, characterized in that, The device includes: The data determination module is used to determine the basic metadata corresponding to the file; Version number determination module, used to determine the version number of the target advanced features of the file; An encoding module is used to perform a first encoding on the basic metadata to obtain first encoded data, and to perform a second encoding on the version number of the target advanced feature of the file to obtain second encoded data corresponding to the target advanced feature, wherein the first encoding and / or the second encoding are variable-length encodings. The handle generation module is used to generate a file handle for the file based on the first encoded data and the second encoded data corresponding to the target advanced features.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.
11. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.