Summary of the invention
The object of the present invention is to provide file storage method and file modification method, to solve the above problems.
Provide file storage method in an embodiment of the present invention, comprising:
Obtain data to be stored and treat multiplex data with at least one;
Use and treat that the first mapped identification of multiplex data substitutes data identical with treating multiplex data in data to be stored, to generate alternate data, the first mapped identification is used for transferring treats multiplex data;
Alternate data is stored into default storage location.
Preferably, also comprise:
The storage data obtained in advance is carried out segmentation, multiplely treats multiplex data to be formed;
Treat that multiplex data carries out label to each respectively, to determine the first mapped identification.
Preferably, also comprise: obtain and multiplely treat multiplexing subdata and for transferring the second mapped identification treating multiplexing subdata, second mapped identification is used for transferring one and treats multiplexing subdata;
Multiple second mapped identification combined, to generate the first mapped identification according to putting in order of obtaining in advance;
Treat that multiplexing subdata combines according to putting in order of obtaining in advance by multiple, treat multiplex data to generate.
Preferably, also comprise: according to the size of the data to be stored obtained in advance, and/or type, determine to treat multiplex data, and/or treat the size of multiplexing subdata.
Preferably, also comprise: in the storage data obtained in advance, search the master data section expressing predetermined implication;
Using the storage address of master data section as the first mapped identification, or using the storage address of master data section as the second mapped identification.
Preferably, in the storage data obtained in advance, search the master data section expressing predetermined implication to comprise: determine that between two corresponding newlines, recorded data is master data section;
Other newlines are not had between two corresponding newlines;
Master data section expresses the base unit of specifying implication.
Preferably, also comprise: search in data to be stored and whether there are the data identical with treating multiplex data arbitrarily;
If so, then use and treat that the first mapped identification of multiplex data substitutes data identical with treating multiplex data in data to be stored.
The embodiment of the present invention additionally provides file modification method, based on file storage method, also comprises:
That specifies according to the storage address search of the data to be modified obtained in advance treats multiplex data;
Treat multiplex data according to amending method to modify, revise multiplex data to generate;
Appointment storage location is stored into, to determine the storage address of revising multiplex data by revising multiplex data;
By the storage address of revising multiplex data be used for transferring the first mapped identification having revised multiplex data and associate.
Preferably, if the first mapped identification is used for transferring treat that multiplex data is in multiple file to be stored, and exists and treat that multiplex data does not need amendment at least one file to be stored,
Then modify treating multiplex data according to amending method, with generate revise multiplex data before also comprise:
To be modified is treated that multiplex data backups to backup storage location;
Use and treat that the 3rd mapped identification of multiplex data substitutes data identical with treating multiplex data in data to be stored, to generate alternate data, the 3rd mapped identification for transferring to back up storage location treats multiplex data.
Preferably, treat in multiplex data to multiple file to be stored if the first mapped identification is used for transferring, and need to use multiple alter mode to treat multiplex data and modify, then according to the storage address search of the data to be modified obtained in advance specify treat multiplex data before also comprise:
To be modified is treated that multiplex data repeatedly backs up, to generate many parts of multiplex datas to be modified;
Treat multiplex data according to amending method to modify, revise multiplex data comprise to generate:
According to different amending methods, each multiplex data to be modified is modified respectively, multiplely revise multiplex data to generate.
The file storage method that the embodiment of the present invention provides, with of the prior art when needs storage data, data in each file are all separate, cause identical data to be repeated to store, waste system resource is compared, by using, it treats that the first mapped identification of multiplex data instead of in data to be stored, the data division identical with treating multiplex data, thus when making storage, no longer need to store the part identical with treating multiplex data, but store the first mapped identification, storage area occupied by the first mapped identification is much smaller than treating multiplex data, thus, after alternate data is stored into default storage location, save storage area, solve deficiency of the prior art.
Embodiment
Also by reference to the accompanying drawings the present invention is described in further detail below by specific embodiment.
The embodiment of the present invention 1 provides file storage method, as shown in Figure 1, comprises the steps:
S101, obtains data to be stored and at least one treats multiplex data;
S102, use and treat that the first mapped identification of multiplex data substitutes data identical with treating multiplex data in data to be stored, to generate alternate data, the first mapped identification is used for transferring treats multiplex data;
S103, is stored into default storage location by alternate data.
In step S101, treat that multiplex data can refer to the data existed in stocking system.Because most data are all have certain relevance.The a certain section of article such as write, a certain section of code write, a certain section of video, or audio frequency etc.File in the file stored in computer, or code in file more or less all can with other file, or code has coincidence to a certain extent.But, in traditional stocking system, as shown in Figure 2, some files can only be stored in below a file, or certain one piece of data can only be stored in some appointed areas, namely each storage location separates, as file1, file2 and file3 in figure.When certain file, or certain data needs to appear at different files simultaneously, or in file, is then all the modes copied, and by file, or data copy to the storage location of specifying again.This can take to cause to a great extent unnecessary in system storage area.Thus, the mode " can treating multiplex data " by reference, reduces the storage capacity of data.Treat that multiplex data can be stored in computing machine on assigned address, be used for specially store data, also can be in alternative document, a certain section of code intercepted, as treating multiplex data.In S101, what obtain treats that multiplex data can be multiple, also can be one, in time treating that multiplex data is multiple, also just indicate file to be stored and can have more selection, may can use the more data that multiplex data substitutes reality for the treatment of, taking system storage area can be reduced further like this.
In step S102, the first mapped identification with treat that multiplex data is corresponding.If treat that multiplex data is multiple, so the first mapped identification also should be multiple, treats that multiplex data and the first mapped identification are man-to-man relations.First mapped identification is used for transferring treats multiplex data, refers to when reading data to be stored, directly reads corresponding with it treat multiplex data by reading the first mapped identification.Read the mode of data comparatively generally by the relation of mapped identification and maps data items, at this, repeat no more.Usually, the first mapped identification can be the storage address for the treatment of multiplex data, treats two marks (data corresponding to newline centre are as treating multiplex data) in multiplex data.The storage area occupied by the first mapped identification can be seen thus, normally complete much smaller than one end data.As the first mapped identification only has a few K, treat that multiplex data is generally a few M, a few G, even more.Can seeing thus, treating that multiplex data greatly can reduce the unnecessary of system storage area and take by using the first mapped identification to substitute.As shown in Figure 3, position overlapped in file only can be stored once, alternative document quotes the file of this part overlap by the mode of index, embody in Fig. 4 be a file by another file situation about comprising
In step S103, need the data to be stored using the first mapped identification to carry out substituting to store.Due to through substituting, so the system storage area occupied can reduce greatly.
Further, file storage method provided by the present invention also comprises:
The storage data obtained in advance is carried out segmentation, multiplely treats multiplex data to be formed;
Treat that multiplex data carries out label to each respectively, to determine the first mapped identification.
Namely treat that multiplex data can be produce from the data stored.As in some audio files of making, be through that several existing song carries out synthesizing.So in this audio file, run into the position of existing song, the first mapped identification of existing song just can be used to carry out the actual coding of this song alternative, thus decrease the storage area of the system taken.Certainly, after carrying out segmentation to data, need to drop into line label to each data segment separated, label can be that address etc. has the mark carrying out with other labels distinguishing.Namely unique corresponding one of each label treats multiplex data.
Further, file storage method provided by the present invention also comprises: obtain and multiplely treat multiplexing subdata and for transferring the second mapped identification treating multiplexing subdata, second mapped identification is used for transferring one and treats multiplexing subdata;
Multiple second mapped identification combined, to generate the first mapped identification according to putting in order of obtaining in advance;
Treat that multiplexing subdata combines according to putting in order of obtaining in advance by multiple, treat multiplex data to generate.
As shown in Figure 5 and Figure 6, R1-R7 is for treating multiplex data, S1-S7, for treating multiplexing subdata, treats by using the second mapped identification to quote, multiplex data treats that the mode of multiplexing subdata forms the store files of self, and defines the second mapped identification and the corresponding relation treating multiplexing subdata.In time reading the second mapped identification, just can by the second mapped identification to treat that the relation of multiplexing subdata is transferred and corresponding treat multiplexing subdata, and to show, or operate accordingly.Certainly, use the mode treating multiplexing subdata, also can be understood as multistage multiplexing mode.Treat that multiplexing subdata also can be added and treat multiplexing sub-subdata, namely treated that multiplexing sub-subdata forms treated multiplexing subdata by multiple, this multistage multiplexing mode is similar, repeats no more.
Further, file storage method provided by the present invention also comprises: according to the size of the data to be stored obtained in advance, and/or type, determines to treat multiplex data, and/or treats the size of multiplexing subdata.
From the angle of programming, the code of the lowermost layer of different file is bound to find identical paragraph, as being all binary code be made up of 0 and 1.If but treat multiplex data or treat that the size of multiplexing subdata is if so little unit (only having 1 byte length), so when being supplied to alternative document and calling, season can be caused to call frequently, and this can reduce the travelling speed of system greatly.Same, if treat multiplex data, or treat that multiplexing subdata is excessive, then be difficult to find and treat multiplex data, or treat the data paragraph that multiplexing subdata is identical, therefore, need to look for an one suitable scope to limit and treat multiplex data, or treat the size of multiplexing subdata.Specifically, can determine according to the size of data to be stored, if data to be stored are larger, so treat multiplex data, or treat that multiplexing subdata can be larger accordingly, if data to be stored repeat more data, then also relative increase can treat multiplex data, or treat the size of multiplexing subdata.
Further, file storage method provided by the present invention, also comprises: in the storage data obtained in advance, search the master data section expressing predetermined implication;
Using the storage address of master data section as the first mapped identification, or using the storage address of master data section as the second mapped identification.
In order to ensure to treat multiplex data, or treat that the code content in multiplexing subdata is significant, also just need master data section to be have certain implication, like this, passing through the first mapped identification, or the second mapped identification joins in file to be stored more targeted.Wherein have certain implication to refer to, master data section can express concrete implication, corresponding to master data section be " I " " " etc. word, or the brightness of a pixel in certain image etc.Contrary, if master data section can not express concrete implication, so, even if be multiplexed in concrete file, also need, by again adding character, to make it have certain implication.
Certainly, the problem of Data duplication is considered.Can there is no concrete meaning by a certain section, but the higher data of repetition rate being as master data section, in other words as treating multiplex data, or treating multiplexing subdata.If an end data is 1234567890, other end data bit 1234567899, also has one piece of data position 1234567898, so can identify 123456789, be designated Z, so three segment datas become Z0 respectively, Z9 and Z8, although 123456789 are beyond expression actual implication, the storage area that greatly can be reduced system by such process is taken.
Equally, the position of specifying can be identified in the data and be used as, certain paragraph whether significant mark of tool.
In the storage data obtained in advance, search the master data section expressing predetermined implication comprise: determine that between two corresponding newlines, recorded data is master data section;
Other newlines are not had between two corresponding newlines;
Master data section expresses the base unit of specifying implication.
Usually, in coding, be to express the significant code of certain tool between two corresponding newlines.Certainly, also can be the correspondence of two direct neighbors newline between code, specific as follows:
Code between second and the 3rd braces also has concrete meaning, can by the code between these two brackets, as master data section.
File storage method provided by the present invention can also comprise: search in data to be stored and whether there are the data identical with treating multiplex data arbitrarily;
If so, then use and treat that the first mapped identification of multiplex data substitutes data identical with treating multiplex data in data to be stored.
Namely after determining and treating multiplex data, repeatedly use and treat that multiplex data is retrieved in file to be stored, to determine eachly to treat whether multiplex data exists with file to be stored.
The file storage method that the embodiment of the present invention provides, treat that the first mapped identification of multiplex data instead of in data to be stored by using, the data division identical with treating multiplex data, thus when making storage, no longer need to store the part identical with treating multiplex data, but store the first mapped identification, storage area occupied by the first mapped identification is much smaller than treating multiplex data, and treat that multiplexing subdata strengthens the degree (multistage multiplexing) of data-reusing by employing, the content treating multiplex data can be adjusted more flexibly, thus, after alternate data is stored into default storage location, save storage area, solve deficiency of the prior art.
The embodiment of the present invention 2 provides file modification method, based on the file storage method of embodiment 1, as shown in Figure 7, also comprises the steps:
S201, that specifies according to the storage address search of the data to be modified obtained in advance treats multiplex data;
S202, treats multiplex data according to amending method and modifies, and revises multiplex data to generate;
S203, is stored into appointment storage location by revising multiplex data, to determine the storage address of revising multiplex data;
S204, by the storage address of revising multiplex data be used for transferring the first mapped identification having revised multiplex data and associate.
Determine need amendment after multiplex data, can modify to it according to the mode preset, amendment is concrete as increased, and replaces and deletion etc.The size treating multiplex data may be changed after amendment, if changed, so treat that the storage location of multiplex data just there occurs change.Namely need the mapping relations of change first mapped identification and storage location.
On the other hand, if the first mapped identification is used for transferring treat that multiplex data is in multiple file to be stored, and exists and treat that multiplex data does not need amendment at least one file to be stored,
Then modify treating multiplex data according to amending method, with generate revise multiplex data before also comprise:
To be modified is treated that multiplex data backups to backup storage location;
Use and treat that the 3rd mapped identification of multiplex data substitutes data identical with treating multiplex data in data to be stored, to generate alternate data, the 3rd mapped identification for transferring to back up storage location treats multiplex data.
This situation is there is when using, namely some is quoted and treats that the file of multiplex data needs to treat multiplex data adjustment, some quotes the file treating multiplex data does not need to treat multiplex data adjustment, so, before adjusting, need to treat that multiplex data backs up to what be about to modify, and by need with adjustment after treat that multiplex data carries out recording corresponding mapped identification in the file associated, needing treat that multiplex data carries out recording corresponding mapped identification in the file associated to unadjusted.Namely generate the 3rd mapped identification, for identifying the storage location treating that multiplex data is not revised.
Treat in multiplex data to multiple file to be stored if the first mapped identification is used for transferring, and need to use multiple alter mode to treat multiplex data and modify, then according to the storage address search of the data to be modified obtained in advance specify treat multiplex data before also comprise:
To be modified is treated that multiplex data repeatedly backs up, to generate many parts of multiplex datas to be modified.
Treat multiplex data according to amending method to modify, revise multiplex data comprise to generate:
According to different amending methods, each multiplex data to be modified is modified respectively, multiplely revise multiplex data to generate.
Because different files needs to treat that multiplex data is modified as different appearance, therefore, amendment how many versions are needed also just to back up how many times respectively, and then require to treat that multiplex data is modified to each backup for different amendments, and carry out with corresponding file after modification associating (being associated by the first mapped identification).
Traditional file storing mode, according to concrete needs, under needing that identical file is stored in different catalogues, file.So when modifying, then need to modify to each file respectively, when needing the file content of amendment very huge, as document misregistration replacement etc., then need to adjust accordingly each file data stored respectively, namely need repetition X time, X refers to the quantity repeating to store of file.Simultaneously, due to the deleted and insertion that file repeats, the quantity of data fragment is caused to get more and more, when system needs to read these files time, need to call son file (part for partial data) from different positions, greatly can reduce the travelling speed of system like this.And the amending method of system provided by the present invention, due to disposable can modify to all files be associated (treating that multiplex data revises all data associated therewith by amendment), and there will not be omission.For large data age, more pointed, the data volume of amendment is huger, and the effect of method provided by the present invention is more obvious.
The foregoing is only the preferred embodiments of the present invention, be not limited to the present invention, for a person skilled in the art, the present invention can have various modifications and variations.Within the spirit and principles in the present invention all, any amendment done, equivalent replacement, improvement etc., all should be included within protection scope of the present invention.