Database table aggregation method, device and equipment and computer readable storage medium
By using database table aggregation methods and leveraging real-time and full synchronization mechanisms, the problems of high maintenance difficulty and low efficiency of aggregation services are solved, achieving efficient and stable data aggregation that is suitable for multi-task management and maintenance.
Patent Information
- Application Number
- CN202410936103.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-12
- Publication Date
- 2026-11-20
- Estimated Expiration
- 2044-07-12
AI Technical Summary
In network applications, aggregation services are difficult to maintain and have low data aggregation efficiency, especially when a large number of aggregation tasks are frequently invoked, making it difficult to guarantee data aggregation efficiency.
This paper provides a database table aggregation method that obtains task configuration information and mapping rules, and utilizes the real-time synchronization mechanism and full synchronization mechanism in the target synchronization service to achieve real-time and full data synchronization respectively, supporting independent management and maintenance of each aggregation task.
Creating aggregation tasks in a configurable manner reduces the difficulty of creating aggregation tasks, improves the efficiency and stability of data aggregation, reduces maintenance difficulty, and adapts to a variety of practical work scenarios.
Smart Images

Figure CN118779374B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer data processing technology, specifically to a database table aggregation method, apparatus, device, and computer-readable storage medium. Background Technology
[0002] In the development of web applications, we often encounter functional requirements such as global search, data overview, and business reports. These functional requirements have one thing in common: they need to classify and aggregate a series of data, that is, to transform data from multiple database tables into an aggregate table for easy use in subsequent business.
[0003] To perform these aggregation operations, an aggregation service can read and transform data from the source database tables, then insert the transformed data into a new database table. The workload of the aggregation service is generally proportional to the amount of data in the source database tables. Furthermore, as the source database tables expand, new data transformation logic usually needs to be added to the aggregation service.
[0004] Therefore, when there are a large number of aggregation tasks (such as global search, data overview, business reports, etc., which are frequently called), the maintenance difficulty of the aggregation service increases sharply, and the efficiency of data aggregation is also difficult to guarantee. Summary of the Invention
[0005] In view of this, one or more embodiments of this disclosure provide a database table aggregation method, apparatus, device, and computer-readable storage medium, which can effectively maintain the aggregation service and ensure data aggregation efficiency.
[0006] This disclosure provides a database table aggregation method, the method comprising: obtaining task configuration information, the task configuration information including multiple mapping rules; determining a target aggregation task according to a target mapping rule among the multiple mapping rules, the target aggregation task representing the aggregation of data from at least one target source table into a target aggregation table; and running a target synchronization service for the target aggregation task, the target synchronization service including a first synchronization mechanism and a second synchronization mechanism, the first synchronization mechanism being used to synchronize data change information of the target source table to the target aggregation table in real time, and the second synchronization mechanism being used to fully synchronize the data information of the target source table to the target aggregation table when preset conditions are met.
[0007] This disclosure also provides a database table aggregation apparatus, the apparatus comprising: an acquisition unit for acquiring task configuration information, the task configuration information including multiple mapping rules; a management unit for determining a target aggregation task based on a target mapping rule among the multiple mapping rules, the target aggregation task representing the aggregation of data from at least one target source table into a target aggregation table; and a synchronization unit for running a target synchronization service for the target aggregation task, the target synchronization service including a first synchronization mechanism and a second synchronization mechanism, the first synchronization mechanism being used to synchronize data change information of the target source table to the target aggregation table in real time, and the second synchronization mechanism being used to fully synchronize the data information of the target source table to the target aggregation table when preset conditions are met.
[0008] This disclosure also provides an electronic device including a memory and a processor, the memory being used to store a computer program, which, when executed by the processor, implements the database table aggregation method described above.
[0009] This disclosure also provides a computer-readable storage medium for storing a computer program that, when executed by a processor, implements the database table aggregation method described above.
[0010] This disclosure provides one or more embodiments of the technical solution that allow users to create aggregation tasks in a configurable manner, reducing the difficulty of creating aggregation tasks. Based on multiple mapping rules, different aggregation tasks can be created separately to complete the data synchronization function from the source database table to the aggregation table. Independent aggregation tasks reduce the maintenance difficulty of the aggregation service.
[0011] This disclosure provides one or more implementation methods of a technical solution that, when applied to a specific target aggregation task, can run a corresponding target synchronization service. The target synchronization service can include both real-time synchronization and full synchronization mechanisms. The cooperation between these two mechanisms allows the target synchronization service to meet various practical work scenarios, improving the efficiency and stability of the aggregation task. Attached Figure Description
[0012] The features and advantages of this disclosure will be more clearly understood by referring to the accompanying drawings, which are schematic and should not be construed as limiting the scope of this disclosure in any way.
[0013] Figure 1 This illustration shows the steps of a database table aggregation method in one embodiment of the present disclosure;
[0014] Figure 2 A flowchart illustrating a real-time synchronization mechanism in one embodiment of this disclosure is shown;
[0015] Figure 3 A flowchart illustrating the full synchronization mechanism in one embodiment of this disclosure is shown.
[0016] Figure 4 A flowchart illustrating a full synchronization event in one embodiment of this disclosure is shown.
[0017] Figure 5 A schematic diagram of the composition structure of an automated aggregation program in one embodiment of this disclosure is shown;
[0018] Figure 6 A functional schematic diagram of an automated aggregation program in one embodiment of this disclosure is shown;
[0019] Figure 7 A schematic diagram of the scheduling relationship of the synchronization service in one embodiment of this disclosure is shown;
[0020] Figure 8 A schematic diagram of the functional units of a database table aggregation device in one embodiment of this disclosure is shown;
[0021] Figure 9 A schematic diagram of the structure of an electronic device according to one embodiment of the present disclosure is shown. Detailed Implementation
[0022] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this disclosure, and not all of them. Based on the embodiments of this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.
[0023] Please see Figure 1 The database table aggregation method provided in one embodiment of this disclosure may include the following steps.
[0024] S1: Obtain task configuration information, which includes multiple mapping rules.
[0025] In this implementation, to complete the data aggregation operation, it is necessary to establish a mapping relationship between the source database table and the aggregation table. The task configuration information can provide information about the source database table, the aggregation table, and the mapping rules between them.
[0026] In this embodiment, multiple mapping rules can be obtained through configuration information. Each mapping rule can correspond to an aggregation task. It should be noted that different mapping rules can involve the same source database table. However, for the same source database table, different mapping rules may select different ranges of data from that source database table, or may indicate different data transformation rules for the same data in that source database table.
[0027] In this embodiment, obtaining task configuration information can be achieved by receiving configuration text input by the user, reading configuration parameters transmitted by the user, or parsing configuration commands issued by the user. Depending on the specific application scenario, the method for obtaining task configuration information is not specifically limited here.
[0028] S2: Determine the target aggregation task based on the target mapping rule among the multiple mapping rules. The target aggregation task represents aggregating data from at least one target source table into a target aggregation table.
[0029] In this implementation, a specific target aggregation task can be determined for a specific target mapping rule. Each target aggregation task can be maintained and managed independently. For example, a target aggregation task can be created, modified, paused, started, or deleted from multiple aggregation tasks without affecting the status of other aggregation tasks.
[0030] In some implementations, control commands can be obtained. Based on the control commands, multiple target aggregation tasks can be managed in batches, or a single target aggregation task can be managed in a customized manner.
[0031] S3: For the target aggregation task, run the target synchronization service. The target synchronization service includes a first synchronization mechanism and a second synchronization mechanism. The first synchronization mechanism is used to synchronize the data change information of the target source table to the target aggregation table in real time. The second synchronization mechanism is used to fully synchronize the data information of the target source table to the target aggregation table when preset conditions are met.
[0032] In this embodiment, a target synchronization service can be run for each target aggregation task. Any target synchronization service can have a first synchronization mechanism and a second synchronization mechanism to perform real-time data synchronization and full data synchronization, respectively.
[0033] It should be noted that the target synchronization service has both a first synchronization mechanism and a second synchronization mechanism, meaning it can perform two types of data synchronization functions, but it is not required that the target synchronization service execute both synchronization mechanisms simultaneously. Depending on actual needs, the execution logic of the synchronization mechanism can be customized for each target aggregation task. For example, the first and second synchronization mechanisms can be executed alternately; one synchronization mechanism can be executed continuously while the other is executed periodically; or only the first or second synchronization mechanism can be executed.
[0034] In this embodiment, the target synchronization service can be configured during or after the creation of the target aggregation task. When configuring the target synchronization service, parameters in the task configuration information can be accessed, such as real-time scheduling delay, real-time scheduling queue length, full scheduling cycle, and cache queue length.
[0035] In some implementations, once the target aggregation task is managed and modified, the target synchronization service can be managed and modified accordingly.
[0036] In this embodiment, running the target synchronization service can execute a real-time synchronization mechanism. Executing the real-time synchronization mechanism may include the following steps.
[0037] S31: Monitor the data operation log of the target source table to determine the data change information of the target data row in the target source table.
[0038] S32: Generate a first message body based on the data change information of the target data row. The first message body includes the data change type, the source table ownership information of the target data row, the data change content, and the data change time.
[0039] S33: Based on the data change time, store the first message body into the first data queue of the message cache queue.
[0040] S34: Using the message processor, read the first message body from the first data queue.
[0041] S35: Based on the target mapping rule, the data model of the first message body is transformed from the data model of the target source table to the data model of the target aggregation table to obtain the second message body.
[0042] S36: According to the transformed data change type included in the second message body, the second message body is stored in the corresponding second data queue, which includes at least one of the data addition queue, data modification queue, and data deletion queue.
[0043] S37: Perform the data entry operation for the second message body according to the predetermined data entry conditions.
[0044] S38: In response to the execution of the data entry operation, modify the target aggregation table according to the instructions in the second message body to complete the information synchronization between the target source table and the target aggregation table.
[0045] The data entry conditions in step S36 can be established in one or more ways depending on the actual application scenario.
[0046] In a practical application example, if the data cached in the second data queue reaches its capacity limit, a data insertion operation can be performed. The capacity limit can be determined based on parameters in the task configuration information, such as the length of the real-time scheduling queue.
[0047] In a practical application example, if the second data queue holds a second message body for the same data row, a data entry operation can be performed. For instance, if both delete and add operations occur simultaneously for a data resource, the process cannot wait and the data entry operation needs to be performed immediately.
[0048] In a practical application example, if at least one second message body exists in the second data queue at the end of the preset data entry period, the data entry operation can be executed. The data entry period can be determined by parameters in the task configuration information, such as real-time scheduling delay. If a data entry operation has already been executed by other conditions within a data entry period, the data entry period can be reset. The data entry period ensures the ability to forcibly trigger a data entry operation when it is difficult to form the conditions for data entry.
[0049] Please see Figure 2 In a practical application example, running a target synchronization service can involve three core components: a listener, a message cache queue, and a message handler.
[0050] Specifically, the listener can execute steps S31 to S33 as described above. The data operation log of the target source table that the listener monitors can be a binlog log. The data change type in the first message body can be an add, update, delete, or other change operation. The data change content in the first message body can provide detailed data of the target data row.
[0051] The message cache queue can consist of two parts: a first data queue and an information cache area. The first data queue can be an ordered queue. By sorting the first message body according to its data change time, the first message bodies read by the listener can be placed in the first data queue in an orderly manner for processing. The first data queue can be further divided into a standard cache area and a special cache area. The total length of the first data queue can be determined by the information cache queue length in the task configuration information when creating the target aggregation task. When the first message body enters the first data queue, it generally enters the standard cache area. In certain event scenarios, data in the standard cache area will enter the special cache area. The message cache area can store some special information waiting to be used.
[0052] The message processor can execute steps S34 to S38 as described above. After the first message body enters the message processor, the message processor will transform the data model of the first message body into the data model of the target aggregation table according to the target mapping rules, forming the second message body. At this time, the second message body will not be directly entered into the database, but will be temporarily placed in the second data queue inside the message processor. The message processor can have three second data queues, which are used to store information of type ADD, UPDATE, and DELETE, respectively. When the data entry conditions are met, the message processor will then batch enter the second message bodies in the second data queues into the database. In this way, the data definition language (DDL) operations on the target aggregation table can be reduced, alleviating the pressure on the target database.
[0053] In this implementation, the real-time synchronization mechanism may lead to data inconsistencies under certain abnormal scenarios. Furthermore, during the initialization phase of the target aggregation task, it may be necessary to synchronize existing data once. Therefore, running the target synchronization service can also execute a full synchronization mechanism.
[0054] Please see Figure 3 In some implementations, a full synchronization mechanism can be invoked to traverse at least one target source table. When accessing the current target source table (e.g., table 'a'), the data content of the current target source table and the target aggregate table can be compared to determine the variable data. If the variable data is not empty, the variable data can be synchronized in the target aggregate table, and after synchronizing the variable data, the process jumps to the next target source table. If the variable data is empty, the process can directly jump to the next target source table. The traversal can end once all target source tables have been visited.
[0055] In some implementations, the real-time synchronization mechanism and the full synchronization mechanism can be executed by the real-time scheduler and the full scheduler, respectively. The full scheduler can compare data from the source tables sequentially, one by one. Before starting the comparison, the full scheduler can send a full synchronization start event to the real-time scheduler. After completing the data comparison and ensuring consistency between the source table and the aggregate table, the full scheduler can send a full synchronization complete event to the real-time scheduler.
[0056] In some implementations, running the target synchronization service can perform a full synchronization event on the first source table in the target source table. First, the start information of the full synchronization event can be stored in the message cache area of the message cache queue. Then, performing the data entry operation clears the second message body currently cached in the second data queue. Based on the source table ownership information, a third message body matching the first source table can be determined from the first message body currently cached in the first data queue. This third message body can be transferred from the standard cache area in the first data queue to a special cache area within the first data queue. A fourth message body matching the first source table that subsequently enters the first data queue can be directly stored in the special cache area. Finally, the third and fourth message bodies stored in the special cache area can be read and processed, thereby completing a full information synchronization between the first source table and the target aggregate table.
[0057] In some implementations, after a full synchronization of information between the first source table and the target aggregation table is completed, the start information of the full synchronization event can be replaced with the completion information of the full synchronization event in the message buffer. Remaining message bodies in the special buffer can be transferred to the standard buffer. After the full synchronization event is completed, the fifth message body matching the first source table that enters the first data queue will logically enter the standard buffer normally.
[0058] Please see Figure 4 In a practical application example, a full synchronization event can be divided into two phases: startup and completion. The full synchronization event can be executed by the full synchronizer. When a full synchronization event for a table (e.g., table X) is started, the startup message of the event will be received by the message cache queue and stored in the information cache area.
[0059] When the message cache queue receives a full synchronization start event, it will execute the following logic in sequence:
[0060] 1. Notify the message processor to immediately trigger a data entry into the database.
[0061] 2. Wait for the full synchronization signal of table X, read the message body belonging to table X from the standard buffer of the first data queue, and put it into the special buffer of the first data queue. If the special buffer is full, discard the earliest data.
[0062] 3. Messages originating from table X that subsequently enter the first data queue will directly enter a special cache area.
[0063] After the full data synchronization of table X is completed, the message cache queue will receive a full synchronization completion event. It can then replace the start event information in the message cache with the completion event information and execute the following logic:
[0064] 1. Read the special cache area, put the message body whose data change time is after the completion event time into the standard cache area, and discard the rest of the data.
[0065] 2. Since the full synchronization event of table X has been completed, subsequent message bodies originating from table X will logically enter the standard cache area normally.
[0066] Specifically, during a full synchronization event, the aggregated data corresponding to table X will cease processing in the real-time synchronizer and will be entirely handled by the full synchronizer, thus ensuring the stability of data processing. The logical control of a special buffer ensures that no newly added message bodies are missed after the full synchronization event is completed.
[0067] In a practical application example, if the message handler's processing speed is slower than the listener's production speed, the standard buffer queue may become full, triggering an overflow event. If an overflow event is triggered, it can be recorded in the message buffer, and a special full synchronization request can be initiated to the full scheduler, causing the target synchronization service to immediately execute the full synchronization mechanism.
[0068] It's important to note that only one overflow event can occur at a time; any subsequent overflow data will be discarded. The overflow event ends once the full synchronization mechanism triggered by the overflow event has finished running. This overflow event mechanism prevents the loss of synchronization information caused by the message processor's inability to keep up when a large number of data changes occur instantaneously in certain source tables.
[0069] Please see Figure 5This disclosure provides a database table aggregation method that can be encapsulated into an automated aggregation program. This automated aggregation program focuses on database data aggregation operations, requiring users to define the aggregation table and the mapping relationship between the source database table and the aggregation table. After the automated aggregation program starts, it can initiate real-time synchronization and scheduled full synchronization tasks based on user-defined template information. Real-time synchronization is responsible for synchronizing DML information from the original data table to the aggregation table in real time, while full synchronization periodically compares the data in the original data table and the aggregation table to ensure data consistency. A key feature of this automated aggregation program is its configurability, allowing for unified management of multiple tasks and flexible maintenance of each task. Users can freely modify task logic and pause / start tasks through the program interface according to their business changes and actual needs, saving significant coding time and maintenance costs for aggregation operations across multiple data tables.
[0070] Specifically, the main structure of this automated aggregation program may include a configuration center, resource controller, task manager, task scheduling center, northbound service gateway, and other components.
[0071] The configuration center stores configuration information for the automated aggregation program, such as task information, task scheduling information, and data source information. The resource controller interfaces with the configuration center and is responsible for persisting and querying program information. The task manager is responsible for creating and maintaining aggregation tasks. The task scheduling center controls the aggregation task synchronization service, and internally includes a real-time synchronization task scheduler and a full synchronization task scheduler, responsible for real-time synchronization and full synchronization scheduling, respectively. The northbound service gateway provides northbound interface capabilities for upper-layer applications to configure synchronization logic.
[0072] Upon startup, this automated aggregation program initializes two basic services: a management service and a synchronization service. The management service, essentially the task manager, allows users to create, edit, start, pause, and delete aggregation tasks. This service maintains the aggregation tasks themselves, while the corresponding synchronization service handles the actual data synchronization. Based on the management service, the automated aggregation program allows multiple aggregation tasks to run simultaneously. Each aggregation task's synchronization service is independent and does not affect others. According to the user-configured aggregation task, the task scheduler center starts the task's synchronization service. Each synchronization service is further divided into a real-time synchronization service and a full synchronization service. The real-time synchronization service handles real-time data synchronization of database tables, while the full synchronization service handles periodic data comparisons and data completion in abnormal scenarios. The two synchronization services collaborate to ensure the stability and availability of aggregation tasks across various scenarios.
[0073] Please see Figure 6In a practical application example, after the automated aggregation program starts, users can access the program through the northbound service gateway to create tasks. Following the prompts, users can sequentially select parameters such as data source, aggregation table, full scheduling cycle, and real-time synchronization queue configuration to determine the basic task information. Based on this, users can select the aggregation source table and the mapping relationship between the source table and the aggregation table. Here, data source represents the database connection address; aggregation table represents the selected aggregation table; cache queue length represents the maximum amount of data that can be retained in the cache; full scheduling cycle represents the interval period for full synchronization; real-time scheduling latency represents the maximum frequency at which a data ingestion operation is triggered; real-time scheduling queue length represents the maximum amount of data that the queue within the scheduler can cache; aggregation source table represents the selected source table to participate in the aggregation; and aggregation table mapping represents the field mapping rules between the source table and the aggregation table, supporting simple mappings or complex processing of script logic.
[0074] After the above information is configured, the automated aggregation program will persist the data to the configuration center via the resource controller and simultaneously notify the task scheduling center to initialize the synchronization service for the task. At this point, an aggregation task has been created and initialized. Subsequent data from the source table will be synchronized to the aggregation table by the synchronization service according to the configured mapping model.
[0075] The automated aggregation program allows modification of information such as the task's source table, table mapping, and full scheduling cycle. The overall process for task modification is largely the same as for task creation. The difference lies in the fact that after a modification request reaches the task manager, the task manager will notify the task manager to trigger the synchronization logic for the task's changes. Similar to modification operations, when a task is deleted, paused, or started, the corresponding information will be synchronized to the task manager. The manager controls the status of the synchronization service and simultaneously modifies the persistent information of the task in the configuration center.
[0076] Through the above mechanism, users can quickly maintain the status of aggregation tasks according to the actual situation without manual coding, saving a lot of coding work in business scenarios such as global search and log aggregation.
[0077] Please see Figure 7 In a practical application example, a synchronization service can refer to the collective term for a synchronization program launched by Task Manager that contains all aggregated tasks. Within this program, each aggregated task has a corresponding synchronization service, and they operate independently of each other. Each synchronization service is further divided into a real-time synchronizer and a full synchronizer.
[0078] As can be seen from the above, the technical solutions provided by one or more embodiments of this disclosure allow users to create aggregation tasks in a configurable manner, which can reduce the difficulty of creating aggregation tasks. Based on multiple mapping rules, different aggregation tasks can be created separately to complete the data synchronization function from the source data table to the aggregation table. Independent aggregation tasks can reduce the maintenance difficulty of the aggregation service.
[0079] This disclosure provides one or more implementation methods of a technical solution that, when applied to a specific target aggregation task, can run a corresponding target synchronization service. The target synchronization service can include both real-time synchronization and full synchronization mechanisms. The cooperation between these two mechanisms allows the target synchronization service to meet various practical work scenarios, improving the efficiency and stability of the aggregation task.
[0080] Please see Figure 8 This application also provides a database table aggregation apparatus, the apparatus comprising:
[0081] The acquisition unit 100 is used to acquire task configuration information, which includes multiple mapping rules.
[0082] Management unit 200 is configured to determine a target aggregation task based on a target mapping rule among a plurality of mapping rules, wherein the target aggregation task represents aggregating data from at least one target source table into a target aggregation table;
[0083] Synchronization unit 300 is used to run a target synchronization service for the target aggregation task. The target synchronization service includes a first synchronization mechanism and a second synchronization mechanism. The first synchronization mechanism is used to synchronize the data change information of the target source table to the target aggregation table in real time. The second synchronization mechanism is used to fully synchronize the data information of the target source table to the target aggregation table when preset conditions are met.
[0084] In one embodiment, the management unit 200 is further configured to acquire control instructions; and manage the target aggregation task according to the control instructions, wherein the management includes at least one of the operations of creating, editing, starting, pausing, and deleting.
[0085] In one implementation, the synchronization unit 300 is specifically configured to monitor the data operation log of the target source table, determine the data change information of the target data row in the target source table; generate a first message body based on the data change information of the target data row, the first message body including the data change type, the source table ownership information of the target data row, the data change content, and the data change time; store the first message body into a first data queue of the message cache queue according to the data change time; read the first message body in the first data queue using a message processor; convert the data model of the first message body from the data model of the target source table to the data model of the target aggregation table based on the target mapping rule, to obtain a second message body; store the second message body into a corresponding second data queue according to the converted data change type included in the second message body, the second data queue including at least one of a data addition queue, a data modification queue, and a data deletion queue; perform a data entry operation for the second message body according to predetermined data entry conditions; and modify the target aggregation table according to the instruction information of the second message body in response to the execution of the data entry operation, so as to complete the information synchronization between the target source table and the target aggregation table.
[0086] In one embodiment, the synchronization unit 300 is specifically configured to perform the data entry operation if the data cached in the second data queue reaches its capacity limit, wherein the capacity limit is determined according to the real-time scheduling queue length in the task configuration information; perform the data entry operation if the second data queue stores a second message body for the same data line; and perform the data entry operation if at least one second message body exists in the second data queue at the end of a preset data entry period, wherein the data entry period is determined by the real-time scheduling delay in the task configuration information.
[0087] In one embodiment, the synchronization unit 300 is further configured to: execute a full synchronization event for the first source table in the target source table; store the start information of the full synchronization event in the message cache area of the message cache queue; perform a data entry operation to clear the second message body currently cached in the second data queue; determine a third message body matching the first source table in the first message body currently cached in the first data queue according to the source table ownership information; transfer the third message body from the standard cache area in the first data queue to the special cache area in the first data queue; store a fourth message body matching the first source table that subsequently enters the first data queue into the special cache area; and read and process the third message body and the fourth message body stored in the special cache area to complete a full information synchronization between the first source table and the target aggregation table.
[0088] In one implementation, after completing a full information synchronization between the first source table and the target aggregation table, the synchronization unit 300 is further configured to replace the start information of the full synchronization event with the completion information of the full synchronization event in the message buffer; transfer the remaining message body in the special buffer to the standard buffer; and store the fifth message body that subsequently enters the first data queue and matches the first source table into the standard buffer.
[0089] In one implementation, the synchronization unit 300 is further configured to invoke the full synchronization mechanism to traverse the at least one target source table; when accessing the current target source table, compare the data content of the current target source table with that of the target aggregation table to determine variable data; if the variable data is not empty, synchronize the variable data in the target aggregation table, and after synchronizing the variable data, jump to access the next target source table; if the variable data is empty, jump to access the next target source table; until all target source tables in the at least one target source table have been accessed, the traversal ends.
[0090] The various units described in the above embodiments can be implemented by a computer chip or by a product with a certain function. A typical implementation device is a computer. Specifically, the computer can be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or any combination of these devices.
[0091] For ease of description, the above devices are described separately by function as various units. Of course, in implementing this application, the functions of each unit can be implemented in one or more software and / or hardware.
[0092] Please see Figure 9 This application also provides an electronic device, which includes a memory and a processor. The memory is used to store a computer program, and when the computer program is executed by the processor, it implements the above-described database table aggregation method.
[0093] This application also provides a computer-readable storage medium for storing a computer program that, when executed by a processor, implements the above-described database table aggregation method.
[0094] The processor can be a central processing unit (CPU). It can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or combinations thereof.
[0095] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer-executable programs, and modules, such as the program instructions / modules corresponding to the methods in the embodiments of this disclosure. The processor executes various functional applications and data processing by running the non-transitory software programs, instructions, and modules stored in the memory, thereby implementing the methods in the above-described embodiments.
[0096] The memory may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created by the processor, etc. Furthermore, the memory may include high-speed random access memory and non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, the memory may optionally include memory remotely located relative to the processor, which can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0097] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), random access memory (RAM), flash memory, hard disk drive (HDD), or solid-state drive (SSD), etc.; the storage medium can also include combinations of the above types of memory.
[0098] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, embodiments of devices, electronic devices, and storage media are basically similar to the method embodiments, so the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0099] The above description is merely an embodiment of this application and is not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
[0100] Although embodiments of the present disclosure have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the present disclosure, and such modifications and variations all fall within the scope defined by the appended claims.
Claims
1. A database table aggregation method, characterized in that, The method includes: Obtain task configuration information, which includes multiple mapping rules; Based on the target mapping rule among the multiple mapping rules, a target aggregation task is determined, wherein the target aggregation task represents aggregating data from at least one target source table into a target aggregation table; For the target aggregation task, a target synchronization service is run. The target synchronization service includes a first synchronization mechanism and a second synchronization mechanism. The first synchronization mechanism is used to synchronize the data change information of the target source table to the target aggregation table in real time. The second synchronization mechanism is used to fully synchronize the data information of the target source table to the target aggregation table when preset conditions are met. The target synchronization service includes: monitoring the data operation logs of the target source table to determine the data change information of the target data row in the target source table; generating a first message body based on the data change information of the target data row, the first message body including the data change type, the source table ownership information of the target data row, the data change content, and the data change time; storing the first message body into a first data queue of the message cache queue according to the data change time; reading the first message body from the first data queue using a message processor; converting the data model of the first message body from the data model of the target source table to the data model of the target aggregation table based on the target mapping rule to obtain a second message body; storing the second message body into a corresponding second data queue according to the converted data change type included in the second message body, the second data queue including at least one of a data addition queue, a data modification queue, and a data deletion queue; performing a data entry operation for the second message body according to predetermined data entry conditions; and modifying the target aggregation table according to the instruction information of the second message body in response to the execution of the data entry operation to complete the information synchronization between the target source table and the target aggregation table. The target synchronization service further includes: executing a full synchronization event for the first source table in the target source table; storing the start information of the full synchronization event in the message cache area of the message cache queue; performing a data entry operation to clear the second message body currently cached in the second data queue; determining a third message body matching the first source table in the first message body currently cached in the first data queue according to the source table ownership information; transferring the third message body from the standard cache area in the first data queue to the special cache area in the first data queue; storing a fourth message body matching the first source table that subsequently enters the first data queue into the special cache area; and reading and processing the third and fourth message bodies stored in the special cache area to complete a full information synchronization between the first source table and the target aggregation table. After completing a full information synchronization between the first source table and the target aggregation table, the method further includes: replacing the start information of the full synchronization event with the completion information of the full synchronization event in the message buffer; transferring the remaining message body in the special buffer to the standard buffer; and storing the fifth message body that subsequently enters the first data queue and matches the first source table into the standard buffer.
2. The method according to claim 1, characterized in that, The method further includes: Obtain control commands; The target aggregation task is managed according to the control instructions, and the management includes at least one of the operations of creating, editing, starting, pausing, and deleting.
3. The method according to claim 1, characterized in that, The step of performing a data entry operation matching the second message body according to predetermined data entry conditions includes at least one of the following: If the data cached in the second data queue reaches its capacity limit, the data entry operation is performed. The capacity limit is determined based on the real-time scheduling queue length in the task configuration information. If the second data queue stores a second message body for the same data row, then the data entry operation is performed. If at least one second message body exists in the second data queue at the end of the preset data entry period, the data entry operation is performed. The data entry period is determined by the real-time scheduling delay in the task configuration information.
4. The method according to any one of claims 1-3, characterized in that, The target synchronization service includes: Invoke the full synchronization mechanism to traverse at least one target source table; When accessing the current target source table, the data content of the current target source table is compared with that of the target aggregation table to determine the variable data; If the variable data is not empty, then the variable data is synchronized in the target aggregation table, and after synchronizing the variable data, the process jumps to access the next target source table; If the variable data is empty, then proceed to access the next target source table; The traversal ends when all target source tables in the at least one target source table have been visited.
5. A database table aggregation device, characterized in that, The device includes: An acquisition unit is used to acquire task configuration information, which includes multiple mapping rules. The management unit is used to determine a target aggregation task based on the target mapping rule among the multiple mapping rules, wherein the target aggregation task represents aggregating data from at least one target source table into a target aggregation table; A synchronization unit is used to run a target synchronization service for the target aggregation task. The target synchronization service includes a first synchronization mechanism and a second synchronization mechanism. The first synchronization mechanism is used to synchronize the data change information of the target source table to the target aggregation table in real time. The second synchronization mechanism is used to fully synchronize the data information of the target source table to the target aggregation table when preset conditions are met. The target synchronization service includes: monitoring the data operation logs of the target source table to determine the data change information of the target data row in the target source table; generating a first message body based on the data change information of the target data row, the first message body including the data change type, the source table ownership information of the target data row, the data change content, and the data change time; storing the first message body into a first data queue of the message cache queue according to the data change time; reading the first message body from the first data queue using a message processor; converting the data model of the first message body from the data model of the target source table to the data model of the target aggregation table based on the target mapping rule to obtain a second message body; storing the second message body into a corresponding second data queue according to the converted data change type included in the second message body, the second data queue including at least one of a data addition queue, a data modification queue, and a data deletion queue; performing a data entry operation for the second message body according to predetermined data entry conditions; and modifying the target aggregation table according to the instruction information of the second message body in response to the execution of the data entry operation to complete the information synchronization between the target source table and the target aggregation table. The target synchronization service further includes: executing a full synchronization event for the first source table in the target source table; storing the start information of the full synchronization event in the message cache area of the message cache queue; performing a data entry operation to clear the second message body currently cached in the second data queue; determining a third message body matching the first source table in the first message body currently cached in the first data queue according to the source table ownership information; transferring the third message body from the standard cache area in the first data queue to the special cache area in the first data queue; storing a fourth message body matching the first source table that subsequently enters the first data queue into the special cache area; and reading and processing the third and fourth message bodies stored in the special cache area to complete a full information synchronization between the first source table and the target aggregation table. After completing a full information synchronization between the first source table and the target aggregation table, in the message cache area, the start information of the full synchronization event is replaced with the completion information of the full synchronization event; the remaining message body in the special cache area is transferred to the standard cache area; and the fifth message body that subsequently enters the first data queue and matches the first source table is stored in the standard cache area.
6. An electronic device, characterized in that, The electronic device includes a memory and a processor, the memory being used to store a computer program that, when executed by the processor, implements the method as described in any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store a computer program that, when executed by a processor, implements the method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Controlling multi-database system
CN107004010A
Cache data processing method, device, equipment and system
CN114443777A
