A database table serialization loading query method and related device
By generating and registering the table cache record structure and information class, combined with the cache tool template class, automatic serialization and query of database tables are achieved, solving the problems of code redundancy and low development efficiency caused by changes in database table structure, and improving the development efficiency and flexibility of the system.
Patent Information
- Application Number
- CN202310723903.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-16
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2043-06-16
AI Technical Summary
The frequent changes in the database table structure in the civil aviation fare system lead to code redundancy and low development efficiency, and the existing manual modification method is difficult to maintain.
By obtaining the database table configuration, executing the preset code generation script to generate the table cache record structure and information class, registering it in the array, calling the serialization and cache management program, loading the serialized file into the cache database, and using the calculation engine to query the cache database.
It improves system development efficiency and code quality, enhances the flexibility of system development and deployment, reduces manual intervention, and ensures efficient query services of the computing engine under high concurrency requests.
Smart Images

Figure CN116737771B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of database tables, and in particular to a database table serialization loading and query method and related equipment. Background Art
[0002] In order to reduce the load on the Oracle database and improve the performance of the computing engine, the civil aviation fare system serializes each database table in the Oracle database into different files, and uses the cache database instead of the Oracle database for the computing engine to query.
[0003] However, as airlines' needs grow, the relevant database table structures frequently change. For example, fields are added, field types are changed, and indexes are added or removed. This, in turn, necessitates modifications to the corresponding table cache record structures, serialization functions, loading functions, and query functions. Because each database table has unique code, manual modifications not only lead to significant code redundancy and increased error rates within the civil aviation fare system, but also inefficient system development and ultimately unmaintainability.
[0004] Therefore, how to efficiently implement serialized loading and querying of database tables has become a technical problem that those skilled in the art urgently need to solve. Summary of the Invention
[0005] In view of the above problems, the present disclosure provides a database table serialization loading query method and related devices that overcome the above problems or at least partially solve the above problems. The technical solution is as follows:
[0006] A database table serialization loading query method, comprising:
[0007] Get the table configuration of the database table;
[0008] Executing a preset code generation script to analyze and process the table configuration, generating a table cache record structure and a table cache information class, wherein the table cache information class includes constant information and static functions, wherein the static functions include serialization functions;
[0009] Execute a preset serialization program to register the table cache information class into the first table information entry array;
[0010] Calling the serialization function in the first table information entry array to generate a serialization file for the database table according to the table cache record structure;
[0011] Execute a preset cache management program to register a cache tool template class into the second table information entry array, wherein the cache tool template class includes a cache size calculation template function and a loading template function;
[0012] Calling the cache size calculation template function and the loading template function in the second table information entry array to load the serialized file into the cache database;
[0013] The query cache template class is called by a computing engine connected to the cache database, and the serialized file corresponding to the database table is searched in the cache database.
[0014] A database table serialization loading and query device includes: a table configuration obtaining unit, a table configuration analysis and processing unit, a first entry registration unit, a serialization file generating unit, a second entry registration unit, a serialization file loading unit and a query unit.
[0015] The table configuration obtaining unit is used to obtain the table configuration of the database table;
[0016] The table configuration analysis and processing unit is configured to execute a preset code generation script to analyze and process the table configuration, and generate a table cache record structure and a table cache information class, wherein the table cache information class includes constant information and static functions, wherein the static functions include serialization functions;
[0017] The first entry registration unit is configured to execute a preset serialization program to register the table cache information class into the first table information entry array;
[0018] The serialization file generating unit is configured to call the serialization function in the first table information entry array and generate a serialization file for the database table according to the table cache record structure;
[0019] The second entry registration unit is used to execute a preset cache management program to register the cache tool template class into the second table information entry array, wherein the cache tool template class includes a cache size calculation template function and a loading template function;
[0020] The serialized file loading unit is configured to call the cache size calculation template function and the loading template function in the second table information entry array to load the serialized file into a cache database;
[0021] The query unit is configured to utilize a computing engine connected to the cache database to call a query cache template class, and query the cache database for the serialized file corresponding to the database table.
[0022] A computer-readable storage medium stores a program, which implements the database table serialization loading query method when executed by a processor.
[0023] An electronic device comprising at least one processor, and at least one memory and a bus connected to the processor; wherein the processor and the memory communicate with each other via the bus; and the processor is configured to call program instructions in the memory to execute the database table serialization loading query method.
[0024] By means of the above technical solution, the present disclosure provides a database table serialization loading query method and related equipment, which obtains the table configuration of the database table; executes a preset code generation script to analyze and process the table configuration, generates a table cache record structure and a table cache information class, wherein the table cache information class includes constant information and static functions, wherein the static functions include serialization functions; executes a preset serialization program to register the table cache information class with the first table information entry array; calls the serialization function in the first table information entry array to generate a serialized file for the database table according to the table cache record structure; executes a preset cache management program to register the cache tool template class with the second table information entry array, wherein the cache tool template class includes a cache size calculation template function and a loading template function; calls the cache size calculation template function and the loading template function in the second table information entry array to load the serialized file into the cache database; uses the computing engine connected to the cache database to call the query cache template class to query the serialized file corresponding to the database table in the cache database. The present invention can generate a table cache record structure and a table cache information class through table configuration of a database table, and then combine it with a cache tool template class to register entries when the program is running. Without manual intervention, the database table records can be serialized into files and then loaded into the cache database. The query cache template class is used to query the database table of the cache database, thereby completing the function of querying the cache database instead of querying the Oracle database, thereby improving the development efficiency of the system, ensuring code quality, and enhancing the flexibility of system development and deployment.
[0025] The above description is only an overview of the technical solution of the present disclosure. In order to more clearly understand the technical means of the present disclosure, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present disclosure more obvious and easy to understand, the specific implementation methods of the present disclosure are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The above and other features, advantages, and aspects of the various embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and that the originals and elements are not necessarily drawn to scale.
[0027] Figure 1A schematic diagram showing a process of implementing a method for serialized loading and querying a database table provided by an embodiment of the present disclosure is shown;
[0028] Figure 2 A flow chart illustrating another implementation of the database table serialization loading query method provided by an embodiment of the present disclosure is shown;
[0029] Figure 3 A flow chart showing an implementation of step S620 in the database table serialization loading query method provided by an embodiment of the present disclosure is shown;
[0030] Figure 4 A schematic diagram of the structure of a database table serialization loading query device provided by an embodiment of the present disclosure is shown;
[0031] Figure 5 A schematic structural diagram of an electronic device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0032] The following describes embodiments of the present disclosure in more detail with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as limited to the embodiments described herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of protection of the present disclosure.
[0033] As used herein, the term "including" and its variations are open-ended, i.e., "including but not limited to." The term "based on" means "based, at least in part, on." The term "one embodiment" means "at least one embodiment," the term "another embodiment" means "at least one additional embodiment," and the term "some embodiments" means "at least some embodiments." Other terms are defined in the following description.
[0034] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0035] It should be noted that the modifications of "one" and "multiple" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, they should be understood as "one or more".
[0036] like Figure 1 As shown, a flowchart of an implementation of a database table serialization loading query method provided by an embodiment of the present disclosure is provided. The database table serialization loading query method may include:
[0037] S100, obtain a table configuration of a database table.
[0038] The table configuration is a configuration file in a table unit. The embodiment of the present disclosure can obtain the table configuration written by a technician for a database table. In the case that the database table structure of any database table is changed, the embodiment of the present disclosure can also obtain the table configuration written by the technician for the database table.
[0039] Optionally, the table configuration includes a filtering condition, an index combination, and a table name, a field name and a field type of the database table in an Oracle database.
[0040] The correspondence between the field type of the Oracle database and the field type of the cache database can be as shown in Table 1.
[0041] Table 1
[0042] Oracle database field type Field type of cache database VARCHAR2(n) char[n+1] NUMBER(n) Int,long NUMBER(m,n) Float,double DATE char[] clob char[]
[0043] The field type of the table record in the cache database is determined according to the correspondence between the field type in the Oracle database and Table 3. The "char[]" type field in the cache database must end with a "\0" character, so the length is 1 byte longer than that of the Oracle database. The "DATE" type field in the Oracle database can be formatted as a string and output to the "char[]" type when serialized.
[0044] The filtering condition is used to control the range of the serialized table record. For example, only the effective table record is serialized. The embodiment of the present disclosure can reduce the size of the cache database and improve the speed of querying the cache database through the filtering condition.
[0045] The index combination is a combination of fields used by the computing engine to query the cache database. The index combination can support "char[]", "int", and "long" type fields.
[0046] S200, execute a preset code generation script to analyze and process the table configuration, generate a table cache record structure and a table cache information class, wherein the table cache information class includes constant information and static functions, and the static functions include a serialization function.
[0047] The preset code generation script is an executable file for generating a table cache record structure and a table cache information class by analyzing the table configuration.
[0048] The table cache record structure is the structure used to store table records in serialized files and caches. It consists of a record portion and an indicator portion. It can be used as the type of host variables in serialized functions programmed using ProC, or as the type of table records in serialized files and cache databases.
[0049] The members of the table cache information class include various constant information and static functions of the database table. In the generated code corresponding to the table cache information class, static global variable instances of the table cache information class and global variable instances of the entry registration class are defined to complete the registration of the table information entry array.
[0050] Optionally, the constant information includes the name of the database table in the cache database, the table enumeration value, the maximum length of the index value, the table cache record structure size, and the index combination.
[0051] The maximum index value length is calculated by the preset code generation script based on the field types in the table's index combination. For example, the index value length of a "char[n]" type field is n bytes, the index value length of an "int" type field is 10 bytes, and the index value length of an "int" type field is 19 bytes.
[0052] The index combination in the constant information is the index combination configured in the table, which is stored in the form of a constant string.
[0053] The serialization function can be programmed using ProC, and the serialization functions of different database tables only differ in SQL statements and host variables.
[0054] The preset code generation script can generate one or more SQL statements based on the Oracle database table name, field type, and filter conditions configured in the table. These SQL statements select the same number and type of database fields. The type of the host variable is the table cache record structure.
[0055] The serialization function can use ProC macros, SQL statements, and host variables to read the fields selected by the SQL statement into the table cache record structure, and then write the cache record structure into the serialization file.
[0056] Optionally, the table cache record structure of the serialized file may consist of a table cache record structure array, header information, and the number of header information.
[0057] Optionally, the static function may further include: a function for obtaining table record index values and a function for obtaining index combination-related functions.
[0058] The table record index value retrieval function corresponds one-to-one with the index combination. This function is called during the loading process and is passed a table cache record structure read from a serialized file. It retrieves the value of the field corresponding to the index combination, converts it into a string, and concatenates the string. This is then passed as the index value for the table cache record structure.
[0059] Among them, the function related to obtaining the index combination is called during the loading process, and the address of the function for obtaining the index combination and the index value of the table record is transmitted.
[0060] S300: Execute a preset serialization program to register the table cache information class into the first table information entry array.
[0061] The preset serialization program is a program compiled from the generated code, the template class and the control code, and is used to serialize the database table records into files.
[0062] The preset serialization program includes a first table information entry array. In the embodiment of the present disclosure, when the preset serialization program is executed, the program automatically registers the table cache information class into the first table information entry array.
[0063] In the table cache information class code generated for each database table, a static global variable instance of the table cache information class of the corresponding database table and a global variable instance of the entry registration class are defined.
[0064] The entry registration class is used to register the constant information and function addresses of the instances of the table cache information class and the table cache tool template class of each database table into the table information entry array.
[0065] The disclosed embodiment can selectively link a target file compiled from the generated table cache information class code to a serializer and a cache management program. When the program starts, the constructor of the global variable instance of the entry registration class is automatically called immediately. The constructor writes the constant information and static function address of the passed-in table cache information class into the corresponding elements of the table information entry array, thereby completing the registration of the first table information entry array.
[0066] The first table information entry array stores constant information and static function addresses in the table cache information class, including: the name of the table in the cache database, the table enumeration value, the table cache record structure size, and the serialization function address.
[0067] S400: Calling a serialization function in the first table information entry array to generate a serialization file for the database table according to the table cache record structure.
[0068] The embodiment of the present disclosure can traverse the first table information entry array, execute the serialization function pointed to by the function address therein, and serialize the database table records into a serialization file.
[0069] S500: Execute a preset cache management program to register a cache tool template class into a second table information entry array, wherein the cache tool template class includes a cache size calculation template function and a loading template function.
[0070] The preset cache management program is a program compiled from generated code, template class and control code, and is used to load serialized files into shared memory as a cache database.
[0071] The preset cache management program includes a second table information entry array. In the embodiment of the present disclosure, when the preset cache management program is executed, the program automatically registers the cache tool template class into the second table information entry array.
[0072] Among them, the second table information entry array stores the static function address of the cache tool template class, including the cache size calculation template function and the loading template function. In the subsequent loading process, it will also store the number of table records in the obtained serialized file, the space size of the data area and index area of the cache database, and the number of hash buckets in the cache database index area.
[0073] The cache tool template class takes a table cache record structure and a table cache information class as its type parameters. Its member functions include a cache size calculation template function and a cache load template function. These functions retrieve constant information and static functions for the corresponding database table, use the table cache record structure array to read the serialized file of the corresponding database table, and use the table cache record structure pointer to traverse the cache records of the corresponding database table.
[0074] S600: Call the cache size calculation template function and the loading template function in the second table information entry array to load the serialized file into the cache database.
[0075] The disclosed embodiment can traverse the second table information entry array through a preset cache management program, first call the cache size calculation template function of the required database table, then allocate shared memory, and finally execute the loading template function of the database table to load the serialized file into the shared memory as a cache database, thereby completing the loading of the serialized file corresponding to the database table.
[0076] Optional, based on Figure 1 The method shown, such as Figure 2 As shown, a flowchart of another implementation of the database table serialization loading query method provided by an embodiment of the present disclosure is shown, and step S600 may include:
[0077] S610. Call the calculation cache size template function in the second table information entry array, read the serialized file, obtain the number of table records, and use the number of table records and the constant information in the first table information entry array to determine the storage space of the serialized file in the cache database.
[0078] During the loading process, the disclosed embodiment calls a cache size calculation template function, reads the header information of the serialized file through the cache size calculation template function, obtains the required number of table records, and calculates the space size of the data area and index area required by the database table in the cache database in combination with the maximum length of the index value registered in the second table information entry array and the table cache record structure size. These data are first stored in the second table information entry array for applying for shared memory and calculating the location of the data area and index area corresponding to each database table, and finally stored in the cache database.
[0079] S620: Call the loading template function in the second table information entry array, use the static function in the first table information entry array, and load the serialized file into the shared memory of the cache database based on the storage space.
[0080] Optional, based on Figure 2 The method shown, such as Figure 3 As shown, a flowchart of an implementation of step S620 in the database table serialization loading query method provided by an embodiment of the present disclosure is provided. Step S620 includes:
[0081] S621. Call the loading template function in the second table information entry array, read the table records in the serialized file into the table cache record structure array, and copy the table cache record structure array to the data area corresponding to the storage space in the shared memory of the cache database.
[0082] S622: Call the index combination acquisition related function in the first table information entry array to obtain the table record index value acquisition function in the first table information entry array and each group of index combinations in the constant information.
[0083] S623. Traverse each index combination. When traversing to any index combination, obtain the table record corresponding to the index combination in the data area, pass the table record into the table record index value acquisition function, and obtain the index value of the table record.
[0084] S624: Copy the index value to the index area corresponding to the storage space in the shared memory of the cache database.
[0085] S625. Calculate the hash bucket index corresponding to the index value in the index area using a hash algorithm.
[0086] S626. Based on the hash bucket index, an association relationship between the index value and the table record is established on the hash linked table of the cache database until the traversal of each index combination is completed and the serialized file loading is completed.
[0087] The embodiment of the present disclosure can, after completing the call to the calculation cache size template function, read the table records in the required serialized file into the table cache record structure array by calling the loading template function, and then copy it to the data area of the corresponding database table in the cache database; then call the index combination acquisition related function of the table cache information class to obtain each group of index combinations and the table record index value acquisition function. The number of index combinations is the number of index areas of the database table in the cache database, and the index combination is the name of the index area. When calling the loading template function to traverse each group of index combinations, each table record in the data area is taken, and the table record index value function is passed in to obtain the index value of the table record, and the index value is copied to the index area. The index value is then used to obtain the index bucket subscript of the index area using a hash algorithm, and the hash linked list is found. Finally, the hash linked list node is filled in, and the node is associated with the table record and the index value. When the index combination traversal is completed, the serialized file corresponding to the database table is loaded.
[0088] S700: Utilize the computing engine connected to the cache database to call the query cache template class, and query the cache database for a serialized file corresponding to the database table.
[0089] The embodiment of the present disclosure can obtain the location of the data area and index area of the serialized file stored in the cache database for each database table by connecting to the computing engine of the cache database, and then call the query cache template class to complete the query of the cache database.
[0090] The computing engine is a program compiled from generated code, template classes, and business code, and is used to query the cache database.
[0091] The query cache template class is a template class that takes a table cache record structure as a type parameter and is used to query corresponding table cache records. The query cache template class takes a table cache record structure as a type parameter and its member functions include two static template functions: a first record traversal function and a second record traversal function.
[0092] The first traversal record function is used to traverse all table records of the table in the cache database. In the disclosed embodiment, the table name of the serialized file corresponding to the database table stored in the cache database can be passed to the first traversal record function. The first traversal record function then searches the cache database for the location of the serialized file in the data area of the cache database, and then uses the table cache record structure pointer to traverse the data area and output the table record corresponding to the serialized file.
[0093] The second traversal record function is used to search for records of a table in a cache database according to a specified index combination. In the disclosed embodiment, the table name, index combination, and corresponding index value of the serialized file corresponding to the database table stored in the cache database can be passed into the second traversal record function. The second traversal record function then searches the cache database for the location of the serialized file in the index area of the cache database using the table name, index combination, and corresponding index value. The hash function is then used to calculate the index value, locate the hash bucket in the index area, and then traverse the hash linked list nodes in the hash bucket to output the table records with the same associated index value.
[0094] When the database table structure changes, the embodiment of the present disclosure only needs to modify the corresponding table configuration and some query-related business codes to compile a serialization program, cache management program, and calculation engine that are compatible with the new table structure, thereby completing the function of querying the cache database instead of querying the Oracle database.
[0095] By ensuring that the computing engine can efficiently obtain results under high-concurrency requests, the disclosed embodiments can provide users with highly efficient query services. This also improves the development efficiency, code quality, and flexibility of the civil aviation fare system, facilitating management of the system by developers and operations personnel.
[0096] The present disclosure provides a database table serialization loading query method, which obtains the table configuration of a database table; executes a preset code generation script to analyze and process the table configuration, and generates a table cache record structure and a table cache information class, wherein the table cache information class includes constant information and static functions, and wherein the static functions include a serialization function; executes a preset serialization program to register the table cache information class with a first table information entry array; calls the serialization function in the first table information entry array to generate a serialization file for the database table according to the table cache record structure; executes a preset cache management program to register the cache tool template class with a second table information entry array, wherein the cache tool template class includes a cache size calculation template function and a loading template function; calls the cache size calculation template function and the loading template function in the second table information entry array to load the serialized file into a cache database; uses a computing engine connected to the cache database to call the query cache template class to query the serialized file corresponding to the database table in the cache database. The present invention can generate a table cache record structure and a table cache information class through table configuration of a database table, and then combine it with a cache tool template class to register entries when the program is running. Without manual intervention, the database table records can be serialized into files and then loaded into the cache database. The query cache template class is used to query the database table of the cache database, thereby completing the function of querying the cache database instead of querying the Oracle database, thereby improving the development efficiency of the system, ensuring code quality, and enhancing the flexibility of system development and deployment.
[0097] Although the operations are depicted in a particular order, this should not be understood as requiring that the operations be performed in the particular order shown or in a sequential order.Multitasking and parallel processing may be advantageous under certain circumstances.
[0098] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0099] Corresponding to the above method embodiment, the embodiment of the present disclosure also provides a database table serialization loading query device, whose structure is as follows: Figure 4 As shown, it may include: a table configuration obtaining unit 100, a table configuration analyzing and processing unit 200, a first entry registering unit 300, a serialized file generating unit 400, a second entry registering unit 500, a serialized file loading unit 600 and a querying unit 700.
[0100] The table configuration obtaining unit 100 is used to obtain the table configuration of a database table.
[0101] The table configuration analysis and processing unit 200 is used to execute a preset code generation script to analyze and process the table configuration, generate a table cache record structure and a table cache information class, wherein the table cache information class includes constant information and static functions, wherein the static functions include serialization functions.
[0102] The first entry registration unit 300 is configured to execute a preset serialization program to register the table cache information class into the first table information entry array.
[0103] The serialization file generating unit 400 is configured to call a serialization function in the first table information entry array and generate a serialization file for the database table according to the table cache record structure.
[0104] The second entry registration unit 500 is used to execute a preset cache management program and register the cache tool template class into the second table information entry array, wherein the cache tool template class includes a cache size calculation template function and a loading template function.
[0105] The serialized file loading unit 600 is used to call the cache size calculation template function and the loading template function in the second table information entry array to load the serialized file into the cache database.
[0106] The query unit 700 is configured to use a computing engine connected to a cache database to call a query cache template class, and query the cache database for a serialized file corresponding to a database table.
[0107] Optionally, the serialized file loading unit 600 includes: a table record number obtaining subunit, a storage space determining subunit, and a loading subunit.
[0108] The table record number obtaining subunit is used to call the calculation cache size template function in the second table information entry array, read the serialized file, and obtain the table record number.
[0109] The storage space determination subunit is configured to determine the storage space of the serialized file in the cache database by using the number of table records and the constant information in the first table information entry array.
[0110] The loading subunit is used to call the loading template function in the second table information entry array, use the static function in the first table information entry array, and load the serialized file into the shared memory of the cache database based on the storage space.
[0111] Optionally, the static function also includes: a function for obtaining the index value of a table record and a function for obtaining related index combinations.
[0112] Optionally, the loading subunit includes: a first calling subunit and a second calling subunit.
[0113] The first calling sub-unit is used to call the loading template function in the second table information entry array, read the table records in the serialized file into the table cache record structure array, and copy the table cache record structure array to the data area corresponding to the storage space in the shared memory of the cache database.
[0114] The second calling sub-unit is used to call the index combination acquisition related function in the first table information entry array, obtain the table record index value acquisition function in the first table information entry array and each group of index combinations in the constant information, traverse each index combination, and when traversing to any index combination: obtain the table record corresponding to the index combination in the data area, pass the table record into the table record index value acquisition function, obtain the index value of the table record, copy the index value to the index area corresponding to the storage space in the shared memory of the cache database, use the hash algorithm to calculate the hash bucket subscript corresponding to the index value in the index area, and based on the hash bucket subscript, establish an association relationship between the index value and the table record on the hash linked list of the cache database until the traversal of each index combination is completed and the serialized file loading is completed.
[0115] Optionally, table configuration includes filter conditions, index combinations, and the table name, field name, and field type of the database table in the Oracle database.
[0116] Optionally, the constant information includes the name of the database table in the cache database, the table enumeration value, the maximum length of the index value, the table cache record structure size, and the index combination.
[0117] The present disclosure provides a database table serialization loading and query device, which obtains the table configuration of a database table; executes a preset code generation script to analyze and process the table configuration, and generates a table cache record structure and a table cache information class, wherein the table cache information class includes constant information and static functions, and wherein the static functions include a serialization function; executes a preset serialization program to register the table cache information class with a first table information entry array; calls the serialization function in the first table information entry array to generate a serialization file for the database table according to the table cache record structure; executes a preset cache management program to register the cache tool template class with a second table information entry array, wherein the cache tool template class includes a cache size calculation template function and a loading template function; calls the cache size calculation template function and the loading template function in the second table information entry array to load the serialized file into a cache database; uses a computing engine connected to the cache database to call the query cache template class to query the serialized file corresponding to the database table in the cache database. The present invention can generate a table cache record structure and a table cache information class through table configuration of a database table, and then combine it with a cache tool template class to register entries when the program is running. Without manual intervention, the database table records can be serialized into files and then loaded into the cache database. The query cache template class is used to query the database table of the cache database, thereby completing the function of querying the cache database instead of querying the Oracle database, thereby improving the development efficiency of the system, ensuring code quality, and enhancing the flexibility of system development and deployment.
[0118] Regarding the apparatus in the above embodiment, the specific manner in which each unit performs operations has been described in detail in the embodiment of the method, and will not be elaborated on here.
[0119] The database table serialization loading and query device includes a processor and a memory. The above-mentioned table configuration acquisition unit 100, table configuration analysis and processing unit 200, first entry registration unit 300, serialization file generation unit 400, second entry registration unit 500, serialization file loading unit 600 and query unit 700 are all stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to realize corresponding functions.
[0120] The processor includes a kernel, which retrieves the corresponding program unit from the memory. One or more kernels can be set. By adjusting kernel parameters, the table configuration of the database table is generated to generate a table cache record structure and a table cache information class. Combined with the cache tool template class, entries are registered during program execution. Without manual intervention, database table records can be serialized into files and then loaded into the cache database. The query cache template class is used to query the database tables of the cache database, thereby completing the function of querying the cache database instead of querying the Oracle database, thereby improving system development efficiency, ensuring code quality, and enhancing the flexibility of system development and deployment.
[0121] An embodiment of the present disclosure provides a computer-readable storage medium having a program stored thereon, which implements the database table serialization loading query method when executed by a processor.
[0122] An embodiment of the present disclosure provides a processor, which is used to run a program, wherein the database table serialization loading query method is executed when the program is run.
[0123] An embodiment of the present disclosure provides an electronic device, which includes at least one processor, and at least one memory and a bus connected to the processor; wherein the processor and the memory communicate with each other via the bus; the processor is used to call program instructions in the memory to execute a database table serialization loading query method.
[0124] like Figure 5 As shown, the electronic device 800 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage device 808 into a random access memory (RAM) 803. Various programs and data required for the operation of the electronic device 800 are also stored in the RAM 803. The processing device 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0125] Typically, the following devices may be connected to the I / O interface 805: an input device 806 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 807 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 808 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 809. The communication device 809 may allow the electronic device 800 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 5The electronic device 800 is shown with various devices, but it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed instead.
[0126] The present disclosure also provides a computer program product, which, when executed on an electronic device, is suitable for executing a program initialized with the steps of the database table serialization loading query method.
[0127] The present disclosure is described with reference to the flowcharts and / or block diagrams of the methods, apparatuses, electronic devices (systems), and computer program products according to the embodiments of the present disclosure. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable device to produce a machine, so that the instructions executed by the processor of the computer or other programmable device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0128] In a typical configuration, an electronic device includes one or more processors (CPUs), a memory, and a bus. The electronic device may also include an input / output interface, a network interface, and the like.
[0129] Memory may include non-permanent memory in a computer-readable medium, random access memory (RAM), and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory includes at least one memory chip. Memory is an example of a computer-readable medium.
[0130] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0131] In the description of the present disclosure, it should be understood that if the terms "up", "down", "front", "back", "left" and "right" are used to indicate directions or positional relationships, they are based on the directions or positional relationships shown in the accompanying drawings. They are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the positions or elements referred to must have a specific direction, be constructed and operate in a specific direction. Therefore, they should not be understood as limitations of the present disclosure.
[0132] Those skilled in the art will appreciate that embodiments of the present disclosure may be provided as methods, systems, or computer program products. Thus, the present disclosure may take the form of a fully hardware embodiment, a fully software embodiment, or an embodiment combining software and hardware. Furthermore, the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0133] Although the subject matter has been described in language specific to structural features and / or methodological logical acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims.
[0134] Although several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of separate embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented in multiple embodiments individually or in any suitable sub-combination.
[0135] The above description is merely a preferred embodiment of the present disclosure and an illustration of the technical principles employed. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by the specific combination of the above-mentioned technical features, but also includes other technical solutions formed by any combination of the above-mentioned technical features or their equivalents without departing from the above-mentioned disclosed concepts. For example, a technical solution formed by replacing the above-mentioned features with (but not limited to) technical features with similar functions disclosed in this disclosure.
Claims
1. A database table serialization loading query method, characterized in that: include: Get the table configuration of the database table; Executing a preset code generation script to analyze and process the table configuration, generating a table cache record structure and a table cache information class, wherein the table cache information class includes constant information and static functions, wherein the static functions include serialization functions; Execute a preset serialization program to register the table cache information class into the first table information entry array; Calling the serialization function in the first table information entry array to generate a serialization file for the database table according to the table cache record structure; Execute a preset cache management program to register a cache tool template class into the second table information entry array, wherein the cache tool template class includes a cache size calculation template function and a loading template function; Calling the cache size calculation template function and the loading template function in the second table information entry array to load the serialized file into the cache database; The query cache template class is called by a computing engine connected to the cache database, and the serialized file corresponding to the database table is searched in the cache database.
2. The method according to claim 1, characterized in that The calling of the cache size calculation template function and the loading template function in the second table information entry array to load the serialized file into the cache database includes: calling the cache size calculation template function in the second table information entry array, reading the serialized file, obtaining the number of table records, and determining the storage space of the serialized file in the cache database using the number of table records and the constant information in the first table information entry array; The loading template function in the second table information entry array is called, and the static function in the first table information entry array is used to load the serialized file into the shared memory of the cache database based on the storage space.
3. The method according to claim 2, characterized in that The static function further includes: a function for obtaining a table record index value and a function for obtaining an index combination-related function; calling the loading template function in the second table information entry array, utilizing the static function in the first table information entry array, and loading the serialized file into the shared memory of the cache database based on the storage space, including: calling the loading template function in the second table information entry array, reading the table records in the serialized file into a table cache record structure array, and copying the table cache record structure array to a data area corresponding to the storage space in the shared memory of the cache database; Call the index combination acquisition related function in the first table information entry array, obtain the table record retrieval index value function in the first table information entry array and each group of index combinations in the constant information, traverse each of the index combinations, and when traversing to any of the index combinations: obtain the table record corresponding to the index combination in the data area, pass the table record into the table record retrieval index value function, obtain the index value of the table record, copy the index value to the index area corresponding to the storage space in the shared memory of the cache database, use the hash algorithm to calculate the hash bucket subscript corresponding to the index value in the index area, and based on the hash bucket subscript, establish an association relationship between the index value and the table record on the hash linked table of the cache database, until the traversal of each index combination is completed and the serialized file loading is completed.
4. The method according to claim 1, wherein The table configuration includes screening conditions, index combinations, and the table name, field name, and field type of the database table in the Oracle database.
5. The method according to claim 1, wherein The constant information includes the name of the database table in the cache database, the table enumeration value, the maximum length of the index value, the table cache record structure size and the index combination.
6. A database table serialization loading query device, characterized in that: include: table configuration obtaining unit, table configuration analyzing and processing unit, first entry registering unit, serialized file generating unit, second entry registering unit, serialized file loading unit and query unit, The table configuration obtaining unit is used to obtain the table configuration of the database table; The table configuration analysis and processing unit is configured to execute a preset code generation script to analyze and process the table configuration, and generate a table cache record structure and a table cache information class, wherein the table cache information class includes constant information and static functions, wherein the static functions include serialization functions; The first entry registration unit is configured to execute a preset serialization program to register the table cache information class into the first table information entry array; The serialization file generating unit is configured to call the serialization function in the first table information entry array and generate a serialization file for the database table according to the table cache record structure; The second entry registration unit is configured to execute a preset cache management program to register a cache tool template class into the second table information entry array, wherein the cache tool template class includes a cache size calculation template function and a loading template function; The serialized file loading unit is configured to call the cache size calculation template function and the loading template function in the second table information entry array to load the serialized file into a cache database; The query unit is configured to utilize a computing engine connected to the cache database to call a query cache template class, and query the cache database for the serialized file corresponding to the database table.
7. The device according to claim 6, characterized in that The serialized file loading unit includes: a table record number obtaining subunit, a storage space determining subunit and a loading subunit. The table record number obtaining subunit is configured to call the cache size calculation template function in the second table information entry array, read the serialized file, and obtain the table record number; The storage space determination subunit is configured to determine the storage space of the serialized file in the cache database by using the number of table records and the constant information in the first table information entry array; The loading subunit is used to call the loading template function in the second table information entry array, use the static function in the first table information entry array, and load the serialized file into the shared memory of the cache database based on the storage space.
8. The device according to claim 7, characterized in that The static function also includes: a table record index value function and an index combination related function, and the loading subunit includes: a first calling subunit and a second calling subunit. The first calling sub-unit is configured to call the loading template function in the second table information entry array, read the table records in the serialized file into a table cache record structure array, and copy the table cache record structure array to a data area corresponding to the storage space in the shared memory of the cache database; The second calling sub-unit is used to call the index combination acquisition related function in the first table information entry array, obtain the table record retrieval index value function in the first table information entry array and each group of index combinations in the constant information, traverse each of the index combinations, and when traversing to any of the index combinations: obtain the table record corresponding to the index combination in the data area, pass the table record into the table record retrieval index value function, obtain the index value of the table record, copy the index value to the index area corresponding to the storage space in the shared memory of the cache database, use the hash algorithm to calculate the hash bucket subscript corresponding to the index value in the index area, and based on the hash bucket subscript, establish an association relationship between the index value and the table record on the hash linked table of the cache database, until the traversal of each index combination is completed and the serialized file loading is completed.
9. A computer-readable storage medium having a program stored thereon, characterized in that: When the program is executed by a processor, the database table serialization loading query method according to any one of claims 1 to 5 is implemented.
10. An electronic device comprising at least one processor, and at least one memory and a bus connected to the processor; wherein: The processor and the memory communicate with each other via the bus; The processor is configured to call program instructions in the memory to execute the database table serialization loading query method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Automatic code generation method, device and equipment and storage medium
CN112000320A
Data query method and device
CN115952196A