A database integration method and device, electronic equipment and storage medium
Patent Information
- Application Number
- CN202310613873.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-27
- Publication Date
- 2026-09-08
- Estimated Expiration
- 2043-05-27
AI Technical Summary
在项目评估领域,项目在评估时,不同专业的工作人员会进行相对应专业的考察与调研,并将得到的数据记录在不同的数据库中,造成数据库不通用且结构混乱
通过在获取数据整合指令时,为了保证数据的完整性,根据项目名称确定所有与项目名称相关联的多个数据包,读取所有数据包的数据信息,为了降低运行内存,在读取所有数据包的数据信息后,可以创建临时文件,将数据信息写入临时文件,并读取临时文件内容并写入数据库,通过创建的临时文件临时存储得到的数据信息,避免了将所有的数据信息同时写入数据库时运行内存不足导致服务器负载过高的情况,实现了在不影响内存的情况下对数据库的数据信息进行整合。
Smart Images

Figure CN116644076B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of database integration, and in particular to a database integration method, apparatus, electronic device, and storage medium. Background Technology
[0002] A database is a "repository for organizing, storing, and managing data according to a data structure." It is a large collection of organized, shareable, and uniformly managed data that is stored long-term in a computer. In the field of project evaluation, during project evaluation, staff from different disciplines conduct corresponding professional investigations and research, and record the data obtained in different databases, resulting in databases that are not universal and have a chaotic structure.
[0003] In related technologies, the integration of different databases involves organizing the data from different data packets and writing them into the database corresponding to the newly generated project name. However, due to the large amount of data in the project evaluation, writing data from different databases into the newly generated project name database will increase memory consumption and lead to excessive server load.
[0004] Therefore, how to integrate databases without affecting memory is a technical problem that domain engineers urgently need to solve. Summary of the Invention
[0005] To achieve database consolidation without affecting memory usage, this application provides a database consolidation method, apparatus, electronic device, and storage medium.
[0006] Firstly, this application provides a database integration method, which adopts the following technical solution: A database integration method, comprising: Obtain the data integration instructions, which must include at least: the project name; Identify multiple data packets associated with the project name based on the project name; Read the data information corresponding to each of the multiple data packets associated with the project name; Write all data to a temporary file; Read the contents of the temporary file containing all the data and write it to the database.
[0007] By adopting the above technical solution, after obtaining the data integration instruction, in order to ensure data integrity, all multiple data packets associated with the project name are identified based on the project name, and the data information of all data packets is read. In order to reduce running memory, after reading the data information of all data packets, the data information can be written to a temporary file, and the contents of the temporary file are read and written to the database. By temporarily storing the obtained data information in the created temporary file, the situation of insufficient running memory leading to excessive server load when writing all the data information to the database at the same time is avoided. This achieves the integration of database data information without affecting memory.
[0008] In a preferred example, this application can be further configured to include, before writing all data information to a temporary file: Create multiple temporary files with the same format and memory size, and obtain the number information of each temporary file. The number information indicates the order of each temporary file. Accordingly, all data information is written to a temporary file, including: Write all data information into the temporary file according to the number information of each temporary file.
[0009] By adopting the above technical solution, multiple temporary files with the same format are created and written to simultaneously, improving the efficiency of data writing. Furthermore, by writing all data information into the temporary files according to their respective file numbers, the accuracy of the data information is guaranteed.
[0010] In a preferred embodiment, this application can be further configured to: write all data information into temporary files according to the numbering information of each temporary file, including: Get the memory size of the temporary file; For each piece of data, the data is divided into multiple sub-contents based on the memory size of the temporary file; Multiple sub-contents are numbered, and the sub-contents are written to the temporary file according to the number of each sub-content and the number information of the temporary file.
[0011] By adopting the above technical solution, the data information is divided according to the memory size of the acquired temporary file, and the multiple sub-contents are numbered. This avoids data chaos caused by incorrect data writing order, thus improving data accuracy. By writing the sub-contents into the temporary file according to the number of each sub-content and the number of the temporary file, multiple temporary files can be written to simultaneously while ensuring data accuracy, thereby improving the efficiency of writing data information into the temporary file.
[0012] In a preferred example, this application can be further configured to write the contents of a temporary file to a database, including: A buffer corresponding to each temporary file is generated after each temporary file. The buffer is used to read the contents of the temporary file. Get the maximum write speed from the allowed write speeds; Write the contents of each buffer to the database according to the maximum write speed.
[0013] By adopting the above technical solution, a buffer is generated after each temporary file, which can reduce the consumption of running memory and avoid excessive server load. The contents of each buffer are written to the database according to the maximum write speed among the obtained allowed write speeds, which can effectively reduce the consumption of running memory and avoid excessive server load.
[0014] In a preferred example, this application can be further configured to write the contents of each buffer to the database according to the maximum write speed, including: The database is divided into blocks based on the memory size of the temporary files to obtain information for multiple regions; Obtain the starting position information of each region and determine the number of files that can be written to the database simultaneously; The contents of the buffer are written to the database based on the number of files that can be written to the database simultaneously, their numbering information, and the position information of the starting bit of each region.
[0015] By adopting the above technical solution, the database is divided into blocks according to the memory size of the temporary files to obtain multiple region information. Based on the position information of the starting position of each region, the region information corresponding to the buffer content can be accurately determined. Within the determined number of files allowed to be written to the database at the same time, the buffer content is written to the database in correspondence with the region information of the database. This realizes the simultaneous writing of multiple buffer contents to the database, improving the efficiency of writing buffer contents to the database.
[0016] In a preferred example, this application can be further configured to include, after reading all data information from multiple data packets associated with the project name, the following: Retrieve data format information from the database; The data information is converted according to the data format information of the database to obtain the converted data information; Accordingly, the data information is written to a temporary file, including: The converted data is written to a temporary file.
[0017] By adopting the above technical solution, before writing the data information to the temporary file, the data information is converted according to the data format information of the acquired database to obtain the converted data information. The converted data information is then written to the temporary file. By converting the data information format before writing it to the temporary file, data errors caused by inconsistent formats are avoided, and the accuracy of database integration is improved.
[0018] In a preferred embodiment, this application can be further configured to: convert data information according to the data format information of the database to obtain converted data information, including: Obtain the format information corresponding to each data item; The database data format information is matched with the format information corresponding to each data information to obtain the data information with mismatched formats, and the position information corresponding to the data information with mismatched formats is determined. Based on the data format information in the database, the data information with mismatched formats is converted to obtain the converted data information; The converted data will be replaced based on the location information corresponding to the data with mismatched formats.
[0019] By adopting the above technical solution, the data format information in the database is matched with the format information corresponding to each data information, all data information with mismatched formats is filtered out and the position information corresponding to each data information with mismatched formats is determined. After converting the data information with mismatched formats according to the data format information in the database, the converted data information is replaced according to the corresponding position information. By matching the format information in the database with the format information of each data information, filtering out data information with mismatched formats, and converting the format information with mismatched formats, the efficiency of data information format conversion is improved.
[0020] Secondly, this application provides a database integration device, which adopts the following technical solution: A database integration device, comprising: First Acquisition Module: Used to acquire data integration instructions, which must include at least: project name; First determination module: used to determine multiple data packets associated with the project name based on the project name; The second acquisition module is used to read the data information corresponding to each of the multiple data packets associated with the project name; Write module: Used to write all data information to a temporary file; Read / Write Module: Used to read the contents of temporary files in temporary files containing all data and write the contents of those temporary files to the database.
[0021] Thirdly, this application provides an electronic device that adopts the following technical solution: At least one processor; Memory; At least one application, wherein the at least one application is stored in memory and configured to be executed by at least one processor, the at least one application being configured to: execute the database integration method described above.
[0022] Fourthly, this application provides a computer-readable storage medium, which adopts the following technical solution: A computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to perform a database integration method.
[0023] In summary, this application includes at least one of the following beneficial technical effects: To ensure data integrity when acquiring data integration instructions, all data packets associated with the project name are identified based on the project name. Data information from all data packets is read. To reduce memory usage, temporary files are created after reading all data packets. Data information is written to these temporary files, and the contents of the temporary files are read and written to the database. By temporarily storing the obtained data information in the created temporary files, the problem of insufficient memory leading to excessive server load when writing all data information to the database simultaneously is avoided. This allows for the integration of database data without affecting memory usage.
[0024] By matching the database's data format information with the format information corresponding to each data piece of information, all data pieces with mismatched formats are filtered out, and the position information corresponding to each mismatched data piece of information is determined. After converting the mismatched data pieces of information according to the database's data format information, the converted data pieces of information are replaced according to the corresponding position information. By matching the database's format information with the format information of each data piece of information, filtering out data pieces with mismatched formats, and converting the format of the mismatched data pieces of information, the efficiency of data format conversion is improved. Attached Figure Description
[0025] Figure 1This is a flowchart illustrating a database integration method provided in an embodiment of this application.
[0026] Figure 2 This is a schematic diagram of the structure of a database integration device provided in an embodiment of this application; Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0027] The following combination Figures 1-3 This application will be described in further detail.
[0028] This specific embodiment is merely an explanation of this application and is not intended to limit it. After reading this specification, those skilled in the art can make modifications to this embodiment without contributing any inventive step, but such modifications are protected by patent law as long as they fall within the scope of the claims of this application.
[0029] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0030] Furthermore, the term "and / or" in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this article, unless otherwise specified, generally indicates that the preceding and following related objects have an "or" relationship.
[0031] The embodiments of this application will now be described in further detail with reference to the accompanying drawings.
[0032] In related technologies, the integration of different databases involves writing data from different databases into a newly generated database with the project name. However, the amount of data for project evaluation is large. When integrating the data, it is necessary to write a large amount of data from multiple data packets into the database at the same time. However, writing multiple data packets into the database can easily cause data redundancy, increase the consumption of server running memory, and thus lead to excessive server load.
[0033] To address the aforementioned technical problems, embodiments of this application provide a database integration method, apparatus, electronic device, and storage medium. After obtaining a data integration instruction, to ensure data integrity, all data packets associated with the project name are identified based on the project name. Data information from all data packets is read. To reduce memory usage, after reading the data information from all data packets, the data information can be written to a temporary file. The contents of the temporary file are then read and written to the database. By temporarily storing the obtained data information in the created temporary file, the situation of insufficient memory leading to excessive server load when writing all data information to the database simultaneously is avoided. This achieves the integration of database data information without affecting memory usage.
[0034] This application provides a database integration method executed by an electronic device, which can be a server or a terminal device. The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. The terminal device can be a smartphone, tablet computer, laptop computer, desktop computer, etc., but is not limited to these. The terminal device and the server can be directly or indirectly connected through wired or wireless communication methods, and this application does not impose any limitations on this.
[0035] Combination Figure 1 , Figure 1 This application provides a flowchart of a database integration method. For example... Figure 1 As shown, the method includes steps S101, S102, S103, S104, and S105, wherein: Step S101: Obtain the data integration instruction. The data integration instruction shall include at least the project name.
[0036] Data integration commands can be obtained through mechanical button triggering or virtual button triggering. Mechanical button triggering can be achieved by pressing the power button to automatically obtain the command after powering on, or by pressing the corresponding trigger button again after powering on. Virtual button triggering can be achieved by pressing the relevant virtual trigger button in the corresponding software interface.
[0037] The data integration instructions may include: project name and project number corresponding to the project name. This application embodiment does not limit this, as long as it can achieve the purpose of this application embodiment.
[0038] Step S102: Determine multiple data packets associated with the project name based on the project name.
[0039] The data package may include: a public opinion data package corresponding to the project name, a wastewater discharge data package, a noise information data package, a project risk data package, and a project evaluation score data package. The public opinion data package, wastewater discharge data package, and noise information data package are records of on-site investigations and surveys conducted by staff after the project was approved. The project risk data package and project evaluation data package are project evaluation calculations based on the public opinion information, wastewater discharge information, and noise information obtained from the on-site investigations and surveys, and are associated with the project name.
[0040] Step S103: Read the data information corresponding to each of the multiple data packets associated with the project name.
[0041] In this process, after identifying all data packets associated with the project name, the electronic device reads all data information from all the multiple data packets associated with the project name. This embodiment does not limit the method of reading all data information; it can read data sequentially starting from the header, or it can read a fixed number of characters as a data module, block by block.
[0042] Step S104: Write all data information to a temporary file.
[0043] Temporary files are created temporarily after all data information has been read. They are used to temporarily store data, slow down the data transmission speed, and thus reduce the use of running memory. This application does not limit the number, format, or naming rules of temporary files, as long as the purpose of this application can be achieved.
[0044] After creating a temporary file, the read data can be written to the temporary file. The temporary file will temporarily store the data and will be automatically deleted after the electronic device has finished reading the contents of the temporary file.
[0045] Step S105: Read the contents of the temporary file in the temporary file containing all the data information, and write the contents of the temporary file into the database.
[0046] In order to reduce the server's operating memory, after writing data to a temporary file, users can set the writing time or the data writing speed, and read the contents of the temporary file when the server is idle, and write the contents of the temporary file to the database.
[0047] In this embodiment, after obtaining the data integration instruction, in order to ensure data integrity, all multiple data packets associated with the project name are determined according to the project name, and the data information of all data packets is read. In order to reduce running memory, after reading the data information of all data packets, the data information can be written to a temporary file, and the contents of the temporary file are read and written to the database. By temporarily storing the obtained data information in the created temporary file, the situation of insufficient running memory leading to excessive server load when writing all the data information to the database at the same time is avoided. This achieves the integration of data information in the database without affecting memory.
[0048] One possible implementation of this application embodiment includes, before writing all data information into the temporary file, the following: Create multiple temporary files with the same format and memory size, and obtain the number information of each temporary file. The number information indicates the order of each temporary file. Accordingly, all data information is written to a temporary file, including: Write all data information into the temporary file according to the number information of each temporary file.
[0049] In this embodiment, to maintain the uniformity of the created temporary files, multiple temporary files with the same format can be created. The uniformity means that the memory size and data format are identical. The temporary file numbering information can be a naming code in the file name or a corresponding number matched in the electronic device; this embodiment does not limit this approach.
[0050] After creating multiple temporary files with a uniform format, to ensure data accuracy, the read data information can be written sequentially into the temporary files according to their numbers. This embodiment does not limit the method of writing all data information into each temporary file according to its number. Alternatively, all temporary files can be arranged sequentially according to their numbers, and when the current temporary file is full, the next temporary file corresponding to its number can be directly retrieved and written. Another approach is to determine multiple start and end positions based on the memory size of each temporary file, and then determine the start and end positions corresponding to each temporary file based on its number. The contents of the start and end positions corresponding to each temporary file can then be written into the temporary file. This allows for simultaneous writing of multiple temporary files, improving data writing efficiency.
[0051] In this embodiment, by creating multiple temporary files with a uniform format, multiple temporary files can be written simultaneously, which improves the efficiency of data writing. Furthermore, by writing all data information into the temporary files according to the number information of each temporary file, the accuracy of the data information is guaranteed. By creating multiple temporary files with a uniform format and writing data information into the temporary files according to the number information of each temporary file, the efficiency of data writing can be improved while ensuring the accuracy of the data information.
[0052] One possible implementation of this application embodiment involves writing all data information into a temporary file according to the number information of each temporary file, including: Get the memory size of the temporary file; For each piece of data, the data is divided into multiple sub-contents based on the memory size of the temporary file; Multiple sub-contents are numbered, and the sub-contents are written to the temporary file according to the number of each sub-content and the number information of the temporary file.
[0053] The memory size of a temporary file refers to how many characters of data it can temporarily store. Generally, when creating a temporary file, the user can customize the memory size of each temporary file according to actual needs, or calculate the memory size of each temporary file based on the size of the data and the number of temporary files specified by the user. This application embodiment does not limit this.
[0054] In this embodiment of the application, the method for segmenting data information according to the memory size of temporary files can be as follows: obtain the header character of the data information, determine the start and end positions of each temporary file according to the header character and the memory size, and take the content between the start and end positions as a sub-content of the data information.
[0055] In this embodiment, the numbering rules for sub-contents are not limited. They can be: numbering the sub-contents corresponding to each temporary file according to the number of each temporary file; or directly numbering the sub-contents according to the numbering rules of temporary files; or, after numbering each sub-content, associating the number of the sub-content with the number of the temporary file corresponding to the sub-content. Any method that achieves the purpose of this embodiment is acceptable.
[0056] In this embodiment, by dividing the data information according to the memory size of the acquired temporary file and numbering the multiple sub-contents, the data chaos caused by the incorrect order of data writing is avoided, thus improving the accuracy of the data. By writing the sub-contents into the temporary file according to the number of each sub-content and the number of the temporary file, data information can be written to multiple temporary files at the same time while ensuring data accuracy, thus improving the efficiency of writing data information into the temporary file.
[0057] One possible implementation of this application embodiment involves writing the temporary file content into a database, including: A buffer corresponding to each temporary file is generated after each temporary file. The buffer is used to read the contents of the temporary file. Get the maximum write speed from the allowed write speeds; Write the contents of each buffer to the database according to the maximum write speed.
[0058] The buffer is a storage area that mitigates the speed mismatch between the CPU (Central Processing Unit) and I / O (Input / Output) devices, reducing the frequency of CPU interrupts and relaxing the CPU's limitations on interrupt response time. By using a buffer, the wear and tear on RAM can be reduced, preventing excessive server load.
[0059] The allowed write speed is the speed at which an electronic device can write the contents of the buffer to the database without significantly impacting the server, while the maximum write speed is the highest among all allowed write speeds.
[0060] After determining the maximum write speed, the contents of each buffer are written to the database. This application embodiment does not limit the method of writing the contents of each buffer to the database. The buffers can be written in the order of the temporary file numbers, or the contents of multiple buffers can be written to the database at the same time. This application embodiment does not limit the number of buffers written to the database at the same time. Users can customize the settings according to their actual needs.
[0061] In this embodiment of the application, by generating a buffer after each temporary file, the consumption of running memory can be reduced, avoiding excessive server load. Furthermore, by writing the contents of each buffer to the database according to the maximum write speed among the obtained allowed write speeds, the consumption of running memory can be effectively reduced, avoiding excessive server load.
[0062] One possible implementation of this application embodiment involves writing the contents of each buffer to the database according to the maximum write speed, including: The database is divided into blocks based on the memory size of the temporary files to obtain information for multiple regions; Obtain the starting position information of each region and determine the number of files that can be written to the database simultaneously; The contents of the buffer are written to the database based on the number of files that can be written to the database simultaneously, their numbering information, and the position information of the starting bit of each region.
[0063] The block processing involves dividing the database memory into blocks according to the size of the temporary file. After block processing, the contents of the buffer are written into the area information corresponding to the buffer in multiple area information groups obtained from the block processing.
[0064] The number of files that can be written to the database simultaneously can be set by the user or determined by the server's capacity. The number of files that can be written to the database simultaneously is the number of buffer contents that can be written to the database at the same time.
[0065] To improve the accuracy of data writing, after the data is divided into blocks, the position information of the starting bit of each region can be determined, and the starting bit of the content in the buffer can be written accordingly based on the position information of the starting bit of the corresponding region.
[0066] In this embodiment, the database is divided into blocks according to the memory size of the temporary files to obtain multiple region information. Based on the position information of the starting position of each region, the region information corresponding to the buffer content can be accurately determined. The buffer content is written to the database according to the region information of the database within the determined number of files that can be written to the database at the same time. This realizes the simultaneous writing of multiple buffer contents to the database and improves the efficiency of writing buffer contents to the database.
[0067] One possible implementation of this application embodiment, after reading all data information of multiple data packets associated with the project name, further includes: Retrieve data format information from the database; The data information is converted according to the data format information of the database to obtain the converted data information; Accordingly, the data information is written to a temporary file, including: The converted data is written to a temporary file.
[0068] The database's data format information can be either user-preset or freely defined by the database. When the data format information matches the data information's format information, the data is displayed correctly. When the data format information does not match the data information's format information, the data cannot be displayed correctly in the database. Therefore, the data information can be converted according to the database's data format information, and the converted data information can be written to a temporary file.
[0069] In this application, the method of converting data information based on the data format information of the database is not limited. All data information can be converted uniformly based on the data format information of the database, or the data format information of the database can be matched with the format information of the data information to obtain mismatched data information, and then the mismatched data information can be converted with the format information of the database.
[0070] In this embodiment of the application, before writing the data information to the temporary file, the data information is converted according to the data format information of the acquired database to obtain the converted data information. The converted data information is then written to the temporary file. By converting the data information format before writing it to the temporary file, data errors caused by inconsistent formats are avoided, and the accuracy of database integration is improved.
[0071] One possible implementation of this application embodiment involves converting data information according to the data format information of the database to obtain converted data information, including: Obtain the format information corresponding to each data item; The database data format information is matched with the format information corresponding to each data information to obtain the data information with mismatched formats, and the position information corresponding to the data information with mismatched formats is determined. Based on the data format information in the database, the data information with mismatched formats is converted to obtain the converted data information; The converted data will be replaced based on the location information corresponding to the data with mismatched formats.
[0072] In this embodiment, to improve the efficiency of format conversion, the format information corresponding to each data information can be matched with the data format information in the database to identify data information with mismatched formats and determine the location information of each data information with mismatched formats. After converting the data information with mismatched formats according to the data format information in the database, the data information is replaced according to the location information of each data information with mismatched formats and the converted data information. The replaced data information is written to a temporary file. This embodiment does not limit the method of matching the data format information in the database with the format information corresponding to each data information. Users can customize the settings according to the actual situation.
[0073] In this embodiment, by matching the data format information of the database with the format information corresponding to each data information, all data information with mismatched formats is filtered out and the position information corresponding to each data information with mismatched formats is determined. After converting the data information with mismatched formats according to the data format information of the database, the converted data information is replaced according to the corresponding position information. By matching the format information of the database with the format information of each data information, filtering out data information with mismatched formats, and converting the format information with mismatched formats, the efficiency of data information format conversion is improved.
[0074] Furthermore, in this embodiment of the application, the method for matching the data format information of the database with the format information corresponding to each piece of data information to obtain data information with mismatched formats includes: For each set of data, determine the data category based on the data information, and then determine the corresponding data format information from the database based on the data category; The data format is determined based on the data information, and the data format is matched with the data format information corresponding to the data category.
[0075] The above embodiments describe a database integration method from the perspective of process flow. The following embodiments describe a database integration device from the perspective of virtual modules or virtual units. For details, please refer to the following embodiments.
[0076] This application provides a database integration device 200, such as... Figure 2 As shown, Figure 2 This is a schematic diagram of a database integration device provided in an embodiment of this application. The database integration device 200 may specifically include: First acquisition module 201: Used to acquire data integration instructions, which include at least: project name; First determining module 202: used to determine multiple data packets associated with the project name based on the project name; The second acquisition module 203 is used to read the data information corresponding to each of the multiple data packets associated with the project name; Write module 204: Used to write all data information to a temporary file; Read / write module 205: Used to read the contents of temporary files in temporary files containing all data information, and write the contents of temporary files to the database.
[0077] In this embodiment of the application, after obtaining the data integration instruction, in order to ensure data integrity, all multiple data packets associated with the project name are determined according to the project name, and the data information of all data packets is read. In order to reduce running memory, after reading the data information of all data packets, the data information can be written to a temporary file, and the contents of the temporary file are read and written to the database. By temporarily storing the obtained data information in the created temporary file, the situation of insufficient running memory leading to excessive server load when writing all the data information to the database at the same time is avoided, thus realizing the integration of data information in the database without affecting memory.
[0078] In one possible implementation of this application embodiment, the database integration device 200 further includes: The creation module is used to create multiple temporary files with the same format and memory size, and to obtain the number information of each temporary file. The number information indicates the order of each temporary file. Accordingly, when writing all data information to the temporary file, the writing module 204 is specifically used for: Write all data information into the temporary file according to the number information of each temporary file.
[0079] In one possible implementation of this application embodiment, when the creation module writes all data information into the temporary file according to the number information of each temporary file, it is specifically used for: Get the memory size of the temporary file; For each piece of data, the data is divided into multiple sub-contents based on the memory size of the temporary file; Multiple sub-contents are numbered, and the sub-contents are written to the temporary file according to the number of each sub-content and the number information of the temporary file.
[0080] In one possible implementation of this application embodiment, when the read / write module 205 writes the temporary file content to the database, it is specifically used for: A buffer corresponding to each temporary file is generated after each temporary file. The buffer is used to read the contents of the temporary file. Get the maximum write speed from the allowed write speeds; Write the contents of each buffer to the database according to the maximum write speed.
[0081] In one possible implementation of this application embodiment, when the read / write module 205 writes the contents of each buffer to the database according to the maximum write speed, it is specifically used for: The database is divided into blocks based on the memory size of the temporary files to obtain information for multiple regions; Obtain the starting position information of each region and determine the number of files that can be written to the database simultaneously; The contents of the buffer are written to the database based on the number of files that can be written to the database simultaneously, their numbering information, and the position information of the starting bit of each region.
[0082] In one possible implementation of this application embodiment, the database integration device 200 further includes: Format conversion module: used to obtain data format information from the database; The data information is converted according to the data format information of the database to obtain the converted data information; Accordingly, when writing all data information to the temporary file, the writing module 204 is specifically used for: The converted data is written to a temporary file.
[0083] In one possible implementation of this application embodiment, when the format conversion module performs data conversion based on the data format information in the database to obtain the converted data information, it is specifically used for: Obtain the format information corresponding to each data item; The database data format information is matched with the format information corresponding to each data information to obtain the data information with mismatched formats, and the position information corresponding to the data information with mismatched formats is determined. Based on the data format information in the database, the data information with mismatched formats is converted to obtain the converted data information; The converted data will be replaced based on the location information corresponding to the data with mismatched formats.
[0084] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the database integration device 200 described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0085] This application provides an electronic device, such as... Figure 3 As shown, Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 3The illustrated electronic device 300 includes a processor 301 and a memory 303. The processor 301 and the memory 303 are connected, for example, via a bus 302. Optionally, the electronic device 300 may also include a transceiver 304. It should be noted that in practical applications, the transceiver 304 is not limited to one type, and the structure of this electronic device 300 does not constitute a limitation on the embodiments of this application.
[0086] Processor 301 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 301 may also be a combination that implements computational functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.
[0087] Bus 302 may include a pathway for transmitting information between the aforementioned components. Bus 302 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. Bus 302 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 3 The symbol is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0088] The memory 303 may be a ROM (Read Only Memory) or other type of static storage device capable of storing static information and instructions, RAM (Random Access Memory) or other type of dynamic storage device capable of storing information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), CD-ROM (Compact Disc Read Only Memory) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but not limited thereto.
[0089] The memory 303 is used to store application code that executes the solution of this application, and its execution is controlled by the processor 301. The processor 301 is used to execute the application code stored in the memory 303 to implement the content shown in the foregoing method embodiments.
[0090] Electronic devices include, but are not limited to: mobile terminals such as mobile phones, laptops, digital radio receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), and in-vehicle terminals (such as in-vehicle navigation terminals), as well as fixed terminals such as digital TVs and desktop computers. Servers can also be included. Figure 3 The electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0091] This application provides a computer-readable storage medium storing a computer program that, when run on a computer, enables the computer to execute the corresponding content in the aforementioned method embodiments. Compared with related technologies, this application, after obtaining the data integration instruction, in order to ensure data integrity, determines all multiple data packets associated with the project name based on the project name, reads the data information of all data packets, and, to reduce memory usage, writes the data information to a temporary file after reading all data packets, then reads the contents of the temporary file and writes it to the database. By temporarily storing the obtained data information in the created temporary file, it avoids the situation where insufficient memory leads to excessive server load when writing all data information to the database simultaneously, thus achieving the integration of database data information without affecting memory.
[0092] It should be understood that although the steps in the flowcharts of the accompanying figures are shown sequentially as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the accompanying figures may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0093] The above are only some embodiments of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A database integration method, characterized in that, include: Obtain data integration instructions, wherein the data integration instructions include at least: project name; Based on the project name, identify multiple data packets associated with the project name; Read the data information corresponding to each of the multiple data packets associated with the project name; Write all the data information to a temporary file; Read the contents of the temporary file in the temporary file containing all the data, and write the contents of the temporary file into the database; A buffer corresponding to each temporary file is generated after each temporary file, and the buffer is used to read the contents of the temporary file. Get the maximum write speed from the allowed write speeds; Write the contents of each buffer to the database according to the maximum write speed; The step of writing the contents of each buffer to the database according to the maximum write speed includes: The database is divided into blocks based on the memory size of the temporary files to obtain multiple region information. Obtain the starting position information of each region and determine the number of files that can be written to the database simultaneously; The contents of the buffer are written to the database based on the number of files that can be written to the database simultaneously, their numbering information, and the position information of the starting bit of each region.
2. The database integration method according to claim 1, characterized in that, Before writing all the data information to the temporary file, the method further includes: Create multiple temporary files with the same format and memory size, and obtain the number information of each temporary file, wherein the number information represents the order of each temporary file; Accordingly, writing all the data information into a temporary file includes: Write all the data information into a temporary file according to the number information of each temporary file.
3. The database integration method according to claim 2, characterized in that, The step of writing all the data information into a temporary file according to the number information of each temporary file includes: Get the memory size of the temporary file; For each piece of data, the data is divided into multiple sub-contents based on the memory size of the temporary file; Multiple sub-contents are numbered, and the sub-contents are written to the temporary file according to the number of each sub-content and the number information of the temporary file.
4. The database integration method according to claim 1, characterized in that, After reading all data information from the multiple data packets associated with the project name, the process further includes: Retrieve data format information from the database; The data information is converted according to the data format information of the database to obtain the converted data information; Accordingly, writing the data information into a temporary file includes: The converted data information is written to a temporary file.
5. The database integration method according to claim 4, characterized in that, The step of converting the data information according to the data format information of the database to obtain the converted data information includes: Obtain the format information corresponding to each data item; The data format information in the database is matched with the format information corresponding to each data information to obtain data information with mismatched formats, and the position information corresponding to the data information with mismatched formats is determined. Based on the data format information of the database, the data information with mismatched formats is converted to obtain the converted data information; The converted data will be replaced based on the location information corresponding to the data with mismatched formats.
6. A database integration device, characterized in that, include, First acquisition module: used to acquire data integration instructions, the data integration instructions including at least: project name; First determining module: used to determine multiple data packets associated with the project name based on the project name; The second acquisition module is used to read the data information corresponding to each of the multiple data packets associated with the project name; Write module: Used to write all the data information into a temporary file; Read / write module: used to read the contents of temporary files in temporary files containing all data information, and write the contents of the temporary files into the database; A buffer corresponding to each temporary file is generated after each temporary file, and the buffer is used to read the contents of the temporary file. Get the maximum write speed from the allowed write speeds; Write the contents of each buffer to the database according to the maximum write speed; The step of writing the contents of each buffer to the database according to the maximum write speed includes: The database is divided into blocks based on the memory size of the temporary files to obtain multiple region information. Obtain the starting position information of each region and determine the number of files that can be written to the database simultaneously; The contents of the buffer are written to the database based on the number of files that can be written to the database simultaneously, their numbering information, and the position information of the starting bit of each region.
7. An electronic device, characterized in that, include: At least one processor; Memory; At least one application, wherein the at least one application is stored in memory and configured to be executed by at least one processor, said at least one application being configured to: perform the database integration method according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, It stores a computer program, characterized in that when the computer program is executed in a computer, it causes the computer to perform the database integration method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Data aggregation method and aggregation system
CN114780535A
Excel data read-write processing method and device
CN115658792A