Data comparison system, data comparison method and apparatus

By dividing data based on regional identification information and using multi-threaded parallel processing during the database migration process, the timeliness and flexibility issues of data consistency verification after database migration are solved, achieving efficient, comprehensive, and resource-efficient data comparison.

CN123178478APending Publication Date: 2026-11-27AGRICULTURAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611528072.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-29
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

Existing technologies suffer from poor timeliness and insufficient flexibility in data consistency verification after database migration, making it difficult to meet the needs of high concurrency and massive data processing. Furthermore, they can easily lead to the omission of critical data or waste of resources in heterogeneous database environments.

Method used

By dividing data into partitions according to regional identification information, and combining data distribution density and system resource parameters, the data collection interval and the number of threads are dynamically adjusted. A multi-threaded parallel processing method is adopted to extract sampled data from the source database and the target database for comparison and generate comparison results.

Benefits of technology

It achieves improved comparison efficiency, maximizes system resource utilization, avoids data omissions, and meets the needs of high concurrency and large-scale data processing while ensuring the comprehensiveness of data comparison.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123178478A_ABST
    Figure CN123178478A_ABST
Patent Text Reader

Abstract

The application discloses a data comparison system, a data comparison method and device. The method comprises the following steps: dividing service data into each region corresponding partition according to the region identifier information of each region, wherein the service data comprises data in a source database and data in a target database; determining the data collection interval of each region according to the data total amount and data distribution density of each region in the source database; determining the thread number corresponding to the data comparison task of each region according to the service data total amount and system resource parameters of each region; extracting the corresponding sampling data from the source database and the target database based on the data collection interval and the thread number of each region; and comparing the data according to the region to obtain a comparison result. The application solves the technical problems of low efficiency, poor flexibility and insufficient sampling coverage in a large scene in the related art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, and more specifically, to a data comparison system, a data comparison method, and an apparatus. Background Technology

[0002] With the continuous expansion of commercial banking operations and the rapid evolution of information technology architecture, traditional databases are struggling to meet the ever-increasing demands for high concurrency, high availability, and massive data processing. Against this backdrop, new databases, due to their superior scalability, high performance, and flexibility, have become a crucial choice for migrating core banking systems. Data migration is a critical step in upgrading banking systems, and ensuring the accuracy, integrity, and consistency of data between the source and target ends after migration directly impacts the stability of banking operations, the security of customer assets, and the effectiveness of subsequent strategic decisions. Therefore, building an efficient and reliable data comparison mechanism to verify migration quality has become an indispensable core task in the digital transformation of banks.

[0003] Currently, for data consistency verification after database migration, the industry mainly adopts either a full comparison with downtime or a full table comparison based on specific tools (such as DRS). However, these traditional solutions have significant limitations: on the one hand, while a full comparison with downtime maintenance can ensure data consistency, it leads to prolonged unavailability of business systems, severely sacrificing system high availability and making it difficult to meet the 24 / 7 uninterrupted operation requirements of modern banking; on the other hand, existing non-downtime comparison tools or conventional comparison methods typically only support full table data comparison after the migration task is completed, lacking flexibility. When dealing with massive amounts of data, full table scans are not only extremely time-consuming but also cannot dynamically adjust the comparison range according to business priorities, resulting in poor timeliness of the comparison work and failing to meet the needs of agile operations and maintenance for rapid feedback.

[0004] Given the shortcomings of existing technologies in terms of timeliness, flexibility and resource utilization, especially in heterogeneous database environments, the sampling randomness caused by differences in data sorting and uneven distribution may lead to the omission of key data or waste of resources.

[0005] There is currently no effective solution to the above problems. Summary of the Invention

[0006] This invention provides a data comparison system, data comparison method, and apparatus to at least solve the technical problems of low efficiency, poor flexibility, and insufficient sampling coverage in large-scale scenarios in related technologies.

[0007] According to one aspect of the present invention, a data comparison method is provided, comprising: dividing business data into partitions corresponding to each region according to region identification information, wherein the business data includes data in a source database and data in a target database, and the target database refers to a container in which the source database carries data copies after a migration task is completed; determining a data collection interval corresponding to each region based on the total amount of data in each region and the data distribution density of each region in the source database; determining the number of threads corresponding to the data comparison task in each region based on the total amount of business data in each region and system resource parameters; extracting corresponding sampling data from the source database and the target database based on the data collection interval and the number of threads corresponding to each region; and comparing the corresponding sampling data in the source database and the target database by region to obtain a comparison result.

[0008] Optionally, the business data is divided into partitions corresponding to each region according to the region identifier information, including: parsing the business data and extracting a character or number sequence of a preset bit range as the region identifier information; mapping the region identifier information to the corresponding database partition identifier according to a preset partition mapping rule; and dividing business data with the same region identifier information into the partition of the corresponding database partition identifier.

[0009] Optionally, determining the data collection interval corresponding to each region based on the total data volume and data distribution density of each region in the source database includes: counting the total number of business records for each region in the source database and calculating the data distribution density of each region, wherein the data distribution density is determined based on the frequency or interval span of the region identification information in continuous business records; calculating an initial sampling step size based on a preset target sampling quantity and the data distribution density; and adjusting the initial sampling step size based on the total data volume of each region to obtain the data collection interval corresponding to each region.

[0010] Optionally, the number of threads corresponding to the data comparison task in each region is determined based on the total amount of business data and system resource parameters corresponding to each region. This includes: obtaining the system resource parameters corresponding to each region; calculating the proportion of the total amount of business data in each region to the total amount of business data in all regions, and defining the proportion as the task weight of the corresponding region; and calculating and allocating the number of threads corresponding to the data comparison task in each region based on the task weight and the system resource parameters, wherein the number of threads allocated to each region is positively correlated with the corresponding task weight.

[0011] Optionally, based on the data collection interval and the number of threads corresponding to each region, extracting corresponding sampling data from the source database and the target database includes: configuring a target thread pool matching the number of threads for each region, and distributing the data comparison tasks for each region to worker threads in the target thread pool; reading business data records according to the data collection interval of the region corresponding to each worker thread to obtain the target sampling data for the corresponding region, wherein the target sampling data includes first sampling data extracted from the source database and second sampling data extracted from the target database.

[0012] Optionally, the sampled data corresponding to the source database and the target database are compared by region to obtain a comparison result, including: matching and aligning the first sampled data and the second sampled data of the target region; comparing the matched and aligned first sampled data and the second sampled data item by item according to a preset comparison rule to obtain a comparison result; if the comparison result shows consistency, it is determined that the business data corresponding to the target region is complete; if the comparison result shows inconsistency, the inconsistent business data is recorded as difference data.

[0013] Optionally, after comparing the sampled data corresponding to the source database and the target database according to the region to obtain the comparison result, the data comparison method further includes: writing the comparison result into a log, and generating a comparison report based on the log.

[0014] Optionally, the data comparison method further includes: real-time monitoring of the execution progress of the data comparison task in each region and the system resource load status; when a mismatch is detected between the data distribution density and the data acquisition interval, or when the system resource load exceeds a preset threshold, adjusting the data acquisition interval and / or the number of threads in the corresponding region; and re-extracting the business data of the corresponding region based on the adjusted data acquisition interval and / or the number of threads.

[0015] According to one aspect of the present invention, a data comparison apparatus is provided, comprising: a partitioning unit, configured to partition business data into partitions corresponding to each region according to region identification information corresponding to each region, wherein the business data includes data in a source database and data in a target database, and the target database refers to a container in which the source database carries data copies after a migration task is completed; a first determining unit, configured to determine a data collection interval corresponding to each region based on the total amount of data in each region in the source database and the data distribution density of each region; a second determining unit, configured to determine the number of threads corresponding to the data comparison task in each region based on the total amount of business data corresponding to each region and system resource parameters; a first extraction unit, configured to extract corresponding sampling data from the source database and the target database based on the data collection interval and the number of threads corresponding to each region; and a comparison unit, configured to compare the corresponding sampling data in the source database and the target database according to region to obtain a comparison result.

[0016] Optionally, the partitioning unit includes: a parsing module, used to parse the business data and extract a character or number sequence of a preset segment as the region identification information; a mapping module, used to map the region identification information to the corresponding database partition identifier according to a preset partition mapping rule; and a partitioning module, used to partition business data with the same region identification information into the partition of the corresponding database partition identifier.

[0017] Optionally, the first determining unit includes: a statistics module, used to count the total number of business records of each region in the source database and calculate the data distribution density of each region, wherein the data distribution density is determined based on the frequency or interval span of the region identification information in continuous business records; a first calculation module, used to calculate an initial sampling step size according to a preset target sampling quantity and the data distribution density; and an adjustment module, used to adjust the initial sampling step size according to the total amount of data of each region to obtain the data collection interval corresponding to each region.

[0018] Optionally, the second determining unit includes: an acquisition module, configured to acquire the system resource parameters corresponding to each region; a second calculation module, configured to calculate the proportion of the total amount of business data corresponding to each region to the total amount of business data in all regions, and define the corresponding proportion as the task weight of the corresponding region; and a third calculation module, configured to calculate and allocate the number of threads corresponding to the data comparison task of each region based on the task weight and the system resource parameters, wherein the number of threads allocated to each region is positively correlated with the corresponding task weight.

[0019] Optionally, the first extraction unit includes: a configuration module, configured to configure a target thread pool matching the number of threads for each region, and distribute the data comparison tasks of each region to the worker threads in the target thread pool; and a reading module, configured to read business data records according to the data collection interval of the region corresponding to each worker thread, to obtain the target sampling data of the corresponding region, wherein the target sampling data includes first sampling data extracted from the source database and second sampling data extracted from the target database.

[0020] Optionally, the comparison unit includes: a matching module, used to match and align the first sampled data and the second sampled data of the target area; a comparison module, used to compare the matched and aligned first sampled data and the second sampled data item by item according to a preset comparison rule to obtain a comparison result; a determination module, used to determine that the business data corresponding to the target area is complete if the comparison result shows consistency; and a recording module, used to record the inconsistent business data as difference data if the comparison result shows inconsistency.

[0021] Optionally, the data comparison device further includes: a writing unit, configured to write the comparison results into a log after comparing the sampled data corresponding to the source database and the target database according to the region, and generate a comparison report based on the log.

[0022] Optionally, the data comparison device further includes: a monitoring unit, used to monitor in real time the execution progress of the data comparison task in each region and the system resource load status; an adjustment unit, used to adjust the data acquisition interval and / or the number of threads in the corresponding region when a mismatch is detected between the data distribution density and the data acquisition interval, or when the system resource load exceeds a preset threshold; and a second extraction unit, used to re-extract the business data of the corresponding region according to the adjusted data acquisition interval and / or the number of threads.

[0023] According to one aspect of the present invention, a data comparison system is provided, the data comparison system using any one of the data comparison methods described above.

[0024] According to one aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium including a stored program, wherein the program executes the data comparison method described in any one of the foregoing embodiments.

[0025] According to one aspect of the present invention, a processor is provided for running a program, wherein the program executes the data comparison method described in any one of the foregoing embodiments.

[0026] According to one aspect of the present invention, a computer program product is provided, including computer instructions that, when executed by a processor, perform the data comparison method described in any one of the above embodiments.

[0027] By applying the technical solution of this application, the above data comparison method divides business data into partitions corresponding to each region according to the region identification information. The business data includes data in the source database and data in the target database. The target database refers to the container that holds the data copy of the source database after the migration task is completed. The data collection interval for each region is determined based on the total amount of data in each region of the source database and the data distribution density of each region. The number of threads corresponding to the data comparison task in each region is determined based on the total amount of business data in each region and system resource parameters. Based on the data collection interval and the number of threads corresponding to each region, corresponding sampling data is extracted from the source database and the target database. The corresponding sampling data in the source database and the target database are compared by region to obtain the comparison results. This achieves the optimization of multi-region parallel processing and dynamic resource scheduling while ensuring the comprehensiveness of the data comparison. This results in significantly improved comparison efficiency, maximized system resource utilization, and complete data coverage, thus solving the technical problems of low efficiency, poor flexibility, and insufficient sampling coverage in large-scale scenarios in related technologies. Attached Figure Description

[0028] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:

[0029] Figure 1 This is a hardware structure block diagram of a mobile terminal according to an embodiment of the present invention, which describes a data comparison method.

[0030] Figure 2 This is a flowchart of a data comparison method according to an embodiment of the present invention;

[0031] Figure 3 This is a flowchart of the sampling step size calculation method according to an embodiment of the present invention;

[0032] Figure 4 This is a flowchart of a data comparison method based on partitioned positioning and dynamic sampling according to an embodiment of the present invention;

[0033] Figure 5 This is a schematic diagram of a data comparison device according to an embodiment of the present invention.

[0034] The above figures include the following reference numerals:

[0035] 102. Processor; 104. Memory; 106. Transmission device; 108. Input / output device. Detailed Implementation

[0036] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0037] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0038] As described in the background section, related data comparison methods suffer from drawbacks such as low efficiency, poor flexibility, and insufficient sampling coverage in large-scale scenarios. Embodiments of this invention provide a data comparison method and apparatus, a data comparison system, a computer-readable storage medium, a processor, and a computer program product.

[0039] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.

[0040] The methods and embodiments provided in this invention can be executed on a mobile terminal, a computer terminal, or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 This is a hardware structure block diagram of a mobile terminal for a data comparison method according to an embodiment of the present invention. For example... Figure 1 As shown, a mobile terminal may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 104 for storing data are also shown. The mobile terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the mobile terminal described above. For example, the mobile terminal may also include components that are more... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.

[0041] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the data comparison method in this embodiment of the invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, thereby implementing the above-described method. The memory 104 may include high-speed random access memory and non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the mobile terminal via a network. Examples of the aforementioned networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. The transmission device 106 is used to receive or send data via a network. Specific examples of the aforementioned networks may include wireless networks provided by the mobile terminal's communication provider. In one example, the transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to communicate with the Internet. In one example, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0042] Example 1

[0043] According to an embodiment of the present invention, a method embodiment for data comparison is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.

[0044] Figure 2 This is a flowchart of a data comparison method according to an embodiment of the present invention, such as... Figure 2 As shown, the method includes the following steps:

[0045] Step S202: According to the area identification information corresponding to each area, the business data is divided into the corresponding partitions of each area. The business data includes data in the source database and data in the target database. The target database refers to the container that carries the data copy of the source database after the migration task is completed.

[0046] In this embodiment, the regional identification information refers to the province and city code contained in the customer number in the business data, which is the sole basis for distinguishing data from different geographical regions; the business data refers to the full amount of data migrated from the source database to the target database, that is, the original data in the source database and the data carried as a copy in the target database; partitioning refers to routing and storing business data records with the same regional identification information into specific database partitions that match them according to mapping rules; partitioning refers to the physical or logical storage structure built on the underlying database based on the province and city code, which enables data to be stored independently by region; the source database refers to the traditional database system that carries the original business data before migration, which is the benchmark source for data comparison; the target database is a new type of database container that specifically carries the data copy after the source database has completed the migration task; migration refers to the process of completely transferring the existing data in the source database to the new database, which aims to upgrade the system architecture; the data copy refers to the data mapping entity formed in the new database after the source data has been migrated, which is strictly consistent with the source data in terms of content, structure and logical relationship, and is used to verify the accuracy of the migration.

[0047] Optionally, data migration tools refer to software or services that migrate data from the original database to the target database. They typically support full data migration and incremental data synchronization, and support data consistency comparison before and after migration. Existing data migration refers to the process of migrating all data from the original database to the target database. This data is usually all business data up to a certain point in time. The customer number is a key identifier in banking operations. Its structural design has distinctive features, including the customer's province / city code, unique identifier, and other information. The province / city code is the core basis for comparing provincial data in the business table. Both the database business tables before and after migration adopt partitioning rules based on province / city codes. When querying data from a specific province, the corresponding partition can be located directly, avoiding full table scans and supporting parallel processing. A big data platform refers to the ability to store and analyze source data using big data-related technologies.

[0048] This method establishes a mapping relationship between data records and geographical regions based on the fixed feature of the province and city code built into the customer number. The system extracts the customer number of the business data in the source database and the target database, parses the province and city code as regional identification information, and routes business data records with the same province and city code to the corresponding database partition according to the preset partitioning rules, thereby achieving physical or logical isolation of data at the storage level.

[0049] By implementing this control method, precise location of data queries was achieved, avoiding full table scan operations and significantly improving data retrieval efficiency. It also provided a data foundation for the provincial parallel comparison stage, enabling the system to independently execute data reading and comparison tasks for specific regions, effectively supporting multi-threaded concurrent processing and greatly shortening the overall comparison time after large-scale data migration.

[0050] Step S204: Determine the data collection interval for each region based on the total amount of data in each region and the data distribution density of each region in the source database.

[0051] In this embodiment, the total data volume refers to the specific number of business records within a specific area, used to assess the data scale of that area; the data distribution density is the degree of clustering of data within the area in terms of numerical or time dimensions, and the denser the distribution, the higher the density; the data acquisition interval, i.e. the sampling step size, refers to the span value between two adjacent data readings when traversing the data of that area.

[0052] It should be noted that, Figure 3 This is a flowchart of the sampling step size calculation method according to an embodiment of the present invention, as follows: Figure 3 As shown, the system first extracts provincial data files from the big data platform and splits the data by province; then it enters multiple sampling step size setting branches in parallel, setting a sampling step size of 1 up to multiple sets of sampling step sizes n, with each set of step sizes calculating the data distribution; the results of each branch are uniformly merged into the evaluation data distribution stage for comprehensive evaluation; finally, the sampling step size is selected based on the evaluation results to determine the optimal sampling strategy.

[0053] Optionally, the sampling step size is calculated using an optimization strategy based on the distribution of customer numbers and province data. This strategy aims to ensure that all customer numbers within a province are sampled using a reasonable step size, thereby achieving the goal of comprehensively querying and comparing business data. First, the total number of customer numbers and their distribution density in each province are statistically analyzed based on the province data distribution, thus determining the sampling step size for each province. For example, a larger sampling step size can be used for provinces with relatively even data distribution, while a smaller sampling step size is needed for provinces with sparse data distribution. This approach ensures data coverage while reducing unnecessary data reading and comparison operations, thereby improving comparison efficiency. Furthermore, the dynamic adjustment mechanism of the sampling step size can flexibly optimize the comparison process based on actual data changes, further improving the accuracy and reliability of data comparison.

[0054] This method establishes a mapping relationship between data scale and sampling strategy by statistically analyzing the total number of customer numbers and data distribution density of each region (province) in the source database. Specifically, the system extracts provincial data files from the big data platform, calculates the data distribution characteristics of different provinces in parallel, and dynamically determines the data collection interval, i.e., the sampling step size, based on the distribution density. A larger step size is used for provinces with uniform data distribution, and a smaller step size is used for provinces with sparse distribution. Thus, while ensuring coverage of all possible combinations of customer numbers in the region, the optimal sampling step size for each region is calculated.

[0055] By implementing this control method, the comprehensiveness of data comparison is ensured, unnecessary data redundancy caused by over-sampling is effectively avoided, the number of data reading and comparison operations is significantly reduced, and the efficiency of single data comparison is improved. In addition, by flexibly optimizing the comparison process, the system's adaptability to different data distributions and the accuracy of comparison results are enhanced.

[0056] Step S206: Determine the number of threads corresponding to the data comparison task for each region based on the total amount of business data and system resource parameters for each region.

[0057] In this embodiment, the total data volume refers to the total number of data records that need to be compared within a specific region (such as a specific province), used to evaluate the workload of the task; system resource parameters refer to hardware performance indicators such as the number of cores of the server processor, memory capacity, and I / O throughput, reflecting the upper limit of the concurrent processing capacity that the current system can provide; the data comparison task is an independent working unit that performs consistency verification between the source database and the target database, decomposing large-scale comparison work into subdivided sub-tasks to ensure the independence of processing; the number of threads refers to the number of processing threads that the system starts and runs in parallel when executing the task, which is an indicator of concurrent processing capacity and directly determines the efficiency of the system in using multi-core CPUs for parallel computing.

[0058] Optionally, in the data comparison process after database migration, the appropriate setting of the number of threads is one of the key factors in improving comparison efficiency. Determining the number of threads requires comprehensive consideration of factors such as server performance, data volume, and business requirements. Specifically, server performance includes hardware indicators such as the number of CPU cores, memory capacity, and I / O throughput, which directly affect the concurrent processing capabilities of the threads. Furthermore, the size of the data volume also determines the upper limit of the number of threads; an excessively high number of threads may lead to resource contention, thereby reducing overall performance. By dynamically adjusting the number of threads, efficient resource utilization can be achieved based on the actual load. The application of multithreading technology can decompose the data comparison task into multiple subtasks for parallel execution, with each thread independently processing a portion of the data, thus significantly reducing the time required for comparison. This parallel processing capability not only improves the throughput of data comparison but also enhances the processing capability for large-scale datasets, providing a reliable guarantee for subsequent data analysis.

[0059] This method analyzes the total amount of business data in each region and the server hardware performance indicators to establish a balance model between data load and concurrent processing capability. By obtaining the total number of data records to be compared in a specific region and combining system resource parameters such as the number of CPU cores, memory capacity, and I / O throughput, it assesses the current hardware's concurrent processing limit, thereby determining the number of threads corresponding to the data comparison task in that region. This ensures that the number of threads fully utilizes the multi-core processing capability and avoids performance degradation due to resource contention.

[0060] By implementing this control method, based on dynamically adjusting the number of threads, multi-threaded parallel execution of data comparison tasks is achieved. Large-scale data comparison is decomposed into multiple independent sub-tasks for simultaneous processing, which significantly shortens the overall comparison time, improves the throughput and processing efficiency of data comparison, and enhances the system's ability to process large-scale datasets. This provides an efficient and reliable guarantee for rapid quality verification after data migration.

[0061] Step S208: Based on the data acquisition interval and number of threads for each region, extract the corresponding sampling data from the source database and the target database.

[0062] In this embodiment, the sampled data refers to a portion of the business data records that are filtered from the source database and the target database and loaded into memory according to the interval and the number of threads, rather than the full data.

[0063] This method performs parallel data extraction operations based on the determined sampling step size for each region and the number of threads allocated. The system utilizes a multi-threaded concurrency mechanism, with each thread reading the business records corresponding to the customer number at a specific location from the source database and the target database according to the preset sampling step size. The selected data is then loaded into memory to construct the source sampling dataset and the target sampling dataset for subsequent comparison.

[0064] By implementing this control method, the I / O bottleneck problem in traditional full-scale comparison was solved. The sampling strategy significantly reduced the amount of data that needed to be read from the disk, reducing the system's input and output pressure. At the same time, the multi-threaded parallel extraction mechanism made full use of the server's multi-core processing capabilities, achieving concurrent acceleration in the data reading stage, significantly shortening the data loading time, ensuring that the sampled data could cover all possible combinations of customer numbers in each province, ensuring the representativeness of the comparison samples, and improving the overall comparison efficiency by reducing redundant data reading, providing efficient data support for rapid and accurate verification after data migration.

[0065] Step S210: Compare the corresponding sampled data in the source database and the target database according to the region to obtain the comparison results.

[0066] In this embodiment, comparison refers to pairing source data with the same province / city code (i.e., belonging to the same partition) with target data and executing comparison logic in their respective independent threads or processing units; the comparison result refers to a verification record or difference report reflecting whether the source data and target data are consistent in terms of field integrity, consistency, and logical relationship.

[0067] It should be noted that, Figure 4 This is a flowchart of a data comparison method based on partitioned positioning and dynamic sampling according to an embodiment of the present invention, as follows: Figure 4 As shown, the process begins with data provided by the source database. Data files are then extracted by province, and the data distribution is assessed to determine the sampling step size. Simultaneously, application server resources are evaluated, and the number of threads is set accordingly. Subsequently, the sampling step size and the number of threads are input into a multi-threaded data comparison stage to perform parallel comparisons of the provincial data. Finally, the comparison results are recorded, thus achieving dual-dimensional collaborative optimization of data distribution and server resources, efficiently completing quality verification after data migration.

[0068] Optionally, the multi-threaded data comparison process is the core of the technical solution of this invention. It utilizes provincial and municipal codes for province-specific processing and combines multi-threading technology to efficiently compare sampled customer data. Specifically, the process includes the following main steps: First, the data is divided into different provincial groups based on the provincial and municipal codes, with each group corresponding to an independent comparison task. Second, one or more threads are allocated to each task, with the number of threads dynamically adjusted based on server performance and data volume to ensure efficient resource utilization. During the data reading phase, each thread reads the corresponding customer data from the source and target databases according to a preset sampling step size and loads it into memory for processing. Subsequently, predefined comparison rules are applied within each thread to compare the read data line by line. These rules include, but are not limited to, the completeness, consistency, and correctness of logical relationships of data fields. Finally, the comparison results are recorded in a log file for subsequent analysis and verification. Through this process, the multi-threaded data comparison method can significantly improve comparison efficiency while ensuring data accuracy, meeting the bank's need for rapid data quality verification after large-scale data migration.

[0069] This method divides the sampled data into independent comparison task groups based on regional identification information and uses a multi-threaded concurrency mechanism to perform parallel comparisons. The system groups the sampled data loaded into memory from the source and target databases by province according to the province and city codes, and each group of data is assigned to an independent thread for processing. Each thread applies predefined comparison rules to compare records belonging to the same province in the source and target data one by one, checking the field integrity, consistency and logical relationship. Finally, the processing results of each thread are summarized to form an overall comparison result.

[0070] By implementing this control method, the province-specific processing of provincial and municipal codes and multi-threaded parallel comparison are combined to achieve precise division and parallel execution of data comparison tasks. This significantly improves the processing throughput of large-scale datasets, breaks through the time bottleneck caused by serial processing, and effectively isolates mutual interference between tasks by having each thread process data from different provinces independently, ensuring system stability in high-concurrency scenarios. At the same time, by combining direct comparison of data in memory, disk I / O overhead is reduced, thereby significantly shortening the quality verification time after data migration while ensuring the accuracy of data comparison.

[0071] As described above, the technical solution provided by the embodiments of the present invention divides business data into partitions corresponding to each region according to the region identifier information. The business data includes data in the source database and data in the target database. The target database refers to the container in which the source database carries data copies after the migration task is completed. The data collection interval for each region is determined based on the total amount of data in each region of the source database and the data distribution density of each region. The number of threads corresponding to the data comparison task in each region is determined based on the total amount of business data in each region and system resource parameters. Based on the data collection interval and the number of threads corresponding to each region, corresponding sampling data is extracted from the source database and the target database. The corresponding sampling data in the source database and the target database are compared according to region to obtain the comparison results. This achieves the goal of partitioning based on region identifiers, combining dynamic sampling based on data distribution density, and utilizing multi-threaded parallel comparison. This achieves the technical effect of significantly improving the efficiency and resource utilization of large-scale comparisons while ensuring data comprehensiveness and comparison accuracy.

[0072] Therefore, the technical solutions provided by the above embodiments of the present invention solve the technical problems of low efficiency, poor flexibility, and insufficient sampling coverage in large-scale data comparison methods in related technologies.

[0073] According to the above embodiments of the present invention, the business data is divided into partitions corresponding to each region according to the region identification information corresponding to each region, including: parsing the business data and extracting character or number sequences of preset segments as region identification information; mapping the region identification information to the corresponding database partition identifier according to preset partition mapping rules; and dividing business data with the same region identification information into partitions of the corresponding database partition identifiers.

[0074] In this embodiment, business data refers to customer business records stored in the database before and after migration, and its key field, customer number, has a specific data structure; the preset segment refers to a part of a fixed position in the customer number structure, specifically corresponding to the two digits in the customer number that represent the province and city code of the customer; the number sequence refers to a string composed of several characters arranged in order and extracted from a specific position in the customer number in the business data, specifically corresponding to the two digits in the customer number that represent the province and city code, serving as a unique regional identifier; the partition mapping rule refers to a predefined configuration rule that corresponds a specific province and city code with a physical or logical partition identifier in the target database; and the database partition identifier refers to a unique name or ID used in the database system to identify a specific data partition.

[0075] This method performs structured parsing of customer numbers in business data, extracts the province and city codes located in preset segments as regional identification information, and establishes a mapping relationship between this identification information and specific database partition identifiers in the target database according to preset partition mapping rules. By traversing the business data, it extracts the numerical sequence representing the province and city code from the fixed position of the customer number. According to the pre-configured mapping table, data records with the same province and city code are routed and stored in the corresponding database partition, thereby achieving physical or logical isolation and classification of data at the storage level.

[0076] By implementing this control method, precise data location and storage optimization based on geographic regions are achieved. This allows data query and comparison operations to directly locate the corresponding specific partition without performing a full table scan, significantly reducing system I / O overhead. At the same time, this partition-based data organization method supports parallel processing, providing the infrastructure for multi-threaded provincial comparisons and ensuring the independence of data tasks in different provinces.

[0077] According to the above embodiments of the present invention, the data collection interval corresponding to each region is determined based on the total amount of data in each region of the source database and the data distribution density of each region. This includes: counting the total number of business records in each region in the source database and calculating the data distribution density of each region, wherein the data distribution density is determined based on the frequency or interval span of the occurrence of region identification information in continuous business records; calculating the initial sampling step size based on the preset target sampling quantity and data distribution density; and adjusting the initial sampling step size based on the total amount of data in each region to obtain the data collection interval corresponding to each region.

[0078] In this embodiment, the total number of business records refers to the cumulative number of all data rows in the source database belonging to a specific region (i.e., having the same region identification information), used to quantify the data scale of that region; the interval span refers to the number or distance of other business records between two adjacent business records with the same region identification information in the source database, used to quantify the sparsity or density of data in a specific region in the storage sequence; the preset target sampling number refers to the number of sample data records expected to be extracted when comparing data in that region, serving as a benchmark parameter for calculating the initial sampling step size. The initial sampling step size refers to the basic span value between two adjacent data reads initially calculated based on the preset target sampling number (i.e., the number of sample records expected to be extracted) and the aforementioned data distribution density; the data acquisition interval refers to the final determined sampling step size used to guide the actual data extraction operation.

[0079] This method dynamically calculates the sampling step size by quantifying the data distribution characteristics of each region. Specifically, the system first counts the total number of business records in each region (province) in the source database, and calculates the data distribution density based on the frequency or interval span of the regional identification information in consecutive records. Then, it calculates the initial sampling step size by combining the preset target sampling number (i.e., the number of samples to be extracted) with the calculated data distribution density. Finally, the initial sampling step size is corrected and adjusted according to the total amount of data in each region, thereby determining the final data collection interval used to guide data extraction, ensuring that the step size can adapt to the actual density of the data while meeting the sample size requirements.

[0080] By implementing this control method, it is possible to adapt to the uneven distribution of data in different provinces. For provinces with dense data, the sampling step size is automatically increased, while for sparse provinces, the step size is decreased. This ensures coverage of all potential customer number combinations in all regions and maintains the comprehensiveness of the comparison, while avoiding redundant data reading or sample omissions caused by a fixed step size. It optimizes data reading efficiency, reduces unnecessary I / O operations and memory usage, and improves the overall execution efficiency and resource utilization of the comparison task after large-scale heterogeneous data migration.

[0081] According to the above embodiments of the present invention, the number of threads corresponding to the data comparison task in each region is determined based on the total amount of business data and system resource parameters corresponding to each region, including: obtaining the system resource parameters corresponding to each region; calculating the proportion of the total amount of business data in each region to the total amount of business data in all regions, and defining the corresponding proportion as the task weight of the corresponding region; calculating and allocating the number of threads corresponding to the data comparison task in each region based on the task weight and system resource parameters, wherein the number of threads allocated to each region is positively correlated with the corresponding task weight.

[0082] In this embodiment, the task weight refers to the proportion obtained by calculating the total amount of business data in a specific region to the total amount of business data in all regions. This value reflects the relative load of the data comparison task in that region in the entire comparison work; the number of threads refers to the number of parallel processing units allocated when executing the data comparison task in that region.

[0083] This method establishes a dynamic balancing model for thread allocation by quantifying the data load ratio of each region and the system hardware capabilities. Specifically, the system obtains the server hardware performance indicators (such as the number of CPU cores, memory, and I / O throughput) for each region, calculates the proportion of the total business data in a specific region to the total data in all regions, and defines this proportion as the task weight to characterize the relative load. Subsequently, based on the task weight and system resource parameters, a comprehensive calculation is performed, and the number of threads for data comparison tasks in each region is dynamically determined and allocated according to the principle that the task weight of each region is positively correlated with the number of allocated threads, ensuring that regions with heavy loads obtain higher concurrent processing capabilities.

[0084] By implementing this control method, fine-grained scheduling of system computing resources was achieved, enabling regions with large data volumes and long processing times to allocate more threads for parallel processing, while regions with small data volumes could appropriately reduce the number of threads to avoid resource waste. This eliminated the long-tail effect and idle thread phenomenon caused by uneven data distribution, fully utilized the multi-core processing capabilities of the server, significantly improved the overall throughput of data comparison tasks, and ensured the efficiency and timeliness of comparison work after large-scale data migration.

[0085] According to the above embodiments of the present invention, based on the data acquisition interval and the number of threads corresponding to each region, corresponding sampling data is extracted from the source database and the target database, including: configuring a target thread pool matching the number of threads for each region, and distributing the data comparison tasks of each region to the worker threads in the target thread pool; reading business data records according to the data acquisition interval of the region corresponding to each worker thread to obtain the target sampling data of the corresponding region, wherein the target sampling data includes first sampling data extracted from the source database and second sampling data extracted from the target database.

[0086] In this embodiment, the target thread pool refers to a set of reusable worker threads pre-configured for each specific region, with the total number of threads matching the number of threads corresponding to that region, used to isolate the task execution environment of different regions; the worker thread refers to the specific execution unit in the target thread pool that actually performs the data reading and comparison logic; the target sampled data refers to a portion of the business records selected from the database by the worker thread according to the data collection interval, including the first sampled data extracted from the source database and the second sampled data extracted from the target database. These two types of data refer to the business status at the same time, in the same region, and at the same sampling location before and after the migration, respectively.

[0087] This method achieves isolation and reuse of the task execution environment by independently configuring a target thread pool that matches the number of task threads for each region. Specifically, the system distributes the data comparison tasks for each region to the corresponding target thread pool. The worker threads read business records in parallel from the source database and the target database according to a preset data collection interval, extracting the first sample data and the second sample data. Each worker thread performs skip-reading in the massive amount of data according to the collection interval to ensure that it obtains a representative and comprehensive portion of the business data, thereby constructing a target sampling dataset for subsequent comparison.

[0088] By implementing this control method, physical or logical isolation of the task execution environment between regions was achieved, avoiding resource contention and mutual interference between data comparison tasks in different provinces. At the same time, by utilizing worker threads to read source and target data in parallel according to the data acquisition interval, and by leveraging the advantages of multi-threaded concurrency, the data loading process was accelerated, ensuring that the extracted sample data maintained a high degree of consistency and correspondence between the source and target databases. This laid a reliable data foundation for high-precision data comparison and significantly improved the efficiency and stability of the overall data migration verification.

[0089] According to the above embodiments of the present invention, the sampling data corresponding to the source database and the target database are compared by region to obtain the comparison result, including: matching and aligning the first sampling data and the second sampling data of the target region; comparing the matched and aligned first sampling data and the second sampling data item by item according to the preset comparison rules to obtain the comparison result; if the comparison result shows consistency, it is determined that the business data corresponding to the target region is complete; if the comparison result shows inconsistency, the business data with inconsistency is recorded as difference data.

[0090] In this embodiment, matching alignment refers to associating first sampled data and second sampled data belonging to the same specific region and having the same sampling position with the unique identifier (such as customer number) of the business records in the source database and target database, ensuring that both sides of the comparison originate from the same business entity; comparison rules refer to predefined logical standards for judging data consistency, including checking the complete equality of field values, data type compatibility, and the correctness of business logic relationships; item-by-item comparison refers to comparing each field of the corresponding business record with the first sampled data and second sampled data after matching alignment, one by one, independently, numerically or logically, specifically including checking whether the value of each field is equal, whether the format is consistent, and whether the logical relationship conforms to the preset rules, until all relevant fields of the record have been compared; comparison result refers to the verification conclusion generated after item-by-item comparison, specifically represented by a status indicator of consistency or inconsistency; business data integrity means that when the comparison result shows that all matching items are consistent, it is determined that no data loss or tampering has occurred in the target region during the migration process, that is, data integrity is guaranteed; discrepancy data refers to business records where the comparison result shows inconsistency. These records will be extracted and recorded separately as specific basis for investigation or automatic repair.

[0091] This method uses a unique identifier to precisely match and align the first sampled data extracted from the source database with the second sampled data extracted from the target database, ensuring that both belong to the same business entity and the same sampling location. Subsequently, the system compares the aligned data item by item according to preset comparison rules (covering field value equality, data type compatibility, and business logic correctness). If all comparison items meet the rules, the business data in the target area is determined to be complete; if discrepancies are found, the specific records are marked as differential data, thus forming a final comparison result that includes consistency verification conclusions and abnormal records.

[0092] By implementing this control method, the difficulty of comparison caused by the sorting differences of heterogeneous databases is effectively overcome, ensuring the logical correspondence between the source and target data. This enables the system to quickly locate and identify subtle differences in field values, formats, or logical relationships in massive amounts of data, and to distinguish between data integrity and discrepancies, providing accurate basis for data investigation, manual review, or automatic repair. At the same time, combined with multi-threaded parallel processing, it can significantly improve the overall efficiency of quality verification after large-scale data migration while ensuring high accuracy.

[0093] According to the above embodiments of the present invention, after comparing the corresponding sampled data in the source database and the target database according to the region to obtain the comparison results, the data comparison method further includes: writing the comparison results into a log, and generating a comparison report based on the log.

[0094] In this embodiment, a log refers to a persistent data file stored in a structured or semi-structured format that records the entire process and detailed results of data comparison. It includes information such as the consistency status of each region comparison, the specific content of the difference data, and the timestamp of the comparison execution. A comparison report refers to an analysis document in visual or text form generated based on the comparison results recorded in the log file after summarization, statistics, and formatting. It aims to intuitively demonstrate the overall quality of data migration.

[0095] According to the above embodiments of the present invention, the data comparison method further includes: real-time monitoring of the execution progress of the data comparison task in each region and the system resource load status; when it is detected that the data distribution density does not match the data acquisition interval, or the system resource load exceeds a preset threshold, adjusting the data acquisition interval and / or the number of threads in the corresponding region; and re-extracting the business data of the corresponding region according to the adjusted data acquisition interval and / or the number of threads.

[0096] In this embodiment, real-time monitoring refers to the mechanism by which the system continuously and dynamically collects and monitors the task operation status and server hardware load of each region during the execution of data comparison tasks; execution progress refers to an indicator reflecting the degree of completion of the current regional data comparison work, such as the number or proportion of records that have been sampled; system resource load status refers to an indicator reflecting the current resource usage of the server, specifically including CPU utilization, memory usage, and I / O throughput; preset threshold refers to the upper limit warning value of resource load set according to server performance; adjustment refers to the operation of dynamically correcting the current data collection interval and / or the number of threads based on changes in the monitored data distribution or abnormal resource load; re-extraction refers to the process of re-obtaining the corresponding regional business data from the source database and the target database using the corrected parameters.

[0097] This method establishes a closed-loop dynamic feedback adjustment mechanism. During the execution of the data comparison task, it monitors the execution progress of tasks in each region and the load status of system resources such as CPU, memory, and I / O of the server in real time. When a significant change in data distribution density is detected, causing the current data acquisition interval to no longer match, or when the system resource load exceeds a preset safety threshold, the system automatically triggers parameter adjustment logic to dynamically correct the data acquisition interval and / or thread count of the corresponding region. Based on the updated parameters, business data is re-extracted from the source and target databases to achieve adaptive optimization of the comparison strategy.

[0098] By implementing this control method, the problem of insufficient adaptability of static parameter configuration in the face of uneven data distribution or sudden high load is effectively solved. It avoids sampling deviation caused by sparse or dense data and system performance jitter caused by resource overload. It ensures that the optimal resource utilization and comparison efficiency can be maintained under different data characteristics and system states. It not only guarantees the system stability in the process of large-scale data migration and verification, but also improves the accuracy and reliability of the final data comparison results through real-time correction mechanism.

[0099] As described above, the technical solution provided by the embodiments of the present invention divides business data into partitions corresponding to each region according to the region identification information. The business data includes data in the source database and data in the target database. The target database refers to the container that holds data copies of the source database after the migration task is completed. The data collection interval for each region is determined based on the total data volume and data distribution density of each region in the source database. The number of threads corresponding to the data comparison task for each region is determined based on the total business data volume and system resource parameters of each region. Based on the data collection interval and the number of threads corresponding to each region, corresponding sampling data is extracted from the source database and the target database. The corresponding sampling data in the source database and the target database are compared by region to obtain the comparison results. This achieves the goal of overcoming performance bottlenecks caused by uneven data distribution and sorting differences in heterogeneous database migration scenarios, realizing load-aware adaptive resource scheduling and efficient parallel comparison. This significantly improves the overall efficiency and flexibility of data comparison after large-scale data migration, greatly shortens verification time and reduces system resource overhead while ensuring comprehensive sample coverage and comparison accuracy, providing reliable and real-time data quality assurance.

[0100] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.

[0101] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0102] Example 2

[0103] According to embodiments of the present invention, a data comparison apparatus for implementing the above-described data comparison method is also provided. Figure 5 This is a schematic diagram of a data comparison device according to an embodiment of the present invention, such as... Figure 5As shown, the device includes: a division unit 501, a first determination unit 503, a second determination unit 505, a first extraction unit 507, and a comparison unit 509. The device will now be described in detail.

[0104] The partitioning unit 501 is used to divide the business data into the corresponding partitions of each region according to the region identification information of each region. The business data includes data in the source database and data in the target database. The target database refers to the container that carries the data copy of the source database after the migration task is completed.

[0105] The first determining unit 503 is used to determine the data collection interval corresponding to each region based on the total amount of data in each region of the source database and the data distribution density of each region.

[0106] The second determining unit 505 is used to determine the number of threads corresponding to the data comparison task in each region based on the total amount of business data and system resource parameters corresponding to each region.

[0107] The first extraction unit 507 is used to extract corresponding sampling data from the source database and the target database based on the data acquisition interval and the number of threads corresponding to each region.

[0108] The comparison unit 509 is used to compare the corresponding sampled data in the source database and the target database according to the region to obtain the comparison result.

[0109] It should be noted that the division unit 501, the first determination unit 503, the second determination unit 505, the first extraction unit 507, and the comparison unit 509 mentioned above correspond to steps S202 to S210 in the above embodiments. The five units and the corresponding steps implement the same instances and application scenarios, but are not limited to the content disclosed in the above embodiments.

[0110] As can be seen from the above, in the scheme described in the above embodiments of the present invention, the partitioning unit 501 can be used to divide the business data into partitions corresponding to each region according to the region identification information corresponding to each region. The business data includes data in the source database and data in the target database. The target database refers to the container in which the source database carries data copies after the migration task is completed. The first determining unit 503 is used to determine the data collection interval corresponding to each region based on the total amount of data in each region of the source database and the data distribution density of each region. The second determining unit 505 is used to determine the data comparison task for each region based on the total amount of business data corresponding to each region and system resource parameters. The corresponding number of threads; using the first extraction unit 507, the corresponding sampling data is extracted from the source database and the target database based on the data acquisition interval and the number of threads for each region; using the comparison unit 509, the corresponding sampling data in the source database and the target database are compared by region to obtain the comparison results. Through the above technical solution, the sampling strategy and parallel processing resource allocation are dynamically optimized based on the data distribution characteristics, so as to achieve the purpose of automating and fine-grained management of the data comparison process. Thus, while ensuring the comprehensiveness of data coverage and the accuracy of comparison, the technical effect of significantly improving the comparison efficiency and system resource utilization in large-scale data migration scenarios is achieved.

[0111] Therefore, the technical solutions provided by the above embodiments of the present invention solve the technical problems of low efficiency, poor flexibility, and insufficient sampling coverage in large-scale data comparison methods in related technologies.

[0112] Optionally, the partitioning unit includes: a parsing module for parsing business data and extracting character or numeric sequences of preset bit ranges as region identification information; a mapping module for mapping the region identification information to the corresponding database partition identifier according to preset partition mapping rules; and a partitioning module for partitioning business data with the same region identification information into the partitions of the corresponding database partition identifiers.

[0113] Optionally, the first determining unit includes: a statistics module, used to count the total number of business records in the source database for each region and calculate the data distribution density for each region, wherein the data distribution density is determined based on the frequency or interval span of the occurrence of region identification information in continuous business records; a first calculation module, used to calculate the initial sampling step size according to the preset target sampling quantity and data distribution density; and an adjustment module, used to adjust the initial sampling step size according to the total amount of data in each region to obtain the data collection interval corresponding to each region.

[0114] Optionally, the second determining unit includes: an acquisition module for acquiring system resource parameters corresponding to each region; a second calculation module for calculating the proportion of the total amount of business data corresponding to each region to the total amount of business data of all regions, and defining the corresponding proportion as the task weight of the corresponding region; and a third calculation module for calculating and allocating the number of threads corresponding to the data comparison task of each region based on the task weight and system resource parameters, wherein the number of threads allocated to each region is positively correlated with the corresponding task weight.

[0115] Optionally, the first extraction unit includes: a configuration module, used to configure a target thread pool matching the number of threads for each region, and to distribute the data comparison tasks of each region to the worker threads in the target thread pool; and a reading module, used to read business data records according to the data collection interval of the region corresponding to each worker thread, to obtain the target sampling data of the corresponding region, wherein the target sampling data includes first sampling data extracted from the source database and second sampling data extracted from the target database.

[0116] Optionally, the comparison unit includes: a matching module for matching and aligning the first sampled data and the second sampled data of the target area; a comparison module for comparing the matched and aligned first sampled data and the second sampled data item by item according to a preset comparison rule to obtain a comparison result; a determination module for determining that the business data corresponding to the target area is complete if the comparison results are consistent; and a recording module for recording the inconsistent business data as difference data if the comparison results are inconsistent.

[0117] Optionally, the data comparison device further includes a writing unit, used to compare the corresponding sampled data in the source database and the target database according to the region, write the comparison results to a log after obtaining the comparison results, and generate a comparison report based on the log.

[0118] Optionally, the data comparison device further includes: a monitoring unit for real-time monitoring of the execution progress of data comparison tasks in each region and the system resource load status; an adjustment unit for adjusting the data acquisition interval and / or the number of threads in the corresponding region when a mismatch is detected between the data distribution density and the data acquisition interval, or when the system resource load exceeds a preset threshold; and a second extraction unit for re-extracting the business data of the corresponding region based on the adjusted data acquisition interval and / or the number of threads.

[0119] According to another aspect of the present invention, a data comparison system is also provided, which uses any of the data comparison methods described above.

[0120] According to another aspect of the present invention, a computer-readable storage medium is also provided, the computer-readable storage medium including a stored program, wherein the program executes any of the above-described data comparison methods.

[0121] According to another aspect of the present invention, a processor is also provided, which is used to run a program, wherein the program executes any of the above-described data comparison methods during runtime.

[0122] According to one aspect of the present invention, a computer program product is provided, including computer instructions, which, when executed by a processor, perform any of the above-described data comparison methods.

[0123] Optionally, in this embodiment, the computer-readable storage medium may be located in any computer terminal in a group of computer terminals in a computer network, or in any communication device in a group of communication devices.

[0124] Optionally, in this embodiment, the computer-readable storage medium is configured to store program code for performing the following steps: dividing business data into partitions corresponding to each region according to the region identification information corresponding to each region, wherein the business data includes data in the source database and data in the target database, and the target database refers to the container that carries the data copy of the source database after the migration task is completed; determining the data collection interval corresponding to each region according to the total amount of data in each region of the source database and the data distribution density of each region; determining the number of threads corresponding to the data comparison task of each region according to the total amount of business data corresponding to each region and system resource parameters; extracting the corresponding sampling data from the source database and the target database based on the data collection interval and the number of threads corresponding to each region; comparing the corresponding sampling data in the source database and the target database according to region to obtain the comparison result.

[0125] Optionally, in this embodiment, the computer-readable storage medium is configured to store program code for performing the following steps: dividing business data into partitions corresponding to each region according to the region identification information corresponding to each region, including: parsing the business data and extracting character or number sequences of preset bit segments as region identification information; mapping the region identification information to the corresponding database partition identifier according to preset partition mapping rules; and dividing business data with the same region identification information into partitions of the corresponding database partition identifiers.

[0126] Optionally, in this embodiment, the computer-readable storage medium is configured to store program code for performing the following steps: determining the data acquisition interval corresponding to each region based on the total amount of data in each region of the source database and the data distribution density of each region, including: counting the total number of business records in each region in the source database and calculating the data distribution density of each region, wherein the data distribution density is determined based on the frequency or interval span of the occurrence of region identification information in continuous business records; calculating the initial sampling step size based on the preset target sampling quantity and data distribution density; and adjusting the initial sampling step size based on the total amount of data in each region to obtain the data acquisition interval corresponding to each region.

[0127] Optionally, in this embodiment, the computer-readable storage medium is configured to store program code for performing the following steps: determining the number of threads corresponding to the data comparison task in each region based on the total amount of business data and system resource parameters corresponding to each region, including: obtaining the system resource parameters corresponding to each region; calculating the proportion of the total amount of business data in each region to the total amount of business data in all regions, and defining the corresponding proportion as the task weight of the corresponding region; calculating and allocating the number of threads corresponding to the data comparison task in each region based on the task weight and system resource parameters, wherein the number of threads allocated to each region is positively correlated with the corresponding task weight.

[0128] Optionally, in this embodiment, the computer-readable storage medium is configured to store program code for performing the following steps: extracting corresponding sampling data from the source database and the target database based on the data acquisition interval and the number of threads corresponding to each region, including: configuring a target thread pool matching the number of threads for each region, and distributing the data comparison tasks of each region to the worker threads in the target thread pool; reading business data records according to the data acquisition interval of the region corresponding to each worker thread to obtain the target sampling data of the corresponding region, wherein the target sampling data includes first sampling data extracted from the source database and second sampling data extracted from the target database.

[0129] Optionally, in this embodiment, the computer-readable storage medium is configured to store program code for performing the following steps: comparing corresponding sampled data in the source database and the target database by region to obtain comparison results, including: matching and aligning the first sampled data and the second sampled data in the target region; comparing the matched and aligned first sampled data and the second sampled data item by item according to a preset comparison rule to obtain comparison results; if the comparison results show consistency, determining that the business data corresponding to the target region is complete; if the comparison results show inconsistency, recording the inconsistent business data as difference data.

[0130] Optionally, in this embodiment, the computer-readable storage medium is configured to store program code for performing the following steps: after comparing the corresponding sampled data in the source database and the target database by region to obtain the comparison results, the data comparison method further includes: writing the comparison results into a log, and generating a comparison report based on the log.

[0131] Optionally, in this embodiment, the computer-readable storage medium is configured to store program code for performing the following steps: the data comparison method further includes: real-time monitoring of the execution progress of the data comparison task in each region and the system resource load status; when it is detected that the data distribution density does not match the data acquisition interval, or the system resource load exceeds a preset threshold, adjusting the data acquisition interval and / or the number of threads in the corresponding region; and re-extracting the business data of the corresponding region according to the adjusted data acquisition interval and / or the number of threads.

[0132] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0133] In the above embodiments of the present invention, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0134] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For instance, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.

[0135] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0136] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0137] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0138] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.

[0139] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A data comparison method, characterized in that, include: According to the area identification information corresponding to each region, the business data is divided into the partitions corresponding to each region. The business data includes data in the source database and data in the target database. The target database refers to the container that carries the data copy of the source database after the migration task is completed. Based on the total amount of data in each region and the data distribution density in each region of the source database, the data collection interval corresponding to each region is determined; Based on the total amount of business data and system resource parameters corresponding to each region, determine the number of threads corresponding to the data comparison task in each region; Based on the data acquisition interval and the number of threads corresponding to each region, the corresponding sampling data is extracted from the source database and the target database; The sampled data corresponding to the source database and the target database are compared according to region to obtain the comparison results.

2. The data comparison method according to claim 1, characterized in that, Based on the region identifier information corresponding to each region, the business data is divided into the partitions corresponding to each region, including: The business data is parsed, and a character or number sequence in a preset range is extracted as the region identification information; According to the preset partition mapping rules, the region identification information is mapped to the corresponding database partition identification. Business data with the same regional identification information are divided into partitions with the corresponding database partition identification.

3. The data comparison method according to claim 1, characterized in that, Based on the total data volume and data distribution density of each region in the source database, the data collection interval corresponding to each region is determined, including: The total number of business records for each region in the source database is counted, and the data distribution density for each region is calculated, wherein the data distribution density is determined based on the frequency or interval span of the region identification information in consecutive business records; Calculate the initial sampling step size based on the preset target sampling quantity and the data distribution density; Based on the total amount of data in each region, the initial sampling step size is adjusted to obtain the data acquisition interval corresponding to each region.

4. The data comparison method according to claim 1, characterized in that, Based on the total amount of business data and system resource parameters corresponding to each region, the number of threads corresponding to the data comparison task in each region is determined, including: Obtain the system resource parameters corresponding to each region; Calculate the proportion of the total amount of business data in each region to the total amount of business data in all regions, and define the corresponding proportion as the task weight of the corresponding region. Based on the task weights and system resource parameters, the number of threads corresponding to the data comparison tasks in each region is calculated and allocated, wherein the number of threads allocated to each region is positively correlated with the corresponding task weights.

5. The data comparison method according to claim 1, characterized in that, Based on the data acquisition interval and the number of threads corresponding to each region, corresponding sampling data is extracted from the source database and the target database, including: Configure a target thread pool that matches the number of threads for each region, and distribute the data comparison tasks for each region to worker threads in the target thread pool; According to the data collection interval of the region corresponding to each working thread, business data records are read to obtain the target sampling data of the corresponding region. The target sampling data includes first sampling data extracted from the source database and second sampling data extracted from the target database.

6. The data comparison method according to claim 5, characterized in that, The sampled data corresponding to the source database and the target database are compared by region to obtain the comparison results, including: Match and align the first and second sampled data of the target area; According to the preset comparison rules, the first sampled data and the second sampled data after matching and alignment are compared item by item to obtain the comparison results; If the comparison results are consistent, it is determined that the business data corresponding to the target area is complete. If the comparison results show inconsistencies, the inconsistent business data will be recorded as discrepancy data.

7. The data comparison method according to claim 6, characterized in that, After comparing the sampled data corresponding to the source database and the target database according to region to obtain the comparison results, the data comparison method further includes: The comparison results are written to a log, and a comparison report is generated based on the log.

8. The data comparison method according to claim 1, characterized in that, The data comparison method also includes: Real-time monitoring of the execution progress of the data comparison task in each region and the system resource load status; When a mismatch is detected between the data distribution density and the data acquisition interval, or when the system resource load exceeds a preset threshold, the data acquisition interval and / or the number of threads in the corresponding area are adjusted. Based on the adjusted data collection interval and / or number of threads, the business data for the corresponding area is re-extracted.

9. A data comparison device, characterized in that, include: The partitioning unit is used to divide the business data into partitions corresponding to each region according to the region identification information corresponding to each region. The business data includes data in the source database and data in the target database. The target database refers to the container that carries the data copy of the source database after the migration task is completed. The first determining unit is used to determine the data collection interval corresponding to each region based on the total amount of data in each region and the data distribution density of each region in the source database; The second determining unit is used to determine the number of threads corresponding to the data comparison task of each region based on the total amount of business data and system resource parameters of each region. The first extraction unit is used to extract corresponding sampling data from the source database and the target database based on the data acquisition interval and the number of threads corresponding to each region. The comparison unit is used to compare the corresponding sampled data in the source database and the target database according to the region to obtain the comparison result.

10. A data comparison system, characterized in that, The data comparison system uses the data comparison method described in any one of claims 1 to 8.