File editing method and device, electronic equipment and storage medium

By recording editing operations in bytes and writing back to the file during file editing, the time-consuming problem of editing large files is solved, and efficient file editing is achieved.

CN120179619APending Publication Date: 2025-06-20BEIJING HUAFENG TEST & CONTROL TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311753491.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-19
Publication Date
2025-06-20

AI Technical Summary

Technical Problem

When processing large files, the prior art requires loading files into memory in chunks, and each modification operation requires writing back to the file instantly, resulting in frequent disk read and write time.

Method used

By recording the file editing operation in bytes in the editing record table, recording the current status data location, source file data location and edited data, and writing the editing operation back to the corresponding position of the source file data based on this information, the target file data is obtained.

Benefits of technology

It realizes that changes in file data can be recorded without directly manipulating files, and writes changes back to the file at a minimum cost, improving the efficiency of file editing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120179619A_ABST
    Figure CN120179619A_ABST
Patent Text Reader

Abstract

The invention discloses a file editing method and device, electronic equipment and a storage medium. The method comprises the steps that editing operation on source file data is recorded in an editing record table with bytes as units, the editing record table comprises one or more of a current state data position, a source file data position and edited data, and the current state data position indicates the position of edited data in the current state; the source file data position indicates the position where the editing operation is mapped to the source file data; based on the editing record table and the size of the source file data, determining change information of the size of the storage space occupied by the source file data; and based on the editing record table, the source file data and the change information, writing the editing operation recorded in the editing record table back to a position corresponding to the source file data to obtain target file data. According to the scheme, the change of the data in the file can be recorded without directly operating the file, the change can be written back to the file at the minimum cost, and the file editing efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present invention relate to the field of computer technologies, and in particular, to a file editing method, apparatus, electronic device, and storage medium. Background Art

[0002] In software design, if a file needs to be modified, generally it needs to be loaded into memory, and after the data modification is completed, it is written back to the file. When the file is too large, such as an engineering file in the testing field or a large file in other fields, and the physical memory size cannot accommodate the entire file, the file will be loaded in chunks. When using the above solution, all modification operations need to be written back to the file immediately to ensure the consistency of the overall state. However, inserting new data or deleting data in a file will cause the data after the operation position to move. In the case of a huge file size, a large number of disk read and write operations generated by each modification operation will cause serious time consumption. Summary of the Invention

[0003] The present invention provides a file editing method, apparatus, electronic device, and storage medium, which can record the changes of data in a file without directly operating on the file, and can write the changes back to the file at the smallest cost, thereby improving the efficiency of editing the file.

[0004] In a first aspect, embodiments of the present invention provide a file editing method, including:

[0005] Recording the editing operations on the source file data in units of bytes in an edit record table, where the edit record table includes one or more of the current state data position, the source file data position, and the edited data, the current state data position indicates the position of the edited data in the current state, and the source file data position indicates the position of the edit operation mapped to the source file data;

[0006] Determining the change information of the storage space size occupied by the source file data based on the edit record table and the size of the source file data;

[0007] Writing the editing operations recorded in the edit record table back to the corresponding position of the source file data based on the edit record table, the source file data, and the change information to obtain the target file data.

[0008] In a second aspect, embodiments of the present invention provide a file editing apparatus, including:

[0009] An editing record module, configured to record editing operations on source file data in bytes in an editing record table, where the editing record table includes one or more of a current state data position, a source file data position, and edited data, the current state data position indicating the position of the edited data in the current state, and the source file data position indicating the position in the source file data to which the editing operation is mapped;

[0010] A determination module, configured to determine information on changes in the storage space size occupied by the source file data based on the editing record table and the size of the source file data;

[0011] An editing write-back module, configured to write back the editing operations recorded in the editing record table to the corresponding position of the source file data based on the editing record table, the source file data, and the change information, to obtain target file data.

[0012] In a third aspect, an embodiment of the present invention provides an electronic device, including:

[0013] At least one processor; and

[0014] A memory communicatively connected to the at least one processor; wherein,

[0015] The memory stores a computer program executable by the at least one processor, and when the computer program is executed by the at least one processor, the at least one processor is enabled to execute the method as described in the first aspect.

[0016] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the method as described in the first aspect is implemented.

[0017] The technical solution of the embodiment of the present invention can record changes in data in a file without directly operating on the file by recording editing operations on source file data in bytes in an editing record table. Based on the editing record table, the source file data, and the change information on the storage space size occupied by the source file data, the editing operations recorded in the editing record table can be written back to the corresponding position of the source file data to obtain target file data, and the changes can be written back to the file at the lowest cost, which can improve the efficiency of editing the file.

[0018] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present invention, nor is it used to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] To more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the accompanying drawings required for the description of the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can be obtained based on these drawings.

[0020] Figure 1 is a flowchart of a file editing method provided in Embodiment 1 of the present invention;

[0021] Figure 2 is a flowchart of a file editing method provided in Embodiment 2 of the present invention;

[0022] Figure 3 is a flowchart of another file editing method provided in Embodiment 2 of the present invention;

[0023] Figure 4 is a flowchart of determining target query data corresponding to the position of to-be-query status data provided in Embodiment 2 of the present invention;

[0024] Figure 5 is a schematic structural diagram of a file editing device provided in Embodiment 3 of the present invention;

[0025] Figure 6 is a schematic structural diagram of an electronic device for implementing the file editing method of the embodiments of the present invention. Detailed Embodiments

[0026] In order to enable those skilled in the art to better understand the solutions of the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, rather than all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

[0027] It should be noted that the terms "first", "second", etc. in the present invention are used to distinguish similar objects and do not necessarily describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products, or devices.

[0028] It is understandable that before using the technical solutions disclosed in the embodiments of the present invention, the types, usage scopes, usage scenarios, etc. of the personal information involved in this disclosure should be informed to the user and the user's authorization should be obtained through appropriate means in accordance with relevant laws and regulations.

[0029] Embodiment 1

[0030] Figure 1 FIG. is a flowchart of a file editing method provided according to Embodiment 1 of the present invention. This embodiment is applicable to the situation of editing a file. The method can be executed by a file editing device, and the device can be implemented in the form of software and / or hardware and integrated in an electronic device. Further, the electronic device includes, but is not limited to: a computer, a laptop, a server, etc. As Figure 1 shown, the method includes:

[0031] S110. Record the editing operation on the source file data in bytes in an editing record table. The editing record table includes one or more of the current state data position, the source file data position, and the edited data. The current state data position indicates the position of the edited data in the current state, and the source file data position indicates the position of the editing operation mapped to the source file data.

[0032] The source file data can be the data in the source file that needs to be edited. The source file can be a file whose memory size exceeds a certain value, such as an engineering file in the field of automatic testing or a large file in other fields. The editing operation can be an operation to edit the source file data, including but not limited to operations such as data insertion, data deletion, and data modification on the source file data. The current state can be the state recorded in the editing record table after one or more edits. The current state data position can be the data position in the virtual target file obtained by virtual write-back of the source file.

[0033] In an embodiment of the present invention, the access to the source file data can be completed through an interface provided by the operating system for implementing memory mapping. Through this interface, the memory mapping address of the source file data can be obtained, and the reading and modification of the source file data only need to access this continuous address. For example, during memory mapping, the offset of the data at any position in the source file data compared to the starting position can be recorded in bytes, and the recorded offset can be regarded as the memory mapping address, and the starting position can be the starting position when the source file data is memory mapped. Since the access to the source file data is implemented by means of memory mapping, memory mapping refers to mapping the space occupied by a file on the disk to a virtual memory address, and the software can directly operate on the file just like operating on the memory space. This process does not require loading the file into the memory, which improves the loading speed of large files and can break through the limit of the physical memory size to load files of any size. Therefore, the memory size occupied by the source file data can exceed the physical memory size of the device, and there is no need to perform block processing on the source file data during access.

[0034] In the present invention, the source file data can be edited in units of bytes. Each time an editing operation is performed, the content related to the editing operation can be recorded in an editing record table. The editing record table can be a table for recording the editing operations on the source file data.

[0035] The editing record table includes one or more of the current state data position, the source file data position, and the edited data. The current state data position can be the position of the edited data in the current state. The source file data position can be the position where the editing operation is mapped to the source file data. The edited data indicates the data corresponding to the current state data position or the source file data position after the editing operation is executed. The edited data can be the data newly inserted into the source file data, or the data after the data in the source file data is modified. Among them, the positions involved above can all be understood as memory mapping addresses, and the memory mapping address indicates the offset of this position compared to the starting position.

[0036] Recording the editing operations on the source file data in units of bytes can be understood as a process of recording one or more of the current state data position, the source file data position, and the edited data in the editing record table as the editing operation progresses.

[0037] In one embodiment, the editing operation includes one or more of a data insertion operation, a data deletion operation, and a data modification operation;

[0038] The editing record table includes one or more of an insert / delete table and a modification data table;

[0039] The insert-delete table includes one or more insert-delete records, and each insert-delete record corresponds to one data insertion operation or one data deletion operation; the insert-delete record includes the current state data position, the source file data position, and the edited data arranged in sequence; each current state data position in the insert-delete table indicates the offset compared to the starting position during memory mapping with the source file data, and each current state data position is arranged in ascending order of the offset;

[0040] The modified data table includes one or more data modification records corresponding to the data modification operation, and the data modification record includes the source file data position and the edited data arranged in sequence.

[0041] Among them, the data insertion operation can be an operation of inserting new data into the source file data, and one byte can be inserted into the source file data through one data insertion operation. The data deletion operation can be an operation of deleting data in the source file data, and one or more bytes can be deleted from the source file data through one data deletion operation. The data modification operation can be an operation of modifying the existing data in the source file data. The edit record table includes one or more of the insert-delete table and the modified data table. The data insertion operation and the data deletion operation can be recorded in the insert-delete table, and the data modification operation can be recorded in the modified data table.

[0042] Table 1 is the insert-delete table provided in the first embodiment of the present invention. In Table 1, each row corresponds to an insert-delete record of a data insertion operation or a data deletion operation, and the insert-delete record can be a record generated by a data insertion operation or a data deletion operation.

[0043] Table 1 Insert-Delete Table

[0044] Current status data location Source file data location Edited data

[0045] For the data insertion operation, the data insertion operation on the source file data is recorded in the insert-delete table in units of bytes. It can be determined that the position where data needs to be inserted in the current state is the current state data position, the position where the data insertion operation is mapped to the invalid position of the source file data is the source file data position, and the inserted data is the edited data. Among them, the position where the data insertion operation is mapped to the invalid position of the source file data can be represented by an insert flag. The insert flag can be a flag indicating that new data has been inserted currently. The insert flag can be specific data. For example, the insert flag can be -1, which is not limited here.

[0046] For the data deletion operation, record the data deletion operation on the source file data in bytes in the insert-delete table. It can be to determine the position of the data to be deleted in the current state as the current state data position, and determine the position in the source file data that the data corresponding to the current state data position should map to after the data deletion operation as the source file data position. The data after editing is empty.

[0047] In the insert-delete table, each current state data position indicates the offset compared to the starting position when performing memory mapping with the source file data. Each current state data position can be arranged in ascending order of the offset from front to back in sequence, that is, arranged from top to bottom in the table. During the sequential arrangement according to the offset, the insert-delete records corresponding to each current state data position move as the corresponding current state data position moves.

[0048] It should be noted that since adding an insert-delete record in the insert-delete table will affect the insert-delete records arranged after this insert-delete record, it is necessary to update the current state data positions included in the subsequent insert-delete records to ensure the rationality of the current state data positions of the records in the insert-delete table during the data insertion or deletion process.

[0049] In one embodiment, in the insert-delete table, it can also be that each column corresponds to an insert-delete record for a data insertion operation or a data deletion operation, which is not limited here.

[0050] Table 2 is the modified data table provided in the first embodiment of the present invention. In Table 2, each row corresponds to a data modification record for a data modification operation, and the data modification record can be a record generated by the data modification operation.

[0051] Table 2 Modified Data Table

[0052] Source file data location Edited data

[0053] For the data modification operation, record the data modification operation on the source file data in bytes in the modified data table. It can be to determine the position of the data to be modified in the source file data as the source file data position, and determine the modified data as the data after editing.

[0054] In one embodiment, in the modified data table, it can also be that each column corresponds to a data modification record for a data modification operation, which is not limited here.

[0055] S120. Determine the change information of the storage space size occupied by the source file data based on the edit record table and the size of the source file data.

[0056] When the edit record table includes an insert / delete table, determine the last insert / delete record that is arranged from front to back and does not indicate the existence of an invalid position in the insert / delete table, and determine it as the target insert / delete record. Based on the target current state data position and target source file data position included in the target insert / delete record, the number of insert / delete records arranged after the target insert / delete record, and the size of the source file data, determine the size of the edited source file data.

[0057] If the size of the edited source file data is greater than the size of the unedited source file data, the change information indicating the change in the storage space size occupied by the source file data indicates that the size of the source file data is first expanded to the size of the edited source file data, and then the edit operation is written back to the position corresponding to the source file data; otherwise, the change information indicates that the edit operation is first written back to the position corresponding to the source file data, and then the size of the source file data is updated. The update method can be to discard the invalid data at the end of the source file. Among them, the change information can be information indicating the way to change the storage space size occupied by the source file data.

[0058] It should be noted that since in the modification data table included in the edit record table, only the modification of data is involved and not the movement of data positions in the source file, when determining the change information indicating the change in the storage space size occupied by the source file data, the influence of the modification data table can be ignored.

[0059] S130. Based on the edit record table, the source file data, and the change information, write the edit operation recorded in the edit record table back to the position corresponding to the source file data to obtain the target file data.

[0060] Based on the change information determined in step S120, in this step, it can be determined whether to first expand the size of the source file data to the size of the edited source file data and then write the edit operation back to the position corresponding to the source file data; or to first write the edit operation back to the position corresponding to the source file data and then discard the invalid data at the end of the source file. Among them, the process of writing the edit operation of the source file data back to the position corresponding to the source file data is as follows:

[0061] For the modification data table included in the edit record table, since it does not involve the movement of data positions, each edited data in the modification data table can be directly replaced at the position indicated by the source file data position corresponding to the edited data in the source file data.

[0062] For the insert / delete table included in the edit record table, the insert / delete table can be split into a move table and an overwrite table. The move table can be a table indicating the position movement of data in the source file data. In the move table, the position obtained by increasing the offset indicated by the current state data position corresponding to any data insertion operation in the insert / delete table by one byte can be recorded, as well as the position of the source file data corresponding to the current state data position after increasing by one byte; in the move table, the current state data position and the source file data position corresponding to any data deletion operation in the insert / delete table can also be recorded. The overwrite table can be a table indicating the overwrite of data in the source file data. In the overwrite table, the position where data needs to be overwritten in the current state and the data to be overwritten corresponding to this position can be recorded. The position where data needs to be overwritten is the position where data is inserted through any data insertion operation in the current state, and the data to be overwritten corresponding to this position is the data to be inserted through any data insertion operation in the current state. After determining the move table and the overwrite table, the data in the source file data can be moved in the form of data segments based on the move table, and then the data in the moved source file data can be overwritten based on the overwrite table.

[0063] The target file data can be the data obtained after writing the edit operation on the source file data back to the corresponding position of the source file data. The target file data can be understood as the data obtained by writing the operations indicated by the insert / delete records in the insert / delete table back to the source file data, and / or the data obtained by writing the operations indicated by the data modification records in the data modification table back to the source file data.

[0064] It should be noted that when the insert / delete table and the data modification table exist simultaneously, the operations indicated by the data modification records in the data modification table should be written back to the source file data first, and then the operations indicated by the insert / delete records in the insert / delete table should be written back to the source file data, and finally the target file data is obtained.

[0065] The technical solution of the embodiment of the present invention can record the changes of data in the file without directly operating on the file by recording the edit operations on the source file data in bytes in the edit record table. By based on the edit record table, the source file data, and the change information of the storage space size occupied by the source file data, the edit operations recorded in the edit record table can be written back to the corresponding position of the source file data to obtain the target file data, and the changes can be written back to the file at the lowest cost, which can improve the efficiency of editing the file.

[0066] Embodiment 2

[0067] This embodiment is a further refinement based on the above Embodiment 1.

[0068] Figure 2 It is a flowchart of a file editing method provided according to Embodiment 2 of the present invention.Figure 2 The method shown is a further refinement of the above step S110, which records the editing operations on the source file data in the edit record table in bytes. As Figure 2 shown, the method includes:

[0069] S111. When the editing operation includes a data insertion operation, a first insert-delete record is added to the insert-delete table. The first current state data position in the first insert-delete record indicates the position where the data is inserted in the current state. The first source file data position indicates the invalid position of the data insertion operation mapped to the source file data. The first edited data indicates the inserted data. And the offsets indicated by the current state data positions included in the insert-delete records arranged after the first insert-delete record in the insert-delete table are all increased by one byte.

[0070] S112. When the editing operation includes a data deletion operation, a second insert-delete record is added to the insert-delete table. The second current state data position in the second insert-delete record indicates the position where the data is deleted in the current state. The second source file data position indicates the position of the data corresponding to the second current state data position after deletion mapped to the source file data. The second edited data is empty. And the offsets indicated by the current state data positions included in the insert-delete records arranged after the second insert-delete record in the insert-delete table are reduced based on the deletion length. The deletion length is determined based on the second source file data position and the position of the data corresponding to the second current state data position before deletion mapped to the source file data.

[0071] Steps S111 and S112 are described by the following content:

[0072] Table 3 is an insert-delete table provided in the second embodiment of the present invention. In Table 3, there is already an insert-delete record. Among them, the source file data position is "-1". It can be understood that the data insertion operation is indicated by the insert identifier "-1" mapped to the invalid position of the source file data. Then the operation indicated by this insert-delete record is a data insertion operation, and this data insertion operation indicates that in the current state, at the current state data position of 10, the edited data data1 is inserted.

[0073] Table 3 Insert-Delete Table

[0074] Current status data location Source file data location Edited data 10 -1 [data1]

[0075] Table 4 is another insertion and deletion table provided in the second embodiment of the present invention. Table 4 is the insertion and deletion table after performing the data deletion operation corresponding to step S112 on the basis of Table 3. As shown in Table 4, a second insertion and deletion record is added to the insertion and deletion table. The second current state data position 3 in the second insertion and deletion record indicates the position of the deleted data in the current state; the second source file data position 4 indicates the position where the data corresponding to the second current state data position 3 after deletion is mapped to the source file data; the second edited data is empty. Then this second insertion and deletion record indicates that one byte is deleted at the position with an offset of 3 in the current state.

[0076] When adding the second insertion and deletion record, the principle that the offsets indicated by each current state data position are arranged in ascending order from front to back should be followed, and the second insertion and deletion record is added before the insertion and deletion records in the insertion and deletion table of Table 3. And based on the deletion length, the offsets indicated by the current state data positions included in the insertion and deletion records arranged after this second insertion and deletion record in Table 4 are reduced. Among them, the deletion length can be determined by subtracting the position where the data corresponding to the second current state data position 3 before deletion is mapped to the source file data 3 from the second source file data position 4. It can be seen from this that the deletion length is one byte. Therefore, the current state data position 10 in Table 3 can be reduced by one byte to obtain the current state data position 9 in Table 4.

[0077] Table 4 Insertion and Deletion Table

[0078]

[0079] Table 5 is another insertion and deletion table provided in the second embodiment of the present invention. Table 5 is another example of the insertion and deletion table after performing the data deletion operation corresponding to step S112 on the basis of Table 3. As shown in Table 5, a second insertion and deletion record is added to the insertion and deletion table. The second current state data position 3 in the second insertion and deletion record indicates the position of the deleted data in the current state; the second source file data position 5 indicates the position where the data corresponding to the second current state data position 3 after deletion is mapped to the source file data; the second edited data is empty. Then this second insertion and deletion record indicates that 2 bytes are deleted at the position with an offset of 3 in the current state.

[0080] When adding a second insert / delete record in Table 5, add the second insert / delete record before the insert / delete records in the insert / delete table of Table 3. And based on the deletion length, reduce the offsets indicated by the current state data positions included in the insert / delete records arranged after the second insert / delete record in Table 5. Among them, the deletion length can be determined by mapping the data corresponding to the second current state data position 3 before deletion to the position 3 of the source file data in the second source file data position 5. It can be seen that the deletion length is 2 bytes. Therefore, the current state data position 10 in Table 3 can be reduced by 2 bytes to obtain the current state data position 8 in Table 5. Among them, the position of the data corresponding to the second current state data position 3 before deletion mapped to the source file data is not necessarily 3 and needs to be determined according to the actual situation of the records in the insert / delete table.

[0081] Table 5 Insert / Delete Table

[0082]

[0083] Table 6 is another insert / delete table provided in the second embodiment of the present invention. Table 6 is the insert / delete table after performing the data insertion operation corresponding to step S111 on the basis of Table 4. As shown in Table 6, a first insert / delete record is added to the insert / delete table. The first source file data position "-1" in the first insert / delete record indicates an invalid position mapped to the source file data, indicating that the operation of the current record is a data insertion operation; the first current state data position 0 indicates the position where the data is inserted in the current state; the first edited data indicates that the inserted data is data2.

[0084] When adding the first insert / delete record, follow the principle that the offsets indicated by the respective current state data positions are arranged in ascending order from front to back. Add the first insert / delete record before each insert / delete record in the insert / delete table of Table 4. And increase the offsets indicated by the current state data positions included in the insert / delete records arranged after the first insert / delete record in Table 6 by one byte, that is, increase the current state data position 3 in Table 4 by one byte to obtain the current state data position 4 in Table 6, and increase the current state data position 9 in Table 4 by one byte to obtain the current state data position 10 in Table 6.

[0085] Table 6 Insert / Delete Table

[0086]

[0087]

[0088] S113. When the editing operation includes a data modification operation, a third data modification record is added to the modification data table. The third source file data position in the third data modification record indicates the position where the modified data is mapped to the source file data, and the third edited data is the modified data.

[0089] When the editing operation includes a data modification operation, a third data modification record is added to the modification data table. The third source file data position in the third data modification record is the position of the data to be modified in the source file data, and the third edited data is the data obtained by modifying the data corresponding to the third source file data position.

[0090] It should be noted that the present invention embodiment does not limit the execution order of steps S111, S112, and S113.

[0091] S120. Based on the editing record table and the size of the source file data, determine the change information of the storage space size occupied by the source file data.

[0092] S130. Based on the editing record table, the source file data, and the change information, write the editing operation recorded in the editing record table back to the corresponding position of the source file data to obtain the target file data.

[0093] Figure 3 It is a flowchart of another file editing method provided by Embodiment 2 of the present invention. Figure 3 The method shown further refines the above step S120 of determining the change information of the storage space size occupied by the source file data based on the editing record table and the size of the source file data; and further refines the above step S130 of writing the editing operation recorded in the editing record table back to the corresponding position of the source file data based on the editing record table, the source file data, and the change information to obtain the target file data. As Figure 3 shown, the method includes:

[0094] S110. Record the editing operation on the source file data in the editing record table in units of bytes.

[0095] S121. Determine the target insert / delete record in the insert / delete table included in the editing record table. The target insert / delete record is the last insert / delete record in the insert / delete table that does not indicate the existence of an invalid position.

[0096] The target insert / delete record is the last insert / delete record arranged from front to back in the insert / delete table that does not indicate the existence of an invalid position (that is, there is no insert flag "-1"), that is, the target insert / delete record in Table 6 (that is, the target current state data position is 4, and the target source file data position is 4).

[0097] S122. Determine the size of the edited source file data based on the target current state data position and target source file data position included in the target insert / delete record, the number of insert / delete records arranged after the target insert / delete record, and the size of the source file data.

[0098] The expression for determining the size of the edited source file data is: p1 + (origin - m1) + n1. Here, p1 is the target current state data position; m1 is the target source file data position; origin is the size of the source file data; n1 is the number of insert / delete records after the target insert / delete record.

[0099] S123. Determine the change information based on the size of the source file data and the size of the edited source file data.

[0100] If the size of the edited source file data is greater than the size of the source file data, the change information indicates first expanding the size of the source file data to the size of the edited source file data, and then writing the edit operation back to the corresponding position of the source file data; otherwise, the change information indicates first writing the edit operation back to the corresponding position of the source file data, and then updating the size of the source file data. The update method can be to discard the invalid data at the end of the source file.

[0101] S131. For the modified data table included in the edit record table, in the source file data, replace each edited data in the modified data table with the position indicated by the source file data position of the corresponding edited data to obtain the first file data.

[0102] S132. For the insert / delete table included in the edit record table, split the insert / delete table into a move table and a cover table; move the data in the source file data based on the move table; cover the data in the moved source file data based on the cover table to obtain the second file data.

[0103] Among them, the target file data includes one or more of the first file data and the second file data; when the target file data includes the first file data and the second file data, determine the first file data first and then the second file data.

[0104] The change information indicates first expanding the storage space size occupied by the source file data and then writing the edit operation back to the source file data, or indicates first writing the edit operation back to the source file data and then reducing the storage space size occupied by the source file data.

[0105] It should be noted that after step S123, when both the insert / delete table and the modification data table exist, step S131 should be executed first, and then step S132 to obtain the target file data; when there is only the modification data table, only step S131 needs to be executed to obtain the target file data; when there is only the insert / delete table, only step S132 needs to be executed to obtain the target file data.

[0106] For the modification data table included in the edit record table, since it does not involve the movement of data positions, each edited data in the modification data table can be directly replaced at the position indicated by the source file data position of the corresponding edited data in the source file data to obtain the first file data.

[0107] In one embodiment, splitting the insert / delete table into a movement table and an overwrite table includes:

[0108] Increasing the offset indicated by the current state data position included in the insert / delete record with non-empty edited data in the insert / delete table by one byte; based on any of the current state data positions increased by one byte, modifying the corresponding source file data position to the position where the data corresponding to the current state data position increased by one byte is mapped in the source file data; and deleting each edited data in the insert / delete table to obtain the movement table;

[0109] Deleting the insert / delete records with empty edited data in the insert / delete table and deleting each source file data position in the insert / delete table to obtain the overwrite table.

[0110] Table 7 is a movement table provided in the second embodiment of the present invention. Table 7 is based on the insert / delete table shown in Table 6, and the offset indicated by the current state data position included in the insert / delete record with non-empty edited data is increased by one byte. That is, the current state data position 0 in Table 6 is increased by one byte to obtain the current state data position 1 in Table 7, and the current state data position 10 in Table 6 is increased by one byte to obtain the current state data position 11 in Table 7; determining the source file data position corresponding to the current state data position in Table 7, the position where the data corresponding to the current state data position 1 is mapped in the source file data is the offset 0, and the position where the data corresponding to the current state data position 11 is mapped in the source file data is the offset 10; deleting the column where the edited data is located to obtain the movement table.

[0111] Table 7 Movement table

[0112] Current status data location Source file data location 1 0 4 4 11 10

[0113] Table 8 is an overlay table provided in the second embodiment of the present invention. Table 8 is obtained by deleting the rows with empty edited data in the insert / delete table shown in Table 6 and deleting the column where the source file data is located, resulting in the overlay table.

[0114] Table 8 Overlay Table

[0115] Current status data location Edited data 0 [data2] 10 [data1]

[0116] Based on the movement table, the data in the source file data is moved, and based on the overlay table, the data in the moved source file data is overlaid to obtain the second file data.

[0117] Specifically, traverse the movement table in sequence to move the data of the source file. Assume that the current state data position of the current record is p2, the source file data position is m2, and the source file data position of the next record is m3. Then, move the data segment in the source file data starting from the position corresponding to the source file data position m2 with a length of m3 - m2 to the current state data position p2. After the traversal of the movement table is completed, traverse the overlay table, and overlay each edited data in the overlay table to the corresponding current state data position to obtain the second file data.

[0118] In one embodiment, the method further includes:

[0119] By querying the insert / delete table included in the edit record table, determine the target query source file data position corresponding to the to-be-query state data position. The target query source file data position indicates the position where the data corresponding to the to-be-query state data position is mapped to the source file data;

[0120] If the target query source file data position indicates an invalid position mapped to the source file data, then determine the edited data corresponding to the target query source file data position as the target query data corresponding to the to-be-query state data position;

[0121] If the target query source file data position does not indicate an invalid position mapped to the source file data, then query the modified data table included in the edit record table based on the target query source file data position; if the modified data table includes a source file data position that is the same as the target query source file data position, then determine the edited data corresponding to the same source file data position as the target query data, otherwise determine the target query data in the source file data based on the target query source file data position.

[0122] Among them, the position of the status data to be queried can be any offset for querying the data at the corresponding position. Through the position of the status data to be queried, the corresponding target query data can be determined in the source file data based on the edit record table. The target query data can be the data corresponding to the position of the status data to be queried in the source file data.

[0123] By querying the insert / delete table included in the edit record table, determine the target query source file data position corresponding to the position of the status data to be queried. Specifically, if the position of the status data to be queried is the offset indicated by one of the current status data positions in the insert / delete table included in the edit record table, then the source file data position corresponding to this current status data position in the insert / delete table is determined as the target query source file data position corresponding to the position of the status data to be queried.

[0124] If the position of the status data to be queried is not the offset indicated by any of the current status data positions in the insert / delete table, then the expression for determining the target query source file data position is: p4+(P - m4)+n2. Where P is the position of the status data to be queried; p4 and m4 are respectively the current status data position and the source file data position included in the third insert / delete record. The third insert / delete record is the insert / delete record in which the current status data position arranged from front to back in the insert / delete table is less than the position of the status data to be queried and the last one does not indicate the existence of an invalid position; n2 is the number of insert / delete records between the third insert / delete record and the insert / delete record where the position of the status data to be queried is located.

[0125] If the target query source file data position indicates an invalid position mapped to the source file data, it means that the insert / delete record corresponding to the target query source file data position indicates that the current operation is a data insertion operation, and the edited data corresponding to the target query source file data position is determined as the target query data.

[0126] If the target query source file data position does not indicate an invalid position mapped to the source file data, then query the modification data table included in the edit record table based on the target query source file data position. If the modification data table includes a source file data position that is the same as the target query source file data position, it means that there is a data modification operation at this source file data position, and the edited data corresponding to this source file data position in the modification data table needs to be determined as the target query data; otherwise, the target query data can be directly determined in the source file data through the offset indicated by the target query source file data position.

[0127] Figure 4 It is a flowchart for determining the target query data corresponding to the position of the status data to be queried according to Embodiment 2 of the present invention. As Figure 4 shown, it includes the following steps:

[0128] Determine the target query source file data location corresponding to the location of the data to be queried in the status by querying the insert-delete table included in the edit record table;

[0129] Determine whether the target query source file data location is mapped to an invalid location of the source file data?

[0130] If so, obtain the target query data in the insert-delete table, that is, determine the edited data corresponding to the target query source file data location as the target query data;

[0131] If not, query the modified data table included in the edit record table based on the target query source file data location. If the data is hit, that is, the modified data table includes the source file data location that is the same as the target query source file data location, then obtain the target query data in the modified data table; if the data is not hit, then obtain the target query data in the source file data.

[0132] In one embodiment, the method further includes:

[0133] When the number of edit operations recorded in the edit record table exceeds a preset number threshold, trigger an operation to write back the edit operations recorded in the edit record table to the corresponding location of the source file data to clear the edit record table.

[0134] The technical solution of the embodiment of the present invention can adopt a special case of an automatic save mechanism, that is, when the number of edit operations recorded in the insert-delete table and the modified data table reaches a preset number threshold, trigger the automatic save mechanism, and the system performs an automatic save operation to automatically write back the edit operations recorded in the insert-delete table and the modified data table to the source file data, so that the insert-delete table and the modified data table are cleared. After clearing the above two tables, the performance returns to the initial state, so that the query efficiency in the case of too many change records can be guaranteed, and the smooth progress of continued editing can be ensured.

[0135] The technical solution of the embodiment of the present invention can record edit operations in the storage space during the data editing process, rather than directly operating on the file. Therefore, the entire data editing process is smoother and there will be no problem of extremely long time consumption due to the large file size.

[0136] The technical solution of the embodiment of the present invention records edit operations in bytes and can support the editing of any type of file. It is especially suitable for a small number of modifications to large engineering files in the test field. Since an engineering file is a vector file, a vector file is a large file generated by other tools, and users can make a small number of edits on this large file according to their needs. Using this method to process file editing helps users reduce waiting time, improve editing efficiency, thereby improving the overall test efficiency and reducing test costs.

[0137] In the technical solution of the embodiment of the present invention, during the process of writing the edit operation back to the corresponding position of the source file data, it is ensured that each byte of the source file only moves once, minimizing the disk write volume, reducing the save time, and reducing the consumption of the disk life. Before saving the edit operation, if it is necessary to discard the edit operation, it is only necessary to clear the insertion and deletion table and the modified data table in the storage space, which will not affect the source file data.

[0138] Embodiment III

[0139] Figure 5 FIG. is a schematic structural diagram of a file editing device according to Embodiment III of the present invention. This embodiment is applicable to the situation of editing a file, such as Figure 5 As shown, the specific structure of the device includes:

[0140] An edit record module 51, configured to record the edit operation on the source file data in units of bytes in an edit record table, where the edit record table includes one or more of the current state data position, the source file data position, and the edited data. The current state data position indicates the position of the edited data in the current state, and the source file data position indicates the position where the edit operation is mapped to the source file data;

[0141] A determination module 52, configured to determine the change information of the storage space size occupied by the source file data based on the edit record table and the size of the source file data;

[0142] An edit write-back module 53, configured to write back the edit operation recorded in the edit record table to the corresponding position of the source file data based on the edit record table, the source file data, and the change information, to obtain target file data.

[0143] The file editing device provided in this embodiment records the editing operations on the source file data in the editing record table in units of bytes through the editing record module. The editing record table includes one or more of the current state data position, the source file data position, and the edited data. The current state data position indicates the position of the edited data in the current state, and the source file data position indicates the position of the editing operation mapped to the source file data. The determination module determines the change information of the storage space size occupied by the source file data based on the editing record table and the size of the source file data. The editing write-back module writes back the editing operations recorded in the editing record table to the corresponding position of the source file data based on the editing record table, the source file data, and the change information to obtain the target file data. By recording the editing operations on the source file data in the editing record table in units of bytes, this solution can record the changes in the data in the file without directly operating on the file. Based on the editing record table, the source file data, and the change information of the storage space size occupied by the source file data, the editing operations recorded in the editing record table can be written back to the corresponding position of the source file data to obtain the target file data, and the changes can be written back to the file at the lowest cost, which can improve the efficiency of editing the file.

[0144] Further, the editing operation includes one or more of a data insertion operation, a data deletion operation, and a data modification operation;

[0145] The editing record table includes one or more of an insertion and deletion table and a data modification table;

[0146] The insertion and deletion table includes one or more insertion and deletion records, and each insertion and deletion record corresponds to one data insertion operation or one data deletion operation. The insertion and deletion record includes the current state data position, the source file data position, and the edited data arranged in sequence. Each current state data position in the insertion and deletion table indicates the offset compared to the starting position during the memory mapping with the source file data, and the current state data positions are arranged in ascending order of the offset.

[0147] The data modification table includes one or more data modification records corresponding to the data modification operation, and the data modification record includes the source file data position and the edited data arranged in sequence.

[0148] Further, the editing record module 51 is specifically configured to:

[0149] When the editing operation includes the data insertion operation, a first insertion / deletion record is newly added to the insertion / deletion table. The first current state data position in the first insertion / deletion record indicates the position where data is inserted in the current state, the first source file data position indicates the invalid position of the data insertion operation mapped to the source file data, and the first edited data indicates the inserted data; and the offsets indicated by the current state data positions included in the insertion / deletion records arranged after the first insertion / deletion record in the insertion / deletion table are all increased by one byte.

[0150] When the editing operation includes the data deletion operation, a second insertion / deletion record is newly added to the insertion / deletion table. The second current state data position in the second insertion / deletion record indicates the position where data is deleted in the current state, the second source file data position indicates the position of the data corresponding to the second current state data position after deletion mapped to the source file data, and the second edited data is empty; and the offsets indicated by the current state data positions included in the insertion / deletion records arranged after the second insertion / deletion record in the insertion / deletion table are reduced based on the deletion length; the deletion length is determined based on the second source file data position and the position of the data corresponding to the second current state data position before deletion mapped to the source file data.

[0151] When the editing operation includes the data modification operation, a third data modification record is newly added to the modification data table. The third source file data position in the third data modification record indicates the position of the modified data mapped to the source file data, and the third edited data is the modified data.

[0152] Further, the determination module 52 is specifically configured to:

[0153] Determine the target insertion / deletion record in the insertion / deletion table included in the editing record table, where the target insertion / deletion record is the last insertion / deletion record arranged in the insertion / deletion table that does not indicate the existence of an invalid position;

[0154] Based on the target current state data position and the target source file data position included in the target insertion / deletion record, the number of insertion / deletion records arranged after the target insertion / deletion record, and the size of the source file data, determine the size of the edited source file data;

[0155] Based on the size of the source file data and the size of the edited source file data, determine the change information.

[0156] Further, the editing write-back module 53 is specifically configured to:

[0157] For the modified data table included in the editing record table, in the source file data, replace each edited data in the modified data table with the position indicated by the source file data position corresponding to the edited data to obtain the first file data;

[0158] For the insert / delete table included in the editing record table, split the insert / delete table into a move table and a overwrite table; move the data in the source file data based on the move table; overwrite the data in the moved source file data based on the overwrite table to obtain the second file data;

[0159] Wherein, the target file data includes one or more of the first file data and the second file data; when the target file data includes the first file data and the second file data, first determine the first file data and then determine the second file data;

[0160] The change information indicates to first expand the storage space size occupied by the source file data and then write the edit operation back to the source file data, or indicates to first write the edit operation back to the source file data and then reduce the storage space size occupied by the source file data.

[0161] Further, the edit write-back module 53 is specifically configured to:

[0162] Increase the offset indicated by the current status data position included in the insert / delete record where the edited data is not empty in the insert / delete table by one byte; based on any of the current status data positions increased by one byte, modify the corresponding source file data position to the position where the data corresponding to the current status data position increased by one byte is mapped to the source file data; and delete each edited data in the insert / delete table to obtain the move table;

[0163] Delete the insert / delete records where the edited data in the insert / delete table is empty, and delete each source file data position in the insert / delete table to obtain the overwrite table.

[0164] Further, the device further includes:

[0165] The first query module is configured to determine the target query source file data position corresponding to the to-be-query status data position by querying the insert / delete table included in the editing record table, and the target query source file data position indicates the position where the data corresponding to the to-be-query status data position is mapped to the source file data;

[0166] A second query module, configured to, if the target query source file data location indicates mapping to an invalid location of the source file data, determine the edited data corresponding to the target query source file data location as the target query data corresponding to the to-be-query status data location;

[0167] A third query module, configured to, if the target query source file data location does not indicate mapping to an invalid location of the source file data, query a modified data table included in an edit record table based on the target query source file data location; if the modified data table includes a source file data location that is the same as the target query source file data location, determine the edited data corresponding to the same source file data location as the target query data; otherwise, determine the target query data in the source file data based on the target query source file data location.

[0168] The file editing device provided by an embodiment of the present invention can execute the file editing method provided by any embodiment of the present invention, and has function modules and beneficial effects corresponding to the execution of the method.

[0169] Embodiment 4

[0170] Figure 6 It is a schematic structural diagram of an electronic device for implementing the file editing method of an embodiment of the present invention. The electronic device is intended to represent various forms of digital computers, such as, a laptop computer, a desktop computer, a workbench, a personal digital assistant, a server, a blade server, a mainframe computer, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as, a personal digital processor, a cellular phone, a smart phone, a wearable device (such as a helmet, glasses, a watch, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are only examples, and are not intended to limit the implementation of the present invention described and / or claimed herein.

[0171] As Figure 6 shown, the electronic device 10 includes at least one processor 11, and a memory communicatively connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc. Among them, the memory stores a computer program executable by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. The input / output (I / O) interface 15 is also connected to the bus 14.

[0172] Multiple components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disc, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0173] The processor 11 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the processor 11 include but are not limited to a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the file editing method.

[0174] In some embodiments, the file editing method can be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the file editing method described above can be executed. Alternatively, in other embodiments, the processor 11 can be configured to execute the file editing method in any other suitable manner (e.g., by means of firmware).

[0175] The various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on a chip (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include: being implemented in one or more computer programs, which can be executed and / or interpreted on a programmable system including at least one programmable processor, the programmable processor can be a special or general programmable processor, can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit the data and instructions to the storage system, the at least one input device, and the at least one output device.

[0176] A computer program for implementing the method of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, a special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions / operations specified in the flowchart and / or block diagram to be implemented. The computer program may be executed entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine or entirely on the remote machine or server.

[0177] In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. Alternatively, the computer-readable storage medium may be a machine-readable signal medium. More specific examples of the machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0178] In order to provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the electronic device. Other kinds of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0179] The systems and techniques described herein can be implemented in a computing system including backend components (e.g., as a data server), or a computing system including middleware components (e.g., an application server), or a computing system including frontend components (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described herein), or a computing system including any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected to each other by digital data communication in any form or medium (e.g., a communication network). Examples of communication networks include: local area network (LAN), wide area network (WAN), blockchain network, and the Internet.

[0180] A computing system can include a client and a server. The client and the server are generally remote from each other and typically interact through a communication network. The client-server relationship is created by computer programs running on respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or a cloud host, which is a host product in the cloud computing service system and solves the defects of difficult management and weak business scalability existing in traditional physical hosts and VPS services.

[0181] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps recited in the present invention can be executed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of the present invention can be achieved, and no limitation is made herein.

[0182] The above specific embodiments do not constitute a limitation on the protection scope of the present invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention shall be included within the protection scope of the present invention.

Claims

1. A file editing method, characterized in that, Including: Recording the editing operations on the source file data in byte units in an editing record table, where the editing record table includes one or more of the current state data position, the source file data position, and the edited data. The current state data position indicates the position of the edited data in the current state, and the source file data position indicates the position of the source file data to which the editing operation is mapped; Determining the change information regarding the storage space size occupied by the source file data based on the editing record table and the size of the source file data; Writing back the editing operations recorded in the editing record table to the corresponding position of the source file data based on the editing record table, the source file data, and the change information to obtain the target file data.

2. The method according to claim 1, characterized in that, The editing operations include one or more of a data insertion operation, a data deletion operation, and a data modification operation; The editing record table includes one or more of an insert-delete table and a data modification table; The insert-delete table includes one or more insert-delete records, and each insert-delete record corresponds to one data insertion operation or one data deletion operation; the insert-delete record includes the current state data position, the source file data position, and the edited data arranged in sequence; Each current state data position in the insert-delete table indicates the offset compared to the starting position during memory mapping with the source file data, and the current state data positions are arranged in ascending order of the offset; The data modification table includes one or more data modification records corresponding to the data modification operation, and the data modification record includes the source file data position and the edited data arranged in sequence.

3. The method according to claim 2, characterized in that, Recording the editing operations on the source file data in byte units in the editing record table includes: When the editing operation includes the data insertion operation, adding a first insert-delete record to the insert-delete table. The first current state data position in the first insert-delete record indicates the position of the inserted data in the current state, the first source file data position indicates the invalid position of the source file data to which the data insertion operation is mapped, and the first edited data indicates the inserted data; and increasing the offset indicated by the current state data position included in the insert-delete records arranged after the first insert-delete record in the insert-delete table by one byte. When the edit operation includes the data deletion operation, a second insert-delete record is newly added to the insert-delete table. The second current state data position in the second insert-delete record indicates the position of the deleted data in the current state. The second source file data position indicates the position where the data corresponding to the second current state data position after deletion is mapped to the source file data. The second edited data is empty. And based on the deletion length, the offsets indicated by the current state data positions included in the insert-delete records arranged after the second insert-delete record in the insert-delete table are reduced. The deletion length is determined based on the second source file data position and the position where the data corresponding to the second current state data position before deletion is mapped to the source file data. When the edit operation includes the data modification operation, a third data modification record is newly added to the modification data table. The third source file data position in the third data modification record indicates the position where the modified data is mapped to the source file data. The third edited data is the modified data.

4. The method according to claim 1, characterized in that, Based on the edit record table and the size of the source file data, the change information about the storage space size occupied by the source file data is determined, including: Determine the target insert-delete record in the insert-delete table included in the edit record table. The target insert-delete record is the last insert-delete record arranged in the insert-delete table that does not indicate the existence of an invalid position. Based on the target current state data position and the target source file data position included in the target insert-delete record, the number of insert-delete records arranged after the target insert-delete record, and the size of the source file data, determine the size of the edited source file data. Based on the size of the source file data and the size of the edited source file data, determine the change information.

5. The method according to claim 1, characterized in that, Based on the edit record table, the source file data, and the change information, write the edit operations recorded in the edit record table back to the corresponding positions of the source file data to obtain the target file data, including: For the modification data table included in the edit record table, in the source file data, replace each edited data in the modification data table with the position indicated by the source file data position corresponding to the edited data to obtain the first file data. For the insert-delete table included in the edit record table, split the insert-delete table into a move table and a cover table. Move the data in the source file data based on the move table. Overwrite the data in the moved source file data based on the cover table to obtain the second file data. Among them, the target file data includes one or more of the first file data and the second file data. When the target file data includes the first file data and the second file data, determine the first file data first and then determine the second file data. The modified information indicates to first expand the storage space occupied by the source file data and then write the edit operation back to the source file data, or indicates to first write the edit operation back to the source file data and then reduce the storage space occupied by the source file data.

6. The method according to claim 5, characterized in that, Splitting the insert / delete table into a move table and an overwrite table includes: Increasing the offset indicated by the current state data position included in the insert / delete record with non-empty edited data in the insert / delete table by one byte; based on any of the current state data positions increased by one byte, modifying the corresponding source file data position to the position where the data corresponding to the current state data position increased by one byte is mapped to the source file data; and deleting the edited data in each insert / delete record in the insert / delete table to obtain the move table; Deleting the insert / delete records with empty edited data in the insert / delete table and deleting the source file data positions in the insert / delete table to obtain the overwrite table.

7. The method according to claim 1, characterized in that, It further includes: Determining the target query source file data position corresponding to the position of the status data to be queried by querying the insert / delete table included in the edit record table, where the target query source file data position indicates the position where the data corresponding to the position of the status data to be queried is mapped to the source file data; If the target query source file data position indicates an invalid position mapped to the source file data, determining the edited data corresponding to the target query source file data position as the target query data corresponding to the position of the status data to be queried; If the target query source file data position does not indicate an invalid position mapped to the source file data, querying the modified data table included in the edit record table based on the target query source file data position; if the modified data table includes a source file data position that is the same as the target query source file data position, determining the edited data corresponding to the same source file data position as the target query data, otherwise determining the target query data in the source file data based on the target query source file data position.

8. A file editing device, characterized in that, It includes: An edit record module for recording the edit operation on the source file data in units of bytes in the edit record table, where the edit record table includes one or more of the current state data position, the source file data position, and the edited data, the current state data position indicates the position of the edited data in the current state, and the source file data position indicates the position where the edit operation is mapped to the source file data; A determination module for determining the modified information on the storage space size occupied by the source file data based on the edit record table and the size of the source file data; An edit write-back module for writing the edit operation recorded in the edit record table back to the corresponding position of the source file data based on the edit record table, the source file data, and the modified information to obtain the target file data.

9. An electronic device, characterized in that, It includes: At least one processor; And A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and when the computer program is executed by the at least one processor, the at least one processor is enabled to execute the method according to any one of claims 1-7.

10. A computer-readable storage medium, on which a computer program is stored, characterized in that, When the program is executed by a processor, the method according to any one of claims 1-7 is implemented.