Data storage method and device, and electronic device

By obtaining the sub-data objects and their editing interface objects of the project data object, and using the target data compression algorithm and the variable integer length algorithm, the problems of excessively large archived project data and long opening times are solved, and fast incremental saving and loading are achieved.

CN116243856BActive Publication Date: 2026-04-14SUPCON TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SUPCON TECH CO LTD
Filing Date
2022-12-29
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

In existing technologies, saving archived project data according to the actual data type length results in large archives, long opening times, and existing methods cannot achieve one-click incremental saving of the entire project.

Method used

By obtaining the sub-data objects and their editing interface objects of the original engineering data object, the state information is determined, and the actual length integer is compressed to the preset length using the target data compression algorithm. Only the sub-data objects whose state information has been modified are saved, and a variable integer length algorithm is used for data encoding and multi-threaded deserialization.

Benefits of technology

It enables quick one-click incremental saving of projects, significantly reducing archive size, shortening project opening time, and improving saving and loading speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116243856B_ABST
    Figure CN116243856B_ABST
Patent Text Reader

Abstract

The application discloses a data storage method, device and electronic equipment. The method comprises the following steps: obtaining a plurality of sub-data objects of an original engineering data object, and obtaining an editing interface object corresponding to each sub-data object; determining state information of each sub-data object according to the editing interface object; and compressing and storing a target sub-data object by a target data compression algorithm, wherein the target data compression algorithm is used for compressing an actual length integer to a preset length, and the target sub-data object is a sub-data object whose state information is modified. The application solves the technical problem that the current archived engineering data is saved according to the actual data type length, resulting in large archiving and long time consumption for opening the engineering.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data storage, and more specifically, to a data storage method, apparatus, and electronic device. Background Technology

[0002] When editing large configuration projects, saving the entire project repeatedly is time-consuming, requiring a technology to implement incremental saving to speed up the process. Similarly, opening large project archives is time-consuming, necessitating faster archive loading. Using fast binary serialization for project data, serializing data according to defined data type lengths results in large archives, requiring compression of the original data.

[0003] In existing technologies, most configuration archives are saved by binary serialization of project data or as custom format archive data. Incremental saving only supports saving single-page data and cannot achieve one-click incremental saving of the entire project. Saving is based on the actual data type length, resulting in large archives and long opening times for the project.

[0004] There is currently no effective solution to the above problems. Summary of the Invention

[0005] This application provides a data storage method, apparatus, and electronic device to at least solve the technical problem that currently, archival project data is saved according to the actual data type length, resulting in large archives and long opening times.

[0006] According to one aspect of the embodiments of this application, a data storage method is provided, comprising: acquiring a plurality of sub-data objects of an original engineering data object, and acquiring an editing interface object corresponding to each sub-data object; determining the state information of each sub-data object based on the editing interface object; and compressing and storing a target sub-data object using a target data compression algorithm, wherein the target data compression algorithm is used to compress an integer of actual length to a preset length, and the target sub-data object is a sub-data object whose state information has been modified.

[0007] Optionally, the state information of each sub-data object is determined based on the editing interface object, including: obtaining the data processing method provided by the editing interface object of each sub-data object; if the current sub-data object calls the data processing method, the state of the current sub-data object is determined to be a first state, wherein the first state is used to indicate that the state information of the current sub-data object has been modified; if the current sub-data object does not call the data processing method, the state of the current sub-data object is determined to be a second state, wherein the second state is used to indicate that the state information of the current sub-data object has not been modified.

[0008] Optionally, the target data compression algorithm processes the data in the following ways: acquiring the target sub-data object whose state information has changed; converting the value of the target sub-data object into binary data; dividing the binary data according to a preset length to obtain the number of bytes required to convert the target sub-data object into binary data; encoding each byte according to a preset method to obtain the encoded data corresponding to each byte; and determining the compressed data corresponding to the target sub-data object based on the encoded data corresponding to each byte.

[0009] Optionally, each byte is encoded according to a preset method, including: if the length of the data in the current byte does not meet the preset length, 0 is used to fill the data before the current byte until the length of the current byte is the preset length; the first bit of each byte is determined, wherein the first bit of each byte is used to indicate whether there is a next byte after the current byte.

[0010] Optionally, the target sub-data object is compressed and stored using a target data compression algorithm, including: storing the compressed data obtained after compressing the target sub-data object in a data block, wherein the structure of the data block includes: the identifier ID of the data block, the length of the compressed data, the compressed data, the number of child nodes corresponding to the compressed data, the identifier ID corresponding to each child node, and the checksum of the data block.

[0011] Optionally, the method further includes: identifying the modified project data object through the project editing interface object; compressing the project data object according to the target data compression algorithm and storing it in a data block, and obtaining the identifier ID of the data block; traversing the sub-data objects of the project data object according to the identifier ID of the data block; if the sub-data objects are modified, compressing the sub-data objects according to the target data compression algorithm and storing them in a data block; and saving the data block to the disk to obtain the project index file.

[0012] Optionally, the method further includes: loading the binary file corresponding to the data block of the sub-data object based on the project index file; parsing the data block corresponding to the project data object to obtain the project data object; determining the number of threads required to process the data block of the sub-data object based on the number of data blocks of the sub-data object, the size of the data block, and the amount of data that each thread can process; starting threads according to the number of threads, and storing the data block of the sub-data object in a cache after deserialization by the threads; obtaining the identification ID list of the sub-data object from the project data object, retrieving the sub-data object from the cache, and adding it to the project data object.

[0013] According to another aspect of the embodiments of this application, a data storage device is also provided, comprising: an acquisition module, configured to acquire multiple sub-data objects of an original engineering data object, and to acquire an editing interface object corresponding to each sub-data object; a determination module, configured to determine the state information of each sub-data object based on the editing interface object; and a storage module, configured to compress and store a target sub-data object using a target data compression algorithm, wherein the target data compression algorithm is used to compress an integer of actual length to a preset length, and the target sub-data object is a sub-data object whose state information has been modified.

[0014] According to another aspect of the embodiments of this application, an electronic device is also provided, including: a memory for storing program instructions; and a processor connected to the memory for executing program instructions to perform the following functions: acquiring multiple sub-data objects of an original engineering data object, and acquiring an editing interface object corresponding to each sub-data object; determining the state information of each sub-data object based on the editing interface object; and compressing and storing a target sub-data object using a target data compression algorithm, wherein the target data compression algorithm is used to compress an integer of actual length to a preset length, and the target sub-data object is a sub-data object whose state information has been modified.

[0015] According to another aspect of the embodiments of this application, a non-volatile storage medium is also provided, the non-volatile storage medium including a stored computer program, wherein the device where the non-volatile storage medium is located executes the above-mentioned data storage method by running the computer program.

[0016] In this embodiment, multiple sub-data objects of the original engineering data object are obtained, as well as an editing interface object corresponding to each sub-data object. The status information of each sub-data object is determined based on the editing interface object. The target sub-data object is compressed and stored using a target data compression algorithm. The target data compression algorithm is used to compress an integer of actual length to a preset length. The target sub-data object is a sub-data object whose status information has been modified. This achieves the purpose of using the target data compression algorithm to compress and store modified data objects, thereby reducing the space required for data storage. This solves the technical problem that currently, archived engineering data is saved according to the actual data type length, resulting in large archives and long opening times. Attached Figure Description

[0017] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0018] Figure 1This is a hardware structure block diagram of a computer terminal (or electronic device) for implementing a data storage method according to an embodiment of this application;

[0019] Figure 2 This is a flowchart of a data storage method according to an embodiment of this application;

[0020] Figure 3a This is a schematic diagram of the distribution of original engineering data objects according to an embodiment of this application;

[0021] Figure 3b This is a structural diagram of a serialized single data block according to an embodiment of this application;

[0022] Figure 4 This is a structural diagram of a data storage device according to an embodiment of this application. Detailed Implementation

[0023] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0024] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0025] The binary data format archive index files used in related technologies are inconvenient for incremental updates, and incremental updates of configuration data are also quite cumbersome. Furthermore, directly serializing engineering configuration data according to the actual defined data type length results in large archive files. For use cases where the archive needs to be encrypted, excessively large archives also make saving and loading time-consuming. Additionally, related technologies only use progress bars to display the progress of opening the project, without employing any technical means to speed up the process.

[0026] To address the aforementioned problems, this application provides corresponding solutions, which are detailed below.

[0027] The data storage method provided in this application can be executed on a mobile terminal, computer terminal, or similar computing device. Figure 1 A hardware block diagram of a computer terminal (or electronic device) for implementing a data storage method is shown. Figure 1 As shown, the computer terminal 10 (or electronic device 10) may include one or more processors (shown as 102a, 102b, ..., 102n in the figure) (the processor may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 104 for storing data, and a transmission module 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a power supply, and / or a camera. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, computer terminal 10 may also include... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.

[0028] It should be noted that the aforementioned one or more processors and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits may be wholly or partially embodied in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuit may be a single, independent processing module, or may be wholly or partially integrated into any other element within the computer terminal 10 (or electronic device). As involved in the embodiments of this application, the data processing circuit serves as a processor control mechanism (e.g., selection of a variable resistor termination path connected to an interface).

[0029] The memory 104 can be used to store software programs and modules of application software, such as program instructions / data storage devices corresponding to the data storage method in the embodiments of this application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory 104, thereby implementing the above-mentioned data storage method. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor, and these remote memories can be connected to the computer terminal 10 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0030] The transmission module 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the computer terminal 10. In one example, the transmission module 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission module 106 may be a Radio Frequency (RF) module, used for wireless communication with the Internet.

[0031] The display may be, for example, a touchscreen liquid crystal display (LCD) that allows the user to interact with the user interface of the computer terminal 10 (or electronic device).

[0032] It should be noted here that, in some optional embodiments, the above... Figure 1 The computer device (or electronic device) shown may include hardware elements (including circuitry), software elements (including computer code stored on a computer-readable medium), or a combination of both hardware and software elements. It should be noted that... Figure 1 This is only one instance of a particular specific instance, and is intended to illustrate the types of components that may exist in the aforementioned computer equipment (or electronic equipment).

[0033] In the above operating environment, this application provides a data storage method embodiment. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Also, although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than that shown here.

[0034] Figure 2 This is a flowchart of a data storage method according to an embodiment of this application, such as...Figure 2 As shown, the method includes the following steps:

[0035] Step S202: Obtain multiple sub-data objects of the original project data object, and obtain the editing interface object corresponding to each sub-data object;

[0036] Step S204: Determine the status information of each sub-data object based on the editing interface object;

[0037] Step S206: Compress and store the target sub-data object using the target data compression algorithm. The target data compression algorithm is used to compress an integer of actual length to a preset length. The target sub-data object is a sub-data object whose state information has been modified.

[0038] In steps S202 to S206 above, interface objects and data objects are used in pairs, both providing methods to obtain the parent interface and parent data object. The interface object provides a method to obtain the modification flag. A binary format is used when archiving the project, and only modified data objects are saved when saving the project. A variable-length integer algorithm is used to compress the data during archive serialization to reduce the archive size. A multi-threaded approach is used to speed up data deserialization when loading the archive.

[0039] In step S204 of the above data storage method, the state information of each sub-data object is determined based on the editing interface object. Specifically, this includes the following steps: obtaining the data processing method provided by the editing interface object of each sub-data object; determining the state of the current sub-data object as a first state when the current sub-data object calls the data processing method, wherein the first state is used to indicate that the state information of the current sub-data object has been modified; and determining the state of the current sub-data object as a second state when the current sub-data object does not call the data processing method, wherein the second state is used to indicate that the state information of the current sub-data object has not been modified.

[0040] In this embodiment, the original engineering data object will contain hardware data (e.g., MODULE1, MODULE2, MODULE3, MODULE4, etc.), custom function blocks (e.g., UFB1, UFB2, UFB3, UFB4, etc.), custom functions (e.g., UFC1, UFC2, UFC3, UFC4, etc.), and programs (e.g., PROG1, PROG2, PROG3, PROG4, etc.). The hardware data will also contain multiple card data items, and the programs will contain multiple program files. The engineering data object is divided into multiple sub-data objects, such as... Figure 3a As shown.

[0041] Each sub-data object has a corresponding editing interface object. This interface object provides methods for adding, deleting, and modifying data (i.e., the data processing methods mentioned above). Different editing interface objects cache the modification flag state (i.e., the state information mentioned above) of the corresponding current data object or sub-data object, used to determine whether data needs to be saved again when saving data later. For example, if a sub-data object of the current data object calls any of the above methods (add, delete, or modify), and it is determined that the state information of the current sub-data object has been modified, then the state information of the current sub-data object is in state one, and data saving is required for sub-data objects in state one. If a sub-data object of the current data object does not call any of the above methods (add, delete, or modify), and it is determined that the state information of the current sub-data object has not been modified, then the state information of the current sub-data object is in state two, and data saving is not required for sub-data objects in state two.

[0042] In the above data storage method, the target data compression algorithm processes the data in the following ways: obtaining the target sub-data object whose state information has changed; converting the value of the target sub-data object into binary data; dividing the binary data according to a preset length to obtain the number of bytes required to convert the target sub-data object into binary data; encoding each byte according to a preset method to obtain the encoded data corresponding to each byte; and determining the compressed data corresponding to the target sub-data object based on the encoded data corresponding to each byte.

[0043] In the above steps, each byte is encoded according to a preset method, specifically including the following steps: if the data length in the current byte does not meet the preset length, 0 is used to fill the data before the current byte until the length of the current byte is the preset length; the first bit of each byte is determined, wherein the first bit of each byte is used to indicate whether there is a next byte after the current byte.

[0044] In this embodiment of the application, when saving, the state information of the data object cached in the corresponding editing interface object is used to determine whether the sub-data object under the original project data object has been modified. If the sub-data object has been modified, the corresponding sub-data object (i.e. the target sub-data object mentioned above) is binary serialized. The serialization method uses a variable integer length algorithm (i.e. the target data compression algorithm mentioned above) to compress the data.

[0045] Variable-length integer algorithms are binary data serialization and compression algorithms that serialize data according to its actual length. For example, an integer with a value of 10 would be 4 bytes long using conventional serialization methods, but would be 1 byte long using a variable-length integer algorithm.

[0046] The following is an introduction to the encoding principle of the variable integer length algorithm:

[0047] Variable-length integer (varint) compression algorithms are a method of compressing integers into a smaller space than is typically required. For example, the varint algorithm uses one byte to represent 10, while using four bytes to represent 800 million. In practical applications, most values ​​are between 0 and 100, while some values ​​may exceed 16384. Representing these values ​​using a fixed-length space would require a full 32-bit integer, even though most values ​​can be represented with a single byte. The varint algorithm is useful precisely because most numbers are not evenly distributed. Smaller numbers are generally more likely to occur than larger numbers. The varint algorithm makes the trade-off of using less space to store small numbers and more space to store large numbers. Therefore, using this algorithm to encode integers makes sense, as it saves space needed for data storage or bandwidth required for data transmission. Two common methods of varint encoding are using prefix length and using consecutive bit identifiers.

[0048] Using a contiguous bit flagging technique, each byte has a flag bit at the beginning to indicate whether more bytes are to be read and whether the remaining seven bits are actually used to store data. The flag bits are 0 and 1; 1 indicates that bytes following the current byte should be read, and 0 indicates that reading should stop. Once all bytes have been read, the concatenation of these bytes yields the final value. For example, the number 25, in 8 bits, is 0001 1001. The leftmost bit is 0, meaning there are no more bytes following this byte, and further reading is unnecessary. Another example: the number 53, represented in binary as 110101, requires six bits to store. After the flag bit, seven bits remain, so zeros are added after the flag bit to make it seven bits, resulting in 00110101. The first flag bit being 0 indicates that no more bytes are to be read after this byte, and the remaining 0110101 is the stored value. Using this technique, numbers from 0 to 127 can be represented using a single byte. For numbers greater than 127, such as 1732, the binary representation is 11011000100. In reality, only 11 bits are needed for storage. Excluding the flag bit, each byte can only store 7 bits, so the number 1732 requires two bytes. The first byte uses 1 to indicate that there are bytes following it, and the second byte uses 0 to indicate that there are no bytes following it. The final result is: 1000110101000100.

[0049] When performing varint encoding, for example, 255 in binary is 1110 0001. If encoded using 7 bits, it results in two groups: 000 0001 and 110 0001. For Protobuf, the least important group appears first, meaning that a consecutive bit 0 000 0001 and 1 110 0001 should be added to the lower-order group. After reversing the grouping, we get 1110 0001 and 0000 0001, thus encoding 225 using two bytes. For example, the number 123456 is varint encoded. 123456 in binary is 111 1000100 1000000. Each time, 7 bits are taken from low to high and the most significant bit is added to get 11000000 11000100 00000111. Therefore, after varint encoding, 123456 occupies three bytes, which are 192196 7.

[0050] In the process of decoding encoded data, one byte is read first. If the first high-order bit of the byte is 1, the reading continues. If it is 0, the first bit of each byte is removed, the remaining bits are reversed and grouped, and then recombined to obtain the original data. Taking 255 as an example, the decoding process is explained as follows: 1. The read bytes are 1110 0001 and 0000 0001; 2. After removing the first bit, we get 110 0001 and 000 0001; 3. After reversing, we get 000 00001 and 1100001; 4. We get 11100001, which is the original data 225.

[0051] In step S206 of the above data storage method, the target sub-data object is compressed and stored using a target data compression algorithm. Specifically, the following steps are included: the compressed data obtained after compressing the target sub-data object is stored in a data block. The structure of the data block includes: the identifier ID of the data block, the length of the compressed data, the compressed data, the number of child nodes corresponding to the compressed data, the identifier ID corresponding to each child node, and the checksum of the data block.

[0052] In this embodiment of the application, the structure of a single serialized data block is as follows: Figure 3b As shown, in Figure 3bIn this code, the first UUID represents the unique identifier ID of each data block, LEN represents the length of the serialized sub-data object (i.e., the length of the compressed data mentioned above), DATA represents the serialized data of the sub-data objects divided from the original project data object (i.e., the compressed data mentioned above), COUNT represents the number of child nodes under the current data object (i.e., the number of child nodes corresponding to the compressed data mentioned above), CHECKCODE represents calculating the checksum of the data from the start UUID to the end UUID (i.e., the checksum of the data block mentioned above) and placing it at the end of the data. The UUIDs following COUNT (i.e., the identifier IDs corresponding to each child node mentioned above) are the same as the number of child nodes.

[0053] The above data storage method further includes the following steps: determining the modified project data object through the project editing interface object; compressing the project data object according to the target data compression algorithm and storing it in a data block, and obtaining the identifier ID of the data block; traversing the sub-data objects of the project data object according to the identifier ID of the data block; if the sub-data object is modified, compressing the sub-data object according to the target data compression algorithm and storing it in a data block; saving the data block to the disk to obtain the project index file.

[0054] In this embodiment, the process of saving project data is as follows: 1. Determine whether the project data object has been modified through the project editing interface; 2. If the project data object has been modified, serialize the project root node data object, with the serialization format according to... Figure 3b As shown, the serialized data blocks are placed into a data block container, using the UUID of the data block (i.e., the identifier ID of the data block mentioned above) as a unique identifier, and then the sub-data objects of the project data object are traversed; 3. The sub-data objects are checked for modification through the editing interface. If they are modified, the sub-data objects are serialized using compression, and after serialization, they are also placed into the data block container; 4. The above steps are recursively executed until all sub-data objects have been traversed; 5. After all modified sub-data objects have been serialized, the data block container is traversed, and all data blocks are saved to the disk. Each file is named using the UUID of the data block. Finally, the UUID corresponding to the data block of the project root node is saved to the project index file, and then the UUID of all data blocks and the corresponding checksum are also saved to the project index file.

[0055] The above data storage method further includes the following steps: loading the binary file corresponding to the data block of the sub-data object based on the project index file; parsing the data block corresponding to the project data object to obtain the project data object; determining the number of threads required to process the data block of the sub-data object based on the number of data blocks of the sub-data object, the size of the data block, and the amount of data that each thread can process; starting threads according to the number of threads, and storing the data block of the sub-data object in the cache after deserialization operation by the threads; obtaining the identification ID list of the sub-data object from the project data object, retrieving the sub-data object from the cache, and adding it to the project data object.

[0056] In this embodiment, the process of opening the project includes the following steps: 1. Load the project index file, load the binary archive files of data blocks corresponding to all sub-data objects and put them into the cache, and load the checksum of the file in the project index file to check whether it matches; 2. Parse and deserialize the root node data block of the project; 3. Calculate the number of threads required to deserialize the data (i.e., the data blocks of the sub-data objects mentioned above) based on the size and number of data blocks of other sub-data objects and the maximum amount of data that each thread can process; 4. Deserialize the data blocks of all sub-data objects in a multi-threaded manner and put them into the cache; 5. Obtain the UUID list of sub-data objects (i.e., the ID list mentioned above) from the root node data object of the project, obtain the sub-data objects or sub-data nodes from the deserialized cache table and add them to the parent node data (i.e., the project data object mentioned above), and reassemble the complete project data object based on multiple sub-objects in the same way for other data objects or data nodes; 6. Regenerate the corresponding editing interface object based on the project data object.

[0057] The data storage method provided in this application has the following advantages: 1. The saving speed is much faster than the conventional method, and one-click incremental saving of the project can be achieved; 2. The archive size is greatly reduced, with the archive size reduced by about 2 / 3 compared to before compression; 3. The archive loading speed is accelerated, with the time to open the project reduced by about 2 / 3 compared to before optimization.

[0058] Figure 4 This is a structural diagram of a data storage device according to an embodiment of this application, such as... Figure 4 As shown, the device includes:

[0059] The acquisition module 402 is used to acquire multiple sub-data objects of the original project data object, and to acquire the editing interface object corresponding to each sub-data object;

[0060] Module 404 is used to determine the status information of each sub-data object based on the edit interface object;

[0061] Storage module 406 is used to compress and store target sub-data objects using a target data compression algorithm. The target data compression algorithm is used to compress integers of actual length to a preset length. The target sub-data objects are sub-data objects whose state information has been modified.

[0062] In the determination module of the aforementioned data storage device, the state information of each sub-data object is determined based on the editing interface object. Specifically, this includes the following process: obtaining the data processing method provided by the editing interface object of each sub-data object; if the current sub-data object calls the data processing method, determining the state of the current sub-data object as a first state, wherein the first state is used to indicate that the state information of the current sub-data object has been modified; if the current sub-data object does not call the data processing method, determining the state of the current sub-data object as a second state, wherein the second state is used to indicate that the state information of the current sub-data object has not been modified.

[0063] In the storage module of the aforementioned data storage device, the target data compression algorithm processes the data in the following ways: acquiring the target sub-data object whose state information has changed; converting the value of the target sub-data object into binary data; dividing the binary data according to a preset length to obtain the number of bytes required to convert the target sub-data object into binary data; encoding each byte according to a preset method to obtain the encoded data corresponding to each byte; and determining the compressed data corresponding to the target sub-data object based on the encoded data corresponding to each byte.

[0064] In the storage module of the aforementioned data storage device, each byte is encoded according to a preset method, specifically including the following process: if the data length in the current byte does not meet the preset length, 0 is used to fill the data before the current byte until the length of the current byte is the preset length; the first bit of each byte is determined, wherein the first bit of each byte is used to indicate whether there is a next byte after the current byte.

[0065] In the storage module of the aforementioned data storage device, the target sub-data object is compressed and stored using a target data compression algorithm. Specifically, the process includes the following: the compressed data obtained after compressing the target sub-data object is stored in a data block. The structure of the data block includes: the data block identifier ID, the length of the compressed data, the compressed data, the number of child nodes corresponding to the compressed data, the identifier ID corresponding to each child node, and the checksum of the data block.

[0066] In the aforementioned data storage device, the device further includes a processing module 408, which is used to determine the modified engineering data object through the engineering editing interface object; compress the engineering data object according to the target data compression algorithm and store it in a data block, and obtain the identifier ID of the data block; traverse the sub-data objects of the engineering data object according to the identifier ID of the data block; if the sub-data object is modified, compress the sub-data object according to the target data compression algorithm and store it in a data block; save the data block to the disk to obtain the engineering index file.

[0067] In the processing module of the aforementioned data storage device, the processing module is further configured to: load the binary file corresponding to the data block of the sub-data object based on the project index file; parse the data block corresponding to the project data object to obtain the project data object; determine the number of threads required to process the data block of the sub-data object based on the number of data blocks of the sub-data object, the size of the data block, and the amount of data that each thread can process; start threads according to the number of threads, and store the data block of the sub-data object in the cache after deserialization operation by the threads; obtain the identification ID list of the sub-data object from the project data object, and retrieve the sub-data object from the cache and add it to the project data object.

[0068] It should be noted that, Figure 4 The data storage device shown is used to perform Figure 2 The data storage method shown above also applies to the data storage device, and will not be repeated here.

[0069] This application embodiment also provides a non-volatile storage medium, which includes a stored computer program. The device containing the non-volatile storage medium executes the following data storage method by running the computer program: acquiring multiple sub-data objects of an original engineering data object, and acquiring an editing interface object corresponding to each sub-data object; determining the state information of each sub-data object based on the editing interface object; and compressing and storing a target sub-data object using a target data compression algorithm, wherein the target data compression algorithm is used to compress an integer of actual length to a preset length, and the target sub-data object is a sub-data object whose state information has been modified.

[0070] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0071] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0072] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For instance, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.

[0073] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0074] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0075] If the integrated unit is implemented as 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, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.

[0076] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.

Claims

1. A method for storing data, characterized in that, include: Retrieve multiple sub-data objects from the original project data object, and retrieve the editing interface object corresponding to each sub-data object; The state information of each sub-data object is determined based on the editing interface object, wherein the data processing method provided by the editing interface object of each sub-data object is obtained; if the current sub-data object calls the data processing method, the state of the current sub-data object is determined to be a first state, wherein the first state is used to indicate that the state information of the current sub-data object has been modified; if the current sub-data object does not call the data processing method, the state of the current sub-data object is determined to be a second state, wherein the second state is used to indicate that the state information of the current sub-data object has not been modified. The target sub-data object is compressed and stored using a target data compression algorithm. The compressed data obtained after compressing the target sub-data object is stored in a data block. The structure of the data block includes: the data block's identifier ID, the length of the compressed data, the compressed data itself, the number of child nodes corresponding to the compressed data, the identifier ID corresponding to each child node, and the data block's checksum. The target data compression algorithm is used to compress an integer of actual length to a preset length. The target sub-data object is the sub-data object whose state information has been modified. The modified project data object is identified through the project editing interface object; the project data object is compressed according to the target data compression algorithm and stored in a data block, and the identifier ID of the data block is obtained; based on the identifier ID of the data block, the sub-data objects of the project data object are traversed; if the sub-data object is modified, the sub-data object is compressed according to the target data compression algorithm and stored in a data block; the data block is saved to the disk to obtain the project index file.

2. The method according to claim 1, characterized in that, The target data compression algorithm processes the data in the following ways: Obtain the target sub-data object whose state information has changed; Convert the numerical value of the target sub-data object into binary data; The binary data is divided according to a preset length to obtain the number of bytes required to convert the target sub-data object into the binary data. Each byte is encoded according to a preset method to obtain encoded data corresponding to each byte; Based on the encoded data corresponding to each byte, the compressed data corresponding to the target sub-data object is determined.

3. The method according to claim 2, characterized in that, Each byte is encoded according to a preset method, including: If the length of the data in the current byte does not meet the preset length, fill the data in the current byte with 0s until the length of the current byte is the preset length. Determine the first bit of each byte, wherein the first bit of each byte is used to indicate whether there is a next byte after the current byte.

4. The method according to claim 1, characterized in that, The method further includes: Based on the project index file, load the binary file corresponding to the data block of the sub-data object; The engineering data object is obtained by parsing the data blocks corresponding to the engineering data object; The number of threads required to process the data blocks of the sub-data object is determined based on the number of data blocks of the sub-data object, the size of the data blocks, and the amount of data that each thread can process; Threads are started according to the number of threads, and the data blocks of the sub-data objects are deserialized and stored in the cache by the threads; Obtain the list of identifiers (IDs) of the sub-data objects from the project data object, retrieve the sub-data objects from the cache, and add them to the project data object.

5. A data storage device, characterized in that, include: The acquisition module is used to acquire multiple sub-data objects of the original project data object, as well as the editing interface object corresponding to each sub-data object; The determination module is used to determine the state information of each sub-data object based on the editing interface object, wherein it obtains the data processing method provided by the editing interface object of each sub-data object; when the current sub-data object calls the data processing method, it determines the state of the current sub-data object as a first state, wherein the first state is used to indicate that the state information of the current sub-data object has been modified; when the current sub-data object does not call the data processing method, it determines the state of the current sub-data object as a second state, wherein the second state is used to indicate that the state information of the current sub-data object has not been modified. The storage module is used to compress and store target sub-data objects using a target data compression algorithm. The compressed data obtained after compressing the target sub-data objects is stored in data blocks. The structure of each data block includes: an identifier ID of the data block, the length of the compressed data, the compressed data itself, the number of child nodes corresponding to the compressed data, an identifier ID corresponding to each child node, and a checksum of the data block. The target data compression algorithm is used to compress an integer of actual length to a preset length. The target sub-data object is the sub-data object whose state information has been modified. The processing module is used to identify the modified project data object through the project editing interface object; compress the project data object according to the target data compression algorithm and store it in a data block, and obtain the identifier ID of the data block; traverse the sub-data objects of the project data object according to the identifier ID of the data block; if the sub-data object is modified, compress the sub-data object according to the target data compression algorithm and store it in a data block; save the data block to the disk to obtain the project index file.

6. An electronic device, characterized in that, include: Memory, used to store program instructions; A processor, connected to the memory, is configured to execute program instructions that perform the following functions: acquiring multiple sub-data objects of an original engineering data object, and acquiring an editing interface object corresponding to each sub-data object; determining the state information of each sub-data object based on the editing interface object, wherein acquiring the data processing method provided by the editing interface object of each sub-data object; determining the state of the current sub-data object as a first state when the current sub-data object calls the data processing method, wherein the first state indicates that the state information of the current sub-data object has been modified; determining the state of the current sub-data object as a second state when the current sub-data object does not call the data processing method, wherein the second state indicates that the state information of the current sub-data object has not been modified; compressing and storing the target sub-data object using a target data compression algorithm, wherein the target sub-data object... The compressed data obtained after compression is stored in a data block. The structure of the data block includes: the identifier ID of the data block, the length of the compressed data, the compressed data, the number of child nodes corresponding to the compressed data, the identifier ID corresponding to each child node, and the checksum of the data block. The target data compression algorithm is used to compress an integer of actual length to a preset length. The target sub-data object is the sub-data object whose status information has been modified. The modified project data object is determined through the project editing interface object. The project data object is compressed according to the target data compression algorithm and stored in the data block, and the identifier ID of the data block is obtained. Based on the identifier ID of the data block, the sub-data objects of the project data object are traversed. If the sub-data object is modified, the sub-data object is compressed according to the target data compression algorithm and stored in the data block. The data block is saved to the disk to obtain the project index file.

7. A non-volatile storage medium, characterized in that, The non-volatile storage medium includes a stored computer program, wherein the device containing the non-volatile storage medium executes the data storage method according to any one of claims 1 to 4 by running the computer program.

Citation Information

Patent Citations

  • Real-time state monitoring method for garlic storage

    CN115219067A