Data processing method and electronic equipment
By using multiple memories in electronic devices to store and read the content of the target file in parallel, the problem of duplicate data occupies storage space and the problem of high coupling of the same file is solved, and efficient storage and reading performance is achieved.
Patent Information
- Application Number
- CN202311763841.3
- 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
In the prior art, electronic devices occupy a large amount of storage space when storing duplicate data, and the coupling degree between the same files is high, resulting in poor independence and atomicity of the files, affecting performance.
By using two or more memories in an electronic device, parallel storage and reading of target file contents are achieved. The specific method includes: determining whether the memory stores the target file contents. If it has been stored, only the file identifier is written and the storage address is added; if it is not stored, the file identifier and the target file contents are written and the storage address is added.
It effectively reduces the storage space of duplicate data, improves the independence and atomicity of files, improves the efficiency of reading file contents, and improves the security of target file contents.
Smart Images

Figure CN120179150A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of terminals, and in particular, to a data processing method and an electronic device. Background Art
[0002] With the continuous development of terminal technology, the applications of various electronic devices are becoming more and more extensive. During the use of an electronic device, a large amount of duplicate data may be generated in the electronic device, and these duplicate data will occupy a large amount of storage space and affect the performance of the electronic device.
[0003] In the prior art, for multiple identical files, the electronic device can store only the file identifier and file content of one file, and point the file identifiers of other files to the file identifier of this file through a link. It can be understood that the file identifiers of other files copy the file identifier of this file, so that the same file content is stored only once. Although this storage method improves the problem of duplicate data occupying storage space to a certain extent, these multiple files are coupled, and modifying any one of the files will also modify other files, and the independence and atomicity of the files are very poor. Summary of the Invention
[0004] In view of this, this application provides a data processing method and an electronic device, which can improve the problem of duplicate data occupying a large amount of storage space, improve the coupling problem between identical files, and at the same time improve the efficiency of reading files.
[0005] To achieve the above object, in a first aspect, an embodiment of this application provides a data processing method, which is applied to an electronic device. The electronic device includes a first memory and a second memory. The method includes: in response to a request to write a first file, determining whether the first memory and the second memory store the target file content included in the first file; if both the first memory and the second memory store a copy of the target file content, writing the file identifier of the first file to the first memory or the second memory; adding a first address and a second address to the file identifier of the first file, where the first address is the address of the target file content in the first memory, and the second address is the address of the target file content in the second memory.
[0006] In the embodiments of the present application, when the electronic device responds to a request to write the first file, it may determine whether the first memory and the second memory store the target file content, and perform different writing methods on the first file according to different storage situations. If the first memory and the second memory have respectively stored a copy of the target file content, it is not necessary to repeatedly write the target file content. Instead, only the file identifier of the first file is written to the first memory or the second memory, and at the same time, the first address and the second address of the target file content already stored in the first memory and the second memory are written to the file identifier. This not only improves the problem that duplicate data occupies a large storage space, but also creates an independent file identifier for the first file, improves the problem of coupling between the first file and other identical files, enhances the atomicity and independence of the first file, and also facilitates parallel reading of the target file content from the first memory and the second memory, thereby improving the efficiency of reading the target file content.
[0007] In addition, the more times a certain identical file is repeatedly written, it indicates that the electronic device uses the target file content included in the identical file more times, and the importance of the target file content to the electronic device and the user is also higher. Therefore, by storing a copy of the target file content in the first memory and the second memory respectively, the target file content stored in the first memory and the second memory can be mirrored and backed up to each other, which can also improve the security of the target file content.
[0008] The file system divides file data into two parts: file attributes and file content. File attributes can record some attribute information of the file, such as file name path, file creation time, file size, file permissions, etc. File content can include the specific content of the file.
[0009] In some embodiments, the method further includes: in response to a request to read the first file, obtaining the file identifier of the first file from the first memory or the second memory; splitting the target file content into a first part of data blocks and a second part of data blocks; reading the first part of data blocks from the first memory based on the first address, and reading the second part of data blocks from the second memory based on the second address; and merging the first part of data blocks and the second part of data blocks to obtain the target file content.
[0010] In some embodiments, the splitting the target file content into a first part of data blocks and a second part of data blocks includes: based on the reading speed of the first memory and the reading speed of the second memory, splitting the target file content into the first part of data blocks and the second part of data blocks, where the data volume of the first part of data blocks is positively correlated with the reading speed of the first memory, and the second part of data blocks is positively correlated with the reading speed of the second memory.
[0011] In response to a request to read a first file, the target file content included in the first file can be split into a first partial data block and a second partial data block. The first partial data block of the target file content is read from a first memory based on a first address, and the second partial data block of the target file content is read from a second memory based on a second address. The first partial data block and the second partial data block are combined to obtain the target file content. That is, the electronic device can read different parts of the target file content from the first memory and the second memory in parallel, improving the rate of reading the target file content.
[0012] In some embodiments, before responding to the request to write the first file, the method further includes: in response to a request to write a second file, the second file includes the target file content, and the first memory and the second memory jointly store one copy of the target file content, writing a file identifier of the second file to the first memory or the second memory; transferring the target file content to any one of the first memory and the second memory; writing the target file content to the other one of the first memory and the second memory; adding the first address and the second address to the file identifier of the second file.
[0013] In some embodiments, before responding to the request to write the second file, the method further includes: in response to a request to write a third file, the third file includes the target file content, and the first memory and the second memory do not store the target file content, writing a file identifier of the third file to the first memory or the second memory; writing the target file content to the first memory and / or the second memory such that the first memory and the second memory jointly store one copy of the target file content; adding a third address to the file identifier of the third file, the third address being the address of the target file content in the first memory and / or the second memory; after writing the target file content to the other one of the first memory and the second memory, the method further includes: adding the first address and the second address to the file identifier of the third file.
[0014] In some embodiments, after the request for writing the third file is responded to and before the request for writing the second file is responded to, the method further includes: in response to a request for writing a fourth file, where the fourth file includes the target file content, writing the file identifier of the fourth file to the first memory or the second memory; adding the third address to the file identifier of the fourth file; after writing the target file content to the other one of the first memory and the second memory, the method further includes: adding the first address and the second address to the file identifier of the fourth file.
[0015] In some embodiments, before the request for writing the first file is responded to, the method further includes: in response to a request for writing a third file, where the third file includes the target file content and neither the first memory nor the second memory stores the target file content, writing the file identifier of the third file to the first memory or the second memory; writing the target file content to the first memory and the second memory respectively; adding the first address and the second address to the file identifier of the third file.
[0016] That is to say, when multiple requests for writing files are received and multiple files all include the same target file content, when neither the first memory nor the second memory stores the target file content, that is, when writing the file for the first time, only one copy of the target file content is written to the first memory and / or the second memory in total, further improving the problem that duplicate data occupies a large amount of storage space; when one copy of the target file content is stored in the first memory and the second memory in total, that is, when repeating the same file for the first time, the target file content is written to the first memory and the second memory respectively; and when one copy of the target file content is stored in the first memory and the second memory respectively, that is, when repeating the writing of the same file again, the target file content is not written repeatedly, thereby improving the efficiency of reading duplicate data and the security of duplicate data on the basis of adding less duplicate data.
[0017] Alternatively, when multiple requests for writing files are received and multiple files all include the same target file content, when neither the first memory nor the second memory stores the target file content, that is, when writing the file for the first time, only one copy of the target file content is written to the first memory and / or the second memory in total; when one copy of the target file content is stored in the first memory and the second memory in total, that is, when repeating the writing of the same file for the first time, the target file content is not written repeatedly temporarily, but when repeating the writing of the same file again, one copy of the target file content is written to the first memory and the second memory respectively, so that for data with a small number of repeated writes, the number of times of writing duplicate data can be reduced, further improving the problem that duplicate data occupies a large amount of storage space.
[0018] Alternatively, when multiple requests to write files are received and the multiple files all include the same target file content, and when the target file content is not stored in either the first memory or the second memory, that is, when writing the file for the first time, a copy of the target file content can be written to the first memory and the second memory respectively, so that the electronic device can store the target file content in the first memory and the second memory earlier and faster, further improving the rate of reading the target file content and the security of the target file content.
[0019] In some embodiments, the method further includes: in response to a request to modify the first file, writing the modified target file content to the first memory and the second memory respectively; adding a fourth address and a fifth address to the file identifier of the first file, where the fourth address is the address of the modified target file content in the first memory, and the fifth address is the address of the modified target file content in the second memory.
[0020] In some embodiments, the method further includes: obtaining the first file from the installation package of the application to be installed. This reduces the duplicate data written to the memory when installing the application, improves the problem that the electronic device writes duplicate data every time an application is installed, and enhances the performance of the electronic device.
[0021] In a second aspect, an embodiment of the present application provides a data processing method applied to an electronic device, where the electronic device includes at least two memories, and the method includes: in response to detecting at least two copies of target file content in the at least two memories, retaining one copy of the target file content in the first memory and the second memory respectively, where the first memory and the second memory belong to the at least two memories; adding a first address and a second address to the file identifier of at least one file, where the at least one file includes the target file content, the first address is the address of the target file content in the first memory, and the second address is the address of the target file content in the second memory.
[0022] The stored data can be sorted. When there are at least two copies of the target file content stored in the first memory and the second memory, only one copy of the target file content is retained in the first memory and the second memory respectively, which improves the problem that duplicate data occupies a large amount of storage space, and also improves the rate of reading the target file content and the security of the target file content.
[0023] In some embodiments, the at least one file includes a first file, and the method further includes: in response to a request to read the first file, obtaining a file identifier of the first file from the first memory or the second memory; splitting the target file content into a first partial data block and a second partial data block; reading the first partial data block from the first memory based on the first address, and reading the second partial data block from the second memory based on the second address; and combining the first partial data block and the second partial data block to obtain the target file content.
[0024] In response to a request to read a first file, the target file content included in the first file can be split into a first partial data block and a second partial data block, the first partial data block of the target file content is read from the first memory based on the first address, the second partial data block of the target file content is read from the second memory based on the second address, and the first partial data block and the second partial data block are combined to obtain the target file content. That is, the electronic device can read different parts of the target file content from the first memory and the second memory in parallel, improving the rate of reading the target file content.
[0025] In a third aspect, an embodiment of the present application provides a data processing method, which is applied to an electronic device. The electronic device includes a first set, and the first set includes a plurality of memories. The method includes: in response to a request to write a first file, determining whether each of the memories in the first set stores the target file content included in the first file; if each of the memories in the first set stores a copy of the target file content, writing a file identifier of the first file to any one of the memories in the first set; and adding a third set to the file identifier of the first file, where the third set includes a plurality of addresses, and each address in the third set is an address of the target file content in any one of the memories in the first set.
[0026] When responding to a request to write the first file, it is possible to determine whether each memory in the first set stores the target file content, and perform different writing methods on the first file according to different storage situations. If each memory in the first set has already stored a copy of the target file content respectively, it is possible to no longer repeatedly write the target file content, but only write the file identifier of the first file to any one memory in the first set. At the same time, the addresses of the target file content already stored in each memory in the first set are written with this file identifier. This not only improves the problem that duplicate data occupies a large amount of storage space, but also creates an independent file identifier for the first file, improves the coupling problem between the first file and other identical files, enhances the atomicity and independence of the first file, and also facilitates parallel reading of the target file content from the first memory and the second memory, improving the efficiency of reading the target file content, and can also improve the security of the target file content.
[0027] In some embodiments, the method further includes: in response to a request to read the first file, obtaining the file identifier of the first file from any one of the memories in the first set; splitting the target file content into multiple partial data blocks; based on each of the addresses in the fourth set, obtaining the partial data blocks from each of the memories in the second set, the fourth set including at least two of the addresses in the third set, and the second set including at least two of the memories in the first set; merging the obtained multiple partial data blocks to obtain the target file content.
[0028] In response to a request to read the first file, the target file content included in the first file can be split into multiple partial data blocks, and different parts of the target file content can be read in parallel from multiple memories, which improves the rate of reading the target file content.
[0029] In a fourth aspect, an embodiment of the present application provides a data processing method applied to an electronic device. The electronic device includes a first set, and the first set includes multiple memories. The method includes: in response to the number of copies of the target file content detected in the first set being greater than or equal to the number of the multiple memories included in the first set, respectively retaining a copy of the target file content in each of the memories in the first set; adding a third set to the file identifier of at least one file, the at least one file including the target file content, and the third set including multiple addresses, and each address in the third set being the address of the target file content in any one of the memories in the first set.
[0030] The stored data can be sorted. When the number of copies of the content of the target file stored is greater than or equal to the number of memories included in the first set, only one copy of the content of the target file is reserved in each memory in the first set, which improves the problem that duplicate data occupies a large storage space, and also improves the rate of reading the content of the target file and the security of the content of the target file.
[0031] In some embodiments, the at least one file includes the first file, and the method further includes: in response to a request to read the first file, obtaining a file identifier of the first file from any one of the memories in the first set; splitting the content of the target file into multiple partial data blocks; based on each address in the fourth set, obtaining the partial data blocks from each memory in the second set, the fourth set includes at least two of the addresses in the third set, and the second set includes at least two of the memories in the first set; merging the obtained multiple partial data blocks to obtain the content of the target file.
[0032] In a fifth aspect, an embodiment of the present application provides a data processing device, which has a function of implementing the behaviors of an electronic device in the above aspects and possible implementation manners of the above aspects. The function can be implemented by hardware or by hardware executing corresponding software. The hardware or software includes one or more modules or units corresponding to the above functions. For example, a processing module or unit, etc.
[0033] In a sixth aspect, an embodiment of the present application provides an electronic device, including: a memory and a processor, the memory is used to store a computer program; the processor is used to execute the method described in any one of the first aspect, any one of the second aspect, any one of the third aspect, or any one of the fourth aspect when calling the computer program.
[0034] In a seventh aspect, an embodiment of the present application provides a chip system, the chip system includes a processor, the processor is coupled to a memory, and the processor executes a computer program stored in the memory to implement the method described in any one of the first aspect, any one of the second aspect, any one of the third aspect, or any one of the fourth aspect.
[0035] Wherein, the chip system can be a single chip or a chip module composed of multiple chips.
[0036] In an eighth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the method described in any one of the first aspect, any one of the second aspect, any one of the third aspect, or any one of the fourth aspect.
[0037] In a ninth aspect, an embodiment of the present application provides a computer program product. When the computer program product runs on an electronic device, the electronic device is caused to execute the method described in any one of the first aspect, any one of the second aspect, any one of the third aspect, or any one of the fourth aspect above.
[0038] It can be understood that for the beneficial effects of the second aspect to the ninth aspect above, reference can be made to the relevant descriptions in the first aspect above, and details are not elaborated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 FIG. [ID] is a schematic structural diagram of an electronic device provided by an embodiment of the present application;
[0040] Figure 2 FIG. [ID] is a software structural block diagram of an electronic device provided by an embodiment of the present application;
[0041] Figure 3 FIG. [ID] is a structural block diagram of a file system provided by an embodiment of the present application;
[0042] Figure 4 FIG. [ID] is a structural block diagram of another file system provided by an embodiment of the present application;
[0043] Figure 5 FIG. [ID] is a structural block diagram of another file system provided by an embodiment of the present application;
[0044] Figure 6 FIG. [ID] is a schematic flowchart of a method for writing data provided by an embodiment of the present application;
[0045] Figure 7 FIG. [ID] is a structural block diagram of another file system provided by an embodiment of the present application;
[0046] Figure 8 FIG. [ID] is a schematic flowchart of another method for writing data provided by an embodiment of the present application;
[0047] Figure 9 FIG. [ID] is a schematic flowchart of another method for writing data provided by an embodiment of the present application;
[0048] Figure 10 FIG. [ID] is a schematic flowchart of another method for writing data provided by an embodiment of the present application;
[0049] Figure 11 FIG. [ID] is a schematic flowchart of another method for writing data provided by an embodiment of the present application;
[0050] Figure 12 FIG. [ID] is a schematic flowchart of another method for writing data provided by an embodiment of the present application;
[0051] Figure 13Schematic flowchart of another method for writing data provided by an embodiment of the present application;
[0052] Figure 14 Schematic flowchart of a method for sorting data provided by an embodiment of the present application;
[0053] Figure 15 Schematic flowchart of a method for reading data provided by an embodiment of the present application;
[0054] Figure 16 Schematic flowchart of another method for writing data provided by an embodiment of the present application;
[0055] Figure 17 Schematic flowchart of another method for sorting data provided by an embodiment of the present application;
[0056] Figure 18 Schematic flowchart of another method for reading data provided by an embodiment of the present application. Detailed implementation manners
[0057] The data processing method provided by the embodiments of the present application can be applied to electronic devices such as mobile phones, tablet computers, wearable devices, in-vehicle devices, augmented reality (AR) / virtual reality (VR) devices, laptop computers, ultra-mobile personal computers (UMPCs), netbooks, and personal digital assistants (PDAs). The embodiments of the present application do not impose any restrictions on the specific types of electronic devices.
[0058] Figure 1 It is a schematic structural diagram of an electronic device 100 provided by an embodiment of the present application. The electronic device 100 may include a processor 110, a memory 120, a communication module 130, etc.
[0059] Among them, the processor 110 may include one or more processing units, and the memory 120 is used to store program codes and data. In the embodiments of the present application, the processor 110 can execute the computer execution instructions stored in the memory 120 to control and manage the actions of the electronic device 100.
[0060] In some embodiments, the memory 120 may include a program storage area and a data storage area. Among them, the program storage area can store an operating system, application programs required for at least one function, etc. The data storage area can store data created during the use of the electronic device 100.
[0061] In some embodiments, the electronic device 100 may include one or N memories 120, where N is a positive integer greater than 1.
[0062] The communication module 130 can be used for communication between various internal modules of the electronic device 100, or for communication between the electronic device 100 and other external electronic devices, etc. Exemplarily, if the electronic device 100 communicates with other electronic devices in a wired connection manner, the communication module 130 may include an interface, such as a USB interface. The USB interface can be an interface that conforms to the USB standard specification, specifically, it can be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface can be used to connect a charger to charge the electronic device 100, and can also be used to transfer data between the electronic device 100 and peripheral devices. It can also be used to connect headphones to play audio. This interface can also be used to connect other electronic devices.
[0063] Alternatively, the communication module 130 may include audio devices, radio frequency circuits, Bluetooth chips, wireless fidelity (Wi-Fi) chips, near-field communication (NFC) modules, etc., and can implement the interaction between the electronic device 100 and other electronic devices in a variety of different ways.
[0064] Optionally, the electronic device 100 may further include a display screen 140, and the display screen 140 can display images, videos, etc. in the human-computer interaction interface.
[0065] Optionally, the electronic device 100 may further include peripheral devices 150, such as a mouse, a keyboard, a speaker, a microphone, etc.
[0066] It should be understood that in addition to Figure 1 the various components or modules listed above, the embodiments of the present application do not specifically limit the structure of the electronic device 100. In other embodiments of the present application, the electronic device 100 may further include more or fewer components than shown in the figure, or combine certain components, or split certain components, or have different component arrangements. The illustrated components can be implemented in hardware, software, or a combination of software and hardware.
[0067] The software system of the electronic device 100 can adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservices architecture, or a cloud architecture. In the embodiments of the present application, taking the layered architecture as an example, the software structure of the electronic device 100 is exemplarily described.
[0068] Please refer to Figure 2, which is a schematic diagram of the software structure of an electronic device 100 provided by an embodiment of the present application. The electronic device 100 includes a user layer, an application framework layer, and a kernel layer from top to bottom.
[0069] The user layer is an application execution space directly operated by the user. The user layer may include one or more application programs, such as a camera,
[0070] gallery, calendar, call, map, navigation, wireless local area networks (WLAN), Bluetooth, music,
[0071] video, short message and other application programs.
[0072] The application framework layer provides application programming interfaces (APIs) and programming frameworks for the application programs in the application layer. The application framework layer includes some predefined functions.
[0073] As Figure 2 shown, the application framework layer may include an application installation management service. The application installation management service may reside in the electronic device 100 and may be used to complete the installation, update, configuration, and uninstallation of application programs, optimize the data of application programs, etc.
[0074] In some embodiments, the application framework layer (such as the application installation management service) may include a preset interface, which may be used to implement an application program to access the data of another application program.
[0075] It can be understood that in actual applications, the application framework layer may also include more services, such as a window manager, a content provider, a view system, a telephone manager, a resource manager, a notification manager, etc.
[0076] The kernel layer is a layer between hardware and software and is a kernel program execution space for completing specific functions.
[0077] As Figure 2 shown, the kernel layer may include a file system. The file system is a method and data structure used by an operating system to define files on a memory, that is, a method of organizing files on a memory, and can implement functions such as file read / write and file management.
[0078] Please refer to Figure 3, is a schematic diagram of the structure of a file system provided in an embodiment of the present application. The file system divides file data into two parts: file attributes and file content. File attributes can record some attribute information of the file, such as file name path, file creation time, file size, file permissions, etc. File content can include the specific content of the file. Compared with file content, file attributes occupy less space, and when searching and operating files, operations on file attributes are more frequent. Therefore, when storing files, the file system divides the files into file identifiers and file contents for storage.
[0079] like Figure 3 As shown, a file identifier, also called an inode, stores file attributes and the address of the file content in the memory. In some embodiments, a file identifier can occupy 4k Byte (kilobytes) of storage space, which is relatively small. When reading a file, the attribute information of the file can be obtained by reading the file identifier.
[0080] like Figure 3 As shown, the file content may include one or more data blocks. The address of the file content in the memory stored in the file identifier may indicate the location of the one or more data blocks in the memory, and the file content may be read from the memory based on the address.
[0081] When the contents of two files are identical, the two files are identical files or duplicate files.
[0082] The following is an example of the workflow of electronic device software and hardware, combined with the scenario of installing an application.
[0083] The electronic device obtains the installation package of the application to be installed, obtains a file from the installation package through the application installation management service, and sends the writing process of the file to the file system. The file system writes the file identifier and file content of the file to the memory respectively, and writes the address of the file content in the memory into the file identifier.
[0084] In order to facilitate understanding of the technical solutions in the embodiments of the present application, the application scenarios of the embodiments of the present application are first introduced below.
[0085] When an electronic device installs an application, it writes the application data that the application depends on to the memory. However, since a large number of open source components and open source libraries are used in the development of the application, the application data includes a large amount of duplicate data, such as runtime library files in .so format. In addition, during the operation of the electronic device, duplicate user data may also be generated, such as photos, documents, music, videos, etc. When there is a lot of duplicate data, it will take up a lot of storage space and affect the performance of the electronic device.
[0086] In some embodiments, as Figure 4 shown, for the same File 1 and File 2, the electronic device may store the file identifier and file content of File 1 in the memory, and point the file identifier of File 2 to File 1 through a link. It can also be understood that File 2 copies the file identifier of File 1. At this time, the same file content in the file system is stored only once, which improves the problem of duplicate data occupying storage space to a certain extent. However, on the one hand, when File 1 and File 2 belong to different application programs respectively, since one application program does not perceive or access the files of other application programs, the duplicate application data cannot be reduced by this way of linking file identifiers. On the other hand, since File 1 and File 2 are exactly the same, modifying File 1 will cause File 2 to be modified as well, that is, File 1 and File 2 are coupled, making the files lose independence and atomicity.
[0087] In other embodiments, as Figure 5 shown, for the same File 1 and File 2, the electronic device may store the file identifier of File 1, the file identifier of File 2, and the file content of File 1 in the memory respectively, and add the address of the file content in the memory to the file identifier of File 1 and the file identifier of File 2, so as to improve the problem of duplicate data occupying storage space. However, this method cannot fully utilize the performance advantages of an electronic device including multiple memories.
[0088] To solve at least some of the above technical problems, an embodiment of the present application provides another method for writing data. This method can improve the problem of large storage space occupied by duplicate data, and can also improve the data reading speed and data security. The technical solution of the present application will be described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments.
[0089] Please refer to Figure 6 , which is a flowchart of a method for writing data provided by an embodiment of the present application. Among them, this method can be used for the electronic device described above, and the electronic device includes a first memory and a second memory. In some embodiments, the first memory and the second memory may be all or part of the memories in the electronic device. It should be noted that this method is not limited by Figure 6 the specific order described below. It should be understood that in some embodiments, the order of some steps of this method can be interchanged according to actual needs, or some of the steps can also be omitted or deleted. The method includes the following steps:
[0090] S601. When the electronic device responds to a request to write a first file, where the first file includes target file content, it determines whether the target file content is stored in the first memory and the second memory. If the target file content is not stored in either the first memory or the second memory, then S602 is executed; if the first memory and the second memory together store one copy of the target file content, then S603 is executed; if the first memory and the second memory each store one copy of the target file content, then S604 is executed.
[0091] When the electronic device detects a request to write a first file, it can first determine whether the target file content is stored in the first memory and the second memory, so as to subsequently execute different writing processes based on different judgment results, thereby improving the problem that duplicate data occupies a relatively large storage space.
[0092] In some embodiments, the first file can be user data, such as photos, documents, or music; or, the first file can be application data of an application, such as a library running file in an application installation package.
[0093] In some embodiments, the electronic device can determine the hash value of the target file content, and compare the hash value of the target file content with the hash values of the file contents of at least one file stored in the database. If the hash value of the target file content is not the same as any of the hash values in the database, it can be determined that the target file content is not stored. If the hash value of the target file content is the same as the hash value of the file content of a second file, the file content of the target file and the file content of the second file can also be compared byte by byte in full. If the full byte-by-byte comparison result of the file content of the target file and the file content of the second file is the same, it is determined that the file content of the second file is the target file content, that is, the target file content is stored in the first memory and the second memory; otherwise, it is determined that the target file content is not stored in the second file in the first memory and the second memory.
[0094] In some embodiments, the database may include the hash values of at least one file stored in the first memory and the second memory, and / or include the file contents of the at least one file.
[0095] It can be understood that in practical applications, the electronic device can also use other methods to determine whether the target file content is stored in the first memory and the second memory.
[0096] S602. The electronic device writes the first file based on a first writing method, so that the first memory and the second memory together store one copy of the target file content.
[0097] When a request to write the first file is detected and the target file content included in the first file is not currently stored, the electronic device may write the first file based on a first writing method, so that the first memory and the second memory store a copy of the target file content.
[0098] In some embodiments, the first writing method may include writing the file identifier of the first file to the first memory or the second memory, and writing a copy of the target file content to the first memory and / or the second memory. That is, writing the file identifier included in the first file and the target file content included in the first file. In some embodiments, the first writing method may also be referred to as ordinary file writing.
[0099] In some embodiments, the electronic device may write all data blocks included in the target file content to the first memory or the second memory. In other embodiments, as shown in a of Figure 7 the electronic device may write a part of the data blocks in the all data blocks to the first memory, and write another part of the data blocks in the all data blocks to the second memory.
[0100] In some embodiments, the electronic device may add a third address to the file identifier of the first file, where the third address is the address of the target file content in the first memory and / or the second memory.
[0101] In some embodiments, the electronic device may add a first flag bit to the file attributes included in the file identifier of the first file, where the first flag bit is used to indicate that the first file is an ordinary file.
[0102] S603, the electronic device writes the first file based on a second writing method, so that the first memory and the second memory respectively store a copy of the target file content.
[0103] When a request to write the first file is detected and the first memory and the second memory together store a copy of the target file content, the electronic device may write the first file based on a second writing method, so that the first memory and the second memory respectively store a copy of the target file content. Wherein, the target file content is repeated once, and the target file content stored in the first memory and the second memory can be used as the mirror image and backup of the target file content stored in each other. This enables parallel reading of the target file content from the first memory and the second memory when reading the target file content subsequently, improving the reading rate of the target file content and also enhancing the security of the target file content.
[0104] In some embodiments, the second writing method may include writing the file identifier of the first file to the first memory or the second memory, and writing the target file content to the memory in the first memory and the second memory that does not store the target file content. That is, writing the first file includes writing the file identifier and creating a mirror image of the target file content. Creating an independent file identifier for the first file can improve the problem of coupling between the first file and other identical files, and improve the atomicity and independence of the first file. In some embodiments, the second writing method may also be referred to as mirror file writing.
[0105] In some embodiments, the first memory and the second memory currently store partial data blocks of the target file content, as Figure 7 shown in a of. Therefore, the electronic device can transfer all the data blocks of the target file content to any one of the first memory and the second memory, and then write all the data blocks included in the target file content to the other memory in the first memory and the second memory, as Figure 7 shown in b of; alternatively, the electronic device can transfer a part of the data blocks of the target file content stored in the first memory to the second memory, and transfer another part of the data blocks of the target file content stored in the second memory to the first memory; or, the electronic device can delete some of the data blocks included in the target file content stored in the first memory and the second memory, and then write all the data blocks included in the target file content to the first memory and the second memory respectively.
[0106] In some embodiments, the electronic device can add the first address and the second address to the file identifier of the first file. The first address is the address of the target file content in the first memory, and the second address is the address of the target file content in the second memory. In some embodiments, the electronic device can add the first address and the second address to the file identifier of another second file associated with the target file content, so as to update the address of the target file content included in the file identifier of the second file.
[0107] In some embodiments, the electronic device can add a second flag bit to the file attributes included in the file identifier of the first file. The second flag bit is used to indicate that the first file is a mirror file.
[0108] In some embodiments, when a request to write the first file is detected and the target file content included in the first file is not currently stored, the electronic device can also write the first file based on the second writing method, so that the first memory and the second memory respectively store a copy of the target file content.
[0109] S604, the electronic device writes the first file based on the third writing method, so that the target file content stored in the first memory and the second memory is associated with the first file.
[0110] When a request to write the first file is detected and the first memory and the second memory each store a copy of the target file content, the electronic device can write the first file based on the third writing method, so that the target file content stored in the first memory and the second memory is associated with the first file, that is, the target file content is no longer written to the first memory or the second memory, and the first memory and the second memory still each store a copy of the target file content, thereby improving the problem of the electronic device repeatedly storing the same data. At the same time, the effect of being able to read the target file content in parallel from the first memory and the second memory is retained, as well as the effect that the target file content stored in the first memory and the target file content stored in the second memory can be mirror images and backups of each other.
[0111] In some embodiments, the third writing method may include writing only the file identifier of the first file to the first memory or the second memory. Among them, creating an independent file identifier for the first file can improve the problem of coupling between the first file and other identical files, and improve the atomicity and independence of the first file. In some embodiments, the third writing method may also be referred to as duplicate file writing.
[0112] In some embodiments, the electronic device may add the first address and the second address to the file identifier of the first file. The first address is the address of the target file content in the first memory, and the second address is the address of the target file content in the second memory.
[0113] For example, as Figure 7 shown in c, when the electronic device detects a request to write the first file, the first memory and the second memory have each stored a copy of the target file content, and the target file content is the file content included in the second file and the third file. Moreover, the first address and the second address of the target file content are included in the file identifier of the second file and the third file identifier. Then, when the electronic device writes the first file, it can only write the file identifier of the first file and add the first address and the second address of the target file content to the file identifier.
[0114] In some embodiments, the electronic device may add a third flag bit to the file identifier of the first file, and the third flag bit is used to indicate that the first file is a duplicate file.
[0115] In an embodiment of the present application, when the electronic device responds to a request to write a first file, it may determine whether the target file content is stored in the first memory and the second memory, and perform different writing methods on the first file according to different storage situations. If the first memory and the second memory have already stored a copy of the target file content respectively, it is not necessary to repeatedly write the target file content. Instead, only the file identifier of the first file is written to the first memory or the second memory, and at the same time, the first address and the second address of the target file content already stored in the first memory and the second memory are written to the file identifier. This not only improves the problem that duplicate data occupies a large storage space, but also creates an independent file identifier for the first file, improves the coupling problem between the first file and other identical files, enhances the atomicity and independence of the first file, and also facilitates parallel reading of the target file content from the first memory and the second memory, improving the efficiency of reading the target file content.
[0116] In addition, the more times a certain identical file is repeatedly written, it indicates that the electronic device uses the target file content included in the identical file more times, and the importance of the target file content to the electronic device and the user is also higher. Therefore, by storing a copy of the target file content in the first memory and the second memory respectively at the same time, the target file content stored in the first memory and the second memory can be mirror images and backups of each other, which can also improve the security of the target file content.
[0117] Please refer to Figure 8 , which is a flowchart of a method for writing data provided by an embodiment of the present application. Among them, this method can correspond to the second writing method described above and is used to directly create a normal file and a mirror file. In some embodiments, the electronic device may execute the following S801 - S804 through a file system such as Figure 2 shown. It should be noted that this method is not limited by Figure 8 and the specific order described below. It should be understood that in some embodiments, the order of some steps of this method can be interchanged according to actual needs, or some of the steps can also be omitted or deleted. This method includes the following steps:
[0118] S801, the electronic device detects a request to write a first file.
[0119] Among them, the first file includes the target file content.
[0120] In some embodiments, a request to write a first file may be issued by a user layer (such as a certain application program) as shown in Figure 2 , and the file system in the kernel layer may receive this request.
[0121] S802, the electronic device creates a file identifier for the first file.
[0122] In some embodiments, the file identifier of the first file may include file attributes such as the time when the first file was written, the size of the first file, the file type of the first file, etc. It can be understood that in practical applications, the file identifier of the first file may also include more or fewer file attributes.
[0123] S803. The electronic device writes all data blocks of the target file content to each memory, so that each memory stores a copy of all data blocks of the target file content.
[0124] In some embodiments, the electronic device may write all data blocks of the target file content to the first memory and the second memory respectively.
[0125] S804. The electronic device writes the addresses of the target file content in each memory to the file identifier of the first file.
[0126] After writing the target file content to each memory, the file identifier of the first file can be updated, including adding the addresses of the target file content in each memory to the file identifier, such as the first address of the target file content in the first memory and the second address in the second memory.
[0127] In some embodiments, S803 may also be executed first, and then S802 and S804.
[0128] Please refer to Figure 9 , which is a flowchart of a method for writing data provided by an embodiment of the present application. Among them, this method may correspond to the second writing method described above and is used to create a mirror file for an already stored ordinary file. In some embodiments, the electronic device may execute the following S901 - S904 through a file system as Figure 2 shown. It should be noted that this method is not limited by Figure 9 the specific order described below, and it should be understood that in some embodiments, the order of some steps of this method can be interchanged according to actual needs, or some of the steps can also be omitted or deleted. This method includes the following steps:
[0129] S901. The electronic device detects a request to create a mirror of the first file.
[0130] Among them, the first file includes the target file content.
[0131] S902. The electronic device transfers all data blocks included in the target file content to one memory.
[0132] In some embodiments, the electronic device may obtain the distribution of all data blocks included in the first target file content on each memory. If all the data blocks are distributed on multiple memories, all the data blocks are transferred to one memory. If any memory stores all the data blocks, S902 may be omitted and the following steps may be continued.
[0133] S903, the electronic device writes all data blocks included in the target file content to other memories.
[0134] S904, the electronic device updates the file identifiers of each file associated with the target file content.
[0135] In some embodiments, the electronic device may determine the file identifiers of at least one file associated with the target file content, such as the first file, the second file, and the third file shown in c in Figure 7 , and update the file identifiers of the at least one file, including adding the addresses of the target file content in each memory to each file identifier.
[0136] Please refer to Figure 10 , which is a flowchart of a method for writing data provided by an embodiment of the present application. Among them, this method is an implementation manner of the method shown in the foregoing Figure 6 . In this method, when writing the third file, the second file, and the first file including the target file content in sequence, the file is first written in the second writing manner, and when the first memory and the second memory respectively store a copy of the target file content, the file is then written based on the third writing manner. This method can also be understood as "mirroring first and then deduplicating". It should be noted that this method is not limited to Figure 10 and the specific order described below. It should be understood that in some embodiments, the order of some steps of this method can be interchanged according to actual needs, or some of the steps can also be omitted or deleted. This method includes the following steps:
[0137] S1001, in response to a request to write the third file, and when neither the first memory nor the second memory stores the target file content, the electronic device writes the third file based on the first writing manner.
[0138] When the electronic device detects a request to write the third file, and when neither the current first memory nor the second memory stores the target file content, the electronic device may write the third file based on the first writing manner so that the first memory and the second memory jointly store a copy of the target file content.
[0139] In some embodiments, the electronic device may write the file identifier of the third file to the first memory or the second memory, and write a copy of the target file content to the first memory and / or the second memory.
[0140] Exemplarily, the electronic device may write a part of the data blocks included in the target file content into the first memory, and write another part of the data blocks included in the target file content into the second memory.
[0141] In some embodiments, the electronic device may add a third address to the file identifier of the third file, where the third address is the address of the target file content in the first memory and / or the second memory.
[0142] In some embodiments, the electronic device may add a first flag bit to the file attributes included in the file identifier of the third file, where the first flag bit is used to indicate that the third file is an ordinary file.
[0143] In some embodiments, after writing the third file, in response to a request to write a fourth file, and the fourth file includes the target file content, the electronic device may write the file identifier of the fourth file to the first memory or the second memory, and add the third address to the file identifier of the fourth file.
[0144] S1002, in response to a request to write a second file, and the first memory and the second memory store a copy of the target file content in total, the electronic device writes the second file based on the second writing method.
[0145] After writing the third file, the first memory and the second memory store a copy of the target file content in total. When the electronic device detects a request to write a second file, the electronic device may write the second file based on the second writing method, so that the first memory and the second memory respectively store a copy of the target file content.
[0146] In some embodiments, the electronic device may write the file identifier of the second file to the first memory or the second memory, and write the target file content to the memory in the first memory and the second memory that does not store the target file content.
[0147] Exemplarily, the electronic device may transfer another part of the data blocks included in the target file content stored in the second memory to the first memory, so that the first memory stores all the data blocks included in the target file content, and then write all the data blocks to the second memory, so that the second memory also stores all the data blocks included in the target file content.
[0148] In some embodiments, the electronic device may add a first address and a second address to the file identifier of a second file, where the first address is the address of the target file content in the first memory, and the second address is the address of the target file content in the second memory. In some embodiments, the electronic device may add a first address and a second address to the file identifiers of a third file and a fourth file, so as to update the addresses of the target file content included in the file identifiers of the third file and the fourth file.
[0149] In some embodiments, the electronic device may add a second flag bit to the file attributes included in the file identifier of the second file, and the second flag bit is used to indicate that the second file is a mirror file.
[0150] S1003. In response to a request to write a first file, and when the first memory and the second memory respectively store a copy of the target file content, the electronic device writes the first file based on a third writing method.
[0151] After writing the third file and the second file, the first memory and the second memory respectively store a copy of the target file content. When the electronic device detects a request to write the first file, the electronic device may write the first file based on the third writing method, so that the target file content already stored in the first memory and the second memory is associated with the first file, that is, the target file content is no longer written to the first memory or the second memory, and the first memory and the second memory still respectively store a copy of the target file content.
[0152] In some embodiments, the electronic device may write only the file identifier of the first file to the first memory or the second memory.
[0153] In some embodiments, the electronic device may add a first address and a second address to the file identifier of the first file, where the first address is the address of the target file content in the first memory, and the second address is the address of the target file content in the second memory.
[0154] In some embodiments, the electronic device may add a third flag bit to the file identifier of the first file, and the third flag bit is used to indicate that the first file is a duplicate file.
[0155] It can be understood that after the target file content is stored in the first memory and the second memory respectively, if the electronic device detects more requests to write files, and these files also include the target file content, it can write only the file identifiers of these files in the same or similar manner as in S1003 for responding to the request to write the first file, and add the first address and the second address of the target file content to the file identifier. That is, when the electronic device writes more than two files including the target file content, the electronic device can write the file identifier of each file, but only store one copy of the target file content in each memory respectively.
[0156] In the embodiment of the present application, when the electronic device receives multiple requests to write files, and all the multiple files include the same target file content, when the first memory and the second memory do not store the target file content, that is, when writing files for the first time, only one copy of the target file content is written to the first memory and / or the second memory in total, further improving the problem that duplicate data occupies a large amount of storage space; when one copy of the target file content is stored in the first memory and the second memory in total, that is, when repeating the same file for the first time, the target file content is written to the first memory and the second memory respectively; and when one copy of the target file content is stored in the first memory and the second memory respectively, that is, when repeating to write the same file again, the target file content is not written repeatedly, thereby improving the efficiency of reading duplicate data and the security of duplicate data on the basis of adding less duplicate data.
[0157] Please refer to Figure 11 , which is a flowchart of a method for writing data provided by an embodiment of the present application. Among them, this method is an implementation manner of the method shown above, and in this method, when writing the third file, the second file, and the first file including the target file content in sequence, the file is written according to the third writing method first, and then the file is written based on the second writing method. This method can also be understood as "deduping first and then mirroring". It should be noted that this method is not limited to Figure 6 and the specific order described below. It should be understood that in some embodiments, the order of some steps of this method can be interchanged according to actual needs, or some of the steps can also be omitted or deleted. The method includes the following steps: Figure 11 S1101, in response to a request to write the third file, and when the first memory and the second memory do not store the target file content, the electronic device writes the third file based on the first writing method.
[0158] Among them, the manner in which the electronic device executes S1101 can be the same as or similar to the manner of executing S1001, and will not be elaborated here one by one.
[0159]
[0160] S1102. The electronic device responds to a request to write a second file. Since the first memory and the second memory store a copy of the target file content in common, the second file is written based on a third writing method.
[0161] After writing the third file, the first memory and the second memory store a copy of the target file content in common. When the electronic device detects a request to write a second file, the second file can be written based on the third writing method, that is, the already stored target file content is associated with the second file, and there is no need to write the target file content again.
[0162] In some embodiments, the electronic device may only write the file identifier of the second file to the first memory or the second memory.
[0163] In some embodiments, the electronic device may add a third address to the file identifier of the second file.
[0164] In some embodiments, the electronic device may add a third flag bit to the file identifier of the second file, and the third flag bit is used to indicate that the second file is a duplicate file.
[0165] S1103. The electronic device responds to a request to write a first file. Since the first memory and the second memory store a copy of the target file content in common, the first file is written based on a second writing method.
[0166] After writing the third file, the first memory and the second memory store a copy of the target file content in common. When the electronic device detects a request to write a first file, the first file can be written based on the second writing method so that the first memory and the second memory respectively store a copy of the target file content.
[0167] In some embodiments, the electronic device may write the file identifier of the second file to the first memory or the second memory, and write the target file content to the memory that does not store the target file content among the first memory and the second memory.
[0168] In some embodiments, the electronic device may add a first address and a second address to the file identifiers of the first file, the second file, and the third file. The first address is the address of the target file content in the first memory, and the second address is the address of the target file content in the second memory.
[0169] In some embodiments, the electronic device may add a second flag bit to the file attributes included in the file identifier of the first file, and the second flag bit is used to indicate that the second file is a mirror file.
[0170] It can be understood that after the target file content is stored in the first memory and the second memory respectively, if the electronic device detects more requests to write files and these files also include the target file content, it can write only the file identifiers of these files in the same or similar manner as in S1102 in response to the request to write the second file, and add the first address and the second address of the target file content to the file identifier. That is, when the electronic device writes more than two files including the target file content, the electronic device can write the file identifier of each file, but only store one copy of the target file content in each memory respectively.
[0171] In the embodiment of the present application, when the electronic device receives multiple requests to write files and all the multiple files include the same target file content, when the target file content is not stored in the first memory and the second memory, that is, when writing the file for the first time, only one copy of the target file content is written to the first memory and / or the second memory in total; when one copy of the target file content is stored in the first memory and the second memory in total, that is, when writing the same file repeatedly for the first time, the target file content is not written repeatedly temporarily, but when writing the same file repeatedly again, one copy of the target file content is written to the first memory and the second memory respectively, so that for data with a small number of repeated writes, the number of times of writing repeated data can be reduced, and the problem that the repeated data occupies a large storage space can be further improved.
[0172] Please refer to Figure 12 , which is a flowchart of a method for writing data provided by the embodiment of the present application. Among them, this method is an implementation manner of the method shown above, and in this method, when writing the third file, the second file, and the first file including the target file content in sequence, when writing the third file, that is, when writing the target file content for the first time, the file can be written according to the second writing method, so that the first memory and the second memory store one copy of the target file content respectively, and then the second file, the first file, and other repeated files are written based on the third writing method. It should be noted that this method is not limited to Figure 6 the specific order described below. It should be understood that in some embodiments, the order of some steps of this method can be interchanged according to actual needs, or some of the steps can also be omitted or deleted. The method includes the following steps: Figure 12 S1201, the electronic device responds to the request to write the third file, and when the target file content is not stored in the first memory and the second memory, writes the third file based on the second writing method.
[0173]
[0174] In some embodiments, the electronic device may write the file identifier of the second file to the first memory or the second memory, and write the target file content to the first memory and the second memory respectively, so that the first memory and the second memory each store a copy of the target file content.
[0175] Exemplarily, the electronic device may write all data blocks included in the target file content to the first memory and the second memory respectively.
[0176] In some embodiments, the electronic device may add a first address and a second address to the file identifier of the third file, where the first address is the address of the target file content in the first memory, and the second address is the address of the target file content in the second memory.
[0177] S1202. In response to a request to write the second file, and when the first memory and the second memory each store a copy of the target file content, the electronic device writes the second file based on a third writing method.
[0178] After writing the third file, when the first memory and the second memory each store a copy of the target file content, and when the electronic device detects a request to write the second file, the electronic device may write the second file based on the third writing method, so that the target file content already stored in the first memory and the second memory is associated with the second file, that is, the target file content is no longer written to the first memory or the second memory, and the first memory and the second memory still each store a copy of the target file content.
[0179] In some embodiments, the electronic device may only write the file identifier of the second file to the first memory or the second memory.
[0180] In some embodiments, the electronic device may add a first address and a second address to the file identifier of the second file.
[0181] S1203. In response to a request to write the first file, and when the first memory and the second memory each store a copy of the target file content, the electronic device writes the first file based on a third writing method.
[0182] Wherein, the manner in which the electronic device executes S1203 may be the same as or similar to the manner of executing S1202, and will not be elaborated here one by one.
[0183] In some embodiments, the electronic device may only write the file identifier of the first file to the first memory or the second memory.
[0184] In some embodiments, the electronic device may add a first address and a second address value to the file identifier of the first file.
[0185] It is understandable that after storing a copy of the target file content in the first memory and the second memory respectively, if the electronic device detects more requests to write files, and these files also include the target file content, it can only write the file identifiers of these files in the same or similar manner as responding to the request to write the second file in S1202, and add the first address and the second address of the target file content in the file identifier. That is, in the case where the electronic device writes more than two files including the target file content, the electronic device can write the file identifier of each file, but only store a copy of the target file content in each memory respectively.
[0186] In an embodiment of the present application, when the electronic device receives multiple requests to write files and the multiple files all include the same target file content, when the target file content is not stored in the first memory and the second memory, that is, when the file is written for the first time, a copy of the target file content is written to the first memory and the second memory respectively, so that the electronic device can store the target file content in the first memory and the second memory earlier and faster, further improving the speed of reading the target file content and the security of the target file content.
[0187] In some embodiments, the electronic device may respond to the request to modify the first file and write the modified first file in the same or similar manner as the aforementioned writing of the first file. Exemplarily, the modified first file includes the modified target file content, and the electronic device may write the modified target file content to the first memory and the second memory respectively, and add a fourth address and a fifth address to the file identifier of the first file, the fourth address being the address of the modified target file content in the first memory, and the fifth address being the address of the modified target file content in the second memory.
[0188] Please refer to Figure 13 , is a flow chart of a method for arranging data provided by an embodiment of the present application. The method takes the installation of an application as an example to illustrate the method of writing data. It should be noted that the method does not Figure 13 The specific order described below is a limitation, and it should be understood that in some embodiments, the order of some steps in the method can be interchanged according to actual needs, or some steps can be omitted or deleted. The method includes the following steps:
[0189] S1301: The electronic device decompresses a compressed package of an application to be installed to obtain a first file included in the compressed package.
[0190] It is understandable that the compressed package of the application may include more files, and the electronic device may write each file included in the compressed file in the same or similar manner as writing the first file.
[0191] S1302, the electronic device determines the hash value of the first file.
[0192] In some embodiments, the first file includes the target file content, and the hash value of the first file may include a digest of the target file content.
[0193] S1303, the electronic device determines whether the database includes a second file identical to the first file. If the second file is not included, S1304 is executed; otherwise, S1305 is executed.
[0194] In some embodiments, the second file may be data of another application.
[0195] In some embodiments, the database includes the hash values of at least one file, and the electronic device may compare the hash values of the at least one file with the hash value of the first file. If the hash value of the second file is the same as the hash value of the first file, it is determined that the second file is the same as the first file; otherwise, it is determined that the second file is different from the first file. Alternatively, in some other embodiments, the database includes at least one file. When the hash value of the second file is the same as the hash value of the first file, the electronic device performs a full binary comparison of the at least one file with the first file. If the full binary comparison result of the second file and the first file is the same, it is determined that the second file is the same as the first file; otherwise, it is determined that the second file is different from the first file.
[0196] In some embodiments, the electronic device may write the hash value of the first file into the database to update the database.
[0197] S1304, the electronic device writes the first file based on the first writing method.
[0198] Wherein, the manner in which the electronic device executes S1304 may be the same as or similar to the manner of executing the foregoing S602, and will not be elaborated herein one by one.
[0199] S1305, the electronic device obtains the file identifier of the second file.
[0200] S1306, the electronic device determines whether the file identifier of the second file includes a first flag bit or a second flag bit. If the file identifier includes the first flag bit, S1307 is executed; if the file identifier includes the second flag bit, S1308 is executed.
[0201] In some embodiments, when the file identifier of the second file includes the first flag bit, it is determined that the first file is recognized as a duplicate of the second file of another application, and the second file is a normal file; when the file identifier of the second file includes the second flag bit, it is determined that the first file is recognized as a duplicate of the second file of another application, and the second file is a mirror file.
[0202] S1307, the electronic device writes the first file based on a second writing method.
[0203] When installing an application, if it is recognized that the first file duplicates the second file of another application and the second file is a normal file, then the two duplicate files can be converted into mirror files. Exemplarily, the first memory and the second memory can respectively store a copy of the target file content included in the first file, which enables subsequent parallel reading of the target file content from the first memory and the second memory, thereby improving the reading rate of the first file and the second file.
[0204] Among them, the manner in which the electronic device executes S1307 can be the same as or similar to the manner of executing the foregoing S603, and details are not described herein again.
[0205] S1308, the electronic device writes the first file based on a third writing method.
[0206] When installing an application, if it is recognized that the first file duplicates the second file of another application and the second file is a mirror file, that is, the same file duplicates three times or more, then the electronic device can write the first file based on the third writing method, thereby only writing the file identifier of the first file, which not only improves the writing rate of the first file, but also improves the problem that the storage space occupied by duplicate data is relatively large, and at the same time improves the reading rate of the first file.
[0207] Among them, the manner in which the electronic device executes S1308 can be the same as or similar to the manner of executing the foregoing S604, and details are not described herein again.
[0208] In the embodiments of the present application, when installing an application, the electronic device reduces the duplicate data written to the memory, improves the problem that the electronic device writes duplicate data every time an application is installed, and improves the performance of the electronic device.
[0209] Please refer to Figure 14 , which is a flowchart of a method for sorting data provided by the embodiments of the present application. Among them, this method can be used for the electronic device described above, and the electronic device includes at least two memories, such as a first memory and a second memory. It should be noted that this method is not limited by Figure 14 the specific order described below, and it should be understood that in some embodiments, the order of some steps of this method can be interchanged according to actual needs, or some of the steps can also be omitted or deleted. The method includes the following steps:
[0210] S1401. The electronic device, in response to detecting at least two copies of target file content in at least two memories, respectively retains one copy of the target file content in the first memory and the second memory, where the first memory and the second memory belong to the at least two memories.
[0211] When at least two memories of the electronic device store at least two copies of target file content, the at least two memories repeatedly store at least some data blocks included in the target file content. The at least some data blocks occupy storage space and cannot improve the rate of reading the target file content. Therefore, only one copy of the target file content can be retained in the first memory and the second memory, thereby saving storage space.
[0212] In some embodiments, the electronic device can write one copy of the target file content to the first memory and the second memory respectively, and delete other target file content stored in the first memory and the second memory. It can be understood that in actual applications, the electronic device can also retain the target file content in the first memory and the second memory in other ways.
[0213] S1402. The electronic device adds the first address and the second address of the target file content to the file identifier of at least one file, where the at least one file includes the target file content, the first address is the address of the target file content in the first memory, and the second address is the address of the target file content in the second memory.
[0214] After the electronic device sorts out the target file content stored in the first memory and the second memory, it can update the file identifier of at least one file including the target file content, so that the target file content can still be read based on the file identifier of the at least one file.
[0215] In the embodiments of the present application, the electronic device can sort out the stored data. When the first memory and the second memory are included and the stored target file content is greater than or equal to two copies, only one copy of the target file content is respectively retained in the first memory and the second memory, which improves the problem that duplicate data occupies a large amount of storage space, and also improves the rate of reading the target file content and the security of the target file content.
[0216] Please refer to Figure 15 , which is a flowchart of a method for reading data provided by the embodiments of the present application. Among them, the method can be used for the electronic device described above. The electronic device includes a first memory and a second memory, where the first memory and the second memory respectively store one copy of the target file content. In some embodiments, the first memory and the second memory can be all or part of the memories in the electronic device. It should be noted that the method is not based on Figure 15And subject to the specific order described below, it should be understood that in some embodiments, the order of some of the steps of this method can be interchanged according to actual needs, or some of the steps can also be omitted or deleted. The method includes the following steps:
[0217] S1501, in response to a request to read a first file, the electronic device reads the file identifier of the first file from the first memory or the second memory, and the file identifier of the first file includes a first address and a second address of the target file content.
[0218] Wherein, the first address is the address of the target file content in the first memory, and the second address is the address of the target file content in the second memory.
[0219] In some embodiments, the electronic device may issue a request to read the first file to the file system through the user layer.
[0220] S1502, the electronic device splits the target file content into a first part data block and a second part data block.
[0221] Since the first memory and the second memory respectively store the target file content of the first file, the request to read the first file can be split, so that the target file content is split into a first part data block and a second part data block, which is convenient for subsequent parallel reading of the target file content from the first memory and the second memory.
[0222] In some embodiments, the electronic device may perform an equal proportion division on the target file content, that is, the data volume of the first part data block is the same as that of the second part data block.
[0223] In some embodiments, the electronic device may divide the first part data block and the second part data block based on the reading speed of the first memory and the reading speed of the second memory. Among them, the data volume of the first part data block may be positively correlated with the reading speed of the first memory, and the data volume of the second part data block may be positively correlated with the reading speed of the second memory.
[0224] For example, the target file content of the first file includes a data block of 0MB (megabyte) - 10MB, and the electronic device may divide the target file content into the 0MB - the 5MB and the 6MB - the 10MB.
[0225] In some embodiments, the first part data block and the second part data block may include some identical data blocks.
[0226] In some embodiments, the read instructions sent by the file system to the memory are multiples of m KB (kilobytes). When the operation of reading the content of the target file is triggered, if the size of the requested data is less than or equal to m KB, the data can be read from the first memory or the second memory; if the size of the requested data is greater than m KB, for example, n m KB, the first part of the data blocks can include the 1st to the n / 2 (rounded down) data blocks in the data, and the second part of the data blocks can include the n / 2th to the nth data blocks in the data. Thus, the 1st to the n / 2th data blocks are read from the first memory, and the n / 2th to the nth data blocks are read from the second memory to achieve parallel data reading. Here, m and n are positive integers. Exemplarily, m can be 4.
[0227] S1503. The electronic device reads the first part of the data blocks of the target file content from the first memory based on the first address, and reads the second part of the data blocks of the target file content from the second memory based on the second address.
[0228] Since the electronic device can read the first part of the data blocks from the first memory and the second part of the data blocks from the second memory in parallel, the rate at which the electronic device reads the target file content from the first memory and the second memory is higher than the rate of reading the target file content from one memory.
[0229] In some embodiments, the electronic device can determine the position of the first part of the data blocks in the first memory based on the first address, read the first part of the data blocks from this position, determine the position of the second part of the data blocks in the second memory based on the second address, and read the second part of the data blocks from this position.
[0230] S1504. The electronic device combines the first part of the data blocks and the second part of the data blocks to obtain the target file content.
[0231] In some embodiments, if the first part of the data blocks and the second part of the data blocks include some identical data blocks, the electronic device can delete the identical data blocks in the first part of the data blocks or the identical data blocks in the second part of the data blocks, and combine the remaining other data blocks to obtain the target file content.
[0232] In some embodiments, the electronic device can return the target file content to the user layer through the file system.
[0233] In an embodiment of the present application, the electronic device may, in response to a request to read a first file, split the target file content included in the first file into a first partial data block and a second partial data block, read the first partial data block of the target file content from a first memory based on a first address, read the second partial data block of the target file content from a second memory based on a second address, and merge the first partial data block and the second partial data block to obtain the target file content. That is, the electronic device may read different parts of the target file content from the first memory and the second memory in parallel, thereby improving the rate of reading the target file content.
[0234] Please refer to Figure 16 , which is a flowchart of a method for writing data provided by an embodiment of the present application. Among them, this method can be used for the electronic device described above, and the electronic device includes a first set, and the first set includes multiple memories. In some embodiments, the multiple memories included in the first set may be all or part of the memories in the electronic device. It should be noted that this method is not limited by Figure 16 the specific order described below. It should be understood that in some embodiments, the order of some steps of this method may be interchanged according to actual needs, or some of the steps may also be omitted or deleted. The method includes the following steps:
[0235] S1601. When the electronic device responds to a request to write a first file, where the first file includes target file content, it determines whether each memory in the first set stores the target file content. If the multiple memories in the first set do not store the target file content, then S1602 is executed. If the multiple memories in the first set store a copy of the target file content in total, then S1603 is executed. If each memory in the first set stores a copy of the target file content respectively, then S1604 is executed.
[0236] In some embodiments, the first set may include the first memory and the second memory described above.
[0237] S1602. The electronic device writes the first file based on a first writing method, so that the multiple memories in the first set store a copy of the target file content in total.
[0238] When a request to write a first file is detected and the multiple memories included in the first set do not currently store the target file content included in the first file, the electronic device may write the first file based on a first writing method, so that the multiple memories in the first set store a copy of the target file content in total.
[0239] In some embodiments, the first writing method may include writing the file identifier of the first file to any memory in the first set, and co-writing a target file content to at least some of the memories in the first set. That is, writing the first file includes the file identifier and the target file content included in the first file.
[0240] In some embodiments, the electronic device may write all data blocks included in the target file content to any memory in the first set. In some other embodiments, the electronic device may write partial data blocks included in the target file content to at least two memories in the first set respectively, so that the at least two memories include all data blocks included in the target file content.
[0241] In some embodiments, the electronic device may add a third address to the file identifier of the first file, and the third address is the address of the target file content in the first set.
[0242] In some embodiments, the electronic device may add a first flag bit to the file attributes included in the file identifier of the first file, and the first flag bit is used to indicate that the first file is a normal file.
[0243] S1603, the electronic device writes the first file based on the second writing method, so that each memory in the first set stores a copy of the target file content respectively.
[0244] When detecting a request to write the first file and a plurality of memories in the first set co-store a copy of the target file content, the electronic device may write the first file based on the second writing method, so that each memory in the first set co-stores and stores a copy of the target file content respectively. Among them, the target file content is repeated once in each memory, and the target file content stored in each memory can be used as a mirror and backup of the target file content stored in other memories. This enables parallel reading of the target file content from multiple memories when reading the target file content subsequently, improving the reading rate of the target file content and the security of the target file content.
[0245] In some embodiments, the second writing method may include writing the file identifier of the first file to any memory in the first set, and writing the target file content to the memories in the first set that do not store the target file content respectively. That is, writing the file identifier included in the first file and creating a mirror of the target file content.
[0246] In some embodiments, the target file content is dispersedly stored in at least two memories in the first set. The electronic device may transfer all data blocks included in the target file content to any memory in the first set, and write the all data blocks to the other memories in the first set respectively.
[0247] In some embodiments, the electronic device may add a third set to the file identifier of the first file, where the third set includes multiple addresses, and each address in the third set is the address of the target file content in any one of the memories in the first set. In some embodiments, the electronic device may add the third set to the file identifier of another second file associated with the target file content, so as to update the address of the target file content included in the file identifier of the second file.
[0248] In some embodiments, the electronic device may add a second flag bit to the file attributes included in the file identifier of the first file, and the second flag bit is used to indicate that the first file is a mirror file.
[0249] In some embodiments, when a request to write the first file is detected and the multiple memories included in the first set do not currently store the target file content included in the first file, the electronic device may also write the first file based on a second writing method, so that each memory in the first set stores a copy of the target file content respectively.
[0250] S1604, the electronic device writes the first file based on a third writing method, so that the target file content already stored in each memory in the first set is associated with the first file.
[0251] When a request to write the first file is detected and each memory in the first set stores a copy of the target file content respectively, the electronic device may write the first file based on a third writing method, so that the target file content already stored in each memory in the first set is associated with the first file, that is, no longer write the target file content to any memory in the first set, and each memory in the first set still maintains storing a copy of the target file content respectively, thereby improving the problem that the electronic device repeatedly stores the same data, and at the same time retaining the effect that the target file content can be read in parallel from each memory in the first set.
[0252] In some embodiments, the third writing method may include writing only the file identifier of the first file to any one of the memories in the first set.
[0253] In some embodiments, the electronic device may add a third set to the file identifier of the first file, where the third set includes multiple addresses, and each of the multiple addresses is the address of the target file content in any one of the memories included in the first set.
[0254] In some embodiments, the electronic device may add a third flag bit to the file identifier of the first file, and the third flag bit is used to indicate that the first file is a duplicate file.
[0255] In some embodiments, the manner in which the electronic device executes S1601 - S1604 may be the same as or similar to the manner of executing S601 - S604, and will not be elaborated here one by one.
[0256] In the embodiments of the present application, when the electronic device responds to a request to write a first file, it may determine whether each memory in the first set stores the target file content, and perform different writing methods on the first file according to different storage situations. If each memory in the first set has already stored a copy of the target file content, then it may not be necessary to repeatedly write the target file content. Instead, only the file identifier of the first file is written to any one memory in the first set, and at the same time, the addresses of the target file content already stored in each memory in the first set are written with this file identifier. This not only improves the problem that duplicate data occupies a large amount of storage space, but also creates an independent file identifier for the first file, improves the problem of coupling between the first file and other identical files, enhances the atomicity and independence of the first file, and also facilitates parallel reading of the target file content from the first memory and the second memory, improving the efficiency of reading the target file content, and can also improve the security of the target file content.
[0257] Please refer to Figure 17 , which is a flowchart of a method for sorting data provided by an embodiment of the present application. Among them, this method can be used for the electronic device described above. The electronic device includes a first set, and the first set includes multiple memories. In some embodiments, the multiple memories included in the first set may be all or part of the memories in the electronic device. It should be noted that this method is not limited by Figure 17 the specific order described below. It should be understood that in some embodiments, the order of some steps of this method can be interchanged according to actual needs, or some of the steps can also be omitted or deleted. The method includes the following steps:
[0258] S1701, the electronic device responds to detecting the target file content in multiple memories included in the first set, and when the number of copies of the target file content is greater than or equal to the number of the multiple memories, a copy of the target file content is reserved in each memory included in the first set.
[0259] When the number of copies of the target file content stored in multiple memories included in the first set is greater than or equal to the number of the multiple memories, at least some of the multiple memories have repeatedly stored at least some data blocks included in the target file content. These at least some data blocks occupy storage space and cannot increase the rate of reading the target file content. Therefore, a copy of the target file content can be reserved in each memory included in the first set, thereby saving storage space.
[0260] In some embodiments, the electronic device may write a copy of the target file content to each memory in the first set and delete other target file contents stored in each memory in the first set. It can be understood that in practical applications, the electronic device may also retain a copy of the target file content in each memory included in the first set in other ways.
[0261] S1702. The electronic device adds a third set of the target file content to the file identifiers of at least one file. The third set includes a plurality of addresses, and each address in the plurality of addresses is the address of the target file content in any one of the memories included in the first set.
[0262] After the electronic device sorts out the target file contents stored in the multiple memories in the first set, it can update the file identifiers of at least one file including the target file content, so that the target file content can still be read based on the file identifiers of the at least one file.
[0263] In some embodiments, the at least one file includes a first file.
[0264] In the embodiments of the present application, the electronic device can sort out the stored data. When the number of copies of the stored target file content is greater than or equal to the number of memories included in the first set, only one copy of the target file content is respectively retained in each memory in the first set, which improves the problem that duplicate data occupies a large storage space. At the same time, it also improves the rate of reading the target file content and the security of the target file content.
[0265] Please refer to Figure 18 , which is a flowchart of a method for reading data provided by the embodiments of the present application. Among them, the method can be used for the electronic device described above. The electronic device includes a first set, and the first set includes a plurality of memories, and each memory in the plurality of memories stores a copy of the target file content. In some embodiments, the plurality of memories included in the first set may be all or part of the memories in the electronic device. It should be noted that the method is not limited to Figure 18 the specific order described below. It should be understood that in some embodiments, the order of some steps of the method can be interchanged according to actual needs, or some of the steps can also be omitted or deleted. The method includes the following steps:
[0266] S1801. In response to a request to read the first file, the electronic device reads the file identifier of the first file from any one of the memories in the first set. The file identifier of the first file includes a third set of the target file content, and the third set includes a plurality of addresses.
[0267] Wherein, each of the multiple addresses is the address of the target file content in the first set in any one of the memories.
[0268] In some embodiments, the first set may include the first memory and the second memory among the foregoing.
[0269] S1802, the electronic device splits the target file content into multiple partial data blocks.
[0270] Since each memory in the first set stores the target file content of the first file respectively, the request for reading the first file can be split, so that the target file content is split into multiple partial data blocks, which is convenient for subsequent parallel reading of the target file content from multiple memories.
[0271] S1803, the electronic device obtains partial data blocks from each memory in the second set based on each address in the fourth set, the fourth set includes at least two addresses in the third set, and the second set includes at least two memories in the first set.
[0272] Since the electronic device can parallelly read the partial data blocks included in the target file content from multiple memories, the rate at which the electronic device reads the target file content from multiple memories is higher than the rate of reading the target file content from one memory.
[0273] In some embodiments, the third set and the fourth set are the same, and the first set and the second set are the same. In some embodiments, the fourth set includes the first address and the second address, or the fourth set includes the fourth address and the fifth address; the second set includes the first memory and the second memory.
[0274] S1804, the electronic device merges the obtained multiple partial data blocks to obtain the target file content.
[0275] In the embodiments of the present application, the electronic device can respond to the request for reading the first file, split the target file content included in the first file into multiple partial data blocks, and parallelly read different parts of the target file content from multiple memories, thereby improving the rate of reading the target file content.
[0276] Based on the same inventive concept, as an implementation of the above method, the embodiments of the present application provide a data processing device. The device embodiments correspond to the foregoing method embodiments. For the convenience of reading, the details in the foregoing method embodiments will not be described one by one in the device embodiments, but it should be clear that the device in this embodiment can correspondingly implement all the content in the foregoing method embodiments.
[0277] In a possible implementation, the data processing device may correspond to the electronic device in the above method embodiments. For example, it may be an electronic device or a chip configured in an electronic device. The data processing device is used to execute each step or process corresponding to the electronic device in the above method.
[0278] Based on the same inventive concept, an embodiment of the present application further provides an electronic device. The electronic device includes: a memory and a processor. The memory is used to store a computer program; the processor is used to execute the method described in the above method embodiments when calling the computer program.
[0279] The electronic device provided in this embodiment can execute the above method embodiments, and its implementation principle and technical effects are similar, so details are not described herein again.
[0280] Based on the same inventive concept, an embodiment of the present application further provides a chip system. The chip system includes a processor, and the processor is coupled to a memory. The processor executes a computer program stored in the memory to implement the method described in the above method embodiments.
[0281] Among them, the chip system may be a single chip or a chip module composed of multiple chips.
[0282] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method described in the above method embodiments is implemented.
[0283] An embodiment of the present application further provides a computer program product. When the computer program product runs on an electronic device, the electronic device is caused to execute the method described in the above method embodiments.
[0284] When the above integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, to implement all or part of the processes in the above method embodiments of this application, a computer program can be used to instruct relevant hardware to complete. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, the steps of the above method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in the form of source code, object code, executable file or some intermediate form, etc. The computer-readable storage medium can at least include: any entity or device that can carry the computer program code to an electronic device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disc, etc.
[0285] In the above embodiments, the descriptions of the various embodiments have their own emphases. For parts not detailed or recorded in a certain embodiment, reference can be made to the relevant descriptions of some embodiments.
[0286] Those of ordinary skill in the art can realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.
[0287] In the embodiments provided in this application, it should be understood that the disclosed apparatus / devices and methods can be implemented in other ways. For example, the apparatus / device embodiments described above are merely illustrative. For example, the division of the modules or units is only a logical function division. In actual implementation, there can be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces. The indirect couplings or communication connections of the devices or units can be in electrical, mechanical or other forms.
[0288] It should be understood that, as used in the specification of the present application and the appended claims, the term "comprising" indicates the presence of the described features, integers, steps, operations, elements and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or their combinations.
[0289] It should also be understood that the term "and / or" as used in the specification of the present application and the appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0290] As used in the specification of the present application and the appended claims, the term "if" may be construed, depending on the context, as "when", "once", "in response to determining", or "in response to detecting". Similarly, the phrase "if determined" or "if [the described condition or event] is detected" may be construed, depending on the context, as meaning "once determined", "in response to determining", "once [the described condition or event] is detected", or "in response to detecting [the described condition or event]".
[0291] In addition, in the description of the specification of the present application and the appended claims, the terms "first", "second", "third", etc. are used only for descriptive distinction and should not be construed as indicating or implying relative importance.
[0292] The reference to "one embodiment" or "some embodiments" or the like described in the specification of the present application means that a specific feature, structure or characteristic described in connection with that embodiment is included in one or more embodiments of the present application. Thus, the statements "in one embodiment", "in some embodiments", "in other some embodiments", "in still other embodiments", etc. that appear in different places in this specification are not necessarily all referring to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in another way. The terms "comprising", "including", "having" and their variants all mean "including but not limited to", unless otherwise specifically emphasized in another way.
[0293] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application and are not intended to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some or all of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A data processing method, characterized in that, Applied to an electronic device, the electronic device includes a first memory and a second memory, and the method includes: In response to a request to write a first file, determining whether the first memory and the second memory store the target file content included in the first file; If both the first memory and the second memory store a copy of the target file content, writing the file identifier of the first file to the first memory or the second memory; Adding a first address and a second address to the file identifier of the first file, where the first address is the address of the target file content in the first memory, and the second address is the address of the target file content in the second memory.
2. The method according to claim 1, characterized in that, The method further includes: In response to a request to read the first file, obtaining the file identifier of the first file from the first memory or the second memory; Splitting the target file content into a first partial data block and a second partial data block; Reading the first partial data block from the first memory based on the first address, and reading the second partial data block from the second memory based on the second address; Merging the first partial data block and the second partial data block to obtain the target file content.
3. The method according to claim 2, characterized in that, The splitting of the target file content into a first partial data block and a second partial data block includes: Based on the reading speed of the first memory and the reading speed of the second memory, splitting the target file content into the first partial data block and the second partial data block, where the data volume of the first partial data block is positively correlated with the reading speed of the first memory, and the second partial data block is positively correlated with the reading speed of the second memory.
4. The method according to any one of claims 1-3, characterized in that, Before the response to the request to write the first file, the method further includes: In response to a request to write a second file, the second file includes the target file content, and the first memory and the second memory jointly store a copy of the target file content, writing the file identifier of the second file to the first memory or the second memory; Transferring the target file content to any one of the first memory and the second memory; Writing the target file content to the other memory of the first memory and the second memory; Adding the first address and the second address to the file identifier of the second file.
5. The method according to claim 4, characterized in that, Before the response to the request to write the second file, the method further includes: In response to a request to write a third file, the third file includes the target file content, and the first memory and the second memory do not store the target file content, writing the file identifier of the third file to the first memory or the second memory; Writing the target file content to the first memory and / or the second memory such that the first memory and the second memory jointly store a copy of the target file content; Add a third address to the file identifier of the third file, where the third address is the address of the target file content in the first memory and / or the second memory; After writing the target file content to the other memory of the first memory and the second memory, the method further includes: Add the first address and the second address to the file identifier of the third file.
6. The method according to claim 5, characterized in that, After responding to the request to write the third file and before responding to the request to write the second file, the method further includes: In response to a request to write a fourth file, where the fourth file includes the target file content, write the file identifier of the fourth file to the first memory or the second memory; Add the third address to the file identifier of the fourth file; After writing the target file content to the other memory of the first memory and the second memory, the method further includes: Add the first address and the second address to the file identifier of the fourth file.
7. The method according to any one of claims 1-3, characterized in that, Before responding to the request to write the first file, the method further includes: In response to a request to write a third file, where the third file includes the target file content and neither the first memory nor the second memory stores the target file content, write the file identifier of the third file to the first memory or the second memory; Write the target file content to the first memory and the second memory respectively; Add the first address and the second address to the file identifier of the third file.
8. The method according to any one of claims 1-7, characterized in that, The method further includes: In response to a request to modify the first file, write the modified target file content to the first memory and the second memory respectively; Add a fourth address and a fifth address to the file identifier of the first file, where the fourth address is the address of the modified target file content in the first memory, and the fifth address is the address of the modified target file content in the second memory.
9. The method according to any one of claims 1-8, characterized in that The method further includes: Obtain the first file from the installation package of the application to be installed.
10. A data processing method, characterized in that Applied to an electronic device, the electronic device includes at least two memories, and the method includes: In response to detecting at least two copies of target file content in the at least two memories, retain one copy of the target file content in the first memory and the second memory respectively, where the first memory and the second memory belong to the at least two memories; Add a first address and a second address to the file identifier of at least one file, where the at least one file includes the target file content, the first address is the address of the target file content in the first memory, and the second address is the address of the target file content in the second memory.
11. The method according to claim 10, characterized in that The at least one file includes a first file, and the method further includes: In response to a request to read the first file, obtain the file identifier of the first file from the first memory or the second memory; Split the target file content into a first part data block and a second part data block; Read the first partial data block from the first memory based on the first address, and read the second partial data block from the second memory based on the second address; Merge the first partial data block and the second partial data block to obtain the target file content.
12. An electronic device, characterized in that Comprising: A memory and a processor, the memory is used to store a computer program; the processor is used to execute the method according to any one of claims 1-9 or any one of claims 10-11 when calling the computer program.
13. A computer-readable storage medium, on which a computer program is stored, characterized in that When the computer program is executed by the processor, the method according to any one of claims 1-9 or any one of claims 10-11 is implemented.
14. A computer program product, characterized in that When the computer program product runs on an electronic device, the electronic device is caused to execute the method according to any one of claims 1-9 or any one of claims 10-11.