Data comparison method and device
Through multi-threaded real-time monitoring and message queue technology, it solves the scalability and efficiency problems of existing database data comparison technology, realizes pipelined data comparison, improves the efficiency and versatility of data comparison, and reduces development costs.
Patent Information
- Application Number
- CN202110935850.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-16
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2041-08-16
AI Technical Summary
The data comparison technology of existing databases has poor scalability, lack of versatility, inflexible application scenarios, and low comparison efficiency, especially in the case of multiple tables and large amounts of data.
Multi-threaded real-time monitoring is used to conduct data comparison through message queues, database query statements are generated and queries are performed, distributed cache is used to store query results, and finally data comparison results are generated to achieve pipeline-style data comparison.
It improves the efficiency and versatility of data comparison, reduces development costs, and enables flexible adaptation of the solution.
Smart Images

Figure CN113656432B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of database technology, and in particular to a data comparison method and device. Background Art
[0002] The existing database data comparison technology solutions generally compare the data of two databases based on a specific scenario. The general implementation method is to query all the data of the two databases respectively, then compare the data table by table and item by item, and then record the comparison results. The existing technology has problems such as poor scalability, lack of universality, inflexible application scenarios, and low comparison efficiency, especially when it involves multiple tables and large data volumes. Summary of the invention
[0003] In view of the problems existing in the prior art, the main purpose of the embodiments of the present invention is to provide a data comparison method and device to realize pipeline data comparison and improve the efficiency and versatility of data comparison.
[0004] In order to achieve the above object, an embodiment of the present invention provides a data comparison method, the method comprising:
[0005] Using a multi-threaded real-time monitoring method, obtaining library table comparison information from the first message queue, parsing the library table comparison information, generating a first database query statement, and querying the first database using the first database query statement to obtain a first query result, and sending the library table comparison information to the second message queue;
[0006] Using a multi-threaded real-time monitoring method, the library table comparison information is obtained from the second message queue, the library table comparison information is parsed, a second database query statement is generated, and the second database is queried using the second database query statement, the second query result is compared with the first query result, a second query result is obtained, and the library table comparison information is sent to a third message queue;
[0007] The library table comparison information is obtained and analyzed from the third message queue by using a multi-threaded real-time monitoring method, and a data comparison result is generated according to the first query result and the second query result.
[0008] Optionally, in an embodiment of the present invention, the method further includes: acquiring preset library table comparison information, and sending the library table comparison information to the first message queue.
[0009] Optionally, in one embodiment of the present invention, the library table comparison information includes table name, query field, comparison type, sort field, incremental comparison control field, incremental comparison control field type, joint table query incremental comparison table name and joint table query incremental comparison joint table field.
[0010] Optionally, in an embodiment of the present invention, parsing the library-table comparison information to generate a first database query statement includes:
[0011] Parse the library table comparison information to obtain the table name, query field, comparison type, sort field, incremental comparison control field, incremental comparison control field type, joint table query incremental comparison table name, and joint table query incremental comparison joint table field;
[0012] The first database query statement is generated according to the data format of the first database by using the table name, query field, comparison type, sort field, incremental comparison control field, incremental comparison control field type, joint table query incremental comparison table name and joint table query incremental comparison joint table field.
[0013] Optionally, in an embodiment of the present invention, querying the second database using the second database query statement and comparing the first query result to obtain the second query result includes:
[0014] Query the second database using the second database query statement to obtain the query record HASH value;
[0015] The query record HASH value is compared with the HASH value in the first query result to generate a comparison result, and a second query result is generated according to the comparison result.
[0016] Optionally, in an embodiment of the present invention, obtaining and parsing the library table comparison information from the third message queue, and generating a data comparison result according to the first query result and the second query result includes:
[0017] Obtaining the library-table comparison information from the third message queue and parsing it, and obtaining the first query result and the second query result from the distributed cache according to the obtained parsing result;
[0018] The data comparison result is generated according to the first query result and the second query result.
[0019] An embodiment of the present invention further provides a data comparison device, the device comprising:
[0020] A first query result module is used to obtain the library-table comparison information from the first message queue by using a multi-threaded real-time monitoring method, parse the library-table comparison information, generate a first database query statement, query the first database by using the first database query statement, obtain a first query result, and send the library-table comparison information to the second message queue;
[0021] A second query result module is used to obtain the library table comparison information from the second message queue by using a multi-threaded real-time monitoring method, parse the library table comparison information, generate a second database query statement, query the second database by using the second database query statement, compare the first query result, obtain a second query result, and send the library table comparison information to a third message queue;
[0022] The data comparison result module is used to obtain and parse the library table comparison information from the third message queue using a multi-threaded real-time monitoring method, and generate a data comparison result based on the first query result and the second query result.
[0023] Optionally, in an embodiment of the present invention, the device further includes: an information acquisition module, configured to acquire preset library table comparison information, and send the library table comparison information to the first message queue.
[0024] Optionally, in one embodiment of the present invention, the library table comparison information includes table name, query field, comparison type, sort field, incremental comparison control field, incremental comparison control field type, joint table query incremental comparison table name and joint table query incremental comparison joint table field.
[0025] Optionally, in an embodiment of the present invention, the first query result module includes:
[0026] An information parsing unit, used to parse the library table comparison information to obtain the table name, query field, comparison type, sort field, incremental comparison control field, incremental comparison control field type, joint table query incremental comparison table name and joint table query incremental comparison joint table field;
[0027] A query statement unit is used to generate a query statement for the first database according to the data format of the first database by using the table name, query field, comparison type, sort field, incremental comparison control field, incremental comparison control field type, joint table query incremental comparison table name and joint table query incremental comparison joint table field.
[0028] Optionally, in an embodiment of the present invention, the second query result module includes:
[0029] A HASH value unit, used to query the second database using the second database query statement to obtain a query record HASH value;
[0030] The query result unit is used to compare the HASH value of the query record with the HASH value in the first query result to generate a comparison result, and generate a second query result according to the comparison result.
[0031] Optionally, in an embodiment of the present invention, the data comparison result module includes:
[0032] A result acquisition unit, configured to acquire and parse the library-table comparison information from the third message queue, and acquire the first query result and the second query result from the distributed cache according to the parsing result;
[0033] A comparison result unit is used to generate the data comparison result according to the first query result and the second query result.
[0034] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above method when executing the program.
[0035] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program for executing the above method.
[0036] The present invention overcomes the deficiencies of the prior art through a message queue, realizes pipeline data comparison, improves the efficiency of data comparison, configures library table comparison information, realizes universal adaptation of the solution, and reduces development costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0038] Figure 1 A flow chart of a data comparison method according to an embodiment of the present invention;
[0039] Figure 2 A flowchart of generating a first database query statement in an embodiment of the present invention;
[0040] Figure 3 A flowchart of obtaining a second query result in an embodiment of the present invention;
[0041] Figure 4 A flow chart of generating data comparison results in an embodiment of the present invention;
[0042] Figure 5 A flowchart of data comparison in a specific embodiment of the present invention;
[0043] Figure 6 This is a schematic diagram of the structure of a data comparison device according to an embodiment of the present invention;
[0044] Figure 7It is a structural schematic diagram of a data comparison device in a specific embodiment of the present invention;
[0045] Figure 8 is a schematic diagram of the structure of the first query result module in an embodiment of the present invention;
[0046] Fig. 9 is a schematic diagram of the structure of the second query result module in an embodiment of the present invention;
[0047] Fig.10 This is a schematic diagram of the structure of a data comparison result module in an embodiment of the present invention;
[0048] Fig.11 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0049] The embodiments of the present invention provide a data comparison method and device, which can be used in the financial field and other fields. It should be noted that the data comparison method and device of the present invention can be used in the financial field, and can also be used in any field other than the financial field. The application field of the data comparison method and device of the present invention is not limited.
[0050] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0051] like Figure 1 The flowchart of a data comparison method according to an embodiment of the present invention is shown. The execution subject of the data comparison method provided by the embodiment of the present invention includes but is not limited to a computer. The method shown in the figure includes:
[0052] Step S1, using a multi-threaded real-time monitoring method, obtains library table comparison information from the first message queue, parses the library table comparison information, generates a first database query statement, and uses the first database query statement to query the first database to obtain a first query result, and sends the library table comparison information to the second message queue.
[0053] The message queue is a container for storing messages during the transmission of the messages. The message queue of the present invention is used to store the library table comparison information. During the entire data comparison process, the library table comparison information is consumed and forwarded from one message queue to another message queue until the comparison result is obtained.
[0054] Furthermore, the library table comparison information is preset, including table name, query field, comparison type, sort field, incremental comparison control field, incremental comparison control field type, joint table query incremental comparison table name and joint table query incremental comparison joint table field, etc. The library table comparison information represents which tables are compared in the database, which fields are compared in each table, and the comparison mode (incremental or full), etc., which can be pre-configured by means of database records, and the configuration is stored in the first message queue.
[0055] Furthermore, the multi-threads monitor the first message queue in real time, and when there is a message in the first message queue, the multi-threads consume it. The database table comparison information of the first message queue is obtained, parsed, and an SQL query statement is assembled according to the format of the first database, that is, the first query statement, which generally adopts a paging loop query method.
[0056] Further, the obtained first query result is saved in the first distributed cache, and the saved data format is HASH. In this way, all the compared database tables store a HASH type data result set, that is, the first query result. After each query completes a database table, its database table comparison information is saved in the second message queue.
[0057] Step S2, using a multi-threaded real-time monitoring method, obtains the library table comparison information from the second message queue, parses the library table comparison information, generates a second database query statement, and uses the second database query statement to query the second database, compares the first query result, obtains the second query result, and sends the library table comparison information to the third message queue.
[0058] Among them, the multi-threads monitor the second message queue in real time, and when there is a message in the second message queue, the multi-threads consume it. The database table comparison information of the second message queue is obtained, parsed, and an SQL query statement is assembled according to the format of the second database, that is, the second query statement, which generally adopts a paging loop query method (same as the first query statement).
[0059] Further, the HASH value of the query record is calculated, and the data with the same HASH of the same library table of the first database is removed from the first distributed cache, indicating that the data of the table is the same. If there is no identical HASH record of the same library table of the first database in the first distributed cache, the data is stored in the second distributed cache according to the same rule as the first query result. Each time a database table is compared, its library table comparison information is saved in the third message queue.
[0060] Step S3, using a multi-threaded real-time monitoring method, obtaining and parsing the library table comparison information from the third message queue, and generating a data comparison result based on the first query result and the second query result.
[0061] Among them, the multi-threads monitor the third message queue in real time, and when there is a message in the third message queue, the multi-threads consume it. The library table comparison information in the third message queue is obtained, parsed, and then the data in the first and second distributed caches, that is, the first query result and the second query result, are obtained respectively. It is saved in the library table comparison result table in the database, thereby obtaining the data comparison result.
[0062] As an embodiment of the present invention, the method further includes: acquiring preset library table comparison information, and sending the library table comparison information to the first message queue.
[0063] The library table comparison information represents which tables are compared in the database, which fields are compared in each table, the comparison mode (incremental or full), etc., which can be pre-configured through database records and the configuration is stored in the first message queue.
[0064] As an embodiment of the present invention, the library table comparison information includes table name, query field, comparison type, sort field, incremental comparison control field, incremental comparison control field type, joint table query incremental comparison table name and joint table query incremental comparison joint table field.
[0065] The specific information of the library-table comparison is shown in Table 1. The library-table comparison information represents which tables are compared in the database, which fields are compared in each table, and the comparison mode (incremental or full). All of these can be configured through database records. In this way, the configuration can be modified according to the actual situation to make the data comparison more flexible and controllable.
[0066] Table 1
[0067]
[0068]
[0069] In this embodiment, if Figure 2 As shown, parsing the library table comparison information and generating a first database query statement includes:
[0070] Step S21, parsing the library table comparison information to obtain the table name, query field, comparison type, sort field, incremental comparison control field, incremental comparison control field type, joint table query incremental comparison table name and joint table query incremental comparison joint table field;
[0071] Step S22, using the table name, query field, comparison type, sort field, incremental comparison control field, incremental comparison control field type, joint table query incremental comparison table name and joint table query incremental comparison joint table field, generate the first database query statement according to the data format of the first database.
[0072] The database table comparison information of the first message queue is obtained and parsed to obtain the table name, query field, comparison type, sort field, incremental comparison control field, incremental comparison control field type, joint table query incremental comparison table name and joint table query incremental comparison joint table field. Then, an SQL query statement is assembled according to the format of the first database, i.e., the first query statement, which generally adopts a paging loop query method.
[0073] As an embodiment of the present invention, Figure 3 As shown, the second database is queried using the second database query statement, and the second query result is obtained by comparing the first query result, including:
[0074] Step S31, querying the second database using the second database query statement to obtain a query record HASH value;
[0075] Step S32: compare the HASH value of the query record with the HASH value in the first query result to generate a comparison result, and generate a second query result according to the comparison result.
[0076] The second database is queried using the second database query statement, the HASH value of the query record is calculated, and the data with the same HASH in the same library table of the first database is removed from the first distributed cache, indicating that the data in the table is the same. If the same library table of the first database in the first distributed cache does not have the same HASH record, the data is stored in the second distributed cache according to the same rules as the first query result.
[0077] As an embodiment of the present invention, Figure 4 As shown, obtaining the library table comparison information from the third message queue and parsing it, and generating a data comparison result according to the first query result and the second query result includes:
[0078] Step S41, obtaining the library-table comparison information from the third message queue and parsing it, and obtaining the first query result and the second query result from the distributed cache according to the obtained parsing result;
[0079] Step S42: generating the data comparison result according to the first query result and the second query result.
[0080] The library table comparison information in the third message queue is obtained, parsed, and then the data in the first and second distributed caches, namely the first query result and the second query result, are obtained respectively, and saved to the library table comparison result table in the database, thereby obtaining the data comparison result.
[0081] In a specific embodiment of the present invention, Figure 5 As shown, the present invention utilizes message queues to implement pipeline processing of data comparison.
[0082] Among them, the assembly line, also known as the assembly line, is an industrial production method, which means that each production unit only focuses on processing a certain segment of work to improve work efficiency and output. The assembly line of the present invention is that each program unit only focuses on processing a certain data comparison function point, and finally obtains the data comparison result through multiple assembly line program processing. In addition, the data comparison of the present invention refers to comparing the data differences of two different databases when the database table structure is exactly the same.
[0083] Further, pipeline 1: database A (first database) source data enters cache
[0084] Multi-threaded real-time monitoring of message queue A (first message queue), when there is a message in message queue A, multi-threaded consumption. Obtain the database table comparison information of message queue A, parse it, and assemble SQL query statements (first query statements) according to the format of database A, generally using paging loop query method. For example, MySQL database is assembled as:
[0085] Full comparison:
[0086] SELECT${select_columns}FROM${table_name}limit${startNo},${querySize}
[0087] Incremental comparison:
[0088] SELECT${select_columns}FROM${table_name}where${raise_columns}>${raise_colums_value}limit${startNo},${querySize}
[0089] Incremental comparison of joint table query:
[0090] select${select_columns}from${table_name}a left join${join_table}b on${join_columns}where b.${raise_columns}>${raise_colums_value}limit${startNo},${querySize}
[0091] The query result (first query result) is saved in distributed cache A (first distributed cache). The saved data format is HASH, the KEY is the database type + table name, and the VALUE is MAP<KEY,VALUE> The KEY in MAP is the HASH value of the record, and the VALUE is the record identification field value. In this way, all the compared database tables store a HASH type data result set.
[0092] After each query of a database table is completed, the database table comparison information is saved in another message queue B (second message queue).
[0093] Further, pipeline 2: database B (second database) target data comparison
[0094] Multi-threads monitor message queue B in real time. When there is a message in message queue B, multi-threads consume it. Obtain the database table comparison information of message queue B, parse it, and assemble SQL query statements (second query statements) according to the format of database B. Generally, paging loop query is adopted (same as pipeline 1).
[0095] Calculate the HASH value of the query record, and remove the data with the same HASH in the same table of database A from distributed cache A, indicating that the data in the table is the same. If there is no identical HASH record in the same table of database A in distributed cache A, store the data in distributed cache B (the second distributed cache) according to the rules of pipeline 1 as the second query result.
[0096] After each comparison of a database table is completed, the database table comparison information is saved in another message queue C (the third message queue).
[0097] Further, pipeline three: database AB comparison results are stored in the database
[0098] Multithreading monitors message queue C in real time. When there is a message in message queue C, multithreading consumes it. Obtain the library table comparison information in message queue C, parse it, and then obtain the data in distributed cache A and B respectively, and save it to the library table comparison result table in the database, thereby obtaining the data comparison result.
[0099] The present invention overcomes the deficiencies of the prior art through a message queue, realizes pipeline data comparison, improves the efficiency of data comparison, configures library table comparison information, realizes universal adaptation of the solution, and reduces development costs.
[0100] like Figure 6 FIG. 1 is a schematic diagram of a data comparison device according to an embodiment of the present invention. The device shown in the figure includes:
[0101] The first query result module 10 is used to obtain library table comparison information from the first message queue using a multi-threaded real-time monitoring method, parse the library table comparison information, generate a first database query statement, and use the first database query statement to query the first database to obtain a first query result, and send the library table comparison information to the second message queue.
[0102] The message queue is a container for storing messages during the transmission of the messages. The message queue of the present invention is used to store the library table comparison information. During the entire data comparison process, the library table comparison information is consumed and forwarded from one message queue to another message queue until the comparison result is obtained.
[0103] Furthermore, the library table comparison information is preset, including table name, query field, comparison type, sort field, incremental comparison control field, incremental comparison control field type, joint table query incremental comparison table name and joint table query incremental comparison joint table field, etc. The library table comparison information represents which tables are compared in the database, which fields are compared in each table, and the comparison mode (incremental or full), etc., which can be pre-configured by means of database records, and the configuration is stored in the first message queue.
[0104] Furthermore, the multi-threads monitor the first message queue in real time, and when there is a message in the first message queue, the multi-threads consume it. The database table comparison information of the first message queue is obtained, parsed, and an SQL query statement is assembled according to the format of the first database, that is, the first query statement, which generally adopts a paging loop query method.
[0105] Further, the obtained first query result is saved in the first distributed cache, and the saved data format is HASH. In this way, all the compared database tables store a HASH type data result set, that is, the first query result. After each query completes a database table, its database table comparison information is saved in the second message queue.
[0106] The second query result module 20 is used to obtain the library table comparison information from the second message queue using a multi-threaded real-time monitoring method, parse the library table comparison information, generate a second database query statement, and use the second database query statement to query the second database, compare the first query result, obtain the second query result, and send the library table comparison information to the third message queue.
[0107] Among them, the multi-threads monitor the second message queue in real time, and when there is a message in the second message queue, the multi-threads consume it. The database table comparison information of the second message queue is obtained, parsed, and an SQL query statement is assembled according to the format of the second database, that is, the second query statement, which generally adopts a paging loop query method (same as the first query statement).
[0108] Further, the HASH value of the query record is calculated, and the data with the same HASH of the same library table of the first database is removed from the first distributed cache, indicating that the data of the table is the same. If there is no identical HASH record of the same library table of the first database in the first distributed cache, the data is stored in the second distributed cache according to the same rule as the first query result. Each time a database table is compared, its library table comparison information is saved in the third message queue.
[0109] The data comparison result module 30 is used to obtain and parse the library table comparison information from the third message queue using a multi-threaded real-time monitoring method, and generate a data comparison result according to the first query result and the second query result.
[0110] Among them, the multi-threads monitor the third message queue in real time, and when there is a message in the third message queue, the multi-threads consume it. The library table comparison information in the third message queue is obtained, parsed, and then the data in the first and second distributed caches, that is, the first query result and the second query result, are obtained respectively. It is saved in the library table comparison result table in the database, thereby obtaining the data comparison result.
[0111] As an embodiment of the present invention, Figure 7 As shown, the device further includes: an information acquisition module 40, which is used to acquire preset library table comparison information and send the library table comparison information to the first message queue.
[0112] As an embodiment of the present invention, the library table comparison information includes table name, query field, comparison type, sort field, incremental comparison control field, incremental comparison control field type, joint table query incremental comparison table name and joint table query incremental comparison joint table field.
[0113] In this embodiment, if Figure 8As shown, the first query result module 10 includes:
[0114] An information parsing unit 11 is used to parse the library-table comparison information to obtain a table name, a query field, a comparison type, a sorting field, an incremental comparison control field, an incremental comparison control field type, a joint table query incremental comparison table name, and a joint table query incremental comparison joint table field;
[0115] The query statement unit 12 is used to generate the first database query statement according to the data format of the first database by using the table name, query field, comparison type, sort field, incremental comparison control field, incremental comparison control field type, joint table query incremental comparison table name and joint table query incremental comparison joint table field.
[0116] As an embodiment of the present invention, Fig. 9 As shown, the second query result module 20 includes:
[0117] A HASH value unit 21 is used to query the second database using the second database query statement to obtain a query record HASH value;
[0118] The query result unit 22 is used to compare the HASH value of the query record with the HASH value in the first query result to generate a comparison result, and generate a second query result according to the comparison result.
[0119] As an embodiment of the present invention, Fig.10 As shown, the data comparison result module 30 includes:
[0120] A result acquisition unit 31 is used to acquire and parse the library-table comparison information from the third message queue, and acquire the first query result and the second query result from the distributed cache according to the parsing result;
[0121] The comparison result unit 32 is used to generate the data comparison result according to the first query result and the second query result.
[0122] Based on the same application concept as the above-mentioned data comparison method, the present invention also provides the above-mentioned data comparison device. Since the principle of solving the problem by the data comparison device is similar to that of the data comparison method, the implementation of the data comparison device can refer to the implementation of the data comparison method, and the repeated parts will not be repeated.
[0123] The present invention overcomes the deficiencies of the prior art through a message queue, realizes pipeline data comparison, improves the efficiency of data comparison, configures library table comparison information, realizes universal adaptation of the solution, and reduces development costs.
[0124] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above method when executing the program.
[0125] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program for executing the above method.
[0126] like Fig.11 As shown, the electronic device 600 may further include: a communication module 110, an input unit 120, an audio processing unit 130, a display 160, and a power supply 170. It is worth noting that the electronic device 600 does not necessarily have to include Fig.11 In addition, the electronic device 600 may also include Fig.11 For components not shown, reference may be made to the prior art.
[0127] like Fig.11 As shown, the central processor 100 is sometimes also referred to as a controller or an operation control, and may include a microprocessor or other processor devices and / or logic devices. The central processor 100 receives inputs and controls the operations of various components of the electronic device 600.
[0128] The memory 140 may be, for example, one or more of a cache, a flash memory, a hard drive, a removable medium, a volatile memory, a non-volatile memory or other suitable devices. The above-mentioned information related to the failure may be stored, and a program for executing the relevant information may also be stored. The CPU 100 may execute the program stored in the memory 140 to implement information storage or processing.
[0129] The input unit 120 provides input to the CPU 100. The input unit 120 is, for example, a key or a touch input device. The power supply 170 is used to provide power to the electronic device 600. The display 160 is used to display display objects such as images and text. The display may be, for example, an LCD display, but is not limited thereto.
[0130] The memory 140 may be a solid-state memory, such as a read-only memory (ROM), a random access memory (RAM), a SIM card, etc. It may also be a memory that saves information even when the power is off, can be selectively erased, and is provided with more data, examples of which are sometimes referred to as EPROMs, etc. The memory 140 may also be some other type of device. The memory 140 includes a buffer memory 141 (sometimes referred to as a buffer). The memory 140 may include an application / function storage unit 142, which is used to store application programs and function programs or processes for executing the operation of the electronic device 600 through the central processor 100.
[0131] The memory 140 may also include a data storage unit 143 for storing data, such as contacts, digital data, pictures, sounds, and / or any other data used by the electronic device. The driver storage unit 144 of the memory 140 may include various drivers for communication functions of the electronic device and / or for executing other functions of the electronic device (such as messaging applications, address book applications, etc.).
[0132] The communication module 110 is a transmitter / receiver 110 that transmits and receives signals via an antenna 111. The communication module (transmitter / receiver) 110 is coupled to the central processor 100 to provide input signals and receive output signals, which may be the same as the case of a conventional mobile communication terminal.
[0133] Based on different communication technologies, multiple communication modules 110 may be provided in the same electronic device, such as a cellular network module, a Bluetooth module and / or a wireless LAN module. The communication module (transmitter / receiver) 110 is also coupled to a speaker 131 and a microphone 132 via an audio processor 130 to provide an audio output via the speaker 131 and receive an audio input from the microphone 132, thereby realizing a common telecommunication function. The audio processor 130 may include any suitable buffer, decoder, amplifier, etc. In addition, the audio processor 130 is also coupled to the central processor 100, so that the sound can be recorded on the local machine through the microphone 132, and the sound stored on the local machine can be played through the speaker 131.
[0134] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0135] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0136] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0137] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0138] The present invention uses specific embodiments to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A data comparison method, It is characterized in that The method comprises: Using a multi-threaded real-time monitoring method, obtaining library table comparison information from the first message queue, parsing the library table comparison information, generating a first database query statement, and querying the first database using the first database query statement to obtain a first query result, and sending the library table comparison information to the second message queue; Using a multi-threaded real-time monitoring method, the library table comparison information is obtained from the second message queue, the library table comparison information is parsed, a second database query statement is generated, and the second database is queried using the second database query statement, the second query result is compared with the first query result, a second query result is obtained, and the library table comparison information is sent to a third message queue; Using a multi-threaded real-time monitoring method, the library table comparison information is obtained from the third message queue and analyzed, and a data comparison result is generated according to the first query result and the second query result; The querying the second database using the second database query statement and comparing the query result with the first query result to obtain the second query result includes: Query the second database using the second database query statement to obtain the query record HASH value; The query record HASH value is compared with the HASH value in the first query result to generate a comparison result, and a second query result is generated according to the comparison result.
2. The method according to claim 1, It is characterized in that The method further includes: acquiring preset library table comparison information, and sending the library table comparison information to the first message queue.
3. The method according to claim 1, It is characterized in that The library table comparison information includes table name, query field, comparison type, sort field, incremental comparison control field, incremental comparison control field type, joint table query incremental comparison table name and joint table query incremental comparison joint table field.
4. The method according to claim 3, It is characterized in that The parsing of the library table comparison information to generate a first database query statement includes: Parse the library table comparison information to obtain the table name, query field, comparison type, sort field, incremental comparison control field, incremental comparison control field type, joint table query incremental comparison table name, and joint table query incremental comparison joint table field; The first database query statement is generated according to the data format of the first database by using the table name, query field, comparison type, sort field, incremental comparison control field, incremental comparison control field type, joint table query incremental comparison table name and joint table query incremental comparison joint table field.
5. The method according to claim 1, It is characterized in that The acquiring and parsing the library table comparison information from the third message queue, and generating a data comparison result according to the first query result and the second query result includes: Obtaining the library-table comparison information from the third message queue and parsing it, and obtaining the first query result and the second query result from the distributed cache according to the obtained parsing result; The data comparison result is generated according to the first query result and the second query result.
6. A data comparison device, It is characterized in that The device comprises: A first query result module is used to obtain the library-table comparison information from the first message queue by using a multi-threaded real-time monitoring method, parse the library-table comparison information, generate a first database query statement, query the first database by using the first database query statement, obtain a first query result, and send the library-table comparison information to the second message queue; A second query result module is used to obtain the library table comparison information from the second message queue by using a multi-threaded real-time monitoring method, parse the library table comparison information, generate a second database query statement, query the second database by using the second database query statement, compare the first query result, obtain a second query result, and send the library table comparison information to a third message queue; A data comparison result module, used to obtain and parse the library table comparison information from the third message queue using a multi-threaded real-time monitoring method, and generate a data comparison result according to the first query result and the second query result; The second query result module includes: A HASH value unit, used to query the second database using the second database query statement to obtain a query record HASH value; The query result unit is used to compare the HASH value of the query record with the HASH value in the first query result to generate a comparison result, and generate a second query result according to the comparison result.
7. The device according to claim 6, It is characterized in that The device further includes: an information acquisition module, configured to acquire preset library table comparison information, and send the library table comparison information to the first message queue.
8. The device according to claim 6, It is characterized in that The library table comparison information includes table name, query field, comparison type, sort field, incremental comparison control field, incremental comparison control field type, joint table query incremental comparison table name and joint table query incremental comparison joint table field.
9. The device according to claim 8, It is characterized in that The first query result module includes: An information parsing unit, used to parse the library table comparison information to obtain the table name, query field, comparison type, sort field, incremental comparison control field, incremental comparison control field type, joint table query incremental comparison table name and joint table query incremental comparison joint table field; A query statement unit is used to generate a query statement for the first database according to the data format of the first database by using the table name, query field, comparison type, sort field, incremental comparison control field, incremental comparison control field type, joint table query incremental comparison table name and joint table query incremental comparison joint table field.
10. The device according to claim 6, It is characterized in that The data comparison result module includes: A result acquisition unit, configured to acquire and parse the library-table comparison information from the third message queue, and acquire the first query result and the second query result from the distributed cache according to the parsing result; A comparison result unit is used to generate the data comparison result according to the first query result and the second query result.
11. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the computer program, the method according to any one of claims 1 to 5 is implemented.
12. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program for executing the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
ETL loading table structure comparison method and system
CN110704475A
Database data comparison method and comparison system
CN111143406A
