Heterogeneous data synchronization method and related equipment
By receiving data change notifications and processing strongly dependent data in the retrieval table, heterogeneous data synchronization is achieved, solving the problem of low development efficiency of heterogeneous data synchronization, improving data retrieval performance and reducing costs.
Patent Information
- Application Number
- CN202410715928.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-04
- Publication Date
- 2024-09-10
AI Technical Summary
The synchronization development efficiency of heterogeneous data in the existing technology is low, resulting in poor data retrieval performance and high development costs.
By receiving data change notifications, the changed data information is obtained, and the corresponding strongly dependent data is determined based on the retrieval table, and the retrieval table is processed to achieve heterogeneous data synchronization. Dependencies are used to support a small amount of coding for data processing and transformation, and to improve data retrieval performance.
It greatly improves the development efficiency of heterogeneous data synchronization, improves data retrieval performance, reduces development costs, and ensures data consistency and accuracy.
Smart Images

Figure CN118626558A
Abstract
Description
Background Art
[0002] In various application scenarios where data configuration exists, relational databases are usually used for data storage and maintenance. However, for some data retrieval scenarios, relational databases cannot well meet the functional or performance requirements in terms of data aggregation, similarity search, and multi-table joins. Generally, a dedicated retrieval database is selected, and the data involved in the retrieval is synchronized to the retrieval database.
[0003] In the related art, in order to better meet the retrieval needs, data analysis is generally performed according to functional requirements, and data synchronization is achieved in a hard-coded manner, which has high development costs and low development efficiency.
[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0005] The present disclosure provides a heterogeneous data synchronization method and related devices, which at least to a certain extent overcome the problem of low development efficiency of heterogeneous data synchronization in the related art.
[0006] Other features and advantages of the present disclosure will become apparent from the following detailed description, or may be learned in part by the practice of the present disclosure.
[0007] According to one aspect of the present disclosure, a method for synchronizing heterogeneous data is provided, including: obtaining changed data information based on a received data change notification; determining strongly dependent data corresponding to the changed data information based on a retrieval table; processing the retrieval table based on the processing actions and strongly dependent data corresponding to the changed data information to obtain an updated retrieval table to synchronize heterogeneous data.
[0008] In one embodiment of the present disclosure, determining the strongly dependent data corresponding to the changed data information based on the retrieval table includes: in response to the changed data information being within the scope of the dependency table and the changed data information being a strong dependency item required by the retrieval table, obtaining the strongly dependent data corresponding to the changed data information; in response to the changed data information being within the scope of the dependency table and the changed data being not a strong dependency item required by the retrieval table, processing the synchronization subtask corresponding to the changed data information to obtain the strongly dependent data associated with the changed data information.
[0009] In one embodiment of the present disclosure, processing a synchronization subtask corresponding to the changed data information to obtain strongly dependent data associated with the changed data information includes: creating a synchronization subtask corresponding to the changed data information and saving the changed data information; inserting the synchronization subtask into a task queue; obtaining expired synchronization subtasks in the task queue and merging at least one corresponding synchronization subtask according to the changed data information; and determining strongly dependent data associated with the merged synchronization subtask according to the dependency relationship.
[0010] In one embodiment of the present disclosure, processing the retrieval table according to the processing action and the strongly dependent data corresponding to the changed data information includes: in response to the operation event corresponding to the changed data information being a deletion event, and the strongly dependent data being the strongly dependent data corresponding to the changed data information, deleting the corresponding data in the retrieval table according to the strongly dependent data; in response to the operation event corresponding to the changed data information being a deletion event, and the strongly dependent data being the strongly dependent data associated with the changed data information, updating the retrieval table according to the strongly dependent data.
[0011] In one embodiment of the present disclosure, processing the retrieval table according to the processing action corresponding to the changed data information and the strongly dependent data includes: in response to the operation event corresponding to the changed data information not being a deletion event, updating the retrieval table according to the strongly dependent data.
[0012] In one embodiment of the present disclosure, it also includes: in response to the data change notification that is not supported, obtaining the strong dependencies and non-strong dependencies required for the retrieval table; comparing the target data corresponding to the strong dependencies with the data in the retrieval table to determine the operation event corresponding to the retrieval table; processing the retrieval table according to the strong dependency data associated with the non-strong dependencies.
[0013] In one embodiment of the present disclosure, the target data includes: at least one of full data and incremental data; in response to an unsynchronized strong dependency, the target data is the full data of the strong dependency; in response to an over-synchronized strong dependency, the target data is the incremental data of the synchronized strong dependency.
[0014] According to another aspect of the present disclosure, a heterogeneous data synchronization device is also provided, including:
[0015] A data acquisition module is used to obtain changed data information according to the received data change notification;
[0016] A data determination module, used to determine the strongly dependent data corresponding to the changed data information according to the search table;
[0017] The data processing module is used to process the search table according to the processing actions corresponding to the changed data information and the strongly dependent data, and obtain the processed search table to synchronize heterogeneous data.
[0018] In one embodiment, the data determination module is also used to obtain the strong dependency data corresponding to the changed data information in response to the changed data information being within the scope of the dependency table and the changed data information being a strong dependency item required by the retrieval table; in response to the changed data information being within the scope of the dependency table and the changed data information being not a strong dependency item required by the retrieval table, process the synchronization subtask corresponding to the changed data information to obtain the strong dependency data associated with the changed data information.
[0019] In one embodiment, the data determination module is also used to create a synchronization subtask corresponding to the changed data information and save the changed data information; insert the synchronization subtask into the task queue; obtain the expired synchronization subtasks in the task queue, and merge at least one corresponding synchronization subtask according to the changed data information; and determine the strongly dependent data associated with the merged synchronization subtask based on the dependency relationship.
[0020] In one embodiment, the data processing module is also used to respond to the operation event corresponding to the changed data information being a deletion event, and the strong dependent data being the strong dependent data corresponding to the changed data information, delete the corresponding data in the retrieval table according to the strong dependent data; respond to the operation event corresponding to the changed data information being a deletion event, and the strong dependent data being the strong dependent data associated with the changed data information, update the retrieval table according to the strong dependent data; respond to the operation event corresponding to the changed data information being not a deletion event, update the retrieval table according to the strong dependent data.
[0021] In one embodiment, it also includes a data active synchronization module for obtaining strong dependencies and non-strong dependencies required for the retrieval table in response to unsupported data change notifications; comparing the target data corresponding to the strong dependencies with the data in the retrieval table to determine the operation events corresponding to the retrieval table; and processing the retrieval table according to the strong dependency data associated with the non-strong dependencies.
[0022] According to another aspect of the present disclosure, an electronic device is also provided, including: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to perform any one of the above-mentioned heterogeneous data synchronization methods by executing the executable instructions.
[0023] According to another aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, any one of the above heterogeneous data synchronization methods is implemented.
[0024] According to another aspect of the present disclosure, a computer program product is also provided. The computer program product includes a computer program or computer instructions. The computer program or computer instructions are loaded and executed by a processor so that a computer implements any one of the above heterogeneous data synchronization methods.
[0025] The heterogeneous data synchronization method and related equipment provided by the embodiments of the present disclosure obtain the changed data information according to the received data change notification; determine the strongly dependent data corresponding to the changed data information according to the search table; process the search table according to the processing action and the strongly dependent data corresponding to the changed data information to obtain an updated search table to synchronize the heterogeneous data. In the process of data synchronization, the present disclosure can determine the strongly dependent data according to the dependency relationship between the search table and the changed data information, and thus process the search table according to the strongly dependent data and the processing action corresponding to the changed data information to achieve heterogeneous data synchronization. Based on the above dependency relationship, it can support the processing and transformation of the original data through a small amount of coding, improve the data retrieval performance, and greatly improve the development efficiency.
[0026] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.
[0028] Figure 1 A flow chart of a heterogeneous data synchronization method according to an embodiment of the present disclosure is shown;
[0029] Figure 2 A flow chart of a method for determining strongly dependent data in an embodiment of the present disclosure is shown;
[0030] Figure 3 A flow chart of a retrieval table processing method in an embodiment of the present disclosure is shown;
[0031] Figure 4 A flow chart of another heterogeneous data synchronization method according to an embodiment of the present disclosure is shown;
[0032] Figure 5 A schematic diagram of a heterogeneous data synchronization device according to an embodiment of the present disclosure is shown;
[0033] Figure 6 A schematic diagram of a heterogeneous data synchronization system according to an embodiment of the present disclosure is shown;
[0034] Figure 7 A flow chart of an incremental data synchronization method according to an embodiment of the present disclosure is shown;
[0035] Figure 8 A flow chart of a full data synchronization method according to an embodiment of the present disclosure is shown; and
[0036] Fig. 9 A structural block diagram of an electronic device in an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0037] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that the disclosure will be more comprehensive and complete and to fully convey the concepts of the example embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
[0038] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.
[0039] The present exemplary implementation is described in detail below with reference to the accompanying drawings and embodiments.
[0040] First, a heterogeneous data synchronization method is provided in an embodiment of the present disclosure, and the method can be executed by any electronic device with computing and processing capabilities.
[0041] Figure 1 A flow chart of a heterogeneous data synchronization method according to an embodiment of the present disclosure is shown as follows: Figure 1 As shown, the heterogeneous data synchronization method provided in the embodiment of the present disclosure includes the following steps:
[0042] S102: Acquire changed data information according to the received data change notification.
[0043] In one embodiment, data change notifications are monitored and extracted through a log analyzer to perceive changes in heterogeneous data, such as the specific content of insert, update, and delete operations and the time when they occur.
[0044] It should be noted that data change notifications corresponding to heterogeneous data are received and parsed to obtain changed data information; heterogeneous data refers to data of different types, formats or structures contained in a data set, which may involve complex dependencies and associations between multiple data sources, such as time series data, network log data, user behavior data, etc.
[0045] In one embodiment, the data change notification is parsed to obtain changed data information, which includes but is not limited to: a changed data table, a changed data field, and the like.
[0046] S104, determining the strongly dependent data corresponding to the changed data information according to the search table.
[0047] In one embodiment, when the changed data information is within the scope of the dependency table, it is determined whether the changed data information is a strong dependency item required by the retrieval table; if so, the strongly dependent data corresponding to the changed data information is obtained; otherwise, the synchronization subtask corresponding to the changed data information is processed to obtain the strongly dependent data associated with the changed data information.
[0048] Strongly dependent data includes but is not limited to: strongly dependent tables, strongly dependent fields, etc. Strongly dependent data refers to referential integrity constraints between database tables; for example, in a relational database, if a foreign key field (ForeignKey) in one table references a primary key field (Primary Key) in another table, then these two fields form a strong dependency relationship; when a record in the primary table (parent table) is updated or deleted, operations on the slave table (child table) are automatically triggered.
[0049] S106, processing the search table according to the processing action corresponding to the changed data information and the strongly dependent data to obtain a processed search table to synchronize heterogeneous data.
[0050] The retrieval table is an aggregated table formed by various tables, that is, an aggregated data table.
[0051] In one embodiment, when the operation event corresponding to the changed data information is a deletion event, and the strongly dependent data is the strongly dependent data corresponding to the changed data information, the corresponding data in the search table is deleted according to the strongly dependent data.
[0052] In one embodiment, when the operation event corresponding to the changed data information is a deletion event, and the strongly dependent data is the strongly dependent data associated with the changed data information, the search table is updated according to the strongly dependent data.
[0053] In one embodiment, whether the operation event corresponding to the change data information is a deletion event is determined by analyzing the internal log of the database system or using a specific mechanism provided by the database (such as a trigger or a change data capture function).
[0054] In one embodiment, when the operation event corresponding to the changed data information is not a deletion event, the search table is updated according to the strongly dependent data.
[0055] In the above embodiment, during the data synchronization process, even if the original data needs to be processed and modified, only a small amount of coding is required to support it according to the defined dependencies, which is conducive to the management and maintenance of the database, improves data retrieval performance, ensures data consistency and accuracy, reduces development costs, and greatly improves development efficiency.
[0056] Figure 2 A flow chart of a method for determining strongly dependent data in an embodiment of the present disclosure is shown as follows: Figure 2 As shown, the method for determining strongly dependent data provided in the embodiment of the present disclosure includes the following steps:
[0057] S1042: In response to the changed data information being within the range of the dependency table and the changed data information being a strong dependency item required by the retrieval table, obtaining strong dependency data corresponding to the changed data information.
[0058] In one embodiment, the result of whether the changed data information is within the scope of the dependency table can be directly obtained through the data model, or a data identifier and dependency table mapping table can be established, and the mapping table can be queried through the data identifier corresponding to the changed data information to obtain the result of whether the changed data information is within the scope of the dependency table.
[0059] In one embodiment, the result of whether the changed data information is a strong dependency required by the retrieval table can be directly obtained through the data model, or a data identifier and dependency mapping table can be established. The mapping table can be queried through the data identifier corresponding to the changed data information to obtain whether the changed data information is a strong dependency required by the retrieval table.
[0060] In one embodiment, when the changed data information is not within the scope of the dependency table, the changed data information corresponding to the data change notification is ignored and / or discarded.
[0061] A dependent table is a table that is constrained to establish an association relationship with another table. The source definition information in the data model file is the data source required to build the current search library; the data model defines several data tables, the association relationship between tables, etc.
[0062] In one embodiment, the strongly dependent table, strongly dependent field, etc. corresponding to the changed data information are obtained. The strongly dependent data may be obtained according to the data model or according to the mapping information.
[0063] S1044, in response to the changed data information being within the range of the dependency table and the changed data not being a strong dependency item required by the retrieval table, processing the synchronization subtask corresponding to the changed data information to obtain the strong dependency data associated with the changed data information.
[0064] In one embodiment, when the changed data information is not within the range of the dependency table, the changed data information is merged according to the changed data identifier to obtain the strongly dependent data associated with the changed data information.
[0065] In the embodiments of the present disclosure, by changing the relationship between data information and the scope of the dependency table and the relationship between the changed data and the strong dependencies required by the retrieval table, the method for obtaining strongly dependent data is determined, thereby providing accurate data support for heterogeneous data synchronization and improving the efficiency and accuracy of heterogeneous data synchronization.
[0066] In one embodiment, a synchronization subtask corresponding to the changed data information is created and the changed data information is saved; the synchronization subtask is inserted into the task queue; the expired synchronization subtasks in the task queue are obtained, and at least one corresponding synchronization subtask is merged according to the changed data information; based on the dependency relationship, the strongly dependent data associated with the merged synchronization subtask is determined; specifically, a delayed synchronization subtask is created, the changed data information such as data tables and data fields is saved, and the delayed synchronization subtasks are inserted into the delayed task queue, a batch of expired delayed synchronization subtasks in the delayed task queue are obtained, and at least one corresponding synchronization subtask is merged according to the changed data information. For example, if a piece of data in a data table is updated multiple times in a short period of time, the delayed synchronization subtasks corresponding to the multiple updates of the data table are merged; based on the dependency relationship defined in the data model, the strongly dependent data associated with the merged synchronization subtask is determined; for example, answer_id information is used in the ir_group table, and answer_id is the strong dependency required to build the retrieval table.
[0067] In one embodiment, the merged synchronization subtask may be associated with a plurality of strongly dependent data, and the priority of the strongly dependent data may be set according to user needs.
[0068] In the above embodiment, strongly dependent data associated with the changed data information is obtained based on a delayed task method, and all related items are queued in the form of tasks and processed in sequence to ensure the final consistency of the data and avoid operating the same retrieval data simultaneously in concurrent situations, which may cause data confusion. Through the strongly dependent data corresponding to or associated with the changed data information and the processing actions corresponding to the changed data information, the retrieval table is efficiently processed, the data retrieval performance is improved, the consistency and accuracy of the data are ensured, the development cost is reduced, and the development efficiency is greatly improved.
[0069] Figure 3 A flowchart of a retrieval table processing method in an embodiment of the present disclosure is shown. Figure 3 As shown, the retrieval table processing method provided in the embodiment of the present disclosure includes the following steps:
[0070] S302: In response to the operation event corresponding to the changed data information being a deletion event, and the strongly dependent data being the strongly dependent data corresponding to the changed data information, delete the corresponding data in the search table according to the strongly dependent data.
[0071] For example, the original search table includes data table A, data table B and data table C; the search table is updated to obtain data table A and data table B according to the processing actions corresponding to the changed data information and the strongly dependent data.
[0072] In one embodiment, triggers are set in the database to manage this strong dependency. For example, if there is a field customer_id in the orders table that references the id field of the customers table as a foreign key, a DELETE trigger can be created for the customers table. When a customer record is deleted, the trigger will automatically execute a piece of code to process the records in the orders table associated with it as needed (such as deleting or updating these orders). In this way, the trigger source is the delete operation of the customers table, and the response is the operation on the strongly dependent table orders.
[0073] S304: In response to the operation event corresponding to the changed data information being a deletion event, and the strongly dependent data being the strongly dependent data associated with the changed data information, update the search table according to the strongly dependent data.
[0074] S306: In response to the fact that the operation event corresponding to the changed data information is not a deletion event, the search table is updated according to the strongly dependent data.
[0075] For example, the original search table includes data table A, data table B and data table C; according to the processing action corresponding to the changed data information and the strongly dependent data, data table A, data table B and data table C in the search table are deleted; it should be noted that this deletion is a logical deletion, which exists physically and can be set to be physically deleted later.
[0076] In the above embodiment, the corresponding operation event is determined according to the processing action corresponding to the changed data information and whether it is the strongly dependent data corresponding to the changed data information, and the operation is executed. There is no need to achieve data synchronization through a large amount of hard coding, which greatly improves development efficiency.
[0077] Figure 4 A flow chart of another heterogeneous data synchronization method in an embodiment of the present disclosure is shown as follows: Figure 4 As shown, the heterogeneous data synchronization method provided in the embodiment of the present disclosure includes the following steps:
[0078] S402: In response to the data change notification not being supported, obtaining strong dependencies and non-strong dependencies required for the retrieval table.
[0079] In one embodiment, when data change notification is not supported, the system can actively initiate a request or query to obtain all updated content of the data source, retrieve strong dependencies and non-strong dependencies required by the table, etc., and synchronize these data to the target system.
[0080] S404, comparing the target data corresponding to the strong dependency item with the data in the search table to determine the operation event corresponding to the search table.
[0081] In one embodiment, the target data includes but is not limited to: at least one of the full data and incremental data of the strong dependency; when the strong dependency is not synchronized, the target data is the full data of the strong dependency; when the strong dependency is synchronized, the target data is the incremental data of the strong dependency after synchronization.
[0082] In one embodiment, by comparing the target data corresponding to the strong dependency with the data in the search table, the operation event corresponding to the search table is determined, which can reduce the workload of comparing data, save costs, and improve efficiency.
[0083] In one embodiment, the time of the most recent strong dependency synchronization is obtained. If the time of the most recent synchronization cannot be obtained, it indicates that the strong dependency data has not been synchronized, and the full data of the strong dependencies is extracted respectively. If the time of the most recent synchronization is obtained, it indicates that the strong dependency data has been synchronized too much, and the full data of the strong dependencies after the most recent synchronization time is extracted respectively.
[0084] Full data refers to all data records in a data set, database, or system at a specific moment or within a specified time period. Compared with incremental data, full data includes not only newly added or changed data, but also all existing records.
[0085] Incremental data refers to data that is newly added, modified, or deleted in a data set or database over a period of time. These changes only contain the differences since the last data snapshot (full data). Incremental data is usually used to update existing information bases to maintain the real-time and consistency of data and reduce the resources required to transmit and process all data.
[0086] In one embodiment, the target data corresponding to the strong dependency is compared with the full data of the retrieval table. If the target data is new compared to the full data of the retrieval table, the operation event corresponding to the retrieval table is an update event, and an insert operation is performed. If the target data is deleted compared to the full data of the retrieval table, the operation event corresponding to the retrieval table is a delete event, and a delete operation is performed.
[0087] S406, processing the search table according to the strong dependency data associated with the non-strong dependency item.
[0088] In one embodiment, associating strongly dependent data is to find associated strongly dependent data according to the definition of the data model, comprehensively retrieve each external table data that the table depends on to obtain a complete data, and perform an update operation.
[0089] In the above embodiment, when data change notification is not supported, the strong dependencies and non-strong dependencies required for the retrieval table are obtained according to the defined dependency relationships, and the retrieval table is processed based on the strong dependency data determined by the strong dependencies and non-strong dependencies. This eliminates the need for data synchronization through a large amount of hard coding, greatly improving development efficiency.
[0090] Based on the same inventive concept, the present disclosure also provides a heterogeneous data synchronization device, such as the following embodiment. Since the principle of solving the problem in the device embodiment is similar to that in the above method embodiment, the implementation of the device embodiment can refer to the implementation of the above method embodiment, and the repeated parts will not be repeated.
[0091] Figure 5 A schematic diagram of a heterogeneous data synchronization device according to an embodiment of the present disclosure is shown. Figure 5 As shown, the heterogeneous data synchronization device 5 includes: a data acquisition module 501, a data determination module 502, and a data processing module 503;
[0092] The data acquisition module 501 is used to acquire the changed data information according to the received data change notification.
[0093] The data determination module 502 is used to determine the strongly dependent data corresponding to the changed data information according to the search table.
[0094] The data processing module 503 is used to process the search table according to the processing action corresponding to the changed data information and the strongly dependent data to obtain the processed search table to synchronize the heterogeneous data.
[0095] In one embodiment, the data determination module 502 is also used to obtain the strong dependency data corresponding to the changed data information in response to the changed data information being within the scope of the dependency table and the changed data information being a strong dependency item required by the retrieval table; in response to the changed data information being within the scope of the dependency table and the changed data being not a strong dependency item required by the retrieval table, process the synchronization subtask corresponding to the changed data information to obtain the strong dependency data associated with the changed data information.
[0096] In one embodiment, the data determination module 502 is also used to create a synchronization subtask corresponding to the changed data information, save the changed data information; insert the synchronization subtask into the task queue; obtain the expired synchronization subtasks in the task queue, merge at least one corresponding synchronization subtask according to the changed data information; and determine the strongly dependent data associated with the merged synchronization subtask according to the dependency relationship. In one embodiment, the data processing module 503 is also used to respond to the operation event corresponding to the changed data information being a deletion event, and the strongly dependent data being the strongly dependent data corresponding to the changed data information, delete the corresponding data in the retrieval table according to the strongly dependent data; respond to the operation event corresponding to the changed data information being a deletion event, and the strongly dependent data being the strongly dependent data associated with the changed data information, update the retrieval table according to the strongly dependent data; respond to the operation event corresponding to the changed data information being not a deletion event, update the retrieval table according to the strongly dependent data.
[0097] In one embodiment, the heterogeneous data synchronization device 5 also includes a data active synchronization module, which is used to obtain the strong dependencies and non-strong dependencies required for the retrieval table in response to unsupported data change notifications; compare the target data corresponding to the strong dependencies with the data in the retrieval table to determine the operation events corresponding to the retrieval table; and process the retrieval table according to the strong dependency data associated with the non-strong dependencies.
[0098] In the above embodiment, during the data synchronization process, even if the original data needs to be processed and modified, only a small amount of coding is required to support it according to the defined dependencies, which is conducive to the management and maintenance of the database, improves data retrieval performance, ensures data consistency and accuracy, reduces development costs, and greatly improves development efficiency.
[0099] Figure 6 A schematic diagram of a heterogeneous data synchronization system in an embodiment of the present disclosure is shown as follows: Figure 6 As shown, the heterogeneous data synchronization system 6 includes: a binlog log analyzer 601, a synchronization task execution engine 602, a database driver layer 603, a cache queue 604, and a data model file 605;
[0100] Binlog log analyzer 601: mainly responsible for data change analysis of relational databases, can be used to perceive database data changes, and notify the data synchronization engine of the change results to achieve quasi-real-time synchronization, optional; for example, when receiving a data change notification, obtain the changed data information.
[0101] Synchronous task execution engine 602: mainly responsible for the synchronization of heterogeneous data, and building execution logic based on the provided data model file;
[0102] Database driver layer 603: mainly used to connect to different databases and implement data read and write control;
[0103] Cache queue 604: mainly assists the synchronization of heterogeneous data and caches synchronization subtasks to be executed. For distributed application scenarios, it can be implemented using memory databases such as Redis, or it can be replaced by a relational database;
[0104] Data model file 605: defines several data tables and the relationships between tables; an example is as follows:
[0105]
[0106]
[0107] Among them, "database": the database identifier;
[0108] "version": identifies the version of the current data model;
[0109] "tables": the data table name of the current database;
[0110] "answer_data.bot_id": the field name of the data table. Other data information that the data depends on will be defined later. Type indicates the type of dependency, and source indicates the data source of the dependency. The database / data table / field information needs to be specified. If query is true, it indicates a strong association between data.
[0111] The data model definition here can be understood as follows: the database idx_answer contains several data tables, among which the answer_data table consists of several fields, among which:
[0112] bot_id comes from the bot_id of opensmartchat.base_answer;
[0113] answer_id comes from the id of opensmartchat.base_answer;
[0114] answer_type comes from the type of opensmartchat.base_answer;
[0115] CID comes from the CID of opensmartchat.ir_group;
[0116] And the construction of the idx_answer.answer_data table is strongly dependent on the two fields bot_id and id of the opensmartchat.base_answer table. The data of base_answer must be available before the complete data can be assembled.
[0117] In the above embodiment, synchronization of heterogeneous data is achieved based on the data model; it is only necessary to maintain the data model, and even if the original data needs to be processed and modified, only a small amount of coding is required to support it, which greatly improves development efficiency.
[0118] Figure 7 A flow chart of an incremental data synchronization method according to an embodiment of the present disclosure is shown as follows: Figure 7 As shown, the incremental data synchronization method provided in the embodiment of the present disclosure includes the following steps:
[0119] If incremental data change notification is supported, the following process can be executed:
[0120] S702, receiving data change notification.
[0121] S704, extracting the changed data table and data information.
[0122] S706, determine whether the data table is within the scope of the dependency table, where the dependency table refers to the information defined by the source in the data model file, that is, the data source required to build the current search library. If not, ignore it directly. If so, continue to S708.
[0123] S708, determine whether the data table is a strong dependency required by the retrieval table, if so, continue to S714, if not, continue to S710.
[0124] S710, create a delayed synchronization subtask, save the data table and data information, and insert it into the delayed task queue, and continue to S712; it should be noted that this is implemented in the form of a delayed task, which is to assume that a complete data of the retrieval table comes from multiple data tables, and the update logic of multiple data tables is different, so the received data change messages are in sequence. In order to avoid operating the same retrieval data at the same time in a concurrent situation, which will cause data confusion, all related items are queued as tasks and processed in sequence to ensure the final consistency of the data.
[0125] S712, the delayed task queue obtains a batch of expired tasks and first merges the tasks based on the data information; for example, a piece of data in a data table is updated multiple times in a short period of time; then, based on the dependencies defined in the data model, the strongly dependent table information associated with this data table is found; for example, the answer_id information is used in the ir_group table, and answer_id is the strong dependency required to build the retrieval table.
[0126] S714, extract strongly dependent fields; for example, answer_id and bot_id information.
[0127] S716, if the current operation event is a deletion action, if the trigger source is a strong dependency table, continue to S718; if the trigger source is a non-strong dependency table, continue to S720; if the update event is a non-deletion action, continue to S720.
[0128] S718, retrieve and delete the retrieval table data according to the strongly dependent data; for example, the original retrieval table includes data table A, data table B and data table C; update the retrieval table according to the processing action corresponding to the changed data information and the strongly dependent data to obtain data table A and data table B.
[0129] S720, retrieve and update the retrieval table data according to the strongly dependent data; for example, the original retrieval table includes data table A, data table B and data table C; delete data table A, data table B and data table C in the retrieval table according to the processing action corresponding to the changed data information and the strongly dependent data; it should be noted that the deletion is a logical deletion, which exists physically and can be set to be physically deleted later.
[0130] In the above embodiment, during the data synchronization process, based on the dependency relationship defined by the data model, even if the original data needs to be processed and modified, only a small amount of coding is required to support it, which is conducive to the management and maintenance of the database, improves data retrieval performance, and ensures data consistency and accuracy, reduces development costs, and greatly improves development efficiency.
[0131] Figure 8 A flow chart of a full data synchronization method in an embodiment of the present disclosure is shown as follows: Figure 8 As shown, the full data synchronization method provided in the embodiment of the present disclosure includes the following steps:
[0132] If incremental data change notification is not supported, the full data synchronization process is relied upon, which is implemented in a periodic incremental manner. The specific process is as follows:
[0133] S802, parsing the data model to find out the strong dependencies and non-strong dependencies required for the retrieval table.
[0134] S804, determine the time of the most recent synchronization. If it has not been synchronized, extract the full data of the strong dependencies respectively. If it has been synchronized, extract the incremental data whose update time is after the last synchronization time, and continue to S806.
[0135] S806, extract all the data in the search table and compare it with the result in S804. If there is any addition, perform an insert operation; if there is any deletion, perform a delete operation and continue to S808.
[0136] S808, extract data according to the non-strong dependencies required by the retrieval table, find the information of the associated strong dependencies according to the definition of the data model, comprehensively retrieve the data of each external table that the table depends on to obtain a complete data, and perform an update operation.
[0137] In the above embodiment, during the data synchronization process, based on the dependency relationship defined by the data model, the strong dependencies and non-strong dependencies required for the retrieval table are obtained, and the retrieval table is processed according to the strong dependency data determined by the strong dependencies and non-strong dependencies. This eliminates the need for a large amount of hard coding to achieve data synchronization, greatly improving development efficiency.
[0138] Those skilled in the art will appreciate that various aspects of the present disclosure may be implemented as systems, methods or program products. Therefore, various aspects of the present disclosure may be specifically implemented in the following forms, namely: complete hardware implementation, complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as "circuits", "modules" or "systems".
[0139] Refer to the following Fig. 9 The electronic device 900 according to this embodiment of the present disclosure is described. Fig. 9 The electronic device 900 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0140] like Fig. 9 As shown, the electronic device 900 is in the form of a general computing device. The components of the electronic device 900 may include but are not limited to: at least one processing unit 910, at least one storage unit 920, and a bus 930 connecting different system components (including the storage unit 920 and the processing unit 910).
[0141] The storage unit stores program codes, which can be executed by the processing unit 910, so that the processing unit 910 executes the steps described in the above “Exemplary Method” section of this specification according to various exemplary embodiments of the present disclosure.
[0142] For example, the processing unit 910 can execute the following steps of the above-mentioned method embodiment: when data change notification is supported, obtain the changed data information according to the received data change notification; when the changed data information is within the scope of the dependency table, determine whether the changed data information is a strong dependency item required by the retrieval table; if so, obtain the strong dependency data corresponding to the changed data information; otherwise, process the synchronization subtask corresponding to the changed data information to obtain the strong dependency data associated with the changed data information; and process the retrieval table according to the processing action and strong dependency data corresponding to the changed data information.
[0143] For example, the processing unit 910 can execute the following steps of the above method embodiment: when data change notification is not supported, obtain the strong dependencies and non-strong dependencies required for the retrieval table; compare the target data corresponding to the strong dependencies with the data in the retrieval table to determine the operation event corresponding to the retrieval table; process the retrieval table according to the strong dependency data associated with the non-strong dependencies.
[0144] The storage unit 920 may include a readable medium in the form of a volatile storage unit, such as a random access storage unit (RAM) 9201 and / or a cache storage unit 9202 , and may further include a read-only storage unit (ROM) 9203 .
[0145] The storage unit 920 may also include a program / utility 9204 having a set (at least one) of program modules 9205, such program modules 9205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0146] Bus 930 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0147] The electronic device 900 may also communicate with one or more external devices 940 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 900, and / or may communicate with any device that enables the electronic device 900 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 950. Furthermore, the electronic device 900 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 960. As shown, the network adapter 960 communicates with other modules of the electronic device 900 via a bus 930. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 900, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.
[0148] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0149] In an exemplary embodiment of the present disclosure, a computer-readable storage medium is also provided, which may be a readable signal medium or a readable storage medium. A program product capable of implementing the above-mentioned method of the present disclosure is stored thereon. In some possible implementations, various aspects of the present disclosure may also be implemented in the form of a computer program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps of various exemplary embodiments of the present disclosure described in the above-mentioned "Exemplary Method" section of this specification. In some possible implementations, the computer program product includes a computer program or computer instructions, which are loaded and executed by a processor to enable the computer to implement the steps of the method disclosed in the above-mentioned embodiment.
[0150] For example, the computer program product in the embodiment of the present disclosure implements the following method steps when executed by a processor: when data change notification is supported, obtaining change data information based on the received data change notification; when the change data information is within the range of the dependency table, determining whether the change data information is a strong dependency item required by the retrieval table; if so, obtaining the strong dependency data corresponding to the change data information; otherwise, processing the synchronization subtask corresponding to the change data information to obtain the strong dependency data associated with the change data information; and processing the retrieval table based on the processing action and strong dependency data corresponding to the change data information.
[0151] For example, the program product in the embodiment of the present disclosure implements the following method when executed by a processor: when data change notification is not supported, obtaining strong dependencies and non-strong dependencies required for the retrieval table; comparing the target data corresponding to the strong dependencies with the data in the retrieval table to determine the operation event corresponding to the retrieval table; processing the retrieval table according to the strong dependency data associated with the non-strong dependencies.
[0152] More specific examples of computer-readable storage media in the present disclosure may include, but are not limited to, an electrical connection having one or more conductors, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0153] In the present disclosure, a computer readable storage medium may include a data signal propagated in baseband or as part of a carrier wave, wherein a readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A readable signal medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0154] Alternatively, the program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.
[0155] In a specific implementation, the program code for performing the operations of the present disclosure may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., using an Internet service provider to connect through the Internet).
[0156] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.
[0157] In addition, although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0158] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0159] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the appended claims.
Claims
1. A heterogeneous data synchronization method, characterized in that: include: Obtain changed data information according to the received data change notification; Determine the strongly dependent data corresponding to the changed data information according to the retrieval table; The search table is processed according to the processing action corresponding to the changed data information and the strongly dependent data to obtain a processed search table to synchronize heterogeneous data.
2. The heterogeneous data synchronization method according to claim 1, characterized in that: The step of determining the strongly dependent data corresponding to the changed data information according to the retrieval table includes: In response to the changed data information being within the range of the dependency table and the changed data being a strong dependency item required by the retrieval table, acquiring the strong dependency data corresponding to the changed data information; In response to the changed data information being within the range of the dependency table and the changed data not being a strong dependency item required by the retrieval table, a synchronization subtask corresponding to the changed data information is processed to obtain the strong dependency data associated with the changed data information.
3. The heterogeneous data synchronization method according to claim 2, characterized in that: The step of processing the synchronization subtask corresponding to the changed data information to obtain the strongly dependent data associated with the changed data information includes: Creating a synchronization subtask corresponding to the changed data information, and saving the changed data information; Inserting the synchronization subtask into the task queue; Acquire the expired synchronization subtasks in the task queue, and merge at least one corresponding synchronization subtask according to the change data information; According to the dependency relationship, the strongly dependent data associated with the merged synchronization subtasks is determined.
4. The heterogeneous data synchronization method according to claim 1, characterized in that: According to the processing action corresponding to the changed data information and the strongly dependent data, processing the search table includes: In response to the operation event corresponding to the changed data information being a deletion event, and the strongly dependent data being the strongly dependent data corresponding to the changed data information, deleting the corresponding data in the search table according to the strongly dependent data; In response to the operation event corresponding to the changed data information being a deletion event, and the strongly dependent data being the strongly dependent data associated with the changed data information, the retrieval table is updated according to the strongly dependent data.
5. The heterogeneous data synchronization method according to claim 1, characterized in that: According to the processing action corresponding to the changed data information and the strongly dependent data, processing the search table includes: In response to the operation event corresponding to the changed data information being not a deletion event, the retrieval table is updated according to the strongly dependent data.
6. The heterogeneous data synchronization method according to any one of claims 1 to 5, characterized in that: Also includes: In response to not supporting the data change notification, obtaining strong dependencies and non-strong dependencies required for the retrieval table; Compare the target data corresponding to the strong dependency item with the data in the search table to determine the operation event corresponding to the search table; The lookup table is processed based on the strong dependency data associated with the non-strong dependency.
7. The heterogeneous data synchronization method according to claim 6, characterized in that: The target data includes: at least one of full data and incremental data; In response to the strong dependency not being synchronized, the target data is the full amount of data of the strong dependency; In response to the strong dependency having been synchronized, the target data is the incremental data of the synchronized strong dependency.
8. A heterogeneous data synchronization device, characterized in that: include: A data acquisition module is used to obtain changed data information according to the received data change notification; A data determination module, used to determine the strongly dependent data corresponding to the changed data information according to the search table; The data processing module is used to process the search table according to the processing action corresponding to the changed data information and the strongly dependent data to obtain a processed search table to synchronize heterogeneous data.
9. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to execute the heterogeneous data synchronization method according to any one of claims 1 to 7 by executing the executable instructions.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the heterogeneous data synchronization method described in any one of claims 1 to 7 is implemented.
11. A computer program product, characterized in that The computer program product includes a computer program or computer instructions, and the computer program or the computer instructions are loaded and executed by a processor to enable a computer to implement the heterogeneous data synchronization method as described in any one of claims 1-7.
Citation Information
Patent Citations
Data synchronization method and device, computer equipment and storage medium
CN110489483A
Retrieval service providing method and device, equipment and medium
CN113312539A
Database multi-table association query speed optimization method based on Elasticsearch
CN114385680A
Data synchronization method and device
CN115129788A
