[go: up one dir, main page]

CN120045600A - Database automatic mapping method and device based on structure serialization and inverse serialization - Google Patents

Database automatic mapping method and device based on structure serialization and inverse serialization Download PDF

Info

Publication number
CN120045600A
CN120045600A CN202411957835.6A CN202411957835A CN120045600A CN 120045600 A CN120045600 A CN 120045600A CN 202411957835 A CN202411957835 A CN 202411957835A CN 120045600 A CN120045600 A CN 120045600A
Authority
CN
China
Prior art keywords
query
serialization
function
database
template
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202411957835.6A
Other languages
Chinese (zh)
Inventor
李鹏
魏彬
何金岳
杨忠杰
张棋恒
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
705 Research Institute China Shipbuilding Industry Corp
Original Assignee
705 Research Institute China Shipbuilding Industry Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 705 Research Institute China Shipbuilding Industry Corp filed Critical 705 Research Institute China Shipbuilding Industry Corp
Priority to CN202411957835.6A priority Critical patent/CN120045600A/en
Publication of CN120045600A publication Critical patent/CN120045600A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2458Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
    • G06F16/2474Sequence data queries, e.g. querying versioned data
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2458Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
    • G06F16/2477Temporal data queries
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Computational Linguistics (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Fuzzy Systems (AREA)
  • Probability & Statistics with Applications (AREA)
  • Software Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本发明提供一种基于结构体序列化与反序列化的数据库自动映射方法和装置、设备和介质,其中,方法包括:首先,在C++语言环境中,通过对数据结构体类型的序列化操作符与反序列化操作符进行定义,生成序列化重载函数以及反序列化重载函数。之后,基于序列化重载函数与反序列化重载函数,通过模板编程技术对查询模板的函数进行定义,生成查询模板函数。最后,基于该查询模板函数,通过对查询结构体的元数据进行拼接查询,生成数据库查询结果,并根据数据库查询结果进行结构体字段的赋值,实现对数据库查询结构体的自动映射。本公开实施例实现了自动化数据库语句的合成与查询结果的映射,同时确保了代码的可靠复用性,提升了C++的适用范围。

The present invention provides a method and apparatus, device and medium for automatic database mapping based on structure serialization and deserialization, wherein the method comprises: first, in a C++ language environment, by defining the serialization operator and the deserialization operator of the data structure type, a serialization overload function and a deserialization overload function are generated. Afterwards, based on the serialization overload function and the deserialization overload function, the function of the query template is defined by template programming technology to generate a query template function. Finally, based on the query template function, by performing a splicing query on the metadata of the query structure, a database query result is generated, and the structure field is assigned according to the database query result, thereby realizing automatic mapping of the database query structure. The disclosed embodiment realizes the synthesis of automatic database statements and the mapping of query results, while ensuring the reliable reusability of the code and improving the scope of application of C++.

Description

Database automatic mapping method and device based on structure serialization and inverse serialization
Technical Field
The invention belongs to the technical field of database application, and particularly relates to a database automatic mapping method, device, equipment and medium based on structural body serialization and deserialization.
Background
At present, reflection functions in programming languages can check, access and modify type information in running, provide capabilities of type identification, field access, method call, type conversion and the like, and the characteristics are widely applied to languages such as Java, C# and the like, so that the flexibility and maintainability of codes are greatly improved. However, the c++ language has not provided a native reflection mechanism so far due to design and performance considerations, which makes it impossible to dynamically acquire field information of a structure or class in the c++, so that in the integrated development of a database, the splicing of SQL statements and the assignment process of query results need to be written manually, which is tedious and error-prone, and is also unfavorable for multiplexing and maintenance of codes.
In the prior art, the problem is generally solved by manually defining SQL sentences and assignment sentences, and although basic functions can be realized, the methods lack automation, so that development efficiency is low, and maintenance difficulty caused by manually written code errors is easy to occur. In addition, most of the prior art relies on hard coding modes, and general adaptation to different database tables and structure fields cannot be achieved, so that code reusability is poor and expansibility is poor.
Accordingly, there is a need for one or more approaches to address the above-described problems.
It should be noted that the information disclosed in the above background section is only for enhancing understanding of the background of the present disclosure and thus may include information that does not constitute prior art known to those of ordinary skill in the art.
Disclosure of Invention
Embodiments of the present invention provide a method, apparatus, device, and medium for automatic mapping of a database based on structure serialization and deserialization, thereby overcoming one or more of the problems due to the limitations and disadvantages of the related art to at least a certain extent.
According to one aspect of the present disclosure, there is provided a database auto-mapping method based on structure serialization and anti-serialization, including:
According to the C++ language environment, a serialization reload function is generated by defining a serialization operator of the data structure type;
according to the C++ language environment, a deserialization reload function is generated by defining a deserialization operator of the data structure type;
Defining the function of the query template through a template programming technology according to the serialization reload function and the anti-serialization reload function to generate a query template function;
And according to the query template function, generating a database query result by performing splicing query on metadata of the query structure, and performing assignment of the structure field based on the database query result to realize automatic mapping of the database query structure.
In one exemplary embodiment of the present disclosure, defining a serialization operator for a data structure type in a programming language includes:
Recording metadata of the data structure body through a serialization technology based on a C++ language environment to generate metadata information;
Based on the metadata information, a serialized override function is generated by defining a serialized operator for a data structure type in a programming language.
In one exemplary embodiment of the present disclosure, by defining the deserialization operator for the underlying data type, it comprises:
Based on the C++ language environment, analyzing the given character string by a deserialization technology to generate analysis data information;
based on the parsed data information, a deserialized reload function is generated by defining a deserialized operator of a data structure type in a programming language.
In one exemplary embodiment of the present disclosure, defining the function of the query template by a template programming technique includes:
based on the serialization reload function, carrying out serialization definition on the query structure in the database through a template programming technology to generate serialization parameters;
Based on the inverse serialization reload function, performing inverse serialization definition on the query structure in the database through a template programming technology to generate an inverse serialization parameter;
based on the sub-variable quantity parameters of the database, the field quantity parameters are generated by defining the field quantity of the query structure body in the database;
based on the sub-variable sequence parameters of the database, the field sequence parameters are generated by defining the field sequence of the query structure in the database;
And generating a library table query structure body by integrating the serialization parameter, the deserialization parameter, the field number parameter and the field sequence parameter.
In one exemplary embodiment of the present disclosure, defining the function of the query template by a template programming technique includes:
based on the field quantity parameter and the field sequence parameter, acquiring the query condition of the database query instruction through the serialization parameter, and completing the construction of the search function;
The query result is inversely sequenced into a given type of structure body through the inverse serialization parameters, and the construction of an assignment function is completed;
And integrating the search function and the assignment function to generate a query template function.
In one exemplary embodiment of the present disclosure, by performing a splice query on metadata of a query structure, comprising:
acquiring metadata of the query structure body through the query template function based on a preset query structure body type, and generating the metadata of the query structure body;
Generating a query statement by splicing the structured query language statement based on the query structure metadata;
and generating a database query result by querying the structural body in the database based on the query statement.
In an exemplary embodiment of the present disclosure, assignment of a structure field based on the database query result includes:
Generating a query structure subvariable by performing deserialization assignment on the queried data stream based on the database query result;
generating a dynamic array list by storing the query structure sub-variables in a list;
In one aspect of the present disclosure, there is provided an automatic mapping apparatus for a database based on structure serialization and anti-serialization, including:
The serialization reload function construction module is used for generating a serialization reload function by defining a serialization operator of the type of the data structure body in a C++ language environment;
The anti-serialization reload function construction module is used for generating an anti-serialization reload function by defining an anti-serialization operator of the type of the data structure body in a C++ language environment;
The query template function construction module is used for defining the function of the query template through a template programming technology according to the serialization reload function and the anti-serialization reload function to generate a query template function;
And the database execution module is used for generating a database query result by splicing and querying the metadata of the query structure according to the query template function, and carrying out assignment of the structure field based on the database query result so as to realize automatic mapping of the database query structure.
In one aspect of the present disclosure, there is provided an electronic device comprising:
Processor, and
A memory having stored thereon computer readable instructions which, when executed by the processor, implement a method according to any of the above.
In one aspect of the present disclosure, a computer readable storage medium is provided, on which a computer program is stored, which when executed by a processor, implements a method according to any of the above.
The beneficial effects brought by the invention are as follows:
From the above scheme, the embodiment of the invention provides an automatic mapping method for a database based on structural body serialization and deserialization. The method comprises the steps of firstly, defining a serialization operator and an deserialization operator of a data structure type in a C++ language environment to generate a serialization reload function and an deserialization reload function. And defining the function of the query template by a template programming technology based on the serialization reload function and the anti-serialization reload function to generate the query template function. Finally, based on the query template function, the metadata of the query structure body is subjected to splicing query to generate a database query result, and assignment of the structure body field is performed according to the database query result, so that automatic mapping of the database query structure body is realized. Therefore, the embodiment of the disclosure provides a scheme for automatically synthesizing SQL sentences and automatically filling and assigning query results of a dream database query structure oriented to a C++ programming language by using a template programming technology, a structure serialization technology and a reverse serialization technology. The synthesis of the automatic database statement and the mapping of the query result are realized, meanwhile, the reliability and the reusability of codes are ensured, and the application range of C++ is improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
The technical scheme of the present disclosure is described in further detail below through the accompanying drawings and examples.
Drawings
FIG. 1 is a flow chart of a method for automatically mapping a database based on structure serialization and de-serialization in accordance with one embodiment of the disclosed method;
FIG. 2 is a block diagram of an automated database mapping apparatus based on structure serialization and de-serialization according to one embodiment of the disclosed method;
fig. 3 is a block diagram of an electronic device according to one embodiment of the disclosed method.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the present invention more apparent, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
[ PREPARATION ] A method for producing a polypeptide
SQL, structured Query Language, structured query language, is a standard programming language for managing relational databases. Its main functions are to query, insert, update and delete data in the database, and also to create, modify database structures and control access rights for the database.
The c++ programming language, a general-purpose, efficient programming language, was developed by Bjarne Stroustrup in the early 1980 s. It was developed based on the C language, incorporating the feature of Object Oriented Programming (OOP).
The template < class AR > AR & serialize (AR & AR) { } function, which is a written method of a template function, is widely used in a serialization framework in c++, and can enable data storage and reading between different types of data objects (e.g., instances of classes) and different types of streams (e.g., output streams, input streams, or other data formats).
STRINGSTREAM, in C++, is a standard library class belonging to the < sstream > header file for processing the character stream. It may write data to the string or read data from the string.
In the embodiment of the disclosure, a database automatic mapping method based on structure serialization and inverse serialization is provided first, referring to fig. 1, the database automatic mapping method based on structure serialization and inverse serialization may include the following steps:
step S110, according to the C++ language environment, a serialization reload function is generated by defining a serialization operator of the data structure type;
Step S120, according to the C++ language environment, generating an anti-serialization reload function by defining an anti-serialization operator of the data structure type;
Step S130, defining the function of the query template through a template programming technology according to the serialization reload function and the anti-serialization reload function to generate a query template function;
And step 140, according to the query template function, generating a database query result by performing splicing query on metadata of the query structure, and performing assignment of the structure field based on the database query result to realize automatic mapping of the database query structure.
A method for automatically mapping a database based on structure serialization and deserialization in an embodiment of the present disclosure will be further described below.
In step S110, a serialized override function may be generated by defining a serialized operator for a data structure type according to the c++ language environment.
In some alternative embodiments of the present example, serialization of basic data structure types common in the c++11 programming language is implemented in functions by defining serialization functions, with the purpose of adding a sequence override function defining serialization operators for all common data types, in which the type and name information of variables are recorded, which play a role in indexing values during SQL statement synthesis and query result assignment.
In particular, a serialization function may be defined for common underlying data types (e.g., uint32_t, int32_t, uint64_t, int64_ t, float, double, etc.) in the buffer class first. Each data type has a corresponding serialized reload function that implements the output stream of writing data to the buffer class. The serialization function is not only responsible for converting the data into a format suitable for storage, but also records the type and name information of each field, which is critical in SQL statement synthesis and query result mapping.
Preferably, the serialization function of the buffer class can be further expanded on the basis of implementing the serialization of the basic data types, so as to support more complex data structures, such as std:: list, std:: map, array and the like. For these container types, elements therein need to be traversed and separately serialized, with each element serialized following a similar flow as the underlying data type. In addition, in order to support structure serialization, a template serialization function can be added in the buffer class to process the serialization of the structure members one by one, so that the complex types can be stored and restored as required.
In addition, the buffer class provides the function of converting the format of the serialized data for convenient debugging and output, which allows the result to be more clear and easier to read. And, to support readability and formatting, the buffer class also supports adding indentation characters in the output, making the generated serialized data structure clearer.
In step S120, an deserialized reload function may be generated by defining deserialized operators of the data structure type according to the c++ language environment.
In some alternative embodiments of the present example, an inverse serialization override function of a common data structure type in the c++11 standard is defined to support parsing of a given string, and mapping assignment of query result fields is performed on parsed data information, so as to provide the underlying indexing and positioning assignment functions for automatic mapping assignment of query results required later.
In one specific example, data is parsed from a given string by a parse class and is de-serialized into a structure or other data type. When the constructor accepts a string (query result) and an integer (input encoding type) as input parameters. The inside of the parse class maintains a plurality of private members such as m_ sName (for storing the structure name), m_ oPath (for storing the path information, for locating the field), m_ sErrMsg (error information), m_ oJsonValue (for storing JSON parse results), etc. By initializing these members, the parse class can effectively handle error handling and path parsing problems in the de-serialization process.
At the same time, the parse class provides a series of heavy-duty deserialized operators in order to deserialize the query results into the underlying data types in the structure. Each base type (e.g., uint32_t, int32_t, uint64_t, int64_ t, float, double, etc.) requires a corresponding de-serialized reload function. For example, by parsing the data in the string to assign values to the corresponding fields and to handle possible coding or type conversion errors. For each data type, the inverse serialization function extracts the corresponding value and maps it into a member variable of the structure. In addition, the mapping between the field name of the query result and the field of the structure is also considered, so that the data can be correctly assigned to the corresponding position of the structure. Error information and debug information are recorded in m_ sErrMsg to help locate problems in deserialization.
Preferably, the parsing class also supports the deserialization of more complex data types (such as std:: list, std:: map, std:: vector, etc.) on the basis of implementing the deserialization of the underlying data types. For container types, it is also necessary to traverse each element in the container and de-serialize each element into a corresponding data type. In particular, for std:map, it is necessary to deserialize each key-value pair and ensure that the type of key and value is consistent with the type of the target structure field.
Through the above serialization and deserialization definition of the common data structure types, the field names and field type information in the C++ structure can be expanded, so that the external function can acquire the information.
In step S130, a function of the query template may be defined by a template programming technique according to the serialized reload function and the anti-serialized reload function, so as to generate a query template function.
In some alternative embodiments of the present example, it may also be desirable to define serialization and de-serialization functions for a particular library table query structure. And ensuring that the number and sequence of the added fields in the database table query structure and the sub-variables in the database table with query are in one-to-one correspondence.
In one specific example, this is achieved by a template < classAR > AR & serialize (AR & AR) { } function. First, we define the NAME of the library table query structure, e.g., stuctTrainxCateInfo, which contains a number of fields, such as category ID (CATE _ID), category NAME (CATE _NAME), PARENT ID (part_ID), category hierarchy (CATE _level), and ADD TIME (ADD_TIME). In this architecture we use a template function named serialize that supports the serialization and deserialization of different types of data by templating.
And carrying out serialization definition on the fields of the library table query structure body by serialize functions to generate serialization parameters. And sending each field into a serializer ar for processing by calling the macro, and finally returning the processed object by the serializer to finish deserialization definition and generate deserialization parameters. These fields include different types of data (e.g., integer type, string type) and the serializer will automatically convert to the appropriate format depending on the type of field. Thus, the universal support for fields of various types is realized, and meanwhile, the simplicity and the expandability of codes are ensured.
Meanwhile, the number and sequence of the added fields in the database table query structure must be in one-to-one correspondence with the sub-variables in the database table to be queried. This means that we need to define the number of field parameters and the sequence of field parameters in the database table query structure according to the number of sub-variables information and the sequence of sub-variables information in the database table to be queried. And a change in the number and order of fields during serialization may result in a failure of deserialization. Thus, when adding new fields, it is necessary to ensure that the order of the new fields is uniform with the existing fields and that the expressions in the serialization functions are able to handle the new field types correctly.
In some alternative embodiments of the present example, the query template function may be split into two parts, namely a find function and a assign function. Firstly, according to the field quantity parameter and the field sequence parameter of the library table query structure body, obtaining the query condition. And then, executing SQL query according to query conditions through the serialization parameters by utilizing a template programming technology, if the query is successful, entering a processing stage of a query result, otherwise, recording errors and returning failure. Thus, the construction of the search function is completed.
After entering the processing stage of the query result, the query result is deserialized and assigned into a structure of a given type through deserialization parameters by using a template programming technology, and the returned record number (record_number) is updated. When the whole query process is finished, the function closes the database handle and releases the resource, and the construction of the assignment function is completed.
In step S140, according to the query template function, a database query result is generated by performing a splice query on metadata of the query structure, and assignment of a structure field is performed based on the database query result, so as to implement automatic mapping on the database query structure.
In some alternative embodiments of the present example, first, the SQL string array is initialized to all zeros using the lookup function described above. A STRINGSTREAM object is created again to dynamically construct SQL query statements. If the table name is empty, the lookup function records errors and returns a query field, and if the table name is not empty, the types and names of all variables in the query structure are acquired, and the metadata of the query structure is generated. And splicing the acquired query structure body metadata into a query part in the SQL sentence through a reflection mechanism.
The lookup function then builds other portions of the SQL query based on the incoming conditions.
(1) If the condition parameters are not null, the condition clauses are needed to be added and spliced into the SQL sentences for filtering the query results.
(2) If the ranking parameters are entered, ranking clauses are also added to specify the ranking rules for the query results.
(3) The lookup function examines the constraint parameters, if not null, concatenates the constraint clauses, specifying the returned record range. If the limit is empty, the limit default value of 0,20 is used, indicating the first 20 records to query.
Finally, the query statement generated by splicing all conditions comprises a search statement, a query condition, a sorting condition, a limiting condition and the like, so that the query can be executed according to the designated condition, and the desired database query result is obtained.
In some optional embodiments of the present example, according to the database query result, automatic mapping of the database query structure is achieved by performing deserialization assignment on the queried data stream, and performing list storage on the query structure subvariables obtained by the assignment.
In one specific example, first, the assignment function uses "rolling acquisitions" to get the next row of data for the database query results. If the operation to acquire the data fails, an error message is output and the error code is checked, when there is no more data available to acquire, the flag is set to true and the loop is skipped. If the query is successful and data is returned, the query result is processed continuously and is ready for the deserialization assignment operation. The key to this section is to capture and handle the failure of the database query, ensuring that the program can properly handle the exception and end conditions when executing the query.
After the data is successfully obtained by the query, the program constructs a character string for deserialization, and converts the query result into the character string which accords with the format required by the structural body.
Finally, the program parses and deserializes it using the parse class. In the parsing and deserializing process, each line of data is processed, the program will increment a record number indicating the number of records successfully processed. This ensures that all query results are stored in a list in order.
By the technical scheme, the public query template function can be called as long as the specific serialization and inverse serialization functions are added to any structure body, automatic combination of SQL sentences and automatic assignment of query results are completed, and automatic mapping of the database query structure body is realized.
It should be noted that although the steps of the methods of the present disclosure are illustrated in a particular order in the figures, this does not require or imply that the steps must be performed in that particular order or that all of the illustrated steps must be performed in order to achieve desirable results. Additionally or alternatively, certain steps may be omitted, multiple steps combined into one step to perform, and/or one step decomposed into multiple steps to perform, etc.
In addition, in the present exemplary embodiment, a database automatic mapping apparatus based on structure serialization and deserialization is also provided. Referring to fig. 2, the database auto-mapping apparatus 200 based on structure serialization and deserialization may include a serialization override function construction module 210, an deserialization override function construction module 220, a query template function construction module 230, and a database execution module 340. Wherein:
a serialized override function construction module 210, configured to generate a serialized override function by defining a serialized operator of a data structure type in a c++ language environment;
The deserialization reload function construction module 220 is configured to generate a deserialization reload function by defining a deserialization operator of the data structure type in the c++ language environment;
The query template function construction module 230 is configured to define a function of a query template by a template programming technique according to the serialized reload function and the anti-serialized reload function, so as to generate a query template function;
The database execution module 340 is configured to generate a database query result by performing a splice query on metadata of a query structure according to the query template function, and perform assignment of a structure field based on the database query result, so as to implement automatic mapping on the database query structure.
The database automatic mapping device based on structure body serialization and inverse serialization in the embodiment of the present disclosure corresponds to the embodiment of the database automatic mapping method based on structure body serialization and inverse serialization in the present disclosure, and the relevant contents may be referred to each other and will not be described herein. The beneficial technical effects corresponding to the database automatic mapping device based on structure serialization and inverse serialization in the embodiments of the present disclosure may refer to the corresponding beneficial technical effects of the corresponding exemplary method section, and are not described herein.
It should be noted that although several modules or units of the structure-based serialization and de-serialization based database auto-mapping apparatus 300 are mentioned in the detailed description above, such partitioning is not mandatory. Indeed, the features and functionality of two or more modules or units described above may be embodied in one module or unit in accordance with embodiments of the present disclosure. Conversely, the features and functions of one module or unit described above may be further divided into a plurality of modules or units to be embodied.
Next, an electronic device according to an embodiment of the present disclosure is described with reference to fig. 3. The electronic device may be either or both of the first device and the second device, or a stand-alone device independent thereof, which may communicate with the first device and the second device to receive the acquired input signals therefrom.
Fig. 3 illustrates a block diagram of an electronic device according to an embodiment of the present disclosure.
As shown in fig. 3, the electronic device includes one or more processors and memory.
The processor may be a Central Processing Unit (CPU) or other form of processing unit having data processing and/or instruction execution capabilities, and may control other components in the electronic device to perform the desired functions.
The memory may store one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and/or nonvolatile memory. The volatile memory may include, for example, random Access Memory (RAM) and/or cache memory (cache), and the like. The non-volatile memory may include, for example, read Only Memory (ROM), hard disk, flash memory, and the like. One or more computer program products may be stored on the computer readable storage medium that can be run by a processor to implement the various embodiments methods of the present disclosure and/or other desired functions as described above.
In one example, the electronic device may also include an input device and an output device, which are interconnected by a bus system and/or other form of connection mechanism (not shown).
In addition, the input device may include, for example, a keyboard, a mouse, and the like.
The output device may output various information including the determined distance information, direction information, etc., to the outside. The output device may include, for example, a display, speakers, a printer, and a communication network and remote output devices connected thereto, etc.
Of course, only some of the components of the electronic device relevant to the present disclosure are shown in fig. 3 for simplicity, components such as buses, input/output interfaces, etc. being omitted. In addition, the electronic device may include any other suitable components depending on the particular application.
In addition to the methods and apparatus described above, embodiments of the present disclosure may also be a computer program product comprising computer program instructions which, when executed by a processor, cause the processor to perform steps in a method according to various embodiments of the present disclosure described in the above section of the specification.
The computer program product may write program code for performing the operations of embodiments of the present disclosure in any combination of one or more programming languages, including an object oriented programming language such as Java, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device, partly on a remote computing device, or entirely on the remote computing device or server.
Furthermore, embodiments of the present disclosure may also be a computer-readable storage medium, having stored thereon computer program instructions, which when executed by a processor, cause the processor to perform steps in a method according to various embodiments of the present disclosure described in the above section of the present disclosure.
The computer readable storage medium may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may include, for example, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of a readable storage medium include an electrical connection having one or more wires, a portable disk, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
The foregoing is a preferred embodiment of the present invention and it should be noted that modifications and adaptations to those skilled in the art may be made without departing from the principles of the present invention and are intended to be comprehended within the scope of the present invention.

Claims (10)

1. An automatic mapping method of a database based on structure serialization and deserialization, comprising the following steps:
According to the C++ language environment, a serialization reload function is generated by defining a serialization operator of the data structure type;
according to the C++ language environment, a deserialization reload function is generated by defining a deserialization operator of the data structure type;
Defining the function of the query template through a template programming technology according to the serialization reload function and the anti-serialization reload function to generate a query template function;
And according to the query template function, generating a database query result by performing splicing query on metadata of the query structure, and performing assignment of the structure field based on the database query result to realize automatic mapping of the database query structure.
2. The method of claim 1, wherein defining the serialized operators for the data structure types in the programming language comprises:
Recording metadata of the data structure body through a serialization technology based on a C++ language environment to generate metadata information;
Based on the metadata information, a serialized override function is generated by defining a serialized operator for a data structure type in a programming language.
3. The method of claim 1, wherein defining the deserialization operator by de-serializing the base data type comprises:
Based on the C++ language environment, analyzing the given character string by a deserialization technology to generate analysis data information;
based on the parsed data information, a deserialized reload function is generated by defining a deserialized operator of a data structure type in a programming language.
4. The method of claim 1, wherein defining the function of the query template by a template programming technique comprises:
based on the serialization reload function, carrying out serialization definition on the query structure in the database through a template programming technology to generate serialization parameters;
Based on the inverse serialization reload function, performing inverse serialization definition on the query structure in the database through a template programming technology to generate an inverse serialization parameter;
based on the sub-variable quantity parameters of the database, the field quantity parameters are generated by defining the field quantity of the query structure body in the database;
based on the sub-variable sequence parameters of the database, the field sequence parameters are generated by defining the field sequence of the query structure in the database;
And generating a library table query structure body by integrating the serialization parameter, the deserialization parameter, the field number parameter and the field sequence parameter.
5. The method of claim 4, wherein defining the function of the query template by a template programming technique comprises:
based on the field quantity parameter and the field sequence parameter, acquiring the query condition of the database query instruction through the serialization parameter, and completing the construction of the search function;
The query result is inversely sequenced into a given type of structure body through the inverse serialization parameters, and the construction of an assignment function is completed;
And integrating the search function and the assignment function to generate a query template function.
6. The method of claim 1, wherein querying by stitching metadata of a query structure comprises:
acquiring metadata of the query structure body through the query template function based on a preset query structure body type, and generating the metadata of the query structure body;
Generating a query statement by splicing the structured query language statement based on the query structure metadata;
and generating a database query result by querying the structural body in the database based on the query statement.
7. The method of claim 6, wherein assigning the structure field based on the database query results comprises:
Generating a query structure subvariable by performing deserialization assignment on the queried data stream based on the database query result;
generating a dynamic array list by storing the query structure sub-variables in a list;
based on the dynamic array list, automatic mapping of the database query structure is realized.
8. An automatic mapping device for a database based on structure serialization and deserialization, comprising:
The serialization reload function construction module is used for generating a serialization reload function by defining a serialization operator of the type of the data structure body in a C++ language environment;
The anti-serialization reload function construction module is used for generating an anti-serialization reload function by defining an anti-serialization operator of the type of the data structure body in a C++ language environment;
The query template function construction module is used for defining the function of the query template through a template programming technology according to the serialization reload function and the anti-serialization reload function to generate a query template function;
And the database execution module is used for generating a database query result by splicing and querying the metadata of the query structure according to the query template function, and carrying out assignment of the structure field based on the database query result so as to realize automatic mapping of the database query structure.
9. An electronic device, comprising:
a memory for storing a computer program product;
a processor for executing a computer program product stored in said memory, which, when executed, implements the method of any of the preceding claims 1-7.
10. A computer readable storage medium having stored thereon computer program instructions, which when executed by a processor, implement the method of any of the preceding claims 1-7. .
CN202411957835.6A 2024-12-30 2024-12-30 Database automatic mapping method and device based on structure serialization and inverse serialization Pending CN120045600A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202411957835.6A CN120045600A (en) 2024-12-30 2024-12-30 Database automatic mapping method and device based on structure serialization and inverse serialization

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202411957835.6A CN120045600A (en) 2024-12-30 2024-12-30 Database automatic mapping method and device based on structure serialization and inverse serialization

Publications (1)

Publication Number Publication Date
CN120045600A true CN120045600A (en) 2025-05-27

Family

ID=95760668

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202411957835.6A Pending CN120045600A (en) 2024-12-30 2024-12-30 Database automatic mapping method and device based on structure serialization and inverse serialization

Country Status (1)

Country Link
CN (1) CN120045600A (en)

Similar Documents

Publication Publication Date Title
US10509854B2 (en) Annotation processing of computer files
US7174533B2 (en) Method, system, and program for translating a class schema in a source language to a target language
US5911074A (en) Process for manipulating data models used in software engineering
US11526656B2 (en) Logical, recursive definition of data transformations
US9465590B2 (en) Code generation framework for application program interface for model
US20090254881A1 (en) Code generation techniques for administrative tasks
US20060282452A1 (en) System and method for mapping structured document to structured data of program language and program for executing its method
US8918710B2 (en) Reducing programming complexity in applications interfacing with parsers for data elements represented according to a markup language
US7970779B2 (en) Application interface including dynamic transform definitions
US7490098B2 (en) Apparatus, system, and method for processing hierarchical data in disparate data repositories
CN112698819A (en) Method, device and storage medium for designing tree-oriented object programming program
CN112860584A (en) Test method and device based on workflow model
CN118747175A (en) Method, system, device and medium based on database-driven deep learning model
CN118312551A (en) Method and device for realizing uniform access of heterogeneous data sources
CN120045600A (en) Database automatic mapping method and device based on structure serialization and inverse serialization
US20030037031A1 (en) Mechanism for automatically generating a transformation document
US10275292B1 (en) Shadow Java classes provide private metadata
US20060282437A1 (en) Apparatus, system, and method for ordered processing of a hierarchical data structure according to a data source
WO2020027930A1 (en) Property filtering
CN118796316B (en) A multi-sensor access and data management micro-architecture system for intelligent controllers
CN118426990B (en) Simulation data exchange method and system based on dynamic reflection mechanism
CN108536443B (en) Method for automatically and mutually converting net object and multiple data formats based on declarative form
US7236981B1 (en) Technique for generating code to implement value objects for use with database systems
US8144730B2 (en) Automated tactical datalink translator
CN120669984A (en) Data interaction method and device and nonvolatile storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination