CN106708822B - File storage method and device - Google Patents
File storage method and device Download PDFInfo
- Publication number
- CN106708822B CN106708822B CN201510428980.XA CN201510428980A CN106708822B CN 106708822 B CN106708822 B CN 106708822B CN 201510428980 A CN201510428980 A CN 201510428980A CN 106708822 B CN106708822 B CN 106708822B
- Authority
- CN
- China
- Prior art keywords
- file
- segment
- sequence
- relative
- storage
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Landscapes
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The embodiment of the invention relates to the technical field of communication, in particular to a file storage method and device. In the embodiment of the invention, because the relative path identified by the number is determined according to the acquired number, storing the file according to the relative path identified by the number, updating the number according to a preset rule, and one number corresponds to an M-ary sequence, and the M-ary sequence is divided into first to Nth sections, the M-ary value of the Nth section represents a file name, the first to Nth sections respectively correspond to N-1 level directories, the M-ary value of each section in the first to Nth sections respectively represents a directory name, thus, for each file to be stored, the number obtained to identify the storage path is different, the relative path identified by the number determined is also different, therefore, the process that whether the relative path is repeated needs to be judged in the process of generating the relative path for the file is avoided, and the efficiency of storing the file is improved.
Description
Technical Field
The embodiment of the invention relates to the field of communication, in particular to a file storage method and device.
Background
With the development of information technology, various kinds of information have been rapidly increased, and the single files as these information carriers have come to be in huge quantities, especially files with a not too large capacity. These small files, which are not too large in size, may be as small as a few KB, and large typically do not exceed 20 MB. Common small files, such as: microblog information, photos uploaded by the user, e-mails and the like.
The development bottleneck brought by the appearance of the mass of small files is the storage problem of the small files. In the prior art, when a large amount of small files are stored, sub-directories of the files are usually stored locally, and directory indexes of the files are stored in a database. The specific process is that after receiving a storage request of the small file sent by the client, the server generates a storage path for the small file, and stores the small file to the local disk according to the storage path.
In the above process, after the server generates a saving path for a file, the server needs to determine whether the saving path generated for the file overlaps with other saving paths already generated. Therefore, the efficiency of generating the saving path for the file in the prior art is low, so that the efficiency of storing the file in the prior art is low.
Disclosure of Invention
The embodiment of the invention provides a file storage method and device, which are used for improving the generation efficiency of a relative path of a file, so that the aim of rapidly storing the file is fulfilled.
The embodiment of the invention provides a file storage method, which comprises the following steps:
receiving a storage request, wherein the storage request carries a file to be stored;
acquiring a number for identifying a storage path;
determining a relative path identified by the number according to the acquired number; the method comprises the following steps that a number corresponds to an M system sequence, the M system sequence is divided into a first segment, a second segment and a third segment, the M system value of the Nth segment represents a file name, the first segment, the second segment and the third segment respectively correspond to N-1-level directories, and the M system value of each segment in the first segment, the second segment and the third segment respectively represents a directory name;
naming the file as the M system value of the Nth section in the M system sequence corresponding to the number, and storing the file according to the relative path identified by the number;
and updating the number according to a preset rule, wherein the preset rule specifically means that the number is increased or decreased.
Preferably, a number corresponds to an M-ary sequence having the same size as the value represented by the number, and the sequence length of each M-ary sequence is the same.
Preferably, the sequence length of each of the first to nth segments in each M-ary sequence is the same.
Preferably, before the receiving the storage request, the method further includes:
acquiring a number for identifying a storage path, and generating the number and L relative paths of which the continuous (L-1) numbers respectively correspond to the identification after the number;
the determining, according to the acquired number, the relative path identified by the number specifically includes:
and determining the relative path identified by the number from the generated L relative paths according to the acquired number.
Preferably, the determining, according to the acquired number, the relative path identified by the number specifically includes:
determining a relative path identified by the number under the initial directory according to the acquired number;
after the number is updated according to a preset rule, the method further comprises the following steps:
and if the acquired number reaches the threshold value, setting the acquired number as an initial value, and replacing the initial catalog.
An embodiment of the present invention provides a file storage apparatus, including:
the receiving unit is used for receiving a storage request, and the storage request carries a file to be stored;
an acquisition unit configured to acquire a number for identifying a storage path;
the processing unit is used for determining the relative path identified by the number according to the acquired number; the method comprises the following steps that a number corresponds to an M system sequence, the M system sequence is divided into a first segment, a second segment and a third segment, the M system value of the Nth segment represents a file name, the first segment, the second segment and the third segment respectively correspond to N-1-level directories, and the M system value of each segment in the first segment, the second segment and the third segment respectively represents a directory name; naming the file as the M system value of the Nth section in the M system sequence corresponding to the number, and storing the file according to the relative path identified by the number; and updating the number according to a preset rule, wherein the preset rule specifically means that the number is increased or decreased.
Preferably, a number corresponds to an M-ary sequence having the same size as the value represented by the number, and the sequence length of each M-ary sequence is the same.
Preferably, the sequence length of each of the first to nth segments in each M-ary sequence is the same.
Preferably, the obtaining unit is further configured to:
acquiring a number for identifying a storage path, and generating the number and L relative paths of which the continuous (L-1) numbers respectively correspond to the identification after the number;
the processing unit is specifically configured to:
and determining the relative path identified by the number from the generated L relative paths according to the acquired number.
Preferably, the processing unit is specifically configured to:
determining a relative path identified by the number under the initial directory according to the acquired number;
the processing unit is further configured to:
and if the acquired number reaches the threshold value, setting the acquired number as an initial value, and replacing the initial catalog.
In the embodiment of the invention, a storage request is received, wherein the storage request carries a file to be stored; acquiring a number for identifying a storage path; determining a relative path identified by the number according to the acquired number; the method comprises the following steps that a number corresponds to an M system sequence, the M system sequence is divided into a first segment, a second segment and a third segment, the M system value of the Nth segment represents a file name, the first segment, the second segment and the third segment respectively correspond to N-1-level directories, and the M system value of each segment in the first segment, the second segment and the third segment respectively represents a directory name; naming the file as the M system value of the Nth section in the M system sequence corresponding to the number, and storing the file according to the relative path identified by the number; and updating the number according to a preset rule, wherein the preset rule specifically means that the number is increased or decreased. Because the relative path identified by the number is determined according to the acquired number, the file is stored according to the relative path identified by the number, and then the number is updated according to a preset rule, namely, because the number is increased once every time a file is stored, the acquired number for identifying the storage path is different for each file to be stored, further because one number corresponds to an M-system sequence which is divided into a first segment to an N-th segment, the M-system value of the N-th segment represents the file name, the first segment to the N-1-th segment respectively correspond to N-1-level directories, the M-system value of each segment in the first segment to the N-1-th segment represents the directory name, the file to be stored is named as the M-system value of the N-th segment in the M-system sequence corresponding to the number, and therefore, for each file to be stored, the obtained numbers for identifying the storage paths are different, and the determined relative paths identified by the numbers are also different, so that the process that whether the relative paths are repeated or not needs to be judged in the process of generating the relative paths for the files is avoided, the efficiency of generating the relative paths for the files is improved, and the efficiency of storing the files is improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
FIG. 1 is a diagram of a system architecture suitable for use with an embodiment of the present invention;
fig. 2 is a schematic diagram of a file storage method according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of a file storage device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more clearly apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
As shown in fig. 1, a system architecture diagram applicable to the embodiment of the present invention is shown. The system architecture includes a server 101 and at least one client 102. The server 101 may be a cloud server and may be configured to generate relative paths of file storage for a plurality of clients 102. The files of the clients 102 may be stored locally at the clients, or may be stored in other servers, such as a storage server, a cloud server, and the like.
The embodiment of the invention is suitable for various files, in particular for small files which are usually a few KB and are large and usually not more than 20 MB. The embodiment of the invention is used for providing a file storage method and a file storage device, and the size of a file is not limited.
The embodiment of the present invention is configured to determine a relative path identified by an acquired number according to the acquired number, and specifically, determine an initial directory first, where the initial directory may be a root directory such as a C disc or a D disc, and may also be a root directory plus some folder directories, and for example, the initial directory may be a D: and/AA, representing the relative path in an embodiment of the present invention generated under the AA folder of the D-disc. For convenience of description, the starting directory is set as a D-disc in the embodiment of the present invention.
Based on the system architecture shown in fig. 1, fig. 2 shows a file storage method implemented by a server according to an embodiment of the present invention, which includes the following steps:
In one implementation, in step 202, the number used to identify the storage path may be an unsigned integer number or a signed integer number. Since the range of positive numbers that the unsigned integer number can store is twice as large as the range of positive numbers that the signed integer number can store, in order to increase the range of positive numbers represented by the number identifying the storage path, in the embodiment of the present invention, it is preferable to take the unsigned integer number as the number identifying the storage path. In step 205, the number for identifying the storage route is updated according to a predetermined rule, so that the relative routes are not overlapped, and the judgment is performed without the need for route generation. The preset rule can be to increment the number or decrement the number, and the increment of the number can be to increment the number by one at a time or to increment the number by K at a time, wherein K is an integer larger than one. Decrementing the number sets the number to a larger value at the initial setting, and then decrements the number by one at a time, or decrements the number by K at a time. For convenience of description, in the embodiments of the present invention, the following description uses an example that the number is updated according to a preset rule, that is, the number is increased by one at a time.
In step 203, the first to N-1 th segments in the M-ary sequence correspond to N-1 level directories, respectively, and the M-ary value of each of the first to N-1 th segments represents a directory name. Specifically, after determining the starting directory in the embodiment of the present invention, a relative path is determined under the starting directory, where the first to N-1 th segments in the M-ary sequence respectively correspond to the N-1 level directories in the relative path, that is, the relative path collectively includes N-1 level directories, and the first to N-1 th segments in the M-ary sequence respectively sequentially correspond to the first to N-1 level directories in the relative path.
In step 203, it is determined that the relative path identified by the number includes the file name of the file for storage, at this time, the real file name of the file is changed to the M-ary value of the nth segment in the M-ary sequence corresponding to the number, the file is stored according to the relative path, and the real file name of the file can be stored as the attribute information of the file. By modifying the file name of the file to be stored, the consistency of the generated relative path and the stored file is ensured, and the complexity of generating the relative path is further reduced.
In step 203, preferably, a number corresponds to an M-ary sequence having the same size as the value represented by the number. Specifically, a number for identifying the storage path is acquired, and the number is converted into an M-ary number sequence, so that the numerical value of the number is the same as the numerical value represented by the M-ary number sequence obtained by the number conversion. For example, the number is a decimal number, and the number correspondence is converted into a hexadecimal sequence. Here, M may also be in binary, decimal, octal, etc. form.
Preferably, the sequence length of each M-ary sequence is the same. Specifically, the sequence length of each M-ary sequence is the length of K digits, and when a certain digit is converted into a hexadecimal sequence, if the length of the hexadecimal sequence obtained by digital conversion is not longer than the length of the K digits, the length of the M-ary sequence corresponding to the digit can be made to be the length of the K digits by adding zero in front of the hexadecimal sequence obtained by digital conversion. For example, 2 is converted to hexadecimal sequence, and the length of the sequence is required to be eight digits long, and the sequence for converting 2 to hexadecimal is 00000002.
Since the M-ary sequence divided into the first to nth segments is used to represent the relative path, a drive letter is added between the segments of the M-ary sequence in order to convert the M-ary sequence into the format of the relative path. Preferably, the sequence length of each of the first to nth segments in each M-ary sequence is the same. For example, if 2 is converted into hexadecimal sequence and the sequence length is required to be eight digits long, then 00000002 is required to convert 2 into hexadecimal sequence, and the hexadecimal sequence is divided into four segments, where the sequence length of each segment is two digits long, then 00/00/00/02 is the relative path represented by the M-ary sequence. In the hexadecimal sequence divided into four segments, the first segment to the third segment are 00/00/00/respectively used for representing the directory names of the directories of the first level to the third level in the relative path, that is, the first segment to the third segment are 00/00/00/respectively used for representing the folder names of the first level to the third level in the relative path, the fourth segment 02 is used for identifying the file names, the relative path is 00/00/00/02 specifically means that the file is named 02, and then the file 02 is stored under the third level directory 00 folder under the second level directory 00 folder under the first level directory 00 folder under the initial directory.
In the embodiment of the present invention, a preferred implementation manner is to set the obtained number for identifying the storage path to a decimal number, where the number is an unsigned integer number, M is set to a hexadecimal number, and the sequence length of each of the first to nth segments in each M-ary sequence is two number lengths.
In step 203, determining the relative path identified by the number according to the acquired number may specifically include two preferred embodiments:
in the first mode, according to the acquired number, a relative path identified by the number is generated, and then the generated relative path is distributed to the file;
in the second mode, before receiving the storage request or at the time of system startup, a number for identifying the storage path is acquired, and the number and L relative paths respectively corresponding to the identification by consecutive (L-1) numbers after the number are generated. And then determining the relative path identified by the number from the generated L relative paths according to the acquired number.
In the second method, specifically, when the system of the server is started, the number for identifying the storage path may be first obtained, and then L relative paths may be generated according to the number, where L is 4096, for example. In the embodiment of the present invention, the value of L is not specifically limited, and L may be set by itself. When a file to be stored is received, a relative path identified by a number for identifying the storage path is determined for the file from L relative paths generated in advance, the relative path is assigned to the file, and then the number for identifying the storage path is incremented. And when the next file to be stored is received, continuously determining a relative path for the file from the L relative paths generated in advance, allocating the relative path to the file, and then increasing the number for identifying the storage path. Until the pre-generated L relative paths are used up, or the number of unallocated L relative paths is less than a value, P relative paths can be generated again when the system is idle or a storage request is received, wherein P can be equal to L or not equal to L, so that the relative path identified by the number can be acquired from the pre-generated P relative paths at a later stage.
In the second mode, because a plurality of relative paths are generated in advance, when the file to be stored is received, the speed of determining the relative paths for the file can be increased, and the file storage efficiency is improved.
Further, in order to increase the reading speed of the relative path generated in advance, the relative path generated in advance may be placed in a cache region, and after the server is powered off, the relative path generated in advance is automatically deleted, and when the server starts the system next time, it is necessary to regenerate a plurality of relative paths again according to the obtained numbers for identifying the storage path. In the embodiment of the invention, after a plurality of relative paths are generated in advance according to the acquired numbers for identifying the storage paths, the numbers are not updated according to the preset rules.
In a specific implementation, before step 201, a start directory needs to be preset for storing files in the embodiment of the present invention, and a relative path needs to be generated under the start directory, for example, the start directory may be determined to be a D disc, and the start directory may also be determined to be a folder AA in the D disc. In the embodiment of the invention, a directory which is before a corresponding path and can not be identified by numbers for identifying a storage path is defined as an initial directory, if the acquired numbers reach a threshold value, the acquired numbers are set as initial values, and the initial directory is replaced. Specifically, when the set initial value is zero, that is, when the acquired number reaches a threshold value, the acquired number is cleared, and the initial directory is replaced.
The above process is described in detail below using a specific example.
Setting the numeric range of the number for identifying the storage path to be 0 to 4294967296, correspondingly converting the number into a hexadecimal sequence, wherein the hexadecimal sequence ranges from 0 to FFFFFF, the sequence length of each M-ary sequence is set to be eight numeric lengths, and the sequence length of each segment from the first segment to the Nth segment in each M-ary sequence is two numeric lengths. When the number for identifying the storage path is 0, the hexadecimal corresponding to the number is 0, the hexadecimal sequence corresponding to the number with the length of eight numbers is 00000000, and the relative path identified by the number is 00\00\ 00; when the number used for identifying the storage path is 4294967296, the hexadecimal number corresponding to the number is FFFFFFFF, and the relative path identified by the number is FF \ FF \ FF.
A total of 4294967296 files may be stored under the starting directory of the relative path. If the number used to identify the memory path is 57778888, the number corresponds to 371A2C8, the number corresponds to eight digits long hexadecimal sequence 0371A2C8, and every second digit in the hexadecimal sequence is added with a drive letter to obtain the relative path 03/71/A2/C8 identified by the number. Thereafter, the received file to be stored is named C8, and is stored under folder a2 under folder 71 under folder 03 under the start directory. The number identifying the memory path is then incremented.
After the number is incremented, specifically, after the number is incremented by one, the number for identifying the storage path is updated to 57778889, and a file to be stored is received again, then by the method provided by the embodiment of the present invention, it is determined that the relative path identified by the number 57778889 for identifying the storage path at this time is 03/71/a2/C9, the file to be stored received this time is named C9, and the file is stored under the folder a2 under the folder 71 under the folder 03 under the starting directory.
There is a special case to be explained in this example, for example, when the number for identifying the storage path is 57778943, the number corresponds to 03/71/A2/FF, namely, the file to be stored received this time is named FF, and the file is stored under folder A2 under folder 71 under folder 03. When the first number is 57778944, the relative path corresponding to the first number is 03/71/A3/00, namely, the file corresponding to the relative path 03/71/A3/00 is named as 00, and the file is stored under the folder A3 under the folder 71 under the folder 03. It can be seen that when the number of files reaches 255, the system automatically generates a new third-level directory A3, and resumes storing files under A3.
As is apparent from the above example, according to the method provided in the embodiment of the present invention, the relative path identified by the obtained number is determined, and when the number of files stored in each directory reaches a set value, for example, 255 (FF in hexadecimal), a new directory is automatically generated, and it is not necessary to determine whether the number of files stored in each directory reaches the set value in the process.
Further, the threshold of the obtained number is set to 4294967297, if the obtained number for identifying the storage path is 4294967296, then the relative path identified by the number is FF/FF, after the file is stored according to the relative path identified by the number, the number is incremented, i.e. incremented by one, then the obtained number for identifying the storage path is 4294967297, at this time, the number reaches the threshold, the relative path identified by the number cannot be determined according to the number, at this time, the obtained number is set as the initial value, the start directory is replaced, and the file is stored again according to the method provided by the embodiment of the present invention under the replaced start directory.
From the above, it can be seen that: in the embodiment of the invention, a storage request is received, wherein the storage request carries a file to be stored; acquiring a number for identifying a storage path; determining a relative path identified by the number according to the acquired number; the method comprises the following steps that a number corresponds to an M system sequence, the M system sequence is divided into a first segment, a second segment and a third segment, the M system value of the Nth segment represents a file name, the first segment, the second segment and the third segment respectively correspond to N-1-level directories, and the M system value of each segment in the first segment, the second segment and the third segment respectively represents a directory name; naming the file as the M system value of the Nth section in the M system sequence corresponding to the number, and storing the file according to the relative path identified by the number; and updating the number according to a preset rule, wherein the preset rule specifically means that the number is increased or decreased. Because the relative path identified by the number is determined according to the acquired number, the file is stored according to the relative path identified by the number, and then the number is updated according to a preset rule, namely, because the number is increased once every time a file is stored, the acquired number for identifying the storage path is different for each file to be stored, further because one number corresponds to an M-system sequence which is divided into a first segment to an N-th segment, the M-system value of the N-th segment represents the file name, the first segment to the N-1-th segment respectively correspond to N-1-level directories, the M-system value of each segment in the first segment to the N-1-th segment represents the directory name, the file to be stored is named as the M-system value of the N-th segment in the M-system sequence corresponding to the number, and therefore, for each file to be stored, the obtained numbers for identifying the storage paths are different, and the determined relative paths identified by the numbers are also different, so that the process that whether the relative paths are repeated or not needs to be judged in the process of generating the relative paths for the files is avoided, the efficiency of generating the relative paths for the files is improved, and the efficiency of storing the files is improved.
Based on the same conception, the embodiment of the invention also provides a file storage device, which is used for executing the method flow and can be a server on the network side.
Fig. 3 is a schematic structural diagram of a file storage device according to an embodiment of the present invention.
As shown in fig. 3, the file storage apparatus includes a receiving unit 301, an obtaining unit 302, a processing unit 303:
a receiving unit 301, configured to receive a storage request, where the storage request carries a file to be stored;
an acquisition unit 302 for acquiring a number for identifying a storage path;
a processing unit 303, configured to determine, according to the obtained number, a relative path identified by the number; the method comprises the following steps that a number corresponds to an M system sequence, the M system sequence is divided into a first segment, a second segment and a third segment, the M system value of the Nth segment represents a file name, the first segment, the second segment and the third segment respectively correspond to N-1-level directories, and the M system value of each segment in the first segment, the second segment and the third segment respectively represents a directory name; naming the file as the M system value of the Nth section in the M system sequence corresponding to the number, and storing the file according to the relative path identified by the number; and updating the number according to a preset rule, wherein the preset rule specifically means that the number is increased or decreased.
Preferably, a number corresponds to an M-ary sequence having the same size as the value represented by the number, and the sequence length of each M-ary sequence is the same.
Preferably, the sequence length of each of the first to nth segments in each M-ary sequence is the same.
Preferably, the obtaining unit 302 is further configured to:
acquiring a number for identifying a storage path, and generating the number and L relative paths of which the continuous (L-1) numbers respectively correspond to the identification after the number;
the processing unit 303 is specifically configured to:
and determining the relative path identified by the number from the generated L relative paths according to the acquired number.
Preferably, the processing unit 303 is specifically configured to:
determining a relative path identified by the number under the initial directory according to the acquired number;
the processing unit is further configured to:
and if the acquired number reaches the threshold value, setting the acquired number as an initial value, and replacing the initial catalog.
From the above, it can be seen that: in the embodiment of the invention, a storage request is received, wherein the storage request carries a file to be stored; acquiring a number for identifying a storage path; determining a relative path identified by the number according to the acquired number; the method comprises the following steps that a number corresponds to an M system sequence, the M system sequence is divided into a first segment, a second segment and a third segment, the M system value of the Nth segment represents a file name, the first segment, the second segment and the third segment respectively correspond to N-1-level directories, and the M system value of each segment in the first segment, the second segment and the third segment respectively represents a directory name; naming the file as the M system value of the Nth section in the M system sequence corresponding to the number, and storing the file according to the relative path identified by the number; and updating the number according to a preset rule, wherein the preset rule specifically means that the number is increased or decreased. Because the relative path identified by the number is determined according to the acquired number, the file is stored according to the relative path identified by the number, and then the number is updated according to a preset rule, namely, because the number is increased once every time a file is stored, the acquired number for identifying the storage path is different for each file to be stored, further because one number corresponds to an M-system sequence which is divided into a first segment to an N-th segment, the M-system value of the N-th segment represents the file name, the first segment to the N-1-th segment respectively correspond to N-1-level directories, the M-system value of each segment in the first segment to the N-1-th segment represents the directory name, the file to be stored is named as the M-system value of the N-th segment in the M-system sequence corresponding to the number, and therefore, for each file to be stored, the obtained numbers for identifying the storage paths are different, and the determined relative paths identified by the numbers are also different, so that the process that whether the relative paths are repeated or not needs to be judged in the process of generating the relative paths for the files is avoided, the efficiency of generating the relative paths for the files is improved, and the efficiency of storing the files is improved.
It should be apparent to those skilled in the art that embodiments of the present invention may be provided as a method, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the invention.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.
Claims (10)
1. A file storage method, comprising:
receiving a storage request, wherein the storage request carries a file to be stored;
acquiring a number for identifying a storage path; the number is used for indicating the file sequence number of the file, and the file sequence number refers to the sequence of the file in the received file to be stored;
determining a relative path identified by the number according to the acquired number; wherein the M-ary sequence of file sequence numbers comprises a sequence of relative paths of the files and a sequence of file names of the files; the method comprises the following steps that a number corresponds to an M system sequence, the M system sequence is divided into a first segment, a second segment and a third segment, the M system value of the Nth segment represents a file name, the first segment, the second segment and the third segment respectively correspond to N-1-level directories, and the M system value of each segment in the first segment, the second segment and the third segment respectively represents a directory name;
naming the file as the M system value of the Nth segment in the M system sequence corresponding to the number according to the real file name, and storing the file according to the relative path identified by the number; the storage path of the file comprises a starting directory and the relative path;
and updating the number according to a preset rule, wherein the preset rule specifically means that the number is increased or decreased.
2. The method of claim 1, wherein a number corresponds to an M-ary sequence having the same size as the value represented by the number, and the sequence length of each M-ary sequence is the same.
3. The method of claim 2, wherein the sequence length of each of the first to nth segments in each M-ary sequence is the same.
4. The method of claim 1, wherein prior to receiving the storage request, further comprising:
acquiring a number for identifying a storage path, and generating the number and L relative paths of which the continuous (L-1) numbers respectively correspond to the identification after the number;
determining the relative path identified by the number according to the acquired number specifically includes:
and determining the relative path identified by the number from the generated L relative paths according to the acquired number.
5. The method according to any one of claims 1 to 4, wherein the determining, according to the obtained number, the relative path identified by the number specifically includes:
determining a relative path identified by the number under the initial directory according to the acquired number;
after the number is updated according to the preset rule, the method further comprises the following steps:
and if the acquired number reaches the threshold value, setting the acquired number as an initial value, and replacing the initial catalog.
6. A file storage device, comprising:
the device comprises a receiving unit, a storing unit and a processing unit, wherein the receiving unit is used for receiving a storage request which carries a file to be stored;
an acquisition unit configured to acquire a number for identifying a storage path; the number is used for indicating the file sequence number of the file, and the file sequence number refers to the sequence of the file in the received file to be stored;
the processing unit is used for determining the relative path identified by the number according to the acquired number; wherein the M-ary sequence of file sequence numbers comprises a sequence of relative paths of the files and a sequence of file names of the files; the method comprises the following steps that a number corresponds to an M system sequence, the M system sequence is divided into a first segment, a second segment and a third segment, the M system value of the Nth segment represents a file name, the first segment, the second segment and the third segment respectively correspond to N-1-level directories, and the M system value of each segment in the first segment, the second segment and the third segment respectively represents a directory name; naming the file as the M system value of the Nth segment in the M system sequence corresponding to the number according to the real file name, and storing the file according to the relative path identified by the number; the storage path of the file comprises a starting directory and the relative path; and updating the number according to a preset rule, wherein the preset rule specifically means that the number is increased or decreased.
7. The apparatus of claim 6, wherein a number corresponds to an M-ary sequence having the same size as the value represented by the number, and wherein the sequence length of each M-ary sequence is the same.
8. The apparatus of claim 7, wherein the sequence length of each of the first through nth segments in each M-ary sequence is the same.
9. The apparatus of claim 6, wherein the obtaining unit is further configured to:
acquiring a number for identifying a storage path, and generating the number and L relative paths of which the continuous (L-1) numbers respectively correspond to the identification after the number;
the processing unit is specifically configured to:
and determining the relative path identified by the number from the generated L relative paths according to the acquired number.
10. The apparatus according to any one of claims 6 to 9, wherein the processing unit is specifically configured to:
determining a relative path identified by the number under the initial directory according to the acquired number;
the processing unit is further configured to:
and if the acquired number reaches the threshold value, setting the acquired number as an initial value, and replacing the initial catalog.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510428980.XA CN106708822B (en) | 2015-07-20 | 2015-07-20 | File storage method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510428980.XA CN106708822B (en) | 2015-07-20 | 2015-07-20 | File storage method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106708822A CN106708822A (en) | 2017-05-24 |
CN106708822B true CN106708822B (en) | 2020-04-28 |
Family
ID=58894533
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510428980.XA Active CN106708822B (en) | 2015-07-20 | 2015-07-20 | File storage method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106708822B (en) |
Families Citing this family (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110659154A (en) * | 2018-06-28 | 2020-01-07 | 北京京东尚科信息技术有限公司 | Data processing method and device |
CN110750502A (en) * | 2018-07-23 | 2020-02-04 | 北京奇虎科技有限公司 | Component processing method and device |
CN109471838B (en) * | 2018-10-19 | 2020-05-22 | 北京字节跳动网络技术有限公司 | Directory document operation method and device, electronic equipment and readable storage medium |
CN109491967A (en) * | 2018-11-02 | 2019-03-19 | 科大国创软件股份有限公司 | A kind of distributed file management method and system based on UUID |
CN109740302B (en) * | 2019-04-02 | 2020-01-10 | 深兰人工智能芯片研究院(江苏)有限公司 | Simulation method and device of neural network |
CN111666257B (en) * | 2020-06-03 | 2024-03-19 | 中国建设银行股份有限公司 | Method, device, equipment and storage medium for file fragment storage |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5742817A (en) * | 1995-12-08 | 1998-04-21 | Emc Corporation | Method and apparatus for file server addressing |
CN1574043A (en) * | 2003-05-22 | 2005-02-02 | 佳能株式会社 | Recording apparatus |
CN101051320A (en) * | 2007-05-11 | 2007-10-10 | 北京中星微电子有限公司 | File name generating method and device in file distribution system |
CN102521309A (en) * | 2011-11-24 | 2012-06-27 | 中国船舶重工集团公司第七○九研究所 | Storage organization and search method of digital video videotaping files |
CN103353892A (en) * | 2013-07-05 | 2013-10-16 | 北京东方网信科技股份有限公司 | Method and system for data cleaning suitable for mass storage |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080065698A1 (en) * | 2006-08-25 | 2008-03-13 | Steven Michael French | Method and apparatus for emulating alternate data streams across heterogeneous file systems |
-
2015
- 2015-07-20 CN CN201510428980.XA patent/CN106708822B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5742817A (en) * | 1995-12-08 | 1998-04-21 | Emc Corporation | Method and apparatus for file server addressing |
CN1574043A (en) * | 2003-05-22 | 2005-02-02 | 佳能株式会社 | Recording apparatus |
CN101051320A (en) * | 2007-05-11 | 2007-10-10 | 北京中星微电子有限公司 | File name generating method and device in file distribution system |
CN102521309A (en) * | 2011-11-24 | 2012-06-27 | 中国船舶重工集团公司第七○九研究所 | Storage organization and search method of digital video videotaping files |
CN103353892A (en) * | 2013-07-05 | 2013-10-16 | 北京东方网信科技股份有限公司 | Method and system for data cleaning suitable for mass storage |
Also Published As
Publication number | Publication date |
---|---|
CN106708822A (en) | 2017-05-24 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106708822B (en) | File storage method and device | |
CN111008185B (en) | Data sharing method, system and equipment | |
CN111078653B (en) | Data storage method, system and equipment | |
EP2721504B1 (en) | File processing method, system and server-clustered system for cloud storage | |
EP3754515A1 (en) | Reshard method and system in distributed storage system | |
CN106407207B (en) | Real-time newly-added data updating method and device | |
CN104090806B (en) | The processing method and processing device of AKU, upgrade request | |
CN108874803B (en) | Data storage method, device and storage medium | |
CN111090618B (en) | Data reading method, system and equipment | |
JP2021500649A (en) | Computer implementation methods, computer program products, and systems for storing records in shard database shard tables, computer implementation methods, computer program products, and systems for retrieving records from shard database shard tables. System, as well as a system for storing shard databases | |
CN111723073B (en) | Data storage processing method, device, processing system and storage medium | |
CN111447248A (en) | File transmission method and device | |
CN113468199B (en) | Index updating method and system | |
CN109756533B (en) | Mirror image acceleration method and device and server | |
CN116578746A (en) | Object de-duplication method and device | |
CN112182328A (en) | Method and device for expanding search engine, electronic equipment and storage medium | |
CN111950025A (en) | File distributed storage method based on block chain intelligent contract | |
CN111913925A (en) | Data processing method and system in distributed storage system | |
CN112035413B (en) | Metadata information query method, device and storage medium | |
CN113687852A (en) | Automatic generation method and device for log collection configuration file | |
CN113590703A (en) | ES data importing method and device, electronic equipment and readable storage medium | |
CN117348804A (en) | Hierarchical storage method, hierarchical storage system and hierarchical storage medium for digital networking supervision system | |
TWI420333B (en) | A distributed de-duplication system and the method therefore | |
CN108717438B (en) | Chained data state acquisition system and method | |
CN115129789A (en) | Bucket index storage method, device and medium of distributed object storage system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |