Data writing method and device, storage medium and program product
By detecting the remaining space of MDF file sub-files and dynamically allocating physical storage space, data movement is avoided, the problem of data loss during data writing is solved, and efficient and loss-free data writing is achieved.
Patent Information
- Application Number
- CN202410899968.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-05
- Publication Date
- 2024-10-25
AI Technical Summary
When writing data to an MDF file, it is easy to cause data loss during the data movement, especially when the data needs to be moved and re-recorded after the front part is full.
By detecting the remaining space of the target sub-file, if it is less than the preset space, writing is suspended and allocated to the target sub-file from unallocated physical storage space to avoid data movement and ensure writing efficiency and data integrity.
It effectively avoids data loss, improves writing efficiency and data integrity, and promptly detects that the target sub-file space is full for space expansion to prevent the occurrence of full writing.
Smart Images

Figure CN118838545A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data writing method, device, storage medium and program product. Background Art
[0002] MDF format is a file format for storing measurement data. It is a standard set by the Automobile Industry Association. MDF files can store various data, including time series data, event data, status data, etc. MDF files are often used in the field of automobile testing and diagnosis to record data from automobile sensors, output of control units, and other related information.
[0003] When writing data into an MDF file, in order to distinguish different data categories, the data of the same category needs to be written in one place. For example, the complete MDF file is divided into the front, middle and back parts. The front part is used to record the data of the first category, and the middle part is used to record the data of the second category. If the front part is full, it is necessary to increase the position for recording the data of the first category. At this time, it is necessary to move the data of the first category recorded in the front part to after the data of the second category, and then move the data of the second category and the data of the first category that have been recorded to the front part, and then continue to record the data of the first category at the position after the data of the second category and the data of the first category that have been recorded. However, in the process of moving data, data loss is easy to occur. Summary of the invention
[0004] The embodiments of the present application provide a data writing method, device, storage medium and program product, which can effectively avoid data loss.
[0005] In a first aspect, an embodiment of the present application provides a data writing method, the method comprising:
[0006] In response to a data writing instruction, determining a data category included in the data to be written corresponding to the data writing instruction;
[0007] For any data category, determine to write the data of any data category in the data to be written into a target subfile corresponding to the any data category in the target file, and detect the remaining space of the target subfile during the writing process, wherein the target file corresponds to a target number of subfiles, and the target number is the number of data categories included in the data to be written; different subfiles correspond to different data categories;
[0008] If it is detected that the remaining space of the target sub-file is less than the first preset space, writing is suspended, and a portion of physical storage space is selected from the physical storage space not allocated to the target file, allocated to the target sub-file corresponding to any one data category, and writing is continued.
[0009] In the above embodiment, data of any data category is written into the corresponding target sub-file. When the target sub-file is full, only the space of the target sub-file is expanded without moving the data, which can effectively avoid data loss. Moreover, the remaining space of the target sub-file is periodically detected, so that it can be determined in time that the target sub-file is full, and space expansion measures can be taken in time.
[0010] In a possible implementation manner, writing the data of any one data category in the data to be written into a target subfile corresponding to the any one data category in the target file includes:
[0011] Determining the data format of the data to be written from a preset description file corresponding to the target file;
[0012] The data of any one of the data categories is written into a target sub-file corresponding to the any one of the data categories according to the data format.
[0013] In the above embodiment, a description file corresponding to the target file and including the data format is pre-constructed so that during the data writing process, the data is written in accordance with the prescribed data format, thereby ensuring the uniformity of the data format of the data in the target file.
[0014] In a possible implementation manner, writing the data of any one data category into a target subfile corresponding to the any one data category according to the data format includes:
[0015] Querying the target physical storage space corresponding to the target sub-file from the description file;
[0016] Writing the data of any one data category into the virtual storage space pre-allocated for the target sub-file according to the data format;
[0017] The data in the virtual storage space is written into the queried target physical storage space through a paging operation.
[0018] In the above embodiment, the target physical storage space of the target sub-file is recorded in the pre-constructed description file, so that the corresponding target physical storage space can be quickly determined during the writing process; and writing to the physical storage space through memory mapping can avoid excessive I / O access to the physical storage space, thereby ensuring higher writing efficiency.
[0019] In a possible implementation, the physical storage space includes at least one storage unit, and the allocation status of the storage unit includes allocated and unallocated;
[0020] The selecting a portion of physical storage space from the physical storage space not allocated to the target file and allocating it to the target sub-file corresponding to any one of the data categories comprises:
[0021] A preset number of storage units in an unallocated state are selected from the physical storage space not allocated to the target file and allocated to the target sub-file, and the allocation state of the preset number of storage units is updated to allocated.
[0022] In the above embodiment, the storage unit with an allocation status of unallocated is allocated to the target sub-file, so that the space of the target sub-file can be expanded, and the allocation status of the storage unit is updated to allocated, so as to ensure that the storage unit in the allocated state will not be allocated when the space is allocated later.
[0023] In a possible implementation, the method further includes:
[0024] In response to the data write termination instruction, for any data category, if the remaining space of the target sub-file corresponding to the any data category is greater than the second preset space, unused physical storage space in the physical storage space allocated to the target sub-file is reclaimed.
[0025] In the above embodiment, after data writing is terminated, the unused physical space corresponding to the target sub-file is reclaimed to avoid wasting storage resources.
[0026] In a possible implementation manner, the reclaiming unused physical storage space in the physical storage space allocated to the target sub-file includes:
[0027] The allocation state of the storage unit corresponding to the unused physical storage space is set to unallocated.
[0028] In the above embodiment, the allocation status of the storage units corresponding to the unused physical space is set to unallocated, so that these storage units can be allocated to other files later.
[0029] In a second aspect, an embodiment of the present application provides a data writing device, the device comprising:
[0030] A response module, used for responding to a data writing instruction and determining a data category of the data to be written corresponding to the data writing instruction;
[0031] For any data category, a writing module is used to determine to write the data of any data category in the data to be written into a target subfile corresponding to the any data category in the target file, and detect the remaining space of the target subfile during the writing process, wherein the target file corresponds to a target number of subfiles, and the target number is the number of data categories contained in the data to be written; different subfiles correspond to different data categories;
[0032] The expansion module is used to suspend writing when it is detected that the remaining space of the target sub-file is less than the first preset space, and select a part of the physical storage space from the physical storage space not allocated to the target file, allocate it to the target sub-file corresponding to any one of the data categories, and continue writing.
[0033] In a third aspect, an embodiment of the present application provides an electronic device, the electronic device comprising:
[0034] At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor executes the method as described in the first aspect above.
[0035] In a fourth aspect, an embodiment of the present application provides a vehicle, comprising the electronic device as described in the third aspect above.
[0036] In a fifth aspect, an embodiment of the present application provides a computer storage medium, wherein the computer storage medium stores a computer program, and the computer program is used to enable a computer to execute the method in the first aspect as described above.
[0037] In a sixth aspect, an embodiment of the present application provides a computer program product, which implements the method in the first aspect above when the computer program is executed by a processor. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 A schematic diagram of an application scenario of a data writing method according to an exemplary embodiment of the present invention;
[0039] Figure 2 A schematic diagram of a data writing method according to an exemplary embodiment of the present invention;
[0040] Figure 3 A schematic diagram of a specific flow chart of a data writing method according to an exemplary embodiment of the present invention;
[0041] Figure 4 A schematic diagram of a data writing device according to an exemplary embodiment of the present invention;
[0042] Figure 5 The figure is a schematic diagram of an electronic device according to an exemplary embodiment of the present invention. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical scheme and advantages of the present application clearer, the technical scheme in the embodiment of the present application will be clearly and completely described below in conjunction with the drawings in the embodiment of the present application. Obviously, the described embodiment is only a part of the embodiment of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application. In the absence of conflict, the embodiments in the present application and the features in the embodiments can be arbitrarily combined with each other. In addition, although the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in an order different from that here.
[0044] The acquisition, storage, use, and processing of data in the embodiments of this application comply with the relevant provisions of national laws and regulations.
[0045] First, some concepts involved in the embodiments of the present application are introduced.
[0046] MDF file: is a file format for storing measurement data, which is a standard set by the Automobile Industry Association. MDF files can store various data, including time series data, event data, status data, etc. MDF files are often used in the field of automotive testing and diagnosis, and can record vehicle sensor data, control unit output, and other related information.
[0047] Data block: Also referred to as subfile in the embodiments of the present application. It is a group of records arranged in sequence and is a data unit for transmission between the main memory and the input, output device or external memory. It is a physical record of data. The design of data block size is affected by many factors, including input and output efficiency, storage space cost, and computer application characteristics.
[0048] Physical storage space: a real storage device deployed in a computer device, such as a disk.
[0049] Virtual storage space: It is a technology for computer system memory management. It makes the application think that it has continuous available memory (a continuous and complete address space), but in fact, it is usually divided into multiple physical memory fragments, and some are temporarily stored in external disk storage for data exchange when needed.
[0050] Paging: It can also be called page replacement. The page replacement algorithm is an algorithm used to determine which pages need to be replaced. When the memory is insufficient, some pages can be replaced on the disk to make room for new data. The page replacement algorithm can be a first-in-first-out algorithm, a least recently used algorithm, etc. They determine which pages need to be replaced based on the access situation of the page. The embodiment of the present application does not specifically limit the category of the page replacement algorithm.
[0051] Target file: used to record multiple categories of data, which can be real-time measurement data, such as data measured by a temperature sensor, or pre-calibrated data, such as the mapping relationship between engine speed and gear position. The embodiments of the present application do not make specific limitations.
[0052] Sub-file: also called data block, which is obtained by splitting the blank target file before writing data into the target file.
[0053] Identification file: It can also be called identification data block, which is used to define the data format of the data to be written. For example, if the data format is MDF format, the identification file can also include the format version, such as the MDF version. When writing data in the 2001 version of the MDF file, it is different from the 2010 version.
[0054] Description file: It can also be called a title data block, which is used to describe the target file. It can include the physical storage space of each sub-file corresponding to the target file, the file identifier of each sub-file corresponding to the target file, the number of sub-files corresponding to the target file, the file size of each sub-file corresponding to the target file, the time when each sub-file corresponding to the target file starts writing data, and can also include comments, the purpose of the data to be written, etc. The embodiment of the application does not limit the content contained in the description file. In addition, the content of the identification file can also be merged into the description file, and this embodiment of the application is specifically limited.
[0055] The data writing method in the embodiment of the present application is described in detail below with reference to the accompanying drawings.
[0056] like Figure 1 The figure shows an application scenario of a data writing method provided by an embodiment of the present application, which includes an electronic control unit 101 deployed in a vehicle, at least one sensor (such as sensor 102_1, sensor 102_2, ..., sensor 102_N as shown in the figure) and a physical storage medium 103. The sensor is used to collect the operating parameters of the vehicle and upload them to the electronic control unit 101, and then the electronic control unit controls the collected data to be written into the physical storage medium 103.
[0057] Among them, the sensor can be a sensor for measuring the exhaust temperature during engine operation, or a sensor for measuring the concentration of nitrogen oxides in the exhaust gas during engine operation; the physical storage medium 103 can be a magnetic disk for storing data collected by each sensor in the MDF data format. The embodiment of the present application does not specifically limit the type of sensor and the type of physical storage medium 103.
[0058] The data to be written into the physical storage medium 103 may be data measured in real time by sensors of the vehicle, or may be data copied from other devices, such as data calibrated during an experiment and stored in other devices. The other devices may be servers, terminals, USB flash drives, etc. The embodiments of the present application do not specifically limit the types of other devices.
[0059] Based on the problem of data loss in the existing data writing process, the present application embodiment provides a data writing method, the specific process is as follows: Figure 2 shown.
[0060] S201: In response to a data writing instruction, determine a data category included in the data to be written corresponding to the data writing instruction.
[0061] In the field of automobile testing and diagnosis, the data written to the disk deployed in the automobile can be data measured by the sensor in real time, or data transmitted from other devices, such as pre-calibrated data stored in other devices, which is not specifically limited in the embodiments of the present application. For data measured by the sensor in real time, some sensors can only collect data when the operating state of the vehicle meets specific conditions. Therefore, the response data write instruction can be a response to a write instruction triggered when the operating state of the vehicle is detected to be a preset state. For data transmitted from other devices, the triggering of the write instruction can be achieved through user operation, for example, triggering data writing through the display interface of the vehicle, or triggering data writing by voice. The embodiments of the present application do not limit the specific method of triggering the data write instruction.
[0062] In the data writing instruction, the data category of the data to be written is carried to determine the specific writing process of the data to be written. The data category may include multiple data, such as temperature data, exhaust flow data, engine speed data, etc. The embodiment of the present application does not specifically limit the category of the data to be written.
[0063] S202: For any data category, determine to write the data of the any data category in the data to be written into a target sub-file corresponding to the any data category in the target file, and detect the remaining space of the target sub-file during the writing process.
[0064] Among them, the sub-files (also called data blocks) are obtained by splitting the blank target file. The number of sub-files is the same as the number of data categories contained in the data to be written. For example, the data categories are temperature data, exhaust flow data, and engine speed data. The blank target file is split into 3 sub-files, and then each data category corresponds to a sub-file. For example, the data category "temperature" can be carried in a sub-file, so that the electronic control unit can clearly know which sub-file to write the temperature data into.
[0065] The blank target file is a file pre-allocated for the data to be written, and is specifically used to record the data to be written. For example, a 3G blank target file is reserved for the data to be written, and the data to be written includes 3 categories. The corresponding 3 sub-files have a space of 1G each. The embodiment of the present application does not specifically limit the space size of the blank target file and the space size of the sub-files obtained after splitting.
[0066] When splitting a blank target file, a description file is further constructed, which may include a data format. When writing data, the data format of the data to be written is first determined from the description file corresponding to the preset target file; then, the data of any data category is written into the target sub-file corresponding to the any data category according to the data format. For example, if the data format in the description file is MDF, when writing temperature data, the temperature data needs to be written into the corresponding sub-file according to the MDF format.
[0067] The description file may also include the target physical storage space corresponding to the subfile. When writing data according to the data format, it is necessary to query the target physical storage space corresponding to the target subfile from the description file; write the data of any data category into the virtual storage space pre-allocated for the target subfile according to the data format; and write the data in the virtual storage space into the queried target physical storage space through the paging operation. For example, the target physical storage space corresponding to the target subfile is recorded in the description file as address 0001 to address 1000 on the disk. For the convenience of recording, the addresses of the physical storage spaces corresponding to each subfile can be continuous, so that only the starting address and the ending address need to be recorded in the description file. Among them, the virtual storage space can be pre-allocated according to the size of the target physical storage space. Since the paging operation is performed in real time, the virtual storage space can also be slightly smaller than the target physical storage space. The embodiment of the present application does not specifically limit the size of the virtual storage space.
[0068] Data will eventually be written into the physical storage space, such as into the disk. If data is written directly into the disk, the hard disk I / O port will be frequently accessed, and then file I / O operations will be frequently performed. Buffering is also required when writing data, and the writing efficiency is extremely low. In order to solve the above problems, the embodiment of the present application provides a "memory mapping" method, that is, mapping the target sub-file to the virtual storage space, and then writing the data from the virtual storage space to the physical storage space. Through memory mapping, it is equivalent to establishing the space where the file on the disk is located as a virtual memory. When the program accesses it, it can be performed in a memory manner, which saves some links of the ordinary I / O method and greatly improves the writing efficiency. Writing data from the virtual storage space into the physical storage space can be specifically implemented through a paging operation, and the paging can be implemented specifically through a first-in-first-out algorithm, which is not specifically limited in the embodiment of the present application.
[0069] When writing data of any data category, it is necessary to determine the specific writing area, that is, the target physical storage space. In the present embodiment of the application, a description file can be specially constructed to record this information, or each sub-file can carry its own corresponding physical storage space, for example, the sub-file includes "01-temperature-address 0001~1000", which is not specifically limited in the present embodiment of the application.
[0070] In addition to recording the data format and the physical storage space corresponding to the sub-files, the description file may also record other target file information, such as the file identifier of each sub-file, the number of sub-files, the file size of each sub-file, the purpose of the data to be written, comments, etc., which is not specifically limited in the embodiments of the present application.
[0071] During the writing process, if the reserved space is full, it will affect the writing of subsequent data. For the scene of real-time data upload by vehicle sensors, there may be a situation where the data will not be interrupted as long as the vehicle is running. In this case, the data written is streaming, and the amount of data to be written cannot be pre-judged, and then it may not be possible to reserve enough writing space for the data to be written, so there will be a "full" situation, and the physical storage space of the sub-file needs to be expanded at this time. In order to obtain the writing status of the data in the sub-file during the writing process in time, the embodiment of the present application will periodically detect the remaining space of the sub-file. The detection cycle can be 1 second or 1 minute. It can be set according to the actual situation. For example, for data generated only when specific conditions are met, the generation frequency is low, and the writing rate will also be low. At this time, a larger detection cycle can be set. During the writing process, it may be that multiple categories of data are written into the corresponding sub-files at the same time, so the process of detecting the remaining space is also executed simultaneously. The detection cycle of each sub-file may be the same or different. The embodiment of the present application does not limit the setting method of the detection cycle.
[0072] S203: If it is detected that the remaining space of the target sub-file is less than the first preset space, suspend writing, select a portion of physical storage space from the physical storage space not allocated to the target file, allocate it to the target sub-file corresponding to any one of the data categories, and continue writing.
[0073] For any data category, when it is detected that the remaining space of the target sub-file of any data category is less than the first preset space, for example, for a 1G target sub-file, the first preset space is 64M. If the remaining space is detected to be 63M in the current detection cycle, the writing of data of any data category is stopped to prevent the situation of being full before the expansion is successful. The data that has not been written can be temporarily stored in the cache and written after the expansion. The expansion method can be specifically implemented as follows:
[0074] From the physical storage space not allocated to the target file, a preset number of storage units with an allocation status of unallocated are selected to be allocated to the target subfile, and the allocation status of the preset number of storage units is updated to allocated. For example, 1000 unallocated storage units are selected to be allocated to the target subfile, and the embodiment of the present application does not limit the size of the expanded space. In the embodiment of the present application, these 1000 storage units can be merged with the previous physical storage space by creating a file stream, that is, the target physical storage space corresponding to the target file is expanded by the file stream.
[0075] The physical storage space includes a plurality of storage units, each of which may correspond to a storage address. The allocation status of the storage unit may include allocated and unallocated, and the allocation status of the storage unit may be as shown in Table 1.
[0076] Table 1
[0077]
[0078]
[0079] In a possible implementation, when it is determined that the vehicle is in a parking state, a data write termination instruction may be triggered, and the write termination indicates that no data will be written subsequently. At this time, it is detected whether there is remaining space in each sub-file, and if the remaining space is greater than the second preset space, the remaining space is recycled, that is, the unused physical storage space in the physical storage space allocated to the sub-file is recycled.
[0080] The second preset space can be set to be the same as the first preset space, or can be set to be different, which is not specifically limited in the embodiment of the present application. The space recovery method provided in the embodiment of the present application is specifically as follows:
[0081] The allocation state of the storage unit corresponding to the unused physical storage space is set to unallocated.
[0082] Specifically, the allocation of physical storage space can be achieved by managing Table 1. When the allocation status of a storage unit is set to allocated, it indicates that the storage unit has been allocated. If the allocation status is unallocated, it indicates that the storage unit is currently unallocated. First, the storage unit address of the unused physical storage space is queried from Table 1, and then the corresponding allocation status is updated to unallocated, which indicates that these storage units can be allocated to other data.
[0083] Since each subfile is obtained by splitting the target file, and the data in each subfile is associated (for example, these data need to be analyzed to obtain the final analysis result), after the writing is terminated, the embodiment of the present application can also associate each subfile into a file to facilitate subsequent data analysis. Based on the above S302, the physical storage space of each subfile corresponding to the target file is recorded in the description file, so the "storage information" recorded in the description file can be used to associate each subfile together. When reading the target file, the data in the target file (a file) can be displayed on the display interface according to these storage information, without being divided into multiple subfiles for display. In addition, these storage information can also be recorded in each subfile. For example, for two subfiles, the physical storage space of one of the subfiles is recorded in the description file, and the physical storage space of the subfile itself and the physical storage space of the other subfile are recorded in the subfile. In this way, one of the subfiles can be found through the description file, and then the subfile can be associated with other subfiles, so that the effect of associating multiple subfiles together can also be achieved. The embodiment of the present application does not limit the specific subfile association method.
[0084] The following is based on Figure 3 The data writing method provided in the embodiment of the present application is described in detail.
[0085] S301: Respond to a data write instruction. The data write instruction may be responded to when the data is first recorded, or may be responded to again after a period of data interruption. This embodiment of the present application does not specifically limit this.
[0086] S302: Determine the data category of the data to be written, and determine the sub-file corresponding to the data category; the data category may include multiple data categories, each data category corresponds to a sub-file, and the sub-file is obtained by splitting the blank target file. The number of sub-files is the same as the number of data categories, and the number of sub-files is a fixed value, that is, before the data is written, the total number of data categories included in the data to be written is fixed, but when writing, data of some data categories may be written in the first time period, and data of another data category may be written in the second time period. In other words, data of different data categories may not be written into sub-files at the same time, but which category of data is written into which sub-file is pre-set.
[0087] S303: Write the data into the physical storage space corresponding to the sub-file of the description file according to the data format in the description file. After determining the sub-files corresponding to each data category, the writing process begins. The specific writing process is the same as the implementation method in S202 above, which will not be repeated here.
[0088] S304: Determine whether the remaining space of each sub-file is less than the first preset space, if so, execute S305, otherwise, execute S304 periodically.
[0089] S305: suspend writing, and select a part of physical storage space from the physical storage space not allocated to the target file, allocate it to the sub-file, and continue writing, and then end. The specific expansion process is the same as S203 above, which will not be repeated here.
[0090] In a possible implementation, after the writing is terminated, the sub-files may be further merged, that is, associated together, to obtain an MDF file containing data of each data category, so as to facilitate the reading of the target file.
[0091] The embodiment of the present application can avoid data movement and thus data loss by splitting the target file and using file streams to separately expand the physical storage space of the sub-files. It also uses memory mapping technology to write data, which is equivalent to establishing the space where the file on the disk is located as a virtual memory, which can be accessed by the program in a memory manner, eliminating some links of the ordinary I / O method and improving the speed and accuracy of real-time data writing.
[0092] Based on the same inventive concept, the embodiment of the present application also provides a data writing device, such as Figure 4 As shown, the device comprises:
[0093] A response module 401 is used to respond to a data writing instruction and determine the data category of the data to be written corresponding to the data writing instruction;
[0094] For any data category, the writing module 402 is used to determine to write the data of any data category in the data to be written into the target sub-file corresponding to the any data category in the target file, and detect the remaining space of the target sub-file during the writing process, wherein the target file corresponds to a target number of sub-files, and the target number is the number of data categories included in the data to be written; different sub-files correspond to different data categories;
[0095] The expansion module 403 is used to suspend writing when it is detected that the remaining space of the target sub-file is less than the first preset space, and select a part of the physical storage space from the physical storage space not allocated to the target file, allocate it to the target sub-file corresponding to any one data category, and continue writing.
[0096] In a possible implementation, the writing module 402 is used to:
[0097] Determining the data format of the data to be written from a preset description file corresponding to the target file;
[0098] The data of any one of the data categories is written into a target sub-file corresponding to the any one of the data categories according to the data format.
[0099] In a possible implementation, the writing module 402 is used to:
[0100] Querying the target physical storage space corresponding to the target sub-file from the description file;
[0101] Writing the data of any one data category into the virtual storage space pre-allocated for the target sub-file according to the data format;
[0102] The data in the virtual storage space is written into the queried target physical storage space through a paging operation.
[0103] In a possible implementation, the physical storage space includes at least one storage unit, and the allocation status of the storage unit includes allocated and unallocated;
[0104] The expansion module 403 is used for:
[0105] A preset number of storage units in an unallocated state are selected from the physical storage space not allocated to the target file and allocated to the target sub-file, and the allocation state of the preset number of storage units is updated to allocated.
[0106] In a possible implementation, the device further includes a recovery module, which is used to:
[0107] In response to the data write termination instruction, for any data category, if the remaining space of the target sub-file corresponding to the any data category is greater than the second preset space, unused physical storage space in the physical storage space allocated to the target sub-file is reclaimed.
[0108] In one possible implementation, the recovery module is used to:
[0109] The allocation state of the storage unit corresponding to the unused physical storage space is set to unallocated.
[0110] Based on the same inventive concept, the present application embodiment also provides an electronic device, such as Figure 5 As shown, the electronic device includes:
[0111] Processor 501 , memory 502 and communication interface 503 ; bus 504 . The processor 501 , memory 502 and communication interface 503 are interconnected via the bus 504 .
[0112] The processor 501 is used to read and execute instructions in the memory 502, so that the at least one processor can execute a data writing method provided by the above embodiment.
[0113] The memory 502 is used to store various instructions and programs of the data writing method provided in the above embodiment.
[0114] The communication interface 503 is used for data exchange between various sensors and external devices and the electronic control unit.
[0115] The bus 504 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0116] The processor 501 may be a central processing unit (CPU), a network processor (NP), a graphic processing unit (GPU), or any combination of CPU, NP, and GPU. It may also be a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0117] The memory 502 may include a readable medium in the form of a volatile memory, such as a random access memory (RAM) and / or a cache memory, and may further include a read-only memory (ROM). The memory 502 may also include a program / utility having a set (at least one) of program modules, such program modules including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include the implementation of a network environment.
[0118] Based on the same inventive concept, the embodiment of the present application also provides a vehicle, such as Figure 1 As shown, the vehicle comprises:
[0119] Electronic control units, such as Figure 5 The electronic device shown acquires data uploaded by each sensor and executes a data writing method provided in an embodiment of the present application according to the data;
[0120] The sensor is used to collect the corresponding data to be written and upload it to the electronic control unit so that the electronic control unit writes the data to be written into the physical storage medium;
[0121] Physical storage medium used to store data uploaded by the electronic control unit.
[0122] The embodiment of the present application also provides a computer program product, including a computer program, which implements any of the above-mentioned data writing methods when the computer program is executed by a processor. For example, the method in the present application can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instruction is loaded and executed on a computer, the process or function of the present application is executed in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, a network device, a user device, a core network device, or other programmable device.
[0123] Optionally, a computer-readable storage medium can be used as an implementation method of the above-mentioned computer program product, that is, an embodiment of the present application also provides a computer-readable storage medium, which includes a computer program, and when the computer program is executed by a processor, it implements any of the above-mentioned data writing methods.
[0124] For example, a computer program or instruction may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, a computer program or instruction may be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired or wireless means. A computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. Available media may be magnetic media, such as a floppy disk, a hard disk, or a magnetic tape; may also be optical media, such as a digital video disk; or may be semiconductor media, such as a solid-state drive. The computer-readable storage medium may be a volatile or non-volatile storage medium, or may include both volatile and non-volatile types of storage media.
[0125] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0126] These computer programs can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0127] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0128] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.
[0129] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A data writing method, characterized in that: The method comprises: In response to a data writing instruction, determining a data category included in the data to be written corresponding to the data writing instruction; For any data category, determine to write the data of any data category in the data to be written into a target subfile corresponding to the any data category in the target file, and detect the remaining space of the target subfile during the writing process, wherein the target file corresponds to a target number of subfiles, and the target number is the number of data categories included in the data to be written; different subfiles correspond to different data categories; If it is detected that the remaining space of the target sub-file is less than the first preset space, writing is suspended, and a portion of physical storage space is selected from the physical storage space not allocated to the target file, allocated to the target sub-file corresponding to any one data category, and writing is continued.
2. The method according to claim 1, characterized in that The step of writing the data of any one data category in the data to be written into a target subfile corresponding to the data category in the target file includes: Determining the data format of the data to be written from a preset description file corresponding to the target file; The data of any one of the data categories is written into a target sub-file corresponding to the any one of the data categories according to the data format.
3. The method according to claim 2, characterized in that The step of writing the data of any one of the data categories into a target sub-file corresponding to the any one of the data categories according to the data format comprises: Querying the target physical storage space corresponding to the target sub-file from the description file; Writing the data of any one data category into the virtual storage space pre-allocated for the target sub-file according to the data format; The data in the virtual storage space is written into the queried target physical storage space through a paging operation.
4. The method according to any one of claims 1 to 3, characterized in that: The physical storage space includes at least one storage unit, and the allocation status of the storage unit includes allocated and unallocated; The selecting a portion of physical storage space from the physical storage space not allocated to the target file and allocating it to the target sub-file corresponding to any one of the data categories comprises: A preset number of storage units in an unallocated state are selected from the physical storage space not allocated to the target file and allocated to the target sub-file, and the allocation state of the preset number of storage units is updated to allocated.
5. The method according to claim 4, characterized in that The method further comprises: In response to the data write termination instruction, for any data category, if the remaining space of the target sub-file corresponding to the any data category is greater than the second preset space, unused physical storage space in the physical storage space allocated to the target sub-file is reclaimed.
6. The method according to claim 5, characterized in that The step of reclaiming unused physical storage space in the physical storage space allocated to the target sub-file comprises: The allocation state of the storage unit corresponding to the unused physical storage space is set to unallocated.
7. An electronic device, characterized in that: The electronic device comprises: At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor so that the at least one processor executes a method as claimed in any one of claims 1 to 6.
8. A vehicle, characterized in that: The vehicle comprises the electronic device as claimed in claim 7.
9. A computer storage medium, characterized in that The computer storage medium stores a computer program, and the computer program is used to make a computer execute any one of the methods according to claims 1-6.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Cited By
Data storage method, medium, electronic equipment and program product
CN119937921A
A data storage method, medium, electronic device, and program product
CN119937921B
