WO2015027902A1 - Method, computing device, and computer program product for storing file index - Google Patents

Method, computing device, and computer program product for storing file index Download PDF

Info

Publication number
WO2015027902A1
WO2015027902A1 PCT/CN2014/085219 CN2014085219W WO2015027902A1 WO 2015027902 A1 WO2015027902 A1 WO 2015027902A1 CN 2014085219 W CN2014085219 W CN 2014085219W WO 2015027902 A1 WO2015027902 A1 WO 2015027902A1
Authority
WO
WIPO (PCT)
Prior art keywords
index
record
storing
data block
file
Prior art date
Application number
PCT/CN2014/085219
Other languages
French (fr)
Inventor
Jibing LOU
Bo Li
Wei Huang
Chujia HUANG
Original Assignee
Tencent Technology (Shenzhen) Company Limited
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Tencent Technology (Shenzhen) Company Limited filed Critical Tencent Technology (Shenzhen) Company Limited
Publication of WO2015027902A1 publication Critical patent/WO2015027902A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/13File access structures, e.g. distributed indices
    • G06F16/134Distributed indices

Definitions

  • Particular embodiments of the described technology relate to the field of data storage technologies, and in particular, to a method, computing device, and computer program product for storing a file index.
  • the file concept provided by a distributed file system is usually a combination of multiple data blocks.
  • a file index of a file comprises indexes of these data blocks. Data in a corresponding data block of the file may be read according to the file index. Therefore, data reading and writing of a file requires the consistency between the file index and the actual data to be maintained.
  • an output device and a transmission pipeline, etc. no longer become a bottleneck of an application such as super clear video on demand, large file transmission, or the like.
  • data blocks involved in a large file are many, so that the file index expands dramatically. Therefore, how to effectively store a file index and promote the access performance of the file index has become an issue needed to be considered emphatically for an application design of a large file class.
  • a computing device for storing a file index comprises at least a processor operating in conjunction with a memory and a plurality of modules, the modules comprising: a first judgment module for, when a to-be-stored data block index of a file is received, judging whether the index master record corresponding to the file is associated with an extension record; a first storage module for, when it is judged that the index master record is not associated with an extension record, creating several extension records associated with the index master record, if the length of the data segment of the index master record is equal to or greater than a preset threshold; wherein the first storage module is further used for storing a stored data block index in the data segment and the to-be-stored data block index in a corresponding extension record.
  • a computer program product for storing a file index comprises a non-transitory computer readable medium having computer readable program codes embodied therein that, when executed by a processor, causes the processor to: judge whether an index master record corresponding to a file is associated with an extension record when a to-be-stored data block index of the file is received; when it is judged that the index master record is not associated with an extension record, create several extension records associated with the index master record, if the length of the data segment of the index master record is equal to or greater than a preset threshold; and store a stored data block index in the data segment and the to-be-stored data block index in a corresponding extension record.
  • the method, computing device, and computer program product for storing a file index if the length of the data segment for storing data block indexes in the index master record of a file is equal to or greater than a preset threshold, all the data block indexes in the data segment are split into several extension records associated with the index master record for storage, thereby the storage efficiency of the file index may be increased, and the access performance of the file index may be promoted.
  • Fig. 2 is a flow chart of a method for storing a file index provided by a first embodiment of the present disclosure.
  • Fig. 3 is a flow chart of a method for writing data corresponding to a file.
  • Fig. 5 is a flow chart of a method for creating an extension record associated with the index master record.
  • Fig. 7 is a flow chart of a method for storing a file index provided by a second embodiment of the present disclosure.
  • Fig. 8 is a schematic diagram of storing a data block index corresponding to a file void in the data segment.
  • Fig. 9 is a schematic diagram of storing a data block index corresponding to a file void in an extension record.
  • Fig. 10 is a flow chart of a method for storing a file index provided by a third embodiment of the present disclosure.
  • Fig. 11 is a block diagram of modules in a computing device for storing a file index provided by a fourth embodiment of the present disclosure.
  • Fig. 13 is a block diagram of modules in a computing device for storing a file index provided by a sixth embodiment of the present disclosure.
  • Fig. 1 is simply schematic, and it does not define the structure of the terminal 1.
  • the terminal 1 may further comprise more or less components than what is shown in Fig. 1, or have a configuration different from that as shown in Fig. 1.
  • the individual components as shown in Fig. 1 may be implemented by employing hardware, software or a combination thereof.
  • the memory 11 may be used for storing a software program and a module, e.g., program instructions/modules corresponding to a method for storing a file index in an embodiment, and the processor 12 implements the method for storing a file index by running a software program and a module stored in the memory 11 and thereby performing various functional applications and data processing.
  • a module e.g., program instructions/modules corresponding to a method for storing a file index in an embodiment
  • the processor 12 implements the method for storing a file index by running a software program and a module stored in the memory 11 and thereby performing various functional applications and data processing.
  • the peripheral interface 14 couples various input/output apparatus to the processor 12 and the memory 11.
  • the processor 12 runs various software and instructions in the memory 11 to perform various functions of the terminal 1 and data processing.
  • the communication module 15 is used for communicating with a communication network or other device.
  • the communication module 15 may be for example a network card 151 or an RF (Radio Frequency) module 152.
  • the network card 151 As an interface connecting a computer and a transmission medium in a local area network, the network card 151 is used for implementing a physical connection and electrical signal matching with transmission media in a local area network, thereby establishing the local area network and connecting to the Internet, and communicating with various networks such as a local area network, a metropolitan area network, a wide area network.
  • the network card 151 may comprise various existing circuit elements for performing the above-described functions, e.g. , a processor and a memory (including a ROM and a RAM) , etc.
  • the RF module 152 is used for receiving and sending electromagnetic waves, carrying out a transformation between the electromagnetic waves and an electric signal, and thereby communicating with a communication network or other device.
  • the RF module 152 may comprise various existing circuit elements for performing these functions, e.g. , an antenna, a radio frequency transceiver, a digital signal processor, an encryption/decryption chip, a subscriber identity module (SIM) card, a memory, etc.
  • SIM subscriber identity module
  • the RF module 152 may communicate with various networks, e.g. , an internet, an intranet, a wireless network, or communicate with other device via a wireless network.
  • the above mentioned wireless network may comprise a cellular telephone network, a wireless local area network or a metropolitan area network.
  • the above mentioned wireless network may adopt various communication standards, protocols and technologies, comprising but not limited to, Global System for Mobile Communication, Enhanced Data GSM Environment (EDGE) , wideband code division multiple access (W-CDMA) , code division multiple access (CDMA) , time division multiple access (TDMA) , Wireless Fidelity (WiFi) (e.g. , American Institute of Electrical and Electronics Engineers standards IEEE 802.11a, IEEE 802.11b, IEEE 802.11g and/or IEEE 802.11n) , voice over internet protocol (VolP) , Worldwide Interoperability for Microwave Access (Wi-Max) , other protocols for mails, instant messaging and SMS, as well as any other suitable communication protocols, which may even comprise those protocols currently not yet developed.
  • EDGE Enhanced Data GSM Environment
  • W-CDMA wideband code division multiple access
  • CDMA code division multiple access
  • TDMA time division multiple access
  • WiFi Wireless Fidelity
  • Wi-Max Worldwide Interoperability for Microwave Access
  • the touch control surface 162 may comprise two parts, a touch detecting apparatus and a touch controller.
  • the touch detecting apparatus detects the touch orientation of a user, detects a signal brought about by the touch operation, and transmits the signal to the touch controller; the touch controller receives touch information from the touch detecting apparatus. Converts it to contact coordinates and then sends them to the processor 12, and is capable of receiving a command sent by the processor 12 and executing the same.
  • the touch control surface 162 may be implemented employing many types such as resistance, capacitance, infrared and surface acoustic wave, etc.
  • the input unit 16 may further comprise other input devices.
  • the other input devices comprise, but are not limited to, one or more of a physical keyboard, a track ball, a mouse, a joystick, etc.
  • the display unit 17 is used for displaying information input by a user, information provided to the user, and various graphical interfaces of the terminal 1. These graphical user interfaces may be composed of graphics, text, icons, video and any combination thereof.
  • the display unit 17 comprises a display panel 171.
  • the display panel 171 may be for example a liquid crystal display (LCD) , an organic light-emitting diode (OLED) display panel, an electro-phoretic display (EPD) , etc.
  • the touch control surface 162 may be arranged on the display panel 171, and thereby form an integral with the display panel 171.
  • step S3 creating several extension records associated with the index master record, and storing a stored data block index in the data segment and the to-be-stored data block index in a corresponding extension record;
  • step S4 storing the to-be-stored data block index in the data segment of the index master record
  • the process of writing data corresponding to the file to the memory 11 may be implemented by an existing data storage engine, e.g. , the NoSQL (a non-relational database) storage engine through the following steps:
  • step c writing the to-be-written data of the file into the allocated data blocks sequentially, wherein if the sum of the specified data length of the allocated data blocks is greater than the length of to-be-written data of the file, then there may be several ones in the allocated data blocks that are not filled up with the to-be-written data of the file;
  • step S1 each time the data storage engine returns a data block index and the identification information of the file, step S1 is performed.
  • the data block index returned by the data storage engine is exactly the to-be-stored data block index information.
  • the to-be-stored data block index corresponds to data at the end of the file. Therefore, after receiving the identification information of the file and the data block index, step S1 may find the index master record corresponding to the file in the index storage unit according to the identification information of the file.
  • the index master record comprises a head and a data segment.
  • the head has a fixed length, whereas the data segment has a variable length.
  • the head comprises file meta information, a structural flag and length information of the data segment.
  • the file meta information comprises for example the identification information of the file, the creation time and modification time of the file, the total length of the file, and the specified data length of a corresponding data block, etc.
  • the structural flag indicates whether the index master record is associated with an extension record.
  • the length information of the data segment indicates the length of the data segment of the index master record.
  • step S1 may first read the structural flag from the head of the index master record, and then judge whether the index master record is associated with an extension record according to the structural flag. If the index master record is associated with an extension record, the ID of the associated extension record, e.g. , UUID (Universally Unique Identifier) , is recorded in the data segment of the index master record. The ID of the extension record has uniqueness.
  • UUID Universally Unique Identifier
  • step S2 if the index master record is not associated with an extension record, then the data segment of the index master record is used for storing a data block index of the file in the form of an array, as shown in Fig. 4.
  • the data blocks constituting the file become more and more, and also the data block indexes of the file are more and more, which causes the data segment of the index master record to be longer and longer.
  • Such a situation will give rise to a trend in which the time required for pulling a data block index from the data segment grows linearly, and thus the data segment being too long will directly affect the access efficiency of a data block index.
  • step S2 needs to further judge whether the length of the data segment of the index master record is equal to or greater than a preset threshold.
  • step S2 may read the length information of the data segment from the head of the index master record, and judge whether the length of the data segment is equal to or greater than a preset threshold according to the length information of the data segment.
  • the preset threshold may be an integer multiple of the fixed length of the data block index. If the length of the data segment is less than the preset threshold, then at least one data block index may further be stored in the data segment, and its effect on the access efficiency of a data block index is relatively small. If the length of the data segment is equal to or greater than the preset threshold, then even if one data block index is stored in the data segment, its effect on the access efficiency of a data block index is relatively large.
  • step S3 if the length of the data segment is equal to or greater than the preset threshold, a data block index may be stored in a way of secondary indexing.
  • step S3 comprises the following steps:
  • step S3.1 creating several extension records and allocating an ID for each extension record respectively, wherein the created extension records are stored in the index storage unit in the form of an array, each extension record is used for storing data block indexes of a specified number, the specified number may be recorded in the head of the index master record; since each data block index has a fixed length, each extension record also has a fixed length; the fixed length of the data block index may also be recorded in the head of the index master record; the number of the created extension records needs to be determined according to the number of stored data block indexes and the to-be-stored data block index, for example, if each extension record is used for storing 3 data block indexes, and there are 9 currently stored data block indexes in the data segment, adding the to-be-stored data block index, 4 extension records need to be created;
  • step S3.2 recording the IDs of the created individual extension records in the data segment of the index master record, thereby associating the individual extension records with the index master record;
  • step S3.3 updating the structural flag as indicating that the index master record is associated with an extension record
  • step S3.4 transferring a stored data block index in the data segment into a corresponding extension record, and also storing the to-be-stored data block index in a corresponding extension record.
  • Data block indexes in an individual extension record are still stored in the form of an array.
  • the to-be-stored data block index may be arranged behind the sequence of the stored data block indexes in the data segment. Then, the stored data block indexes in the data segment and the to-be-stored data block index are written to the created individual extension records in sequence one by one.
  • each extension record may store 3 data block indexes, and 9 data block indexes are currently stored in the data segment, 4 extension records need to be created. Then, the first to third stored data block indexes in the data segment are transferred in sequence to the first created extension record, the fourth to sixth stored data block indexes are transferred to the second created extension record, and so on, and at last, the to-be-stored data block index is written to the fourth extension record, as shown in Fig. 6.
  • each extension record since the length of each extension record also needs to be fixed, if the number of data block indexes in the last extension record is insufficient, then first the bytes in the extension record with no data block index being stored thereon are filled with 0 (zero) . When it is needed to continue to store a data block index, the bytes 0 of a corresponding storage area in the last extension record are replaced with the to-be-stored data block index. Continue the previous example. There is only one data block index in the fourth extension record, and then the bytes of the storage areas for storing two additional data block indexes in the fourth extension record are filled with 0.
  • step S4 if the length of the data segment is less than the preset threshold, then the to-be-stored data block index is still stored in the data segment in the form of an array. It is worth noting that, after the to-be-stored data block index is stored in the data segment, it is also necessary to update the length information of the data segment in the head in order for subsequently judging whether the length of the data segment is equal to or greater than the preset threshold.
  • the index master record is associated with an extension record according to the structural flag in the head of the index master record, namely, whether the file is a large file or a small file. If the file is associated with an extension record, then the file is defined to be a large file. If the file is not associated with an extension record, then the file is defined to be a small file.
  • sequence number of the extension record FINT (Fileoffset/ (BIockSize*lndexCount) ) ;
  • the target data block index is located in the located extension record according to the following formula:
  • the file void refers to a void caused by a next write operation of the file in the file because of the set file offset being greater than the current length of the file. And all the bytes located in the file, but not actually written in the file, namely, the bytes corresponding to the void, are set to be repetitive Os. If within a certain data block range of the file are all voids, then the data storage engine does not allocate a data block for the voids to save storage space.
  • step S21 if the to-be-stored data block index corresponds to a void of the file, for example, the data block index information returned by the data storage engine is a null value, then the bytes of the to-be-stored data block index are set to be 0 in the data segment or a corresponding extension record.
  • Fig 8 is a schematic diagram of storing a data block index corresponding to a file void in the data segment
  • Fig. 9 is a schematic diagram of storing a data block index corresponding to a file void in an extension record.
  • the total number of stored data block indexes in an extension record may be recorded in the head of the index master record.
  • the bytes of one storage area of the last extension record are set to 0, so that it can not be judged whether the storage area has not yet stored a data block index, or has stored a data block index corresponding to a file void, it may be judged according to the total number of data block indexes. For example, if the total number of data block indexes is 5, whereas there are already 5 data block indexes stored in areas ahead of the storage area in the extension record, then the storage area has not yet stored a data block index. If there are only 4 data block indexes stored in areas ahead of the storage area in the extension record, then the storage area has stored a data block index corresponding to a file void.
  • a third embodiment provides a method for storing a file index performed by a computing device, e.g. , the above-described terminal 1, which, as compared to the method for storing a file index of the first or second embodiment, further comprises the following steps.
  • step S33 after the modification operation is finished, the ID of the target extension record in the data segment is replaced with the ID of the backup extension record, such that the association of the target extension record with the index master record is removed, and the backup extension record is associated with the index master record.
  • a fourth embodiment provides a computing device 100 for storing a file index, which comprises at least a processor operating in conjunction with a memory (not shown in Fig. 11) and a plurality of modules.
  • the computing device 100 is for example the terminal 1 described hereinabove, and the computing device 100 may comprise a part or all of the components of the terminal 1 and may further comprise other component (s) as needed.
  • the plurality of modules may comprise a first judgment module 101, a second judgment module 102, a first storage module 103, a second storage module 104 and a third storage module 105.
  • the above individual modules refer to computer programs or program segments for implementing one or more particular function. Furthermore, the differentiation of the above individual modules does not represent that the actual program codes must also be separated.
  • the second judgment module 102 is used for judging whether the length of the data segment of the index master record is equal to or greater than a preset threshold if the index master record is not associated with an extension record. If the index master record is not associated with an extension record, then the data segment of the index master record is used for storing a data block index of the file in the form of an array.
  • the second judgment module 102 may read the length information of the data segment from the head of the index master record, and judge whether the length of the data segment is equal to or greater than a preset threshold according to the length information of the data segment.
  • the preset threshold may be an integer multiple of the fixed length of the data block index.
  • the first storage module 103 is used for creating several extension records associated with the index master record, and storing a stored data block index in the data segment and the to-be-stored data block index in a corresponding extension record, if the length of the data segment is equal to or greater than the preset threshold.
  • Each extension record is used for storing data block indexes of a specified number.
  • the created extension records are also stored in the form of an array.
  • the first storage module 103 first creates several extension records and allocates an ID for each extension record respectively. Then, the first storage module 103 records the IDs of the created individual extension records in the data segment of the index master record, thereby associating the individual extension records with the index master record, and updates the structural flag as indicating that the index master record is associated with an extension record. Finally, the first storage module 103 transfers a stored data block index in the data segment into a corresponding extension record, and also stores the to-be-stored data block index in a corresponding extension record.
  • the second storage module 104 is used for storing the to-be-stored data block index in the data segment of the index master record, if the length of the data segment is less than the preset threshold. After storing the to-be-stored data block index in the data segment, the second storage module 104 also needs to update the length information of the data segment in the head.
  • the particular working processes of the above individual modules may further refer to the method for storing a file index provided by the first embodiment, and will not be repeated here.
  • a data block index corresponding to a file void is represented with the bytes being 0 in the data segment of the index master record or in an associated extension record, such that a corresponding data block index may be established for the file void in the case of not allocating a data block to the file void.
  • the ID of the extension record is modified to be a preset value, such that as soon as the ID of the extension record is read to be the preset value, it may be known that the extension record corresponds to a file void, without the need to continue to read the extension record, thereby increasing the read efficiency.
  • the computing device 300 for storing a file index of this embodiment when it is needed to modify a target extension record, first a backup extension record consistent with the target extension record is generated. Then, the backup extension record is modified according to a modification operation. Only after the modification operation is finished, the backup extension record is associated with the index master record instead of the target extension record. Therefore, even if an error occurs in the process of modifying the backup extension record, so that the modification of the backup extension record fails, the failure of modification of the backup extension record will not affect the atomicity of the data corresponding to the target extension record, since the target extension record is not modified and the target extension record is still associated with the index master record.
  • Another embodiment provides a computer program product for storing a file index, comprising a non-transitory computer readable medium having computer readable program codes embodied therein that, when executed by a processor, causes the processor to execute the above described steps of the methods according to the embodiments, e.g., to judge whether an index master record corresponding to a file is associated with an extension record when a to-be-stored data block index of the file is received; when it is judged that the index master record is not associated with an extension record, create several extension records associated with the index master record, if the length of the data segment of the index master record is equal to or greater than a preset threshold; and store a stored data block index in the data segment and the to-be-stored data block index in a corresponding extension record.
  • the computer readable medium is for example a non-volatile memory, such as a CD, a hard disk or a flash memory.

Abstract

A method for storing a file index performed by a computing device comprises the following steps: when a to-be-stored data block index of a file is received, judging whether the index master record corresponding to the file is associated with an extension record; when it is judged that the index master record is not associated with an extension record, creating several extension records associated with the index master record, if the length of the data segment of the index master record is equal to or greater than a preset threshold; and storing a stored data block index in the data segment and the to-be-stored data block index in a corresponding extension record. A computing device for storing a file index is also disclosed. Employing the described technology, the storage efficiency and the access performance of the file index may be increased.

Description

[Title established by the ISA under Rule 37.2] METHOD, COMPUTING DEVICE, AND COMPUTER PROGRAM PRODUCT FOR STORING FILE INDEX FIELD OF THE INVENTION
Particular embodiments of the described technology relate to the field of data storage technologies, and in particular, to a method, computing device, and computer program product for storing a file index.
BACKGROUND OF THE INVENTION
The file concept provided by a distributed file system is usually a combination of multiple data blocks. A file index of a file comprises indexes of these data blocks. Data in a corresponding data block of the file may be read according to the file index. Therefore, data reading and writing of a file requires the consistency between the file index and the actual data to be maintained. In internet applications, with the increase of the bandwidth and the screen resolution, an output device and a transmission pipeline, etc. no longer become a bottleneck of an application such as super clear video on demand, large file transmission, or the like. However, data blocks involved in a large file are many, so that the file index expands dramatically. Therefore, how to effectively store a file index and promote the access performance of the file index has become an issue needed to be considered emphatically for an application design of a large file class.
SUMMARY OF THE INVENTION
In view of this, there is a need to provide a method, computing device, and computer program product for storing a file index which may increase the storage efficiency and access performance.
A method for storing a file index performed by a computing device comprises the following steps: when a to-be-stored data block index of a file is received, judging whether the index master record corresponding to the file is associated with an extension record; when it is judged that the index master record is not associated with an extension record, creating several extension records associated with the index master record, if the length of the data segment of the index master record is equal to or greater than a preset threshold; and storing a stored data block index in the data segment and the to-be-stored data block index in a corresponding extension record.
A computing device for storing a file index comprises at least a processor operating in conjunction with a memory and a plurality of modules, the modules comprising: a first judgment module for, when a to-be-stored data block index of a file is received, judging whether the index master record corresponding to the file is associated with an extension record; a first storage module for, when it is judged that the index master record is not associated with an extension record, creating several extension records associated with the index master record, if the length of the data segment of the index master record is equal to or greater than a preset threshold; wherein the first storage module is further used for storing a stored data block index in the data segment and the to-be-stored data block index in a corresponding extension record.
A computer program product for storing a file index comprises a non-transitory computer readable medium having computer readable program codes embodied therein that, when executed by a processor, causes the processor to: judge whether an index master record corresponding to a file is associated with an extension record when a to-be-stored data block index of the file is received; when it is judged that the index master record is not associated with an extension record, create several extension records associated with the index master record, if the length of the data segment of the index master record is equal to or greater than a preset threshold; and store a stored data block index in the data segment and the to-be-stored data block index in a corresponding extension record.
As compared to the prior art, in the method, computing device, and computer program product for storing a file index, if the length of the data segment for storing data block indexes in the index master record of a file is equal to or greater than a preset threshold, all the data block indexes in the data segment are split into several extension records associated with the index master record for storage, thereby the storage efficiency of the file index may be increased, and the access performance of the file index may be promoted.
To make the foregoing and other objects, features and advantages of the described technology to be more obvious and understandable, in the following, preferred embodiments will be listed and described in detail as follows in connection with the appended drawings.
BRIEF DESCRIPTION OF THE DRAWINGS
Fig. 1 is a structural block diagram of a terminal.
Fig. 2 is a flow chart of a method for storing a file index provided by a first embodiment of the present disclosure.
Fig. 3 is a flow chart of a method for writing data corresponding to a file.
Fig. 4 is a schematic diagram of storing a data block index in the data segment of an index master record.
Fig. 5 is a flow chart of a method for creating an extension record associated with the index master record.
Fig. 6 is a schematic diagram of storing a data block index in an extension record.
Fig. 7 is a flow chart of a method for storing a file index provided by a second embodiment of the present disclosure.
Fig. 8 is a schematic diagram of storing a data block index corresponding to a file void in the data segment.
Fig. 9 is a schematic diagram of storing a data block index corresponding to a file void in an extension record.
Fig. 10 is a flow chart of a method for storing a file index provided by a third embodiment of the present disclosure.
Fig. 11 is a block diagram of modules in a computing device for storing a file index provided by a fourth embodiment of the present disclosure.
Fig. 12 is a block diagram of modules in a computing device for storing a file index provided by a fifth embodiment of the present disclosure.
Fig. 13 is a block diagram of modules in a computing device for storing a file index provided by a sixth embodiment of the present disclosure.
DETAILED DESCRIPTION OF THE INVENTION
To further elucidate technical means employed by the described technology for achieving the intended purposes of the technology and the efficacy, in the following, particular implementations, structures, features according to the technology and the efficacy thereof will be described in detail as follows in connection with the drawings and preferred embodiments.
Fig. 1 is a structural block diagram of a terminal 1, which is an example of the computing device according to embodiments of the present disclosure. As shown in Fig. 1, the terminal 1 comprises one or more (only one shown in the figure) memory 11, a processor 12, a memory controller 13, a peripheral interface 14, a communication module 15, an input unit 16 and a display unit 17. These  components communicate with each other via one or more communication bus/signal line.
It may be appreciated by those of ordinary skills in the art that the structure of Fig. 1 is simply schematic, and it does not define the structure of the terminal 1. For example, the terminal 1 may further comprise more or less components than what is shown in Fig. 1, or have a configuration different from that as shown in Fig. 1. The individual components as shown in Fig. 1 may be implemented by employing hardware, software or a combination thereof.
The memory 11 may be used for storing a software program and a module, e.g., program instructions/modules corresponding to a method for storing a file index in an embodiment, and the processor 12 implements the method for storing a file index by running a software program and a module stored in the memory 11 and thereby performing various functional applications and data processing.
The memory 11 may comprise a high speed random memory, or may further comprise a non-volatile memory, for example, one or more magnetic storage, flash memory, or other non-volatile solid memory. In some examples, the memory 11 may further comprise memories arranged remotely with respect to the processor 12, and such remotely arranged memories may be connected to the terminal 1 via a network. Examples of the above mentioned network comprise, but are not limited to, an internet, an intranet, a local area network, a mobile communication network and a combination thereof. The access to the memory 11 by the processor 12 and other possible components may be carried out under the control of the memory controller 13.
The peripheral interface 14 couples various input/output apparatus to the processor 12 and the memory 11. The processor 12 runs various software and instructions in the memory 11 to perform various functions of the terminal 1 and data processing.
The communication module 15 is used for communicating with a communication network or other device. In particular, the communication module 15 may be for example a network card 151 or an RF (Radio Frequency) module 152. As an interface connecting a computer and a transmission medium in a local area network, the network card 151 is used for implementing a physical connection and electrical signal matching with transmission media in a local area network, thereby establishing the local area network and connecting to the Internet, and communicating with various networks such as a local area network, a metropolitan area network, a wide area network. The network card 151 may comprise various  existing circuit elements for performing the above-described functions, e.g. , a processor and a memory (including a ROM and a RAM) , etc. The RF module 152 is used for receiving and sending electromagnetic waves, carrying out a transformation between the electromagnetic waves and an electric signal, and thereby communicating with a communication network or other device. The RF module 152 may comprise various existing circuit elements for performing these functions, e.g. , an antenna, a radio frequency transceiver, a digital signal processor, an encryption/decryption chip, a subscriber identity module (SIM) card, a memory, etc. The RF module 152 may communicate with various networks, e.g. , an internet, an intranet, a wireless network, or communicate with other device via a wireless network. The above mentioned wireless network may comprise a cellular telephone network, a wireless local area network or a metropolitan area network. The above mentioned wireless network may adopt various communication standards, protocols and technologies, comprising but not limited to, Global System for Mobile Communication, Enhanced Data GSM Environment (EDGE) , wideband code division multiple access (W-CDMA) , code division multiple access (CDMA) , time division multiple access (TDMA) , Wireless Fidelity (WiFi) (e.g. , American Institute of Electrical and Electronics Engineers standards IEEE 802.11a, IEEE 802.11b, IEEE 802.11g and/or IEEE 802.11n) , voice over internet protocol (VolP) , Worldwide Interoperability for Microwave Access (Wi-Max) , other protocols for mails, instant messaging and SMS, as well as any other suitable communication protocols, which may even comprise those protocols currently not yet developed.
The input unit 16 may be used for receiving input character information and generating a signal input to a keyboard, a mouse, a joystick, an optical or track ball related with user settings and functional control. In particular, the input unit 16 may comprise a keypad 161 and a touch control surface 162. The keypad 161 may for example comprise a character key for inputting a character and a control key for triggering a control function. Examples of the control key comprise a Home Screen key, a power on/off key, a camera key, etc. The touch control surface 162 may gather a touch operation by a user on or near it (e.g. , an operation on the touch control surface 162 or near the touch control surface 162 by the user using any suitable object or accessory such as a finger, a stylus, etc. ) , and drive a corresponding connected apparatus according to a pre-established program. Optionally, the touch control surface 162 may comprise two parts, a touch detecting apparatus and a touch controller. Therein, the touch detecting apparatus detects the touch orientation of a user, detects a signal brought about by the touch operation,  and transmits the signal to the touch controller; the touch controller receives touch information from the touch detecting apparatus. Converts it to contact coordinates and then sends them to the processor 12, and is capable of receiving a command sent by the processor 12 and executing the same. Furthermore, the touch control surface 162 may be implemented employing many types such as resistance, capacitance, infrared and surface acoustic wave, etc. In addition to the touch control surface 162, the input unit 16 may further comprise other input devices. The other input devices comprise, but are not limited to, one or more of a physical keyboard, a track ball, a mouse, a joystick, etc.
The display unit 17 is used for displaying information input by a user, information provided to the user, and various graphical interfaces of the terminal 1. These graphical user interfaces may be composed of graphics, text, icons, video and any combination thereof. In an example, the display unit 17 comprises a display panel 171. The display panel 171 may be for example a liquid crystal display (LCD) , an organic light-emitting diode (OLED) display panel, an electro-phoretic display (EPD) , etc. Further, the touch control surface 162 may be arranged on the display panel 171, and thereby form an integral with the display panel 171.
FIRST EMBODIMENT
Reference is made to what is shown in Fig. 2. A first embodiment provides a method for storing a file index, which may be carried out by a computing device, e.g. , the above-described terminal 1. Particular examples of the terminal 1 comprise, but are not limited to, a desktop computer, a portable computer, a smart phone, a tablet computer or other similar arithmetic apparatus. In this embodiment, the method for storing a file index comprises the following steps:
step S1: when a to-be-stored data block index of a file is received, judging whether the index master record corresponding to the file is associated with an extension record, and if no, performing step S2, and if yes, performing step S5;
step S2: judging whether the length of the data segment of the index master record is equal to or greater than a preset threshold, and if yes, performing step S3, and if no, performing step S4;
step S3: creating several extension records associated with the index master record, and storing a stored data block index in the data segment and the to-be-stored data block index in a corresponding extension record;
step S4: storing the to-be-stored data block index in the data segment of the index master record; and
step S5: storing the to-be-stored data block index in a corresponding extension record.
According to the above-described method for storing a file index, if the length of the data segment for storing data block indexes in the index master record of a file is equal to or greater than a preset threshold, all the data block index information in the data segment is split into several extension records associated with the index master record for storage, thereby the storage efficiency of the file index may be increased, and the access performance of the file index may be promoted.
In some examples, the implementation details of the individual steps of the above method are as follows.
The file described in step S1 is a file being written to the memory 11, and the file may be of various types, e.g. , video, document, picture, program, etc. In this embodiment, the process of writing the file to the memory 11 comprises: writing data corresponding to the file to the memory 11, and establishing a file index for the file in the memory 11. The file index is used for locating the file in the memory 11.
In particular, reference is made to what is shown in Fig. 3. The process of writing data corresponding to the file to the memory 11 may be implemented by an existing data storage engine, e.g. , the NoSQL (a non-relational database) storage engine through the following steps:
step a: obtaining the length of to-be-written data of the file when a write request of the file is received, wherein the write request of the file may for example be sent out when the file is downloaded from the internet via the communication module 15, or also may be sent out when the input unit 16 receives creation and modification operations of the file by a user, or also may be sent out when a certain program, e.g. , a camera program runs and generates the file, and the like;
step b: allocating several data blocks for the file in a data storage unit in the memory 11, according to a specified data length of a data block preset for the file and the obtained length of to-be-written data of the file, wherein the specified data length of a data block is the maximum data length that the data block can accommodate, the specified data length of the data block may be set when the write request of the file is received the first time and thereby the file is created in the data storage unit; the data storage unit is a storage area specifically for storing data corresponding to a file, and the data storage unit may exist in the form of a database;
step c: writing the to-be-written data of the file into the allocated data blocks sequentially, wherein if the sum of the specified data length of the allocated  data blocks is greater than the length of to-be-written data of the file, then there may be several ones in the allocated data blocks that are not filled up with the to-be-written data of the file; and
step d: returning a data block index corresponding to an allocated individual data block and the identification information of the file, wherein each data block index has a fixed length, the data block index comprises the ID of a corresponding data block and the effective data length of the data block, the effective data length of the data block refers to the length of the actual stored data, the identification information of the file comprises for example the name, ID, etc. of the file, and the identification information of the file may be obtained when the write request of the file is received.
Moreover, the process of establishing a file index for the file in the memory 11 may be implemented by the method for storing a file index provided by this embodiment. Since the data corresponding to the file is stored in several data blocks, the file index comprises an individual data block index. The data block index may be stored in the data segment of the index master record corresponding to the file according to the number, or stored in an extension record associated with the index master record. The index master record and the extension record may be stored in an index storage unit in the memory 11. In contrast to the data storage unit, the index storage unit is specifically used for storing a file index of an individual file.
In this embodiment, each time the data storage engine returns a data block index and the identification information of the file, step S1 is performed. The data block index returned by the data storage engine is exactly the to-be-stored data block index information. The to-be-stored data block index corresponds to data at the end of the file. Therefore, after receiving the identification information of the file and the data block index, step S1 may find the index master record corresponding to the file in the index storage unit according to the identification information of the file.
In an example, the index master record comprises a head and a data segment. Therein, the head has a fixed length, whereas the data segment has a variable length. The head comprises file meta information, a structural flag and length information of the data segment. The file meta information comprises for example the identification information of the file, the creation time and modification time of the file, the total length of the file, and the specified data length of a corresponding data block, etc. The structural flag indicates whether the index master record is associated with an extension record. The length information of the data segment indicates the length of the data segment of the index master record. 
Therefore, step S1 may first read the structural flag from the head of the index master record, and then judge whether the index master record is associated with an extension record according to the structural flag. If the index master record is associated with an extension record, the ID of the associated extension record, e.g. , UUID (Universally Unique Identifier) , is recorded in the data segment of the index master record. The ID of the extension record has uniqueness.
In step S2, if the index master record is not associated with an extension record, then the data segment of the index master record is used for storing a data block index of the file in the form of an array, as shown in Fig. 4. As the file increases, the data blocks constituting the file become more and more, and also the data block indexes of the file are more and more, which causes the data segment of the index master record to be longer and longer. Such a situation will give rise to a trend in which the time required for pulling a data block index from the data segment grows linearly, and thus the data segment being too long will directly affect the access efficiency of a data block index.
Therefore, step S2 needs to further judge whether the length of the data segment of the index master record is equal to or greater than a preset threshold. In particular, step S2 may read the length information of the data segment from the head of the index master record, and judge whether the length of the data segment is equal to or greater than a preset threshold according to the length information of the data segment. In an example, the preset threshold may be an integer multiple of the fixed length of the data block index. If the length of the data segment is less than the preset threshold, then at least one data block index may further be stored in the data segment, and its effect on the access efficiency of a data block index is relatively small. If the length of the data segment is equal to or greater than the preset threshold, then even if one data block index is stored in the data segment, its effect on the access efficiency of a data block index is relatively large.
In step S3, if the length of the data segment is equal to or greater than the preset threshold, a data block index may be stored in a way of secondary indexing. In particular, see what is shown in Fig. 5, step S3 comprises the following steps:
step S3.1: creating several extension records and allocating an ID for each extension record respectively, wherein the created extension records are stored in the index storage unit in the form of an array, each extension record is used for storing data block indexes of a specified number, the specified number may be recorded in the head of the index master record; since each data block index has  a fixed length, each extension record also has a fixed length; the fixed length of the data block index may also be recorded in the head of the index master record; the number of the created extension records needs to be determined according to the number of stored data block indexes and the to-be-stored data block index, for example, if each extension record is used for storing 3 data block indexes, and there are 9 currently stored data block indexes in the data segment, adding the to-be-stored data block index, 4 extension records need to be created;
step S3.2: recording the IDs of the created individual extension records in the data segment of the index master record, thereby associating the individual extension records with the index master record;
step S3.3: updating the structural flag as indicating that the index master record is associated with an extension record; and
step S3.4: transferring a stored data block index in the data segment into a corresponding extension record, and also storing the to-be-stored data block index in a corresponding extension record. Data block indexes in an individual extension record are still stored in the form of an array. In particular, since each extension record may store data block indexes of a specified number, the to-be-stored data block index may be arranged behind the sequence of the stored data block indexes in the data segment. Then, the stored data block indexes in the data segment and the to-be-stored data block index are written to the created individual extension records in sequence one by one.
For example, if each extension record may store 3 data block indexes, and 9 data block indexes are currently stored in the data segment, 4 extension records need to be created. Then, the first to third stored data block indexes in the data segment are transferred in sequence to the first created extension record, the fourth to sixth stored data block indexes are transferred to the second created extension record, and so on, and at last, the to-be-stored data block index is written to the fourth extension record, as shown in Fig. 6.
It is worth noting that, since the length of each extension record also needs to be fixed, if the number of data block indexes in the last extension record is insufficient, then first the bytes in the extension record with no data block index being stored thereon are filled with 0 (zero) . When it is needed to continue to store a data block index, the bytes 0 of a corresponding storage area in the last extension record are replaced with the to-be-stored data block index. Continue the previous example. There is only one data block index in the fourth extension record, and then the bytes of the storage areas for storing two additional data block indexes in the fourth  extension record are filled with 0. If subsequently one data block index needs to be stored again, then the bytes 0 of a corresponding storage area are replaced with the data block index in sequence, whereas the bytes are 0 corresponding to the remaining storage area of the length of one data block index in the fourth extension record.
In step S4, if the length of the data segment is less than the preset threshold, then the to-be-stored data block index is still stored in the data segment in the form of an array. It is worth noting that, after the to-be-stored data block index is stored in the data segment, it is also necessary to update the length information of the data segment in the head in order for subsequently judging whether the length of the data segment is equal to or greater than the preset threshold.
In step S5, if the index master record is associated with an extension record, then the to-be-stored data block index is stored in a corresponding extension record. In particular, first, it is judged whether data block indexes stored in the last extension record in the array of extension records are equal to or greater than the specified number. If data block indexes stored in the last extension record are equal to or greater than the specified number, then it is needed to create again an extension record associated with the index master record, namely, record the ID of the created extension record in the data segment, and store the to-be-stored data block index in the created extension record. If data block indexes stored in the last extension record are less than the specified number, then the to-be-stored data block index is stored in the last extension record.
The file index established by the above described process in the index storage unit for the file is convenient for efficiently locating any data block index of the file. For example, given that the offset of a certain target data block in the file is Fileoffset, the specified data length of a data block is BlockSize, the length of each data block index is indexSize, the number of data block indexes stored in each extension record is indexCount, and FINT is a rounding operation. Therein, BlockSize, indexSize and indexCount are fixed values respectively.
When it is needed to locate a target data block index corresponding to the target data block, it is first judged whether the index master record is associated with an extension record according to the structural flag in the head of the index master record, namely, whether the file is a large file or a small file. If the file is associated with an extension record, then the file is defined to be a large file. If the file is not associated with an extension record, then the file is defined to be a small file.
If the file is not associated with an extension record, then the target data block index may be located by the following formula:
offset of the target data block index in the data segment of the index master record= (FINT (Fileoffset/BlockSize) ) *Indexsize.
If the file is associated with an extension record, then first the sequence number of the extension record where the target data block index lies is located according to the following formula:
sequence number of the extension record =FINT (Fileoffset/ (BIockSize*lndexCount) ) ;
then, the target data block index is located in the located extension record according to the following formula:
offset of the target data block index in the extension record=(Fileoffset-sequence number of the extension record * (BlockSize*lndexCount) ) /Indexsize.
In summary, after a data block index of a file is stored using the method for storing a file index of this embodiment, it is necessary to read the index master record only once to be able to locate the data block index in the case of the file being small, and the read performance is good. In the case of the file being large, after reading the index master record once to locate an extension record, the extension record is read once again so as to locate the data block index, without the need to read all the extension records. Furthermore, since in general part of historical records of indexes may be cached, the overall access performance of the file index is promoted, because within a certain time, the index master record of the file is hot data and does not need to be pulled repeatedly, whereas an extension record may be cached on demand and read on demand.
SECOND EMBODIMENT
In the process of storing a file, a situation of a file void will usually appear. The file void refers to a void caused by a next write operation of the file in the file because of the set file offset being greater than the current length of the file. And all the bytes located in the file, but not actually written in the file, namely, the bytes corresponding to the void, are set to be repetitive Os. If within a certain data block range of the file are all voids, then the data storage engine does not allocate a data block for the voids to save storage space.
With respect to such a situation, see what is shown in Fig. 7, a second embodiment provides a method for storing a file index performed by a computing  device, e.g., the above-described terminal 1 in which as compared to the method for storing a file index of the first embodiment, in step S3, step S4 or step S5, the step of storing the to-be-stored data block index in the data segment or in a corresponding extension record further comprises the following steps.
In step S21, if the to-be-stored data block index corresponds to a void of the file, for example, the data block index information returned by the data storage engine is a null value, then the bytes of the to-be-stored data block index are set to be 0 in the data segment or a corresponding extension record. See what is shown in Fig. 8 and Fig. 9, Fig 8 is a schematic diagram of storing a data block index corresponding to a file void in the data segment, and Fig. 9 is a schematic diagram of storing a data block index corresponding to a file void in an extension record.
Consider the situation of locating the last data block index stored in the data segment. Since the data segment changes its length according to the number of stored data block indexes, if the bytes of the last data block index in the data segment are 0, then the last data block index corresponds to a void of the file.
Consider the situation of locating the last data block index stored in an extension record. Since the bytes of a storage area in the last created extension record in which no data block index has yet been stored will also all be set to 0, if the bytes of the last data block index in the last extension record are also set to 0, then it is possible to give rise to the problem of misjudging that a storage area of which the bytes are set to 0 corresponding to the last data block index has not yet stored a data block index thereon.
To solve this problem, in an example, the total number of stored data block indexes in an extension record may be recorded in the head of the index master record. When a situation appears in which the bytes of one storage area of the last extension record are set to 0, so that it can not be judged whether the storage area has not yet stored a data block index, or has stored a data block index corresponding to a file void, it may be judged according to the total number of data block indexes. For example, if the total number of data block indexes is 5, whereas there are already 5 data block indexes stored in areas ahead of the storage area in the extension record, then the storage area has not yet stored a data block index. If there are only 4 data block indexes stored in areas ahead of the storage area in the extension record, then the storage area has stored a data block index corresponding to a file void.
In step S22, when the bytes of all the data block indexes stored in an extension record are all 0, the ID of the extension record in the data segment is  updated to be a preset value, for example, the bytes corresponding to the ID of the extension record are all set to 0, as shown in Fig. 9.
In summary, by the method for storing a file index of this embodiment, a data block index corresponding to a file void is represented with the bytes being 0 in the data segment of the index master record or in an associated extension record, such that a corresponding data block index may be established for the file void in the case of not allocating a data block to the file void. Furthermore, if the bytes of all the data block indexes comprised in an extension record are all 0, then the ID of the extension record is modified to be a preset value, such that as soon as the ID of the extension record is read to be the preset value, it may be known that the extension record corresponds to a file void, without the need to continue to read the extension record, thereby increasing the read efficiency.
THIRD EMBODIMENT
After the file index is stored according to the first and second embodiments, multiple write operations of an extension record may be involved in the process of locating an extension record to make a modification. In order to guarantee the atomicity of the extension record in the case of multiple write operations, i.e. , in the case of the extension record not being successfully modified, the data corresponding to the extension record is kept consistent as before the modification. See what is shown in Fig. 10, a third embodiment provides a method for storing a file index performed by a computing device, e.g. , the above-described terminal 1, which, as compared to the method for storing a file index of the first or second embodiment, further comprises the following steps.
In step S31, when it is needed to modify a target extension record, first a backup extension record of the target extension record is generated, and also an ID is allocated to the backup extension record. In particular, when modifying the target extension record, it is needed to first locate the target extension record. The method for locating the target extension record may refer to the formula for locating the sequence number of the extension record, and will not be repeated here. The generated backup extension record is consistent with the target extension record.
In step S32, the backup extension record is modified according to a modification operation. The modification operation comprises for example modifying one or more data block index in the backup extension record.
In step S33, after the modification operation is finished, the ID of the target extension record in the data segment is replaced with the ID of the backup  extension record, such that the association of the target extension record with the index master record is removed, and the backup extension record is associated with the index master record.
In summary, in the method for storing a file index of this embodiment, when it is needed to modify a target extension record, first a backup extension record consistent with the target extension record is generated. Then, the backup extension record is modified according to a modification operation. Only after the modification operation is finished, the backup extension record is associated with the index master record instead of the target extension record. Therefore, even if an error occurs in the process of modifying the backup extension record, so that the modification of the backup extension record fails, the failure of modification of the backup extension record will not affect the atomicity of the data corresponding to the target extension record, since the target extension record is not modified and the target extension record is still associated with the index master record.
FOURTH EMBODIMENT
A fourth embodiment provides a computing device 100 for storing a file index, which comprises at least a processor operating in conjunction with a memory (not shown in Fig. 11) and a plurality of modules. The computing device 100 is for example the terminal 1 described hereinabove, and the computing device 100 may comprise a part or all of the components of the terminal 1 and may further comprise other component (s) as needed. As shown in Fig. 11, the plurality of modules may comprise a first judgment module 101, a second judgment module 102, a first storage module 103, a second storage module 104 and a third storage module 105. It may be appreciated that, the above individual modules refer to computer programs or program segments for implementing one or more particular function. Furthermore, the differentiation of the above individual modules does not represent that the actual program codes must also be separated.
The first judgment module 101 is used for, when a to-be-stored data block index of a file is received, judging whether the index master record corresponding to the file is associated with an extension record. The data block index comprises the ID of a corresponding data block and the effective data length of the data block. The data block index has a fixed length. The index master record comprises a head and a data segment. The head comprises file meta information, a structural flag and length information of the data segment. The file meta information comprises for example the identification information of the file, the creation time and  modification time of the file, the total length of the file, and the specified data length of a corresponding data block, etc. The structural flag indicates whether the index master record is associated with an extension record. The length information of the data segment indicates the length of the data segment of the index master record. Therefore, the first judgment module 101 may first read the structural flag from the head of the index master record, and then judge whether the index master record is associated with an extension record according to the structural flag.
The second judgment module 102 is used for judging whether the length of the data segment of the index master record is equal to or greater than a preset threshold if the index master record is not associated with an extension record. If the index master record is not associated with an extension record, then the data segment of the index master record is used for storing a data block index of the file in the form of an array. The second judgment module 102 may read the length information of the data segment from the head of the index master record, and judge whether the length of the data segment is equal to or greater than a preset threshold according to the length information of the data segment. In an example, the preset threshold may be an integer multiple of the fixed length of the data block index.
The first storage module 103 is used for creating several extension records associated with the index master record, and storing a stored data block index in the data segment and the to-be-stored data block index in a corresponding extension record, if the length of the data segment is equal to or greater than the preset threshold. Each extension record is used for storing data block indexes of a specified number. The created extension records are also stored in the form of an array.
In particular, the first storage module 103 first creates several extension records and allocates an ID for each extension record respectively. Then, the first storage module 103 records the IDs of the created individual extension records in the data segment of the index master record, thereby associating the individual extension records with the index master record, and updates the structural flag as indicating that the index master record is associated with an extension record. Finally, the first storage module 103 transfers a stored data block index in the data segment into a corresponding extension record, and also stores the to-be-stored data block index in a corresponding extension record.
The second storage module 104 is used for storing the to-be-stored data block index in the data segment of the index master record, if the length of the  data segment is less than the preset threshold. After storing the to-be-stored data block index in the data segment, the second storage module 104 also needs to update the length information of the data segment in the head.
The third storage module 105 is used for storing the to-be-stored data block index in a corresponding extension record, if the index master record is associated with an extension record. In particular, the third storage module 105 first judges whether data block indexes stored in the last extension record in the array of extension records are equal to or greater than the specified number. If data block indexes stored in the last extension record are equal to or greater than the specified number, then it is needed to create again an extension record associated with the index master record, namely, record the ID of the created extension record in the data segment, and store the to-be-stored data block index in the created extension record. If data block indexes stored in the last extension record are less than the specified number, then the to-be-stored data block index is stored in the last extension record.
The particular working processes of the above individual modules may further refer to the method for storing a file index provided by the first embodiment, and will not be repeated here.
In summary, in the computing device for storing a file index provided by this embodiment, if the length of the data segment for storing data block indexes in the index master record of a file is equal to or greater than a preset threshold, all the data block index information in the data segment is split into several extension records associated with the index master record for storage, thereby the storage efficiency of the file index may be increased, and the access performance of the file index may be promoted.
FIFTH EMBODIMENT
A fifth embodiment provides a computing device 200 for storing a file index, which comprises at least a processor operating in conjunction with a memory (not shown in Fig. 12) and a plurality of modules. The computing device 200 is for example the terminal 1 described hereinabove, and the computing device 200 may comprise a part or all of the components of the terminal 1 and may further comprise other component (s) as needed. As shown in Fig. 12, as compared to the computing device 100 for storing a file index of the fourth embodiment, the first storage module 103, the second storage module 104 and the third storage module 105 in the  computing device 200 may further comprise a first storage sub-module 201 respectively.
The first storage sub-module 201 is used for, when the to-be-stored data block index is stored in the data segment or in a corresponding extension record, setting the bytes of the to-be-stored data block index to be 0 in the data segment or the corresponding extension record, if the to-be-stored data block index corresponds to a void of the file.
Furthermore, the first storage module 103 and the third storage module 105 further comprise a second storage sub-module 202 respectively, and the second storage sub-module 202 is used for, when the bytes of all the data block indexes stored in an extension record are all 0, updating the ID of the extension record in the data segment to be a preset value.
The particular working processes of the above individual modules may further refer to the method for storing a file index provided by the second embodiment, and will not be repeated here.
In summary, by the computing device 200 for storing a file index of this embodiment, a data block index corresponding to a file void is represented with the bytes being 0 in the data segment of the index master record or in an associated extension record, such that a corresponding data block index may be established for the file void in the case of not allocating a data block to the file void. Furthermore, if the bytes of all the data block indexes comprised in an extension record are all 0, then the ID of the extension record is modified to be a preset value, such that as soon as the ID of the extension record is read to be the preset value, it may be known that the extension record corresponds to a file void, without the need to continue to read the extension record, thereby increasing the read efficiency.
SIXTH EMBODIMENT
A sixth embodiment provides a computing device 300 for storing a file index, which comprises at least a processor operating in conjunction with a memory (not shown in Fig. 13) and a plurality of modules. The computing device 300 is for example the terminal 1 described hereinabove, and the computing device 300 may comprise a part or all of the components of the terminal 1 and may further comprise other component (s) as needed. As shown in Fig. 13, as compared to the computing device 100 for storing a file index of the fourth embodiment or the computing device 200 for storing a file index of the fifth embodiment, the computing device 300 may further comprise a modifying module 301. The modifying module 301 is used for:
when it is needed to modify a target extension record, first generating a backup extension record of the target extension record, and also allocating an ID to the backup extension record;
modifying the backup extension record according to a modification operation; and
after the modification operation is finished, replacing the ID of the target extension record in the data segment with the ID of the backup extension record, such that the association of the target extension record with the index master record is removed, and the backup extension record is associated with the index master record.
The particular working processes of the above individual modules may further refer to the method for storing a file index provided by the third embodiment, and will not be repeated here.
In summary, in the computing device 300 for storing a file index of this embodiment, when it is needed to modify a target extension record, first a backup extension record consistent with the target extension record is generated. Then, the backup extension record is modified according to a modification operation. Only after the modification operation is finished, the backup extension record is associated with the index master record instead of the target extension record. Therefore, even if an error occurs in the process of modifying the backup extension record, so that the modification of the backup extension record fails, the failure of modification of the backup extension record will not affect the atomicity of the data corresponding to the target extension record, since the target extension record is not modified and the target extension record is still associated with the index master record.
SEVENTH EMBODIMENT
Another embodiment provides a computer program product for storing a file index, comprising a non-transitory computer readable medium having computer readable program codes embodied therein that, when executed by a processor, causes the processor to execute the above described steps of the methods according to the embodiments, e.g., to judge whether an index master record corresponding to a file is associated with an extension record when a to-be-stored data block index of the file is received; when it is judged that the index master record is not associated with an extension record, create several extension records associated with the index master record, if the length of the data segment of the index master record is equal to or greater than a preset threshold; and store a stored  data block index in the data segment and the to-be-stored data block index in a corresponding extension record.. The computer readable medium is for example a non-volatile memory, such as a CD, a hard disk or a flash memory.
The above are just preferred embodiments, and not any formal restrictions to the present disclosure. While the described technology has been disclosed above with preferred embodiments, they are not used to define the technology. Some changes or modifications into equivalent embodiments of equal changes may be made with the technical content disclosed above by those skilled in the art without departing from the scope of a technical solution of the technology. Any simple amendments, equal changes and modifications made to the above embodiments according to the technical essence of the technology without departing from the content of technical solutions of the technology, all fall within the scope of technical solutions of the technology.

Claims (33)

  1. A method for storing a file index performed by a computing device, comprising:
    judging whether an index master record corresponding to a file is associated with an extension record when a to-be-stored data block index of the file is received;
    when it is judged that the index master record is not associated with an extension record, creating several extension records associated with the index master record, if the length of the data segment of the index master record is equal to or greater than a preset threshold; and
    storing a stored data block index in the data segment and the to-be-stored data block index in a corresponding extension record.
  2. The method for storing a file index as claimed in claim 1, further comprising:
    when it is judged that the index master record is not associated with an extension record, storing the to-be-stored data block index in the data segment of the index master record, if the length of the data segment is less than the preset threshold.
  3. The method for storing a file index as claimed in claim 2, further comprising:
    storing the to-be-stored data block index in a corresponding extension record, when it is judged that the index master record is associated with an extension record.
  4. The method for storing a file index as claimed in claim 3, wherein the data block index comprises the ID and the effective data length of the data block.
  5. The method for storing a file index as claimed in claim 3, wherein the data block index has a fixed length.
  6. The method for storing a file index as claimed in claim 3, wherein the data block index is stored in the data segment or the extension record in the form of an array, and the extension record associated with the index master record is also stored in the form of an array.
  7. The method for storing a file index as claimed in claim 6, wherein each extension record is used for storing data block indexes of a specified number.
  8. The method for storing a file index as claimed in claim 7, wherein the step of storing the to-be-stored data block index in a corresponding extension record comprises:
    judging whether data block indexes stored in the last extension record in the array of extension records is equal to or greater than the specified number;
    if data block indexes stored in the last extension record is equal to or greater than the specified number, creating again an extension record associated with the index master record, and storing the to-be-stored data block index in the created extension record; and
    if data block indexes stored in the last extension record is less than the specified number, storing the to-be-stored data block index in the last extension record.
  9. The method for storing a file index as claimed in claim 3, wherein the index master record comprises a head and the data segment, the head comprises a structural flag and length information of the data segment; and
    the structural flag indicates whether the index master record is associated with an extension record.
  10. The method for storing a file index as claimed in claim 9, wherein the step of judging whether the index master record corresponding to the file is associated with an extension record comprises:
    reading the structural flag from the head; and
    judging whether the index master record is associated with an extension record according to the structural flag.
  11. The method for storing a file index as claimed in claim 9, further comprising when it is judged that the index master record is not associated with an extension record:
    reading the length information of the data segment from the head; and
    judging whether the length of the data segment is equal to or greater than the preset threshold according to the length information of the data segment.
  12. The method for storing a file index as claimed in claim 9, wherein the step of creating several extension records associated with the index master record comprises:
    creating several extension records and allocating an ID for each extension record respectively;
    recording the IDs of the individual extension records in the data segment; and
    updating the structural flag as indicating that the index master record is associated with an extension record.
  13. The method for storing a file index as claimed in claim 12, wherein the step of storing the to-be-stored data block index in the data segment or a corresponding extension record further comprises:
    setting the bytes of the to-be-stored data block index to be zero in the data segment or the corresponding extension record, if the to-be-stored data block index corresponds to a void of the file.
  14. The method for storing a file index as claimed in claim 13, further comprising:
    when the bytes of all the data block indexes stored in an extension record are all zero, updating the ID of the extension record in the data segment to be a preset value.
  15. The method for storing a file index as claimed in claim 9, further comprising:
    updating the length of the data segment in the head, after storing the to-be-stored data block index in the data segment.
  16. The method for storing a file index as claimed in claim 12, further comprising:
    when it is needed to modify a target extension record, generating a backup extension record of the target extension record, and allocating an ID to the backup extension record;
    modifying the backup extension record according to a modification operation; and
    replacing the ID of the target extension record in the data segment with the ID of the backup extension record after the modification operation is finished.
  17. A computing device for storing a file index comprising at least a processor operating in conjunction with a memory and a plurality of modules, the modules comprising:
    a first judgment module for, when a to-be-stored data block index of a file is received, judging whether the index master record corresponding to the file is associated with an extension record;
    a first storage module for, when it is judged that the index master record is not associated with an extension record, creating several extension records associated with the index master record, if the length of the data segment of the index master record is equal to or greater than a preset threshold;
    wherein the first storage module is further used for storing a stored data block index in the data segment and the to-be-stored data block index in a corresponding extension record.
  18. The computing device for storing a file index as claimed in claim 17, further comprising:
    a second storage module for, when it is judged that the index master record is not associated with an extension record, storing the to-be-stored data block index in the data segment of the index master record, if the length of the data segment is less than the preset threshold.
  19. The computing device for storing a file index as claimed in claim 18, further comprising:
    a third storage module for storing the to-be-stored data block index in a corresponding extension record, when it is judged that the index master record is associated with an extension record.
  20. The computing device for storing a file index as claimed in claim 19, wherein the data block index comprises the ID and the effective data length of the data block.
  21. The computing device for storing a file index as claimed in claim 19, wherein the data block index has a fixed length.
  22. The computing device for storing a file index as claimed in claim 19, wherein the data block index is stored in the data segment or the extension record in the form of an array, and the extension record associated with the index master record is also stored in the form of an array.
  23. The computing device for storing a file index as claimed in claim 22, wherein each extension record is used for storing data block indexes of a specified number.
  24. The computing device for storing a file index as claimed in claim 23, wherein the third storage module is used for:
    judging whether data block indexes stored in the last extension record in the array of extension records is equal to or greater than the specified number, when it is judged that the index master record is associated with an extension record;
    if data block indexes stored in the last extension record are equal to or greater than the specified number, creating again an extension record associated with the index master record, and storing the to-be-stored data block index in the created extension record; and
    if data block indexes stored in the last extension record are less than the specified number, storing the to-be-stored data block index in the last extension record.
  25. The computing device for storing a file index as claimed in claim 19, wherein the index master record comprises a head and the data segment, the head comprises a structural flag and length information of the data segment; and
    the structural flag indicates whether the index master record is associated with an extension record.
  26. The computing device for storing a file index as claimed in claim 25, wherein the first judgment module is used for:
    reading the structural flag from the head; and
    judging whether the index master record is associated with an extension record according to the structural flag.
  27. The computing device for storing a file index as claimed in claim 25, further comprising a second judgment module for:
    reading the length information of the data segment from the head, when it is judged that the index master record is not associated with an extension record; and
    judging whether the length of the data segment is equal to or greater than the preset threshold according to the length information of the data segment.
  28. The computing device for storing a file index as claimed in claim 25, wherein the first storage module is used for:
    creating several extension records and allocating an ID for each extension record respectively;
    recording the IDs of the individual extension records in the data segment; and
    updating the structural flag as indicating that the index master record is associated with an extension record.
  29. The computing device for storing a file index as claimed in claim 28, wherein the first storage module, the second storage module and the third storage module further respectively comprise:
    a first storage sub-module for, when the to-be-stored data block index is stored in the data segment or in a corresponding extension record, setting the bytes of the to-be-stored data block index to be zero in the data segment or the corresponding extension record, if the to-be-stored data block index corresponds to a void of the file.
  30. The computing device for storing a file index as claimed in claim 29, wherein the first storage module and the third storage module further respectively comprise:
    a second storage sub-module for, when the bytes of all the data block indexes stored in an extension record are all zero, updating the ID of the extension record in the data segment to be a preset value.
  31. The computing device for storing a file index as claimed in claim 25, wherein the second storage module is further used for:
    updating the length of the data segment in the head, after storing the to-be-stored data block index in the data segment.
  32. The computing device for storing a file index as claimed in claim 28, further comprising a modifying module for:
    when it is needed to modify a target extension record, generating a backup extension record of the target extension record, and allocating an ID to the backup extension record;
    modifying the backup extension record according to a modification operation; and
    after the modification operation is finished, replacing the ID of the target extension record in the data segment with the ID of the backup extension record.
  33. A computer program product for storing a file index, comprising:
    a non-transitory computer readable medium having computer readable program codes embodied therein that, when executed by a processor, causes the processor to:
    judge whether an index master record corresponding to a file is associated with an extension record when a to-be-stored data block index of the file is received;
    when it is judged that the index master record is not associated with an extension record, create several extension records associated with the index master record, if the length of the data segment of the index master record is equal to or greater than a preset threshold; and
    store a stored data block index in the data segment and the to-be-stored data block index in a corresponding extension record.
PCT/CN2014/085219 2013-08-26 2014-08-26 Method, computing device, and computer program product for storing file index WO2015027902A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201310375596.9A CN104424224B (en) 2013-08-26 2013-08-26 A kind of file index storage method and device
CN201310375596.9 2013-08-26

Publications (1)

Publication Number Publication Date
WO2015027902A1 true WO2015027902A1 (en) 2015-03-05

Family

ID=52585589

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/085219 WO2015027902A1 (en) 2013-08-26 2014-08-26 Method, computing device, and computer program product for storing file index

Country Status (2)

Country Link
CN (1) CN104424224B (en)
WO (1) WO2015027902A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107132993A (en) * 2016-02-26 2017-09-05 高德软件有限公司 A kind of method and device for writing data into internal memory
CN109597571A (en) * 2018-11-15 2019-04-09 金蝶软件(中国)有限公司 Date storage method, method for reading data, device and computer equipment

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106446201A (en) * 2016-09-30 2017-02-22 福建中金在线信息科技有限公司 Processing method and device of social circle data
CN110874388A (en) * 2018-08-31 2020-03-10 阿里巴巴集团控股有限公司 Data storage and reading method, data processing device and electronic equipment
CN110231997A (en) * 2019-06-11 2019-09-13 浪潮软件集团有限公司 A kind of method and system of quick creation message queue file
CN112817980A (en) * 2021-02-05 2021-05-18 腾讯科技(深圳)有限公司 Data index processing method, device, equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1878301A (en) * 2006-07-19 2006-12-13 杭州华为三康技术有限公司 Video monitoring data storage managing method and system
CN1979469A (en) * 2005-11-29 2007-06-13 国际商业机器公司 Index and its extending and searching method
US20090292947A1 (en) * 2008-05-21 2009-11-26 Oracle International Corporation Cascading index compression
CN102968478A (en) * 2012-11-19 2013-03-13 天津书生投资有限公司 Indexing and searching method
CN103186537A (en) * 2011-12-27 2013-07-03 腾讯科技(北京)有限公司 Data reading-writing method and device based on index sorting

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2004095716A2 (en) * 2003-04-17 2004-11-04 Fieldbus Foundation System and method for implementing safety instrumented systems in a fieldbus architecture
CN100561474C (en) * 2006-01-17 2009-11-18 鸿富锦精密工业(深圳)有限公司 Indexes of remote files at multiple points synchro system and method
CN101021842A (en) * 2007-03-09 2007-08-22 清华大学 Automatic learning and extending evolution handling method for Chinese basic block descriptive rule
CN102193917B (en) * 2010-03-01 2014-03-26 中国移动通信集团公司 Method and device for processing and querying data
US8380736B2 (en) * 2010-05-21 2013-02-19 Microsoft Corporation De-duplication in billing system
US8407208B2 (en) * 2011-02-02 2013-03-26 Nanorep Technologies Ltd Method for matching queries with answer items in a knowledge base
CN102646130B (en) * 2012-03-12 2013-08-14 华中科技大学 Method for storing and indexing mass historical data
CN103064906B (en) * 2012-12-18 2016-08-03 华为技术有限公司 File management method and device
CN104239316B (en) * 2013-06-13 2018-09-07 深圳市腾讯计算机系统有限公司 Search the method and device of object

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1979469A (en) * 2005-11-29 2007-06-13 国际商业机器公司 Index and its extending and searching method
CN1878301A (en) * 2006-07-19 2006-12-13 杭州华为三康技术有限公司 Video monitoring data storage managing method and system
US20090292947A1 (en) * 2008-05-21 2009-11-26 Oracle International Corporation Cascading index compression
CN103186537A (en) * 2011-12-27 2013-07-03 腾讯科技(北京)有限公司 Data reading-writing method and device based on index sorting
CN102968478A (en) * 2012-11-19 2013-03-13 天津书生投资有限公司 Indexing and searching method

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107132993A (en) * 2016-02-26 2017-09-05 高德软件有限公司 A kind of method and device for writing data into internal memory
CN107132993B (en) * 2016-02-26 2021-02-02 阿里巴巴(中国)有限公司 Method and device for writing data into memory
CN109597571A (en) * 2018-11-15 2019-04-09 金蝶软件(中国)有限公司 Date storage method, method for reading data, device and computer equipment

Also Published As

Publication number Publication date
CN104424224B (en) 2019-09-20
CN104424224A (en) 2015-03-18

Similar Documents

Publication Publication Date Title
WO2015027902A1 (en) Method, computing device, and computer program product for storing file index
EP2736235B1 (en) Mobile terminal and data provision method thereof
CN103019960B (en) Distributed caching method and system
CN111868750A (en) Machine learning system for content transmission with reduced network bandwidth
CN107786638B (en) Data processing method, device and system
CN109690519A (en) A kind of document handling method and mobile terminal
CN104995895A (en) Compatibly extending offload token size
US20130297563A1 (en) Timestamp management method for data synchronization and terminal therefor
US20160234340A1 (en) Systems and methods for adaptive cloning of mobile devices
CN103530160A (en) Page loading method and device
US11314703B2 (en) Method and apparatus for processing timedly-published data
CN103491152A (en) Metadata obtaining method, device and system in distributed file system
CN103677674A (en) Data processing method and device
US20220138155A1 (en) Locating files using a durable and universal file identifier
US10848558B2 (en) Method and apparatus for file management
CN104063377A (en) Information processing method and electronic equipment using same
CN103412898A (en) Method and device for optimizing webpage
CN104834723A (en) Display processing method and device of map
CN103995706A (en) Method and device for displaying picture thumbnail
CN116991800A (en) File acquisition system, method, device, computer equipment and storage medium
EP3343395A1 (en) Data storage method and apparatus for mobile terminal
CN103795806A (en) Method for achieving cloud storage for mobile terminal
JP2016515258A (en) File aggregation for optimized file operation
CN113301203B (en) Method and device for updating historical information data based on address book
CN104777981A (en) Information fast sharing method and device

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 14840194

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 160616)

122 Ep: pct application non-entry in european phase

Ref document number: 14840194

Country of ref document: EP

Kind code of ref document: A1