Data storage method, device, terminal equipment and computer readable storage medium

By loading and verifying custom Schema files, using JSON format to define the structure and format of stored data, the compatibility issues of different versions of storage files are solved, data integrity and consistency are achieved, and development and maintenance costs are reduced.

CN119377173BActive Publication Date: 2025-03-25SHENZHEN POISSON SOFTWARE TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411930053.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-26
Publication Date
2025-03-25
Estimated Expiration
2044-12-26

AI Technical Summary

Technical Problem

The prior art makes it difficult to maintain a large amount of program code generated when ensuring compatibility of storage files in different versions and increases development and maintenance costs.

Method used

By loading and verifying the customized Schema file, using JSON format to define the structure and format of the stored data, and generating JSON Schema for format verification, ensuring that the data in the file is complete and effective, and avoiding compatibility issues caused by data format errors.

Benefits of technology

It realizes data compatibility between different versions of systems, reduces system development and maintenance costs, and improves data integrity and consistency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119377173B_ABST
    Figure CN119377173B_ABST
Patent Text Reader

Abstract

The present application is applicable to the field of data storage technology, and provides a data storage method, device, terminal device, and computer-readable storage medium, including: loading a first file; wherein the first file is a file describing storage information of stored data; verifying the format of the first file; and when the format of the first file meets the preset format requirements, reading the storage data corresponding to the first file, and storing the storage data in a file. The above method can solve the compatibility of different versions of storage files.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the technical field of data storage, and in particular, relates to a data storage method, apparatus, terminal device, and computer-readable storage medium. Background Art

[0002] In industrial software for geometric modeling, the model data created by designers needs to be properly preserved to support the continuous creation process and effective communication between teams. With the continuous iteration and upgrade of the software, it is particularly important to ensure the compatibility and security of these model data to prevent the original model from being unusable or data loss due to version updates. Therefore, the compatibility of storage files is not only related to the integrity and availability of data, but also directly affects the continuity of the project and the work efficiency of the team.

[0003] In the related art, when a structural file needs to be changed, the compatibility of the data file is ensured by adding a series of IF judgment statements or adopting a standardized format of a local definition such as an XML document structure. However, the above method results in the generation of a large amount of program code that is difficult to maintain and the parsing logic of the XML document structure is relatively complex, resulting in increased development and maintenance costs in solving system compatibility issues. Summary of the invention

[0004] The embodiments of the present application provide a data storage method, apparatus, terminal device, and computer-readable storage medium, which can solve the compatibility of storage files of different versions.

[0005] In a first aspect, an embodiment of the present application provides a data storage method, including:

[0006] Loading a first file; wherein the first file is a file describing storage information of stored data;

[0007] Verifying the format of the first file;

[0008] When the format of the first file meets the preset format requirement, the storage data corresponding to the first file is read and the storage data is stored in a file.

[0009] In the embodiments of the present application, different versions of systems or applications may have different requirements for file formats. Through format verification, different versions of the first file containing data storage information can be format-verified to ensure that the data in the file is complete and valid, avoiding data damage or loss due to data format errors, and ensuring that the file can be correctly parsed and processed in systems with different versions, avoiding compatibility issues caused by inconsistent formats. The above method can solve the compatibility of data objects in different versions of the system and reduce the development cost of the system.

[0010] In a possible implementation manner of the first aspect, loading the first file includes:

[0011] Obtain file version information corresponding to the first file;

[0012] If the file version information corresponding to the first file is the current version, pre-loading the file version information corresponding to the first file;

[0013] If the file version information corresponding to the first file is a historical version, the file version corresponding to the first file is loaded in real time to verify the first file.

[0014] In the embodiment of the present application, by obtaining the version information of the first file and performing pre-loading or real-time loading according to the version information, the storage performance of the system can be effectively improved.

[0015] In a possible implementation manner of the first aspect, the method further includes:

[0016] Define a first data structure for storing data, and a second data structure for storing a plurality of attributes corresponding to each piece of data; wherein the data structure is used to represent the data structure and type;

[0017] A first file is generated according to a first data structure storing data and a second data structure storing a plurality of attributes corresponding to each piece of stored data.

[0018] In an embodiment of the present application, the definition of data storage information or structure is stored as the basis for version management to ensure the consistency of data structures in systems of different versions, facilitate version management and backtracking, and when performing version upgrades, the new data format can be supported by adjusting the data structure definition to ensure a smooth transition between the old and new versions, thereby solving the compatibility issues of different version files.

[0019] In a possible implementation manner of the first aspect, verifying the format of the first file includes:

[0020] generating a verification file according to the first file;

[0021] Verify, according to the verification file, whether the corresponding stored data in the first file meets the preset format requirements;

[0022] If the corresponding stored data in the first file meets the preset format requirements, the first file is verified to be successful.

[0023] In an embodiment of the present application, different versions of the first file containing data storage information can be format checked through format verification, which can ensure that the data in the file is complete and valid, avoid data damage or loss due to data format errors, and ensure that the file can be correctly parsed and processed in systems with different versions, avoiding compatibility issues caused by format inconsistencies.

[0024] In a possible implementation manner of the first aspect, reading storage data corresponding to the first file and storing the storage data in a file includes:

[0025] Generate a first conversion function according to the corresponding storage information in the first file;

[0026] Converting a first data format corresponding to the stored data into a second data format corresponding to the stored information in the first file according to the first conversion function;

[0027] The data stored in the second data format corresponding to the storage information is stored in a file.

[0028] In an embodiment of the present application, a first conversion function is generated based on the corresponding storage information in the first file, and a first data format corresponding to the stored data is converted into a second data format corresponding to the storage information in the first file according to the first conversion function. This ensures that the converted data format is consistent with the format of the storage information in the first file, thereby avoiding data parsing errors caused by inconsistent formats.

[0029] In a possible implementation manner of the first aspect, the method further includes:

[0030] When converting the storage data in the second data format stored in the storage file into the storage data in the first data format;

[0031] Generate a second conversion function according to the corresponding storage information in the first file;

[0032] The storage data in the second data format in the storage file is converted into the storage data in the first data format according to the second conversion function.

[0033] In an embodiment of the present application, a conversion function is generated based on the metadata information (such as data structure, encoding method, format specification, etc.) stored in the first file, and the function is used to convert the second data format into the first data format. Using the generated conversion function, the read storage data in the second data format is converted into the storage data in the first data format, which can ensure that the converted data format is completely consistent with the first data format, avoiding data incompatibility issues.

[0034] In a possible implementation manner of the first aspect, the method further includes:

[0035] When the storage data in the second data format in the storage file is converted into the storage data in the first data format according to the second conversion function;

[0036] If there is storage data in the storage file that is not defined in the first file, filtering out the storage data that is not defined in the first file;

[0037] If the storage data defined in the first file is missing in the storage file, the missing storage data defined in the first file is supplemented.

[0038] In the embodiment of the present application, by filtering out the stored data not defined in the first file and supplementing the missing stored data defined in the first file, it can be ensured that the converted data strictly complies with the format requirements defined in the first file. This not only improves the consistency and integrity of the data, but also ensures the compatibility of different versions of data.

[0039] In a second aspect, an embodiment of the present application provides a data storage device, including:

[0040] A loading module, used to load a first file; wherein the first file is a file describing storage information of stored data;

[0041] A verification module, used for verifying the format of the first file;

[0042] The storage module is used to read the storage data corresponding to the first file and store the storage data in a file when the format of the first file meets the preset format requirements.

[0043] In a third aspect, an embodiment of the present application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the data storage method as described in any one of the first aspects above is implemented.

[0044] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the data storage method as described in any one of the first aspects above.

[0045] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on a terminal device, enables the terminal device to execute any one of the data storage methods of the first aspect.

[0046] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0048] Figure 1 It is a flowchart of a data storage method provided in an embodiment of the present application;

[0049] Figure 2 is a schematic diagram of a process for defining a first file provided in an embodiment of the present application;

[0050] Figure 3 It is a schematic diagram of a process for verifying a first file provided in an embodiment of the present application;

[0051] Figure 4 It is a schematic diagram of the data storage process provided by the embodiment of the present application;

[0052] Figure 5 This is a schematic structural frame of data storage provided by the embodiment of the present application. Figure 1 ;

[0053] Figure 6 This is a schematic structural frame of data storage provided by the embodiment of the present application. Figure 2 ;

[0054] Figure 7 It is a structural block diagram of data storage provided by an embodiment of the present application;

[0055] Figure 8 is a structural block diagram of a data storage device provided in an embodiment of the present application;

[0056] Fig. 9 It is a structural diagram of a terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0057] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.

[0058] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.

[0059] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0060] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.

[0061] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.

[0062] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the phrases "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. appearing in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways.

[0063] In industrial software for geometric modeling, the model data created by designers needs to be properly preserved to support the continuous creation process and effective communication between teams. With the continuous iteration and upgrade of the software, it is particularly important to ensure the compatibility and security of these model data to prevent the original model from being unusable or data loss due to version updates. Therefore, the compatibility of storage files is not only related to the integrity and availability of data, but also directly affects the continuity of the project and the work efficiency of the team.

[0064] In the related art, when a structural file needs to be changed, the compatibility of the data file is ensured by adding a series of IF judgment statements or adopting a standardized format of a local definition such as an XML document structure. However, the above method results in the generation of a large amount of program code that is difficult to maintain and the parsing logic of the XML document structure is relatively complex, resulting in increased development and maintenance costs in solving system compatibility issues.

[0065] In order to solve the problems in the above-mentioned related technologies, an embodiment of the present application provides a data storage method. In the present application, a Schema file for storing data is customized based on a lightweight JSON format. The file is used to define the storage information of the stored data to control the writing format of the file, and different versions of the Schema files containing data storage information can be format-checked through format verification, which can ensure that the data in the file is complete and valid, avoid data damage or loss due to data format errors, and ensure that the file can be correctly parsed and processed in systems of different versions, avoiding compatibility issues caused by inconsistent formats.

[0066] See also Figure 1 , is a flow chart of a data storage method provided in an embodiment of the present application. As an example but not a limitation, the method may include the following steps:

[0067] S101, loading a first file; wherein the first file is a file describing storage information of stored data.

[0068] In an embodiment of the present application, the first file is a custom Schema file of the present application. The Schema file is a file of different versions that describes the data structure, data constraints, storage location and other storage information of the stored data (such as kernel model data). Each version of the Schema file may be used for different application scenarios or different data models. These files usually have a version number for easy management and distinction. These files are usually created by developers or data administrators according to specific needs to ensure the consistency and integrity of the data. Customized Schema files can be used in a variety of scenarios, such as database design, data validation, data exchange, etc.

[0069] Before loading the first file, the process of customizing the Schema file (first file) is described as follows:

[0070] In one embodiment, see Figure 2 , is a schematic diagram of a process for defining a first file provided in an embodiment of the present application, including:

[0071] S201, define a first data structure for storing data, and a second data structure for storing multiple attributes corresponding to each piece of data; wherein the first data structure and the second data structure are used to represent data structure and type.

[0072] In an embodiment of the present application, in order to solve the compatibility problem of stored files, the present application adopts a more concise and lightweight JSON to define the Schema file for file storage. JSON is an open standard file format and data exchange format. It is easy for people to read and write, and it is also easy for machines to parse and generate. It is a lightweight data exchange format and is also a Schema description language recommended by the Digital Industrial Software Alliance.

[0073] Specifically, according to the storage requirements of the geometric kernel model data, first determine the content of the model data to be stored, including the name, field, type, order, etc., and then determine the Schema file format and describe it in JSON language. For example, the data processing unit in the geometric CAD kernel is the entity object (storage data). These entity objects are the basic components in geometric modeling, such as points, lines, surfaces, and bodies. Each entity object contains multiple data expressions, which are called data items. The entity object contains multiple data items, each of which describes a specific attribute or feature. Each data item belongs to a specific entity object and cannot exist alone.

[0074] The main task of the custom Schema file is to define the format (data structure) of entity objects and data items to ensure that the inclusion relationship between them is clear and consistent. For example, a storage data or entity object in the kernel model is a "point", and its corresponding data items (attributes) include "ID", "coordinates", "color", "label", etc. It is necessary to define the first structure or format of the storage data, including the name, type, unique identifier, etc. of the storage data, and the second structure or format of the corresponding attributes of the storage data, including the name, data type, description, etc. of the attribute, and establish the inclusion relationship between the storage data and the attribute.

[0075] S202: Generate a first file according to a first data structure of stored data and a second data structure of multiple attributes corresponding to each stored data.

[0076] In the embodiment of the present application, the basic structure of the stored data is determined, including all entity objects (Object), a unique identifier (ID) is defined for each entity object, multiple attributes, i.e., data items (Field), are defined for each entity object, the name, data type, and description of each attribute are determined, and the defined first data structure and second data structure are converted into JSON format using tools or programming languages ​​(such as Python, JavaScript, etc.). The generated JSON file, i.e., the custom Schema file (first file), should contain all entity objects and their attributes, so as to control the name, field, type, content, etc. of the kernel entity object written into the file. It should be noted that different versions of Schema files can correspond to different system versions corresponding to the kernel model.

[0077] In the above method, the definition of data storage information or structure is stored as the basis for version management, ensuring the consistency of data structure in different versions of the system, facilitating version management and backtracking. When performing version upgrades, the data structure definition can be adjusted to support new data formats, ensuring a smooth transition between the old and new versions, thereby solving the compatibility issues of different version files.

[0078] Before storing the kernel model data, the custom Schema file, i.e. the first file, will be loaded. In order to improve the storage performance of the system, different Schema files are loaded in different ways, as follows:

[0079] In one embodiment, step S101 includes:

[0080] Obtain file version information corresponding to the first file; if the file version information corresponding to the first file is the current version, preload the file version information corresponding to the first file; if the file version information corresponding to the first file is a historical version, load the file version corresponding to the first file in real time for verifying the first file.

[0081] In the embodiment of the present application, loading can be divided into preloading and real-time loading. Preloading is used for the current version of the Schema to improve storage performance, which is a space-for-time tradeoff; real-time loading is used for the non-current version of the Schema, because it must open the file, obtain a clear version, and then load it as needed, which is a time-for-space tradeoff.

[0082] In the above methods, the performance and resource usage of the system can be significantly affected by selecting an appropriate loading strategy.

[0083] S102: Verify the format of the first file.

[0084] In the embodiment of the present application, in order to ensure the correctness and consistency of the data, the format of the defined Schema file (first file) needs to be verified. Only the Schema file that passes the verification can be further read and stored. The specific verification process is as follows:

[0085] In one embodiment, see Figure 3 , is a schematic diagram of a process for verifying a first file provided in an embodiment of the present application, wherein step S102 includes:

[0086] S301, generating a verification file according to the first file.

[0087] In the embodiment of the present application, a JSON Schema can be generated according to the custom Schema file through a corresponding tool. The generated JSON Schema can not only be used as a vocabulary, but also can be used to annotate and verify the structure and content of the JSON document (first file).

[0088] S302: Verify, based on the verification file, whether the corresponding stored data in the first file meets the preset format requirements.

[0089] In the embodiment of the present application, JSON Schema is used to check whether the JSON document conforms to the structure defined by the Schema, such as whether the entity object contains all the necessary data items, whether the data type of each data item is correct, such as whether the string field is indeed a string, and whether the data meets the constraints defined by the Schema, such as whether the string length is within the allowed range, etc. Through JSON Schema, it can be ensured that the storage information of the stored data defined by the JSON document conforms to the defined structure and constraints (meets the preset format requirements), thereby ensuring the consistency and correctness of the data.

[0090] S303: If the corresponding stored data in the first file meets the preset format requirements, the first file is verified to be successful.

[0091] In the embodiment of the present application, it is checked that the entity object contains all the necessary data items, the data type of each data item is correct, such as whether the string field is indeed a string, and the data satisfies the constraints defined by the Schema, such as whether the string length is within the allowable range, etc., then the custom Schema file, i.e., the first file, is verified.

[0092] In the above method, different versions of the first file containing data storage information can be format checked through format verification, which can ensure that the data in the file is complete and valid, avoid data damage or loss due to data format errors, and ensure that the file can be correctly parsed and processed in systems with different versions, avoiding compatibility issues caused by format inconsistencies.

[0093] S103, when the format of the first file meets the preset format requirement, read the storage data corresponding to the first file, and store the storage data in a file.

[0094] In the embodiment of the present application, parsing is started only after the custom Schema file is verified and read, and the defined storage data is stored and cached in the container according to the nested structure of Objects-Object-Fields to facilitate subsequent use.

[0095] In one embodiment, see Figure 4 , is a schematic diagram of a data storage process provided by an embodiment of the present application, step S103 includes:

[0096] S401, generating a first conversion function according to corresponding storage information in a first file.

[0097] In the embodiment of the present application, in order to reduce the impact of changes and modifications to the kernel storage data structure on the serialization of the stored data, the present application introduces an object accessor to isolate the data, such as Figure 5 The following is a schematic diagram of the data storage structure provided by the embodiment of the present application. Figure 1 , Figure 5 Only one object accessor is listed in the example. In actual implementation, each kernel object has a corresponding object accessor, and it can be expanded according to actual needs. Since the simple factory design pattern is adopted, it only needs to be expanded in the accessor factory. It is responsible for reading the data in the kernel model and then controlling the data to be written into the file according to the format defined in the Schema.

[0098] During the data writing process, considering the low speed of file IO, the object accessor does not directly operate the file, but through a stream buffer, such as Figure 6 The following is a schematic diagram of the data storage structure provided by the embodiment of the present application. Figure 2 , which can be used to solve the adaptation problem between high-speed CPU and low-speed file IO. At the same time, the Stream buffer also provides a format control capability, and its inherited classes can solve the support of text format and binary format. Figure 6 As shown, the base stream is a base class, and the text stream (Stream) and binary stream (Stream) are derived classes based on the base stream, which are used to write specific serialization functions or deserialization functions.

[0099] Specifically, when serialized data is stored using an object accessor and a Stream buffer, after the object accessor reads the stored data, it sends it to the text Stream in the Stream buffer according to the data type of the read stored data, such as the text type. The text Stream generates a first conversion function based on the storage information of the stored data defined in the Schema file. The function is used to convert the stored data and then store it as text according to the Schema file.

[0100] S402: Convert a first data format corresponding to the stored data into a second data format corresponding to the stored information in the first file according to a first conversion function.

[0101] In an embodiment of the present application, after the text Stream in the Stream buffer generates the first conversion function, all stored data read by the object accessor are converted to convert the initial format of the stored data, i.e., the first data format, into the storage format defined by the Schema file, i.e., the second data format.

[0102] S403, storing the data in the second data format corresponding to the storage information in a file.

[0103] In an embodiment of the present application, after all the storage data read by the object accessor are converted into a format, the text Stream sends the converted data stream (i.e., the storage data in the second data format) to the reference stream (reference stream) in the Stream buffer to temporarily store the data stream information in the memory cache area for writing to a storage file or other storage medium.

[0104] In the above method, kernel data and files are isolated through object accessors, which can avoid changes in stored data caused by adjustments or additions and deletions to internal data structures, leading to incompatibility between different versions of files. Stream caching can also solve problems with file storage performance and the need to store multiple file formats.

[0105] In one embodiment, when converting the storage data in the second data format stored in the storage file into the storage data in the first data format, the method includes:

[0106] S501, generating a second conversion function according to corresponding storage information in the first file.

[0107] In the embodiment of the present application, when the stored data is deserialized, the second format stored data in the storage file is converted into the initial format of the stored data in the kernel model, that is, the second data format.

[0108] Specifically, the object accessor reads data from the file in the format defined by the custom Schema file, and sends the read storage data to the text Stream of the Stream buffer. The text Stream generates a second conversion function according to the format of the read file storage data to convert the format of the storage data in the file.

[0109] S502: Convert the storage data in the second data format in the storage file into the storage data in the first data format according to the second conversion function.

[0110] In an embodiment of the present application, after converting multiple storage data in the second data format into storage data in the first data format, the text Stream sends this data stream to the reference stream to store the deserialized data stream in the memory cache area for returning to the kernel model.

[0111] In the above method, a conversion function is generated according to the metadata information (such as data structure, encoding method, format specification, etc.) stored in the first file, and the function is used to convert the second data format into the first data format. The generated conversion function is used to convert the read storage data in the second data format into the storage data in the first data format, which can ensure that the converted data format is completely consistent with the first data format, avoiding data incompatibility issues.

[0112] In one embodiment, step S502 includes:

[0113] When converting storage data in the second data format in the storage file into storage data in the first data format according to the second conversion function, if there is storage data in the storage file that is not defined in the first file, the storage data that is not defined in the first file is filtered out; if the storage data defined in the first file is missing in the storage file, the missing storage data defined in the first file is supplemented.

[0114] In an embodiment of the present application, when deserializing the stored data, data is read from the file according to a specific Schema definition, and then the data is passed to the kernel model. In this process, it is necessary to process the redundant data and missing data that may exist between different versions, and it is necessary to clearly define which fields, field types, formats, etc. should be included in the Schema file. Then, Object Accessor is used to read the data from the file, and the data in the file is verified item by item according to the preset Schema definition. If the data in the file exceeds the Schema definition, the redundant data will be discarded. If the data in the file lacks certain fields defined in the Schema, default values ​​will be added, and the processed data will be passed to the kernel model.

[0115] In the above method, by filtering out the storage data not defined in the first file and supplementing the missing storage data defined in the first file, it can be ensured that the converted data strictly complies with the format requirements defined in the first file. This not only improves the consistency and integrity of the data, but also ensures the compatibility of different versions of data.

[0116] See also Figure 7 , is a schematic diagram of the structure of data storage provided in an embodiment of the present application, such as Figure 7 As shown, in order to solve the compatibility problem of the system, the steps of the data storage method provided by this application include:

[0117] ①Custom schema file

[0118] The schema file is defined using the lightweight JSON format. The schema file defines the storage information of the data to be stored, such as the storage format, type, etc.

[0119] ②Generate JSON schema file for verification

[0120] To ensure the integrity and consistency of the data, relevant tools are used to generate a JSON schema file based on the custom schema file. The file is used to verify the format defined in the custom schema file.

[0121] ③After verification, data is stored through the object accessor

[0122] By isolating kernel data and files through the Object Accessor, it is possible to avoid changes in stored data caused by adjustments or additions and deletions to the internal data structure, which may lead to incompatibility between different versions of files. Among them, the object accessor adopts the design pattern of a simple factory and is uniformly generated and managed by the accessor factory.

[0123] ④ Use the stream buffer to cache the stored input data

[0124] The object accessor sends the stored data to the Stream buffer for text stream or binary stream processing, and then sends the generated data stream to the base stream for caching in the memory buffer area and then for storage in a storage medium, such as a file or disk.

[0125] ⑤Serialization and deserialization processing

[0126] In the storage process of kernel model data, the settings of object accessor and stream buffer are bidirectional, and can support data serialization and deserialization at the same time. Storage and reading in the system kernel are two separate processes. Therefore, the file is added by writing and reading files and inheriting the base class of the file processor to realize data storage and reading respectively, so as to realize serialization and deserialization.

[0127] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0128] Corresponding to the data storage method of the above embodiment, Figure 8 This is a structural block diagram of a data storage device provided in an embodiment of the present application. For ease of explanation, only the parts related to the embodiment of the present application are shown.

[0129] Reference Figure 8 , the device comprises:

[0130] The file definition module 81 is used to:

[0131] Define a first data structure for storing data, and a second data structure for storing a plurality of attributes corresponding to each piece of data; wherein the data structure is used to represent the data structure and type;

[0132] A first file is generated according to a first data structure storing data and a second data structure storing a plurality of attributes corresponding to each piece of stored data.

[0133] A file loading module 82 is used to load a first file; wherein the first file is a file describing storage information of stored data;

[0134] A file verification module 83, used to verify the format of the first file;

[0135] The file storage module 84 is used to read the storage data corresponding to the first file and store the storage data in a file when the format of the first file meets the preset format requirement.

[0136] Optionally, the file loading module 81 is further used for:

[0137] Obtain file version information corresponding to the first file;

[0138] If the file version information corresponding to the first file is the current version, pre-loading the file version information corresponding to the first file;

[0139] If the file version information corresponding to the first file is a historical version, the file version corresponding to the first file is loaded in real time to verify the first file.

[0140] Optionally, the file verification module 83 is further used for:

[0141] generating a verification file according to the first file;

[0142] Verify, according to the verification file, whether the corresponding stored data in the first file meets the preset format requirements;

[0143] If the corresponding stored data in the first file meets the preset format requirements, the first file is verified to be successful.

[0144] Optionally, the file storage module 84 is further used for:

[0145] Generate a first conversion function according to the corresponding storage information in the first file;

[0146] Converting a first data format corresponding to the stored data into a second data format corresponding to the stored information in the first file according to the first conversion function;

[0147] The data stored in the second data format corresponding to the storage information is stored in a file.

[0148] Optionally, the file storage module 84 is further used for:

[0149] When converting the storage data in the second data format stored in the storage file into the storage data in the first data format;

[0150] Generate a second conversion function according to the corresponding storage information in the first file;

[0151] The storage data in the second data format in the storage file is converted into the storage data in the first data format according to the second conversion function.

[0152] Optionally, the file storage module 84 is further used for:

[0153] When converting the storage data in the second data format of the storage file into the storage data in the first data format according to the second conversion function, if the version of the first file corresponding to the storage data in the second data format is a historical version, filtering out the storage data newly added in the current file version;

[0154] When the version of the first file corresponding to the storage data in the second data format is the current version, a missing value is set at the first position of the newly added storage data in the current version corresponding to the second position of the historical version.

[0155] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.

[0156] in addition, Figure 8 The data storage device shown may be a software unit, a hardware unit, or a combination of software and hardware units built into an existing terminal device, or may be integrated into the terminal device as an independent accessory, or may exist as an independent terminal device.

[0157] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0158] Fig. 9 Schematic diagram of the structure of the terminal device provided in the embodiment of the present application. Fig. 9 As shown, the terminal device 9 of this embodiment includes: at least one processor 90 ( Fig. 9 Only one is shown in the figure) a processor, a memory 91, and a computer program 92 stored in the memory 91 and executable on at least one processor 90. When the processor 90 executes the computer program 92, the steps of any of the above-mentioned data storage method embodiments are implemented.

[0159] The terminal device may be a computing device such as a desktop computer, a notebook, a PDA, or a cloud server. The terminal device may include, but is not limited to, a processor and a memory. Those skilled in the art will understand that Fig. 9 It is only an example of the terminal device 9 and does not constitute a limitation on the terminal device 9. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components, for example, it may also include input and output devices, network access devices, etc.

[0160] The processor 90 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0161] In some embodiments, the memory 91 may be an internal storage unit of the terminal device 9, such as a hard disk or memory of the terminal device 9. In other embodiments, the memory 91 may also be an external storage device of the terminal device 9, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal device 9. Further, the memory 91 may also include both an internal storage unit of the terminal device 9 and an external storage device. The memory 91 is used to store an operating system, an application program, a boot loader, data, and other programs, such as program codes of a computer program. The memory 91 may also be used to temporarily store data that has been output or is to be output.

[0162] The embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.

[0163] An embodiment of the present application provides a computer program product. When the computer program product runs on a terminal device, the terminal device can implement the steps in the above-mentioned method embodiments when executing the computer program product.

[0164] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the device / terminal device, recording medium, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.

[0165] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0166] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0167] In the embodiments provided in the present application, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0168] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0169] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A data storage method, characterized in that: The method comprises: Loading a first file; wherein the first file is a file describing storage information of stored data; the first file is a Schema file; Verifying the format of the first file; When the format of the first file meets the preset format requirement, reading the storage data corresponding to the first file and storing the storage data; The reading of the storage data corresponding to the first file and storing the storage data in a file includes: Generate a first conversion function according to the corresponding storage information in the first file, specifically: when serialized data is stored using an object accessor and a Stream buffer, after the object accessor reads the storage data, according to the data type of the read storage data, the data type includes a text type, and sends it to the text Stream in the Stream buffer, and the text Stream generates a first conversion function according to the storage information of the storage data defined by the Schema file, and the first conversion function is used to perform data conversion on the storage data and perform text storage according to the Schema file; wherein the object accessor is used to isolate kernel data from storage files; the inherited class of the Stream buffer supports text format and binary format; Converting the first data format corresponding to the stored data into the second data format corresponding to the stored information in the first file according to the first conversion function; The data stored in the second data format corresponding to the storage information is stored in a file.

2. The data storage method according to claim 1, characterized in that: The loading of the first file comprises: Obtaining file version information corresponding to the first file; If the file version information corresponding to the first file is the current version, pre-loading the file version information corresponding to the first file; If the file version information corresponding to the first file is a historical version, the file version corresponding to the first file is loaded in real time to verify the first file.

3. The data storage method according to claim 1, characterized in that: The method further comprises: Define a first data structure of the stored data and a second data structure of a plurality of attributes corresponding to each of the stored data; wherein the data structure is used to represent the data structure and type; The first file is generated according to a first data structure of the stored data and a second data structure of a plurality of attributes corresponding to each of the stored data.

4. The data storage method according to claim 1, characterized in that: The checking the format of the first file includes: generating a verification file according to the first file; Verifying, according to the verification file, whether the corresponding stored data in the first file meets the preset format requirements; If the corresponding stored data in the first file meets the preset format requirements, the first file is verified to be successful.

5. The data storage method according to claim 1, characterized in that: The method further comprises: When converting the storage data in the second data format stored in the storage file into the storage data in the first data format; Generate a second conversion function according to the corresponding storage information in the first file; The storage data in the second data format in the storage file is converted into the storage data in the first data format according to the second conversion function.

6. The data storage method according to claim 5, characterized in that: The method further comprises: When the storage data in the second data format of the storage file is converted into the storage data in the first data format according to the second conversion function; If there is storage data in the storage file that is not defined in the first file, filtering out the storage data that is not defined in the first file; If the storage data defined in the first file is missing in the storage file, the missing storage data defined in the first file is supplemented.

7. A data processing device, characterized in that: include: A loading module, used to load a first file; wherein the first file is a file describing storage information of stored data; the first file is a Schema file; A verification module, used for verifying the format of the first file; A storage module, configured to read storage data corresponding to the first file and store the storage data in a file when the format of the first file meets a preset format requirement; The storage module is further used for: Generate a first conversion function according to the corresponding storage information in the first file, specifically: when serialized data is stored using an object accessor and a Stream buffer, after the object accessor reads the storage data, according to the data type of the read storage data, the data type includes a text type, and sends it to the text Stream in the Stream buffer, and the text Stream generates a first conversion function according to the storage information of the storage data defined by the Schema file, and the first conversion function is used to perform data conversion on the storage data and perform text storage according to the Schema file; wherein the object accessor is used to isolate kernel data from storage files; the inherited class of the Stream buffer supports text format and binary format; Converting the first data format corresponding to the stored data into the second data format corresponding to the stored information in the first file according to the first conversion function; The data stored in the second data format corresponding to the storage information is stored in a file.

8. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 6 is implemented.

9. A computer-readable storage medium storing 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

Patent Citations

  • Data management system construction method and device and cluster

    CN116860755A