Data comparison method and device, storage medium and electronic equipment
By dividing the data source files into multiple shards and comparing them between multiple devices, the problem of low data comparison efficiency in the existing technology is solved, and balanced load and efficient comparison are achieved.
Patent Information
- Application Number
- CN202310238441.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-03
- Publication Date
- 2024-09-10
AI Technical Summary
Existing data comparison methods occupy large storage space, take a long time, and have unbalanced machine loads when the amount of data is large, resulting in low efficiency.
Divide the data source file into multiple data shards, compare the shards between multiple devices, use the correspondence between the shards to perform comparison operations, generate target comparison results, and determine the comparison results through write-off operations difference.
It achieves balanced device load, improves data comparison efficiency, and reduces storage and processing time.
Smart Images

Figure CN118626520A
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and in particular to a data comparison method and device, a storage medium, and an electronic device. Background Art
[0002] At present, in the process of data comparison, most of them adopt the overall method similar to that in relational databases such as MySQL. When comparing, each field is compared for equality according to the needs of their respective business logic. For cross-batch data, the table is first linked and cancelled, and then multiple batches of data are loaded for unified cancellation, and finally the results are output. However, when the amount of data is relatively large, such a comparison method will cause problems such as large storage space, long time-consuming data comparison again, and uneven machine load.
[0003] With respect to the problem of low data comparison efficiency existing in the above-mentioned related technologies, no effective solution has been proposed so far. Summary of the invention
[0004] The embodiments of the present application provide a data comparison method and device, a storage medium, and an electronic device to at least solve the technical problem of low data comparison efficiency.
[0005] According to one aspect of an embodiment of the present application, a data comparison method is provided, comprising: dividing a first data source file and a second data source file into a first group of data shards and a second group of data shards, respectively, wherein the first group of data shards and the second group of data shards have the same number of shards, and the first data source file and the second data source file are data source files to be compared from the same batch; in response to a first comparison task, performing a comparison operation on the first group of data shards and the second group of data shards according to a corresponding relationship between the shards, respectively, to obtain a first group of comparison results, wherein the first comparison task is used to instruct to compare the first data shards and the second data shards on a first device, and compare the first data shards and the second data shards on a second device Compare the third data slice and the fourth data slice, the first data slice and the second data slice have the corresponding relationship, the third data slice and the fourth data slice have the corresponding relationship, the first data source file includes the first data slice and the third data slice, and the second data source file includes the second data slice and the fourth data slice; perform a cancel operation on the first group of comparison results and the second group of comparison results to generate a target comparison result, wherein the data source files used by the second group of comparison results and the first group of comparison results belong to different batches, and the target comparison result is used to indicate whether there is a difference between the first group of comparison results and the second group of comparison results.
[0006] According to another aspect of an embodiment of the present application, a data comparison device is also provided, including: a division module, used to divide a first data source file and a second data source file into a first group of data slices and a second group of data slices, respectively, wherein the number of slices in the first group of data slices is the same as that in the second group of data slices, and the first data source file and the second data source file are data source files to be compared from the same batch; a comparison module, used to respond to a first comparison task, perform a comparison operation on the first group of data slices and the second group of data slices according to the correspondence between the slices, respectively, to obtain a first group of comparison results, wherein the first comparison task is used to instruct to compare the first data slices and the second data slices on the first device, and to compare the first data slices and the second data slices on the first device, and to compare the first data slices and the second data slices on the first device. The third data slice and the fourth data slice are compared on the second device, the first data slice and the second data slice have the corresponding relationship, the third data slice and the fourth data slice have the corresponding relationship, the first data source file includes the first data slice and the third data slice, and the second data source file includes the second data slice and the fourth data slice; a cancellation module is used to perform a cancellation operation on the first group of comparison results and the second group of comparison results to generate a target comparison result, wherein the data source files used by the second group of comparison results and the first group of comparison results belong to different batches, and the target comparison result is used to indicate whether there is a difference between the first group of comparison results and the second group of comparison results.
[0007] Optionally, the device is also used to: obtain the first document identification of each data in the first data slice and the second document identification of each data in the second data slice; when there are first data and second data with the same first document identification and second document identification, compare the comparison fields of the first data and the second data; when the comparison fields of the first data and the second data are the same, and there are multiple first data and second data, merge the multiple first data and the multiple second data respectively to generate third data and fourth data, wherein the third data corresponds to the first data slice, the fourth data corresponds to the second data slice, the value of the comparison field of the third data is the sum of the values of the comparison fields of the multiple first data, and the value of the comparison field of the fourth data is the sum of the values of the comparison fields of the multiple second data.
[0008] Optionally, the device is also used for: when the comparison fields of the first data and the second data are the same, and there are multiple first data and second data, obtaining the first merged fields of the multiple first data and the second merged fields of the multiple second data, wherein the first merged field represents the account book category and batch of the first data, and the second merged field represents the account book category and batch of the second data; when the first merged fields of the multiple first data are the same, and the second merged fields of the multiple second data are the same, merging the multiple first data and the multiple second data respectively to generate third data and fourth data.
[0009] Optionally, the device is also used to: sort the data in the first data shard and the second data shard according to the first document identifier and the second document identifier to obtain a first repeated data set and a second repeated data set, wherein the first repeated data set represents a data set consisting of data with the same first document identifier in the first data shard, and the second repeated data set represents a data set consisting of data with the same second document identifier in the second data shard; traverse the first data shard and the second data shard, and determine comparison abnormal data according to the first repeated data set and the second repeated data set, wherein the target comparison result includes the comparison abnormal data.
[0010] Optionally, the device is also used to: obtain a first parameter for each data file in the first data source file and a second parameter for each data file in the second data source file, wherein the first parameter and the second parameter are unique identifiers of the data files; obtain the number of shards of the target shard set, wherein the target shard set includes shards that are currently allowed to store data shards; divide the first data source file and the second data source file into a first group of data shards and a second group of data shards respectively according to the first parameter, the second parameter and the number of shards, and compress and store them in the first shard and the second shard, wherein the first shard is determined by the first parameter and the remainder of the number of shards, and the second shard is determined by the second parameter and the remainder of the number of shards, and the target shard set includes the first shard and the second shard.
[0011] Optionally, the device is also used for: when the first data shard includes data shard details and data shard summary, uploading the data shard details to the first cluster and the second cluster, and then uploading the data shard summary, wherein the first data shard is deemed to have been successfully uploaded when any one of the first cluster and the second cluster has received the data shard summary, wherein the data shard details include the values of each field of each data in the first data shard, and the data shard summary includes the summary of target field values of each data in the first data shard; before performing comparison operations on the first group of data shards and the second group of data shards according to the correspondence between the shards and obtaining the first group of comparison results, downloading the data shard summary, and downloading the data shard details when the data shard summary is successfully downloaded.
[0012] Optionally, the device is also used to: in response to the first comparison task, when the data shard summary includes a signature field, verify the signature field to obtain a target verification result; when the target verification result indicates that the verification is successful, perform a comparison operation on the first group of data shards and the second group of data shards.
[0013] Optionally, the device is further used to: in response to the first comparison task, respectively perform a comparison operation on the first group of data slices and the second group of data slices according to the corresponding relationship between the slices, and before or after obtaining the first group of comparison results, divide the third data source file and the fourth data source file into a third group of data slices and a fourth group of data slices respectively, wherein the third group of data slices and the fourth group of data slices have the same number of slices, the third data source file and the fourth data source file are from the same batch, and are data source files to be compared from different batches as the first data source file and the second data source file; in response to the second comparison task, perform a comparison operation on the third group of data slices and the fourth data source file respectively, and divide the third data source file and the fourth data source file into a third group of data slices and a fourth group of data slices respectively. The fourth group of data shards are respectively compared according to the correspondence between the shards to obtain a second group of comparison results, wherein the second comparison task is used to instruct the comparison of the fifth data shard and the sixth data shard on the third device, and the comparison of the seventh data shard and the eighth data shard on the fourth device, the fifth data shard has a corresponding relationship with the seventh data shard, the sixth data shard has a corresponding relationship with the eighth data shard, the third data source file includes the fifth data shard and the seventh data shard, and the fourth data source file includes the sixth data shard and the eighth data shard; a cancel operation is performed on the first group of comparison results and the second group of comparison results to generate a target comparison result.
[0014] Optionally, the device is also used to: determine a comparison result set and a third document identifier of each data in the comparison result set based on the first group of comparison results and the second group of comparison results; mark data with the same third document identifier in any comparison result in the comparison result set as canceled abnormal data, wherein the target comparison result includes the canceled abnormal data; mark data with the same third document identifier and the same comparison field in different comparison results as successfully canceled data, wherein the target comparison result includes the successfully canceled data; mark data that any comparison result in the comparison result set has but other comparison results do not have as data to be canceled, wherein the target comparison result includes the data to be canceled.
[0015] Optionally, the device is also used to: pre-set a first comparison task, wherein the first comparison task includes a preset scheduling time; when the preset scheduling time is reached, control multiple devices to obtain the first comparison task, and when the first device and the second device obtain the first comparison task, respond to the first comparison task, compare the first data slice and the second data slice on the first device, and compare the third data slice and the fourth data slice on the second device to obtain a first set of comparison results.
[0016] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the above-mentioned data comparison method when it is run.
[0017] According to another aspect of the embodiments of the present application, a computer program product or a computer program is provided, the computer program product or the computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the above data comparison method.
[0018] According to another aspect of the embodiments of the present application, there is further provided an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the data comparison method through the computer program.
[0019] In an embodiment of the present application, a first data source file and a second data source file are divided into a first group of data shards and a second group of data shards, respectively. In response to a first comparison task, a comparison operation is performed on the first group of data shards and the second group of data shards according to the correspondence between the shards to obtain a first group of comparison results. A cancel operation is performed on the first group of comparison results and the second group of comparison results to generate a target comparison result. The first data source file and the second data source file are divided into slices and then compared. At the same time, multiple devices are used to compare the first source file and the second source file, and then a cancel operation is performed on the comparison results, thereby achieving the technical effects of balancing device loads, improving data comparison efficiency, and improving storage efficiency, thereby solving the technical problem of low data comparison efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0021] Figure 1 is a schematic diagram of an application environment of an optional data comparison method according to an embodiment of the present application;
[0022] Figure 2 is a flow chart of an optional data comparison method according to an embodiment of the present application;
[0023] Figure 3 is a flow chart of another optional data comparison method according to an embodiment of the present application;
[0024] Figure 4 is a flow chart of another optional data comparison method according to an embodiment of the present application;
[0025] Figure 5 is a flow chart of another optional data comparison method according to an embodiment of the present application;
[0026] Figure 6 is a flow chart of another optional data comparison method according to an embodiment of the present application;
[0027] Figure 7 is a flow chart of another optional data comparison method according to an embodiment of the present application;
[0028] Figure 8 is a flow chart of another optional data comparison method according to an embodiment of the present application;
[0029] Fig. 9 is a flow chart of another optional data comparison method according to an embodiment of the present application;
[0030] Fig.10 is a schematic structural diagram of an optional data comparison device according to an embodiment of the present application;
[0031] Fig.11 is a schematic diagram of the structure of an optional data comparison product according to an embodiment of the present application;
[0032] Fig.12 It is a schematic diagram of the structure of an optional electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0033] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0034] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0035] First, some nouns or terms that appear in the description of the embodiments of the present application are subject to the following interpretation:
[0036] Equivalence matching: Match the matching fields one by one and if they are strictly equal, the matching succeeds, otherwise the matching fails.
[0037] Cancellation: The process of comparing data across batches such as those at different hours or days. If the comparison is successful, the cancellation is successful and the marking is successful. If the comparison fails or the comparison is not completed within the time limit, it will be recorded as a cancellation exception.
[0038] HDFS (Hadoop Distributed File System): A distributed file storage system that breaks large files into small file blocks and stores them on multiple machines, ensuring that each block is stored in multiple copies, which can achieve disaster recovery.
[0039] The present application is described below in conjunction with embodiments:
[0040] According to one aspect of an embodiment of the present application, a data comparison method is provided. Optionally, in this embodiment, the data comparison method can be applied to Figure 1 In the hardware environment composed of the server 101 and the terminal device 103 shown in FIG. Figure 1As shown, the server 101 is connected to the terminal 103 via a network, and can be used to provide services for the terminal device or the application installed on the terminal device. The application can be a video application, an instant messaging application, a browser application, an educational application, a game application, etc. A database 105 may be set up on the server or independently of the server to provide data storage services for the server 101, for example, a game data storage server. The above-mentioned network may include, but is not limited to, a wired network and a wireless network, wherein the wired network includes, for example, a local area network, a metropolitan area network, and a wide area network; the wireless network includes, for example, Bluetooth, WIFI, and other networks that implement wireless communication; the terminal device 103 may be a terminal configured with an application program, and may include, but is not limited to, at least one of the following: a mobile phone (such as an Android phone, an iOS phone, etc.), a laptop computer, a tablet computer, a PDA, a MID (Mobile Internet Devices), a PAD, a desktop computer, a smart TV, an intelligent voice interaction device, a smart home appliance, a vehicle-mounted terminal, an aircraft, a virtual reality (VR) terminal, an augmented reality (AR) terminal, a mixed reality (MR) terminal, and other computer devices; the above-mentioned server may be a single server, a server cluster consisting of multiple servers, or a cloud server.
[0041] Combination Figure 1 As shown, the above data comparison method can be implemented in the terminal device 103 through the following steps:
[0042] S1, dividing the first data source file and the second data source file into a first group of data shards and a second group of data shards respectively on the terminal device 103, wherein the first group of data shards and the second group of data shards have the same number of shards, and the first data source file and the second data source file are data source files to be compared in the same batch;
[0043] S2, in response to the first comparison task, respectively performing a comparison operation on the first group of data shards and the second group of data shards according to the corresponding relationship between the shards on the terminal device 103, to obtain a first group of comparison results, wherein the first comparison task is used to instruct to compare the first data shard and the second data shard on the first device, and to compare the third data shard and the fourth data shard on the second device, the first data shard and the second data shard have a corresponding relationship, the third data shard and the fourth data shard have a corresponding relationship, the first data source file includes the first data shard and the third data shard, and the second data source file includes the second data shard and the fourth data shard;
[0044] S3, performing a cancel operation on the first group of comparison results and the second group of comparison results on the terminal device 103 to generate a target comparison result, wherein the data source files used by the second group of comparison results and the first group of comparison results belong to different batches, and the target comparison result is used to indicate whether there is a difference between the first group of comparison results and the second group of comparison results.
[0045] Optionally, in this embodiment, the above data comparison method can also be implemented by a server, for example, Figure 1 It is implemented in the server 101 shown; or it is implemented by the terminal device and the server together.
[0046] The above is only an example and is not specifically limited in this embodiment.
[0047] Optionally, as an optional implementation, as Figure 2 As shown, the above data comparison method includes:
[0048] S202, dividing the first data source file and the second data source file into a first group of data shards and a second group of data shards respectively, wherein the first group of data shards and the second group of data shards have the same number of shards, and the first data source file and the second data source file are data source files to be compared from the same batch;
[0049] Optionally, in this embodiment, the first data source file and the second data source file may include but are not limited to data files in the form of bills, order forms, etc. It should be noted that the first data source file and the second data source file may include but are not limited to source files from the same batch on different platforms. The first data source file and the second data source file are in the same form. For example, it can be understood that the first data source file is a bill, and the second data source file is also a bill.
[0050] Optionally, in this embodiment, the first group of data shards may include but are not limited to those obtained by dividing the first data source file into equal parts, and the second group of data shards may include but are not limited to those obtained by dividing the second data source file into equal parts.
[0051] It should be noted that the number of the first group of data shards and the second group of data shards is the same, but the data size contained in each data shard in the first group of data shards and the data size contained in each data shard in the second group of data shards can be the same or different. For example, data source A and data source B are divided into two data shards respectively, and data shard A1 and data shard A2 are obtained by dividing data source A, that is, data shard A1 and data shard A2 constitute the first group of data shards, and the data size included in data shard A1 and data shard A2 is the same; data source B is divided into data shard B1 and data shard B2, that is, data shard B1 and data shard B2 constitute the second group of data shards, and the data size included in data shard B1 and data shard B2 is different.
[0052] S204, in response to the first comparison task, respectively performing comparison operations on the first group of data shards and the second group of data shards according to the corresponding relationship between the shards, to obtain a first group of comparison results, wherein the first comparison task is used to instruct to compare the first data shard and the second data shard on the first device, and to compare the third data shard and the fourth data shard on the second device, the first data shard and the second data shard have a corresponding relationship, the third data shard and the fourth data shard have a corresponding relationship, the first data source file includes the first data shard and the third data shard, and the second data source file includes the second data shard and the fourth data shard;
[0053] Optionally, in this embodiment, the above-mentioned first comparison task may include but is not limited to the task of comparing the above-mentioned first data source file and the above-mentioned second data source file on the first device and the second device respectively, that is, comparing the first data slice and the second data slice having a corresponding relationship on the first device, and comparing the third data slice and the fourth data slice having a corresponding relationship on the second device.
[0054] It should be noted that the above-mentioned first device and the above-mentioned second device may include but are not limited to devices for performing data comparison operations, wherein the above-mentioned first device and the above-mentioned second device are two different devices, and the first device and the second device may include but are not limited to performing the comparison operation simultaneously.
[0055] In an exemplary embodiment, the first data source file includes the first data slice and the third data slice, which can be understood as the first data slice and the third data slice are both obtained by performing a partitioning operation on the first data source file, wherein the data sizes contained in the first data slice and the third data slice may be equal or unequal.
[0056] Optionally, in this embodiment, the comparison operation may include but is not limited to comparing the data slices with the same identifier in the first group of data slices and the second group of data slices, and the identifier may be but is not limited to an order number, a waybill number, etc. The comparison operation may include but is not limited to comparing whether the data contents of the data slices with the same identifier in the first group of data slices and the second group of data slices are consistent.
[0057] Optionally, in this embodiment, the form of the first group of comparison results may include but is not limited to being the same as the first data slice and the second data slice. The first group of comparison results may include but is not limited to being summarized by comparing multiple pairs of corresponding data slices.
[0058] It should be noted that the comparison operation is performed on the first group of data slices and the second group of data slices according to the correspondence between the slices to obtain the first group of comparison results, which can be understood as comparing the data slices with the same identifier in the first group of data slices and the second group of data slices.
[0059] In an exemplary embodiment, when the first data source file and the second data source file are order bill A and order bill B, data shard a is one of the data shards obtained by dividing order bill A, and data shard b is one of the data shards obtained by dividing order bill B. When the order numbers of data shard a and data shard b are the same or belong to the same value range, that is, it can be understood that data shard a and data shard b have a corresponding relationship, and data shard a and data shard b can be compared.
[0060] S206, canceling the first group of comparison results and the second group of comparison results to generate a target comparison result, wherein the data source files used by the second group of comparison results and the first group of comparison results belong to different batches, and the target comparison result is used to indicate whether there is a difference between the first group of comparison results and the second group of comparison results.
[0061] Optionally, in this embodiment, the second set of comparison results may include but is not limited to results obtained by comparing a third data source file and a fourth data source file, wherein the batches of the third data source file and the fourth data source file are the same, but the batches of the third data source file and the fourth data source file are different from those of the first data source file and the second data source file.
[0062] It should be noted that the cancellation operation may include but is not limited to further performing a comparison operation on the first set of comparison results and the second set of comparison results. For example, the comparison results of different batches at different times are further compared. If the comparison is successful, the data that has been successfully cancelled is deleted. If the comparison fails, the data fragment is used as the data to be cancelled and waits for the next cancellation comparison. If the comparison fails due to timeout or the comparison fields are consistent but the key information is inconsistent, it is listed as abnormal cancellation data.
[0063] In an exemplary embodiment, if the content of the comparison is the order amount, the first group of comparison results includes the shard comparison result 1, and the second group of comparison results includes the shard comparison result 2, wherein the first group of comparison results is the result obtained by comparing the first batch of data source files, and the second group of comparison results is the result obtained by comparing the second batch of data source files. When the cancellation operation is performed on the first group of comparison results and the second group of comparison results, if the shard comparison result 1 and the shard comparison result 2 are consistent in various information such as the order number and the order amount after comparison, The cancellation is successful, and the shard comparison result 1 and the shard comparison result 2 are deleted from the cancellation data; if the shard comparison result 1 and the shard comparison result 2 are consistent in order number but inconsistent in order amount after comparison, the cancellation fails, and the shard comparison result 1 and the shard comparison result 2 are used as the data to be cancelled and wait for the next cancellation operation; if the shard comparison result 1 and the shard comparison result 2 are consistent in order number and order amount after comparison, but inconsistent in key information such as user account, the shard comparison result 1 and the shard comparison result 2 are used as abnormal cancellation data.
[0064] Optionally, in this embodiment, the target comparison result may include but is not limited to a comparison result consisting of the data to be cancelled and the abnormal data cancelled.
[0065] It should be noted that the above-mentioned target comparison result is used to indicate whether there is a difference between the first group of comparison results and the second group of comparison results. It can be understood that the first group of comparison results and the second group of comparison results are cancelled to obtain the target comparison result. When neither the cancelled abnormal data nor the above-mentioned data to be cancelled exists, it indicates that there is no difference between the first group of comparison results and the second group of comparison results. Conversely, when the cancelled abnormal data or the above-mentioned data to be cancelled exists, it indicates that there is a difference between the first group of comparison results and the second group of comparison results.
[0066] For example, Figure 3 is a flow chart of another optional data comparison method according to an embodiment of the present application, such as Figure 3 The data comparison includes but is not limited to the following steps:
[0067] S1, input left source data (corresponding to the first data source file mentioned above) and right source data (corresponding to the second data source file mentioned above);
[0068] S2, input comparison rules, where the comparison rules are the rules used when comparing two source data;
[0069] S3, performing a unified comparison operation on the left source data and the right source data;
[0070] S4, output the left result (corresponding to the first set of comparison results) and the right result (corresponding to the second set of comparison results);
[0071] S5, input warehousing rules;
[0072] S6, unified storage;
[0073] S7, outputting the left data to be cancelled and the right data to be cancelled;
[0074] S8, input cancellation rules;
[0075] S9, executing a unified cancellation operation;
[0076] S10, outputting the cancellation abnormal data.
[0077] Through this embodiment, the first data source file and the second data source file are divided into a first group of data fragments and a second group of data fragments respectively, and in response to the first comparison task, the first group of data fragments and the second group of data fragments are respectively compared according to the corresponding relationship between the fragments to obtain a first group of comparison results, and a cancellation operation is performed on the first group of comparison results and the second group of comparison results to generate a target comparison result. The first data source file and the second data source file are divided into fragments and then compared. At the same time, multiple devices are used to compare the first source file and the second source file, and then a cancellation operation is performed on the comparison results, thereby achieving the technical effects of balancing device loads, improving data comparison efficiency, and improving storage efficiency, thereby solving the technical problem of low data comparison efficiency.
[0078] As an optional scheme, in response to the first comparison task, the comparison operation is performed on the first group of data slices and the second group of data slices according to the correspondence between the slices to obtain a first group of comparison results, including: obtaining the first document identification of each data in the first data slice and the second document identification of each data in the second data slice; when there are first data and second data with the same first document identification and second document identification, comparing the comparison fields of the first data and the second data; when the comparison fields of the first data and the second data are the same, and there are multiple first data and multiple second data, respectively merging the multiple first data and the multiple second data to generate third data and fourth data, wherein the third data corresponds to the first data slice, the fourth data corresponds to the second data slice, the value of the comparison field of the third data is the sum of the values of the comparison fields of the multiple first data, and the value of the comparison field of the fourth data is the sum of the values of the comparison fields of the multiple second data.
[0079] Optionally, in this embodiment, the first document identifier and the second document identifier may include but are not limited to order number, logistics order number, telephone number and other identifiers with unique attributes to identify data, which can be used to distinguish the first data from other data in the first data shard.
[0080] It should be noted that the above-mentioned first data may include but is not limited to data divided into the first data slice such as a certain bill data, a certain pay slip data, a certain waybill data, etc.; the above-mentioned second data may include but is not limited to data divided into the second data slice such as a certain bill data, a certain pay slip data, a certain waybill data, etc., wherein the document identifier of the first data is the same as the document identifier of the second data.
[0081] Optionally, in this embodiment, the above-mentioned comparison fields may include but are not limited to fields set in advance by relevant technical personnel based on prior experience for distinguishing corresponding columns for comparison. For example, the second column in the data can be set as the comparison field, and the third column in the data can also be set as the comparison field.
[0082] Optionally, in this embodiment, the third data may include but is not limited to data obtained by adding the comparison fields of data in the first data shard that have the same identifier and the same comparison field as the data in the second data shard, and the fourth data may include but is not limited to data obtained by adding the comparison fields of data in the second data shard that have the same identifier and the same comparison field as the data in the first data shard. For example, when the comparison fields of data 1 in data shard A and data 1 in data shard B are the same, and the comparison fields of data 2 in data shard A and data 2 in data shard B are the same, the comparison fields of data 1 and data 2 are added to generate data 3 and data 4, and data 3 is stored in data shard A as the comparison result of data shard A, and data 4 is stored in data shard B as the comparison result of data shard B.
[0083] As an optional scheme, when the comparison fields of the first data and the second data are the same, and there are multiple first data and second data, the multiple first data and the multiple second data are merged respectively to generate third data and fourth data, including: when the comparison fields of the first data and the second data are the same, and there are multiple first data and second data, obtaining the first merged field of the multiple first data and the second merged field of the multiple second data, wherein the first merged field represents the account book category and batch of the first data, and the second merged field represents the account book category and batch of the second data; when the first merged fields of the multiple first data are the same, and the second merged fields of the multiple second data are the same, merging the multiple first data and the multiple second data respectively to generate third data and fourth data.
[0084] Optionally, in this embodiment, the first merged field may include but is not limited to fields for indicating the first data book category, batch, user, etc., and the second merged field may include but is not limited to fields for indicating the second data book category and batch.
[0085] Optionally, in this embodiment, when the first merge fields of multiple first data are the same, and the second merge fields of multiple second data are the same, the multiple first data and the multiple second data are merged respectively to generate third data and fourth data. It can be understood that, for example, when the comparison fields of data 1 in data shard A and data 1 in data shard B are the same, and the comparison fields of data 2 in data shard A and data 2 in data shard B are the same, and the merge fields of data 1 and data 2 in data shard A are the same, the comparison fields of data 1 and data 2 in data shard A are added to generate data 3, and the comparison fields of data 1 and data 2 in data shard B are added to generate data 4.
[0086] As an optional solution, after obtaining the first document identifier of each data in the first data shard and the second document identifier of each data in the second data shard, the above method also includes: sorting the data in the first data shard and the second data shard according to the first document identifier and the second document identifier to obtain a first repeated data set and a second repeated data set, wherein the first repeated data set represents a data set composed of data with the same first document identifier in the first data shard, and the second repeated data set represents a data set composed of data with the same second document identifier in the second data shard; traversing the first data shard and the second data shard, and determining comparison abnormal data according to the first repeated data set and the second repeated data set, wherein the target comparison result includes the comparison abnormal data.
[0087] Optionally, in this embodiment, the first repeated data set may include but is not limited to data that appears repeatedly in the first data shard, and the second repeated data set may include but is not limited to data that appears repeatedly in the second data shard. For example, if two data 1 appear in the first data shard, then data 1 is put into the first repeated data set, wherein the two data 1 can be understood as two data with the same document identifier.
[0088] It should be noted that the above-mentioned method of sorting the data in the first data slice and the second data slice according to the first document identifier and the second document identifier may include but is not limited to sorting the order number value from large to small or small to large, and the order number generation time from front to back or from back to front.
[0089] Optionally, in this embodiment, the above-mentioned comparison abnormal data may include but is not limited to data in the above-mentioned first repeated data set or the second repeated data set.
[0090] It should be noted that the above-mentioned method of traversing the first data shard and the second data shard may include but is not limited to performing sequential traversal on the first data shard while performing random traversal on the second data shard, performing sequential traversal on the first data shard while performing sequential traversal on the second data shard, performing random traversal on the first data shard while performing random traversal on the second data shard, and performing random traversal on the first data shard while performing sequential traversal on the second data shard. The above-mentioned traversal on the first data shard and the second data shard to determine the comparison abnormal data according to the first duplicate data set and the second duplicate data set can be understood as determining the data appearing in the first duplicate data set and the second duplicate data set as the comparison abnormal data.
[0091] As an optional solution, the first data source file and the second data source file are divided into a first group of data shards and a second group of data shards respectively, including: obtaining a first parameter for each data file in the first data source file and a second parameter for each data file in the second data source file, wherein the first parameter and the second parameter are unique identifiers of the data files; obtaining the number of shards of a target shard set, wherein the target shard set includes shards that are currently allowed to store data shards; according to the first parameter, the second parameter and the number of shards, the first data source file and the second data source file are divided into a first group of data shards and a second group of data shards respectively, and compressed and stored in the first shard and the second shard, wherein the first shard is determined by the first parameter and the remainder of the number of shards, and the second shard is determined by the second parameter and the remainder of the number of shards, and the target shard set includes the first shard and the second shard.
[0092] Optionally, in this embodiment, the above-mentioned first parameter may include but is not limited to the basis for data segmentation of the first data source file, which may include but is not limited to the last digit of the single number, and the above-mentioned second parameter may include but is not limited to the basis for data segmentation of the second data source file, which may include but is not limited to the last digit of the single number.
[0093] Optionally, in this embodiment, the target shard set may include but is not limited to a shard set pre-set for storing shard data, for example, a set consisting of shards of the first data source file and the second data source file after sharding.
[0094] Optionally, in this embodiment, the above-mentioned first shard is used to store first shard data, and the first shard data may include but is not limited to data obtained by compressing the first group of data shards, wherein the memory occupied by the first shard data is smaller than the memory occupied by the first group of data shards; the above-mentioned second shard is used to store second shard data, and the second shard data may include but is not limited to data obtained by compressing the second group of data shards, wherein the memory occupied by the second shard data is smaller than the memory occupied by the second group of data shards.
[0095] It should be noted that the above-mentioned first fragment is determined by the first parameter and the remainder of the number of fragments, which can be understood as, for example, when the first parameter of data A is 33 and the number of fragments is 8, the remainder is 1. At this time, the data A will be stored in the fragment with identification bit 1.
[0096] As an optional scheme, after dividing the first data source file and the second data source file into the first group of data shards and the second group of data shards respectively according to the first parameter, the second parameter and the number of shards, the method also includes: when the first data shard includes data shard details and data shard summaries, uploading the data shard details to the first cluster and the second cluster, and then uploading the data shard summaries, wherein the first data shard is deemed to have been successfully uploaded when any cluster of the first cluster and the second cluster has received the data shard summary, wherein the data shard details include the values of each field of each data in the first data shard, and the data shard summary includes the summary of the target field values of each data in the first data shard; before performing comparison operations on the first group of data shards and the second group of data shards according to the corresponding relationship between the shards to obtain the first group of comparison results, downloading the data shard summary, and downloading the data shard details when the data shard summary is successfully downloaded.
[0097] Optionally, in this embodiment, the above-mentioned data shard details may include but are not limited to transaction amount, initiator, recipient, transaction type, etc., which are used to represent details of data information; the above-mentioned data shard summary may include but are not limited to the details obtained by summarizing the detailed information in the data shards, and the memory occupied by the data shard summary is smaller than the memory occupied by the data shard details.
[0098] Optionally, in this embodiment, the first cluster may include but is not limited to a cluster such as an HDFS cluster for splitting large files into small file blocks and storing them on a machine. The second cluster may include but is not limited to a cluster for storing data that is the same as or different from the first cluster.
[0099] It should be noted that when any cluster in the above-mentioned first cluster and second cluster has completed receiving the data shard summary, it is considered that the first data shard has been uploaded successfully. For example, when the first cluster has received the data shard details and the data shard summary, and the second cluster is still receiving the data shard summary, it is considered that the first data shard has been uploaded successfully, and vice versa.
[0100] It should be noted that when uploading data, the data segment summary is uploaded first and then the data segment details are uploaded. When downloading data, the data segment summary is downloaded first and then the data segment details are downloaded.
[0101] As an optional scheme, in response to the first comparison task, a comparison operation is performed on the first group of data shards and the second group of data shards, including: in response to the first comparison task, when the data shard summary includes a signature field, the signature field is verified to obtain a target verification result; when the target verification result indicates that the verification is successful, a comparison operation is performed on the first group of data shards and the second group of data shards.
[0102] Optionally, in this embodiment, the above-mentioned signature field may include but is not limited to a field encrypted by a public key. It should be noted that the above-mentioned data segment summary may include but is not limited to a value obtained after encryption by a public key, which can be obtained after decryption by a private key.
[0103] Optionally, in this embodiment, the above-mentioned target verification result may include but is not limited to indicating verification success or verification failure.
[0104] It should be noted that, in the case where the data shard summary includes a signature field, the signature field is verified, and obtaining the target verification result can be understood as, only when the security verification is successfully performed can the data shard summary and data shard detail data be downloaded for performing the comparison task. If the target result indicates a verification failure, it means that the current state is unsafe and the data comparison task cannot be performed.
[0105] As an optional solution, the method further includes: in response to the first comparison task, performing a comparison operation on the first group of data shards and the second group of data shards respectively according to the corresponding relationship between the shards, and before or after obtaining the first group of comparison results, dividing the third data source file and the fourth data source file into a third group of data shards and a fourth group of data shards respectively, wherein the third group of data shards and the fourth group of data shards have the same number of shards, the third data source file and the fourth data source file are from the same batch, and are data source files to be compared from different batches than the first data source file and the second data source file; in response to the second comparison task, performing a comparison operation on the third group of data shards respectively according to the corresponding relationship between the shards, and before or after obtaining the first group of comparison results, dividing the third data source file and the fourth data source file into a third group of data shards and a fourth group of data shards respectively. The shards and the fourth group of data shards are respectively compared according to the corresponding relationship between the shards to obtain a second group of comparison results, wherein the second comparison task is used to instruct the comparison of the fifth data shard and the sixth data shard on the third device, and the comparison of the seventh data shard and the eighth data shard on the fourth device, the fifth data shard has a corresponding relationship with the seventh data shard, the sixth data shard has a corresponding relationship with the eighth data shard, the third data source file includes the fifth data shard and the seventh data shard, and the fourth data source file includes the sixth data shard and the eighth data shard; a cancel operation is performed on the first group of comparison results and the second group of comparison results to generate a target comparison result.
[0106] Optionally, in this embodiment, the third data source file and the fourth data source file may include but are not limited to data files in the form of bills, order forms, etc. It should be noted that the third data source file and the fourth data source file may include but are not limited to data source files from the same batch from different platforms, and the third data source file and the fourth data source file are in the same form. For example, it can be understood that the third data source file is a bill, and the fourth data source file is also a bill.
[0107] Optionally, in this embodiment, the third group of data shards may include but is not limited to those obtained by dividing the third data source file into equal parts, and the fourth group of data shards may include but is not limited to those obtained by dividing the fourth data source file into equal parts.
[0108] It should be noted that the number of the third group of data shards and the fourth group of data shards is the same, but the data size contained in each data shard in the third group of data shards and the data size contained in each data shard in the fourth group of data shards can be the same or different. For example, data source A and data source B are divided into two data shards respectively, and data shard A1 and data shard A2 are obtained by dividing data source A, that is, data shard A1 and data shard A2 constitute the third group of data shards, and the data size included in data shard A1 and data shard A2 is the same; data source B is divided into data shard B1 and data shard B2, that is, data shard B1 and data shard B2 constitute the fourth group of data shards, and the data size included in data shard B1 and data shard B2 is different.
[0109] Optionally, in this embodiment, the second comparison task may include but is not limited to the task of comparing the third data source file and the fourth data source file on the third device and the fourth device, that is, the task of comparing the third group of data slices and the fourth group of data slices on the third device and the fourth device, that is, the task of comparing the fifth data slice and the sixth data slice having a corresponding relationship on the third device, and the task of comparing the seventh data slice and the eighth data slice having a corresponding relationship on the fourth device.
[0110] In an exemplary embodiment, the third device and the fourth device may include but are not limited to devices for performing data comparison operations, wherein the third device and the fourth device are two different devices, and the third device and the fourth device may include but are not limited to performing the comparison operation simultaneously.
[0111] Optionally, in this embodiment, the form of the second group of comparison results may include but is not limited to being the same as the third source file and the fourth source file, and the second group of comparison results may include but is not limited to being summarized by comparing multiple pairs of corresponding data slices.
[0112] It should be noted that the above-mentioned comparison operation is performed on the third group of data slices and the fourth group of data slices according to the correspondence between the slices, and the second group of comparison results can be understood as comparing the data slices with the same identifier in the third group of data slices and the fourth group of data slices.
[0113] It should be noted that the cancellation operation is performed on the first group of comparison results and the second group of comparison results to generate the target comparison results, which can be understood as further performing a comparison operation on the first group of comparison results and the second group of comparison results. For example, the comparison results of different batches at different times are further compared. If the comparison is successful, the data that has been successfully cancelled is deleted. If the comparison fails, the data fragment is used as the data to be cancelled, waiting for the next cancellation comparison. If the comparison fails due to timeout or the comparison fields are consistent but the key information is inconsistent, it is listed as abnormal cancellation data.
[0114] In an exemplary embodiment, if the content of the comparison is the order amount, the first group of comparison results includes the shard comparison result 1, and the second group of comparison results includes the shard comparison result 2, wherein the first group of comparison results is the result obtained by comparing the first batch of data source files, and the second group of comparison results is the result obtained by comparing the second batch of data source files. When the cancellation operation is performed on the first group of comparison results and the second group of comparison results, if the shard comparison result 1 and the shard comparison result 2 are consistent in various information such as the order number and the order amount after comparison, The cancellation is successful, and the shard comparison result 1 and the shard comparison result 2 are deleted from the cancellation data; if the shard comparison result 1 and the shard comparison result 2 are consistent in order number but inconsistent in order amount after comparison, the cancellation fails, and the shard comparison result 1 and the shard comparison result 2 are used as the data to be cancelled and wait for the next cancellation operation; if the shard comparison result 1 and the shard comparison result 2 are consistent in order number and order amount after comparison, but inconsistent in key information such as user account, the shard comparison result 1 and the shard comparison result 2 are used as abnormal cancellation data.
[0115] Optionally, in this embodiment, the target comparison result may include but is not limited to a comparison result consisting of the data to be cancelled and the abnormal data cancelled.
[0116] It should be noted that the above-mentioned target comparison result is used to indicate whether there is a difference between the first group of comparison results and the second group of comparison results. It can be understood that the first group of comparison results and the second group of comparison results are cancelled to obtain the target comparison result. When neither the cancelled abnormal data nor the above-mentioned data to be cancelled exists, it indicates that there is no difference between the first group of comparison results and the second group of comparison results. Conversely, when the cancelled abnormal data or the above-mentioned data to be cancelled exists, it indicates that there is a difference between the first group of comparison results and the second group of comparison results.
[0117] As an optional solution, a cancellation operation is performed on the first group of comparison results and the second group of comparison results to generate a target comparison result, including: determining a comparison result set and a third document identifier of each data in the comparison result set based on the first group of comparison results and the second group of comparison results; marking data with the same third document identifier in any comparison result in the comparison result set as canceled abnormal data, wherein the target comparison result includes the canceled abnormal data; marking data with the same third document identifier and the same comparison field in different comparison results as canceled successfully data, wherein the target comparison result includes the canceled successfully data; marking data that any comparison result in the comparison result set has but other comparison results do not have as data to be cancelled, wherein the target comparison result includes the data to be cancelled.
[0118] Optionally, in this embodiment, the above-mentioned comparison result set may include but is not limited to a result set obtained by aggregating and storing the first group of comparison results and the second group of data results, and the comparison result set is used for subsequent cancellation operations.
[0119] Optionally, in this embodiment, the third document identifier may include but is not limited to the identifier of the data in the comparison result set, and may include but is not limited to the order number, logistics order number, etc.
[0120] Optionally, in this embodiment, the above-mentioned marking of data with the same third document identifier in any comparison result in the comparison result set as canceled abnormal data can be understood as comparing the document identifier of the data in any comparison result in the comparison result set, and if there are multiple data with the same document identifier in the comparison result, the multiple data are marked as canceled abnormal data.
[0121] Optionally, in this embodiment, marking the data that any comparison result in the comparison result set has but other comparison results do not have as data to be cancelled can be understood as, for example, if only comparison result A contains data 1, then data 1 is marked as data to be cancelled.
[0122] As an optional scheme, in response to the first comparison task, the comparison operation is performed on the first group of data shards and the second group of data shards respectively according to the correspondence between the shards, and before obtaining the first group of comparison results, the method also includes: pre-setting the first comparison task, wherein the first comparison task includes a preset scheduling time; when the preset scheduling time arrives, controlling multiple devices to obtain the first comparison task, and when the first device and the second device obtain the first comparison task, in response to the first comparison task, comparing the first data shard and the second data shard on the first device, and comparing the third data shard and the fourth data shard on the second device, to obtain the first group of comparison results.
[0123] Optionally, in this embodiment, the preset scheduling time may include but is not limited to 0:01am, 6:00am and other times preset by relevant technical personnel and may be changed according to actual needs.
[0124] It should be noted that the above-mentioned control of multiple devices to obtain the first comparison task can be understood as that when the first comparison task is issued, multiple devices simultaneously seize the first comparison task record, and run the task if the seizure is successful, and exit if it fails.
[0125] For example, when four devices are given two comparison tasks to perform at 5 p.m. tomorrow, the four devices (device A, device B, device C, and device D) will preempt the two comparison task records starting at 5 p.m. the next day. Device A, which first grabs task one, will set a task lock for task one, and device B, which grabs task two, will set a task lock for task two. At this time, devices C and D fail to preempt and exit, and devices A and B will execute the two tasks.
[0126] The following is a further explanation of this application with reference to specific examples:
[0127] Different business scenarios have different data, and each type of data has different characteristics. The data needs to be pulled, processed, compressed, and sharded in a unified manner. The sharding maps each piece of data according to specific rules (such as taking the modulus based on the last digit of the order number), and outputs the corresponding data source shard file and the corresponding signature summary file;
[0128] The shard mapping function is as follows:
[0129] shard_id = HASH(key_words)
[0130] For example, if the number of shards is shard_number and the last two digits of the order number are tail, the calculation of the shard number shard_id is as follows:
[0131] shard_id=tail%shard_number
[0132] Large-scale data can be split into more pieces (such as Figure 4 For example, 1 million data can be split into 10 pieces according to the last digit of the number, 10 million data can be split into 100 pieces according to the last digit of the number, and so on;
[0133] Compress the shard files before storing them, which can save storage space and reduce the network overhead of transmission. When troubleshooting problems, you only need to pull the corresponding shard files for viewing;
[0134] After the split is completed, the shard files need to be uploaded to the HDFS distributed file system cluster for downstream use. The upload process is to upload the detailed file first, and then upload the signature summary file. Because the detailed file is generally large and the signature summary file is small, the downstream pulls it in reverse order and downloads the signature summary file first. If the download fails, it is considered that the upstream has not succeeded yet, reducing the possibility of failure to download the detailed file. When uploading files, they will be uploaded to two HDFS clusters. If one cluster fails, it will be retried by default. If it fails all the time, as long as one cluster can upload successfully, the task is considered successful. When downloading files, the cluster closest to the local machine is downloaded first.
[0135] Each downstream link strictly verifies whether the signature summary file and detail file are legal. If not, the verification fails.
[0136] Different business scenarios have different verification requirements. The same type of data may be involved in multiple different types of verification, such as Figure 5 As shown, data source 1 and data source 2 participate in the first type of verification, and data source 2 and data source 3 participate in the second type of verification. After the data sources on both sides of the verification are ready, the downstream unified pre-comparison module pulls the shard files on both sides of the corresponding shard according to the rules, verifies the signature summary information of the detail file, and performs pre-comparison according to the rules after the verification passes. During the pre-comparison, the data on both sides are compared for equivalence according to the configured rules, and the records that are successfully compared are merged according to the configured merge rules. The records that are unsuccessful in the comparison are saved as they are in the result, and then the pre-comparison results are output. The pre-comparison results are also in the form of files, including data details and signature summary files. After the two types of files are generated, they are also uploaded to the HDFS cluster.
[0137] Each unified pre-matching task and cancellation task can be run randomly on multiple machines, which will make the overall execution faster and take less time, and each task consumes less memory and CPU resources.
[0138] The comparison compression is as follows Figure 6 As shown, the data on both sides have 4 columns respectively. According to the configuration rules, the unique order number is the first column. In this case, the data on both sides are sorted according to the first column first, and then the duplicate data on both sides are found respectively. Then the data sets on both sides are traversed. For the data on both sides, it is first determined whether they are in the duplicate set. If so, it is listed in the comparison exception and does not participate in the comparison. If not, the corresponding fields are compared one by one according to the configured comparison fields. Here, the second column is compared. If the comparison is unsuccessful, it is listed in the comparison exception. If the comparison is successful, the records with successful comparison and the same merge fields are combined into one according to the merge rules. Finally, the merged records are recorded in one entry on each side, with the same order number and the added amount.
[0139] Bilateral comparison is to find the differences between the two sides. The rules are as follows:
[0140] A xor B=(AB)∪(BA)
[0141] Pre-matching only compares the data on both sides of the same batch. For data across different batches, a unified cancellation module is used to cancel the data again, and the final comparison result is output, such as Figure 7 shown.
[0142] The overall application processing process is as follows Figure 3 shown.
[0143] The comparison results may include, but are not limited to, successful comparison, unsuccessful comparison (field inconsistency, duplication), unilateral record, normal cross-batch, etc. (e.g. Figure 8 shown).
[0144] All kinds of tasks, such as unified pre-matching and cancellation, are managed through unified scheduling tasks. Tasks are generated in advance according to the rules. When the estimated scheduling time comes, multiple machines simultaneously preempt the same task record. If the preemption succeeds, the task will be run. If the preemption fails, the task will be exited. The overall architecture is as follows: Fig. 9 shown.
[0145] The above is only an example, and this application does not make any specific limitation.
[0146] It is understandable that in the specific implementation of this application, related data such as user information is involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.
[0147] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0148] According to another aspect of the embodiment of the present application, a data comparison device for implementing the above data comparison method is also provided. Fig.10 As shown, the device comprises:
[0149] A division module 1002 is used to divide the first data source file and the second data source file into a first group of data shards and a second group of data shards respectively, wherein the first group of data shards and the second group of data shards have the same number of shards, and the first data source file and the second data source file are data source files to be compared from the same batch;
[0150] The comparison module 1004 is used to, in response to the first comparison task, respectively perform a comparison operation on the first group of data shards and the second group of data shards according to the corresponding relationship between the shards to obtain a first group of comparison results, wherein the first comparison task is used to instruct to compare the first data shard and the second data shard on the first device, and to compare the third data shard and the fourth data shard on the second device, the first data shard and the second data shard have a corresponding relationship, the third data shard and the fourth data shard have a corresponding relationship, the first data source file includes the first data shard and the third data shard, and the second data source file includes the second data shard and the fourth data shard;
[0151] The cancel module 1006 is used to cancel the first group of comparison results and the second group of comparison results to generate a target comparison result, wherein the data source files used by the second group of comparison results and the first group of comparison results belong to different batches, and the target comparison result is used to indicate whether there is a difference between the first group of comparison results and the second group of comparison results.
[0152] As an optional solution, the device also includes: obtaining a first document identifier for each data in the first data slice and a second document identifier for each data in the second data slice; when there are first data and second data with the same first document identifier and second document identifier, comparing the comparison fields of the first data and the second data; when the comparison fields of the first data and the second data are the same, and there are multiple first data and multiple second data, respectively merging the multiple first data and the multiple second data to generate third data and fourth data, wherein the third data corresponds to the first data slice, the fourth data corresponds to the second data slice, the value of the comparison field of the third data is the sum of the values of the comparison fields of the multiple first data, and the value of the comparison field of the fourth data is the sum of the values of the comparison fields of the multiple second data.
[0153] As an optional solution, the device also includes: when the comparison fields of the first data and the second data are the same, and there are multiple first data and second data, obtaining the first merged fields of the multiple first data and the second merged fields of the multiple second data, wherein the first merged field represents the account book category and batch of the first data, and the second merged field represents the account book category and batch of the second data; when the first merged fields of the multiple first data are the same, and the second merged fields of the multiple second data are the same, merging the multiple first data and the multiple second data respectively to generate third data and fourth data.
[0154] As an optional solution, the device also includes: sorting the data in the first data shard and the second data shard according to the first document identifier and the second document identifier to obtain a first repeated data set and a second repeated data set, wherein the first repeated data set represents a data set consisting of data with the same first document identifier in the first data shard, and the second repeated data set represents a data set consisting of data with the same second document identifier in the second data shard; traversing the first data shard and the second data shard, and determining comparison abnormal data according to the first repeated data set and the second repeated data set, wherein the target comparison result includes the comparison abnormal data.
[0155] As an optional solution, the device also includes: obtaining a first parameter for each data file in the first data source file and a second parameter for each data file in the second data source file, wherein the first parameter and the second parameter are unique identifiers of the data files; obtaining the number of shards of the target shard set, wherein the target shard set includes shards that are currently allowed to store data shards; dividing the first data source file and the second data source file into a first group of data shards and a second group of data shards respectively according to the first parameter, the second parameter and the number of shards, and compressing and storing them in the first shard and the second shard, wherein the first shard is determined by the first parameter and the remainder of the number of shards, and the second shard is determined by the second parameter and the remainder of the number of shards, and the target shard set includes the first shard and the second shard.
[0156] As an optional scheme, the device also includes: when the first data shard includes data shard details and data shard summary, uploading the data shard details to the first cluster and the second cluster, and then uploading the data shard summary, wherein the first data shard is deemed to have been successfully uploaded when any cluster of the first cluster and the second cluster has received the data shard summary, wherein the data shard details include the values of each field of each data in the first data shard, and the data shard summary includes the summary of target field values of each data in the first data shard; before performing comparison operations on the first group of data shards and the second group of data shards according to the correspondence between the shards and obtaining the first group of comparison results, downloading the data shard summary, and downloading the data shard details when the data shard summary is successfully downloaded.
[0157] As an optional solution, the device also includes: in response to the first comparison task, when the data shard summary includes the signature field, verifying the signature field to obtain a target verification result; when the target verification result indicates that the verification is successful, performing a comparison operation on the first group of data shards and the second group of data shards.
[0158] As an optional solution, the device further includes: in response to the first comparison task, performing a comparison operation on the first group of data slices and the second group of data slices according to the corresponding relationship between the slices, and before or after obtaining the first group of comparison results, dividing the third data source file and the fourth data source file into a third group of data slices and a fourth group of data slices respectively, wherein the third group of data slices and the fourth group of data slices have the same number of slices, the third data source file and the fourth data source file are from the same batch, and are data source files to be compared from different batches than the first data source file and the second data source file; in response to the second comparison task, performing a comparison operation on the third group of data slices according to the corresponding relationship between the slices, and before or after obtaining the first group of comparison results, dividing the third data source file and the fourth data source file into a third group of data slices and a fourth group of data slices respectively. The shards and the fourth group of data shards are respectively compared according to the corresponding relationship between the shards to obtain a second group of comparison results, wherein the second comparison task is used to instruct the comparison of the fifth data shard and the sixth data shard on the third device, and the comparison of the seventh data shard and the eighth data shard on the fourth device, the fifth data shard has a corresponding relationship with the seventh data shard, the sixth data shard has a corresponding relationship with the eighth data shard, the third data source file includes the fifth data shard and the seventh data shard, and the fourth data source file includes the sixth data shard and the eighth data shard; a cancel operation is performed on the first group of comparison results and the second group of comparison results to generate a target comparison result.
[0159] As an optional solution, the device also includes: determining a comparison result set and a third document identifier of each data in the comparison result set based on the first group of comparison results and the second group of comparison results; marking data with the same third document identifier in any comparison result in the comparison result set as canceled abnormal data, wherein the target comparison result includes the canceled abnormal data; marking data with the same third document identifier and the same comparison field in different comparison results as canceled successfully data, wherein the target comparison result includes the canceled successfully data; marking data that any comparison result in the comparison result set has but other comparison results do not have as data to be canceled, wherein the target comparison result includes the data to be canceled.
[0160] As an optional scheme, the device is also used to: pre-set a first comparison task, wherein the first comparison task includes a preset scheduling time; when the preset scheduling time is reached, control multiple devices to obtain the first comparison task, and when the first device and the second device obtain the first comparison task, respond to the first comparison task, compare the first data slice and the second data slice on the first device, and compare the third data slice and the fourth data slice on the second device to obtain a first set of comparison results.
[0161] According to one aspect of the present application, a computer program product is provided, the computer program product comprising a computer program / instruction, the computer program / instruction comprising a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication part 1109, and / or installed from a removable medium 1111. When the computer program is executed by the central processor 1101, various functions provided in the embodiments of the present application are executed.
[0162] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0163] Fig.11 The structure block diagram of a computer system for implementing an electronic device according to an embodiment of the present application is schematically shown.
[0164] It should be noted that Fig.11 The computer system 1100 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0165] like Fig.11 As shown, the computer system 1100 includes a central processing unit 1101 (CPU), which can perform various appropriate actions and processes according to the program stored in the read-only memory 1102 (ROM) or the program loaded from the storage part 1108 to the random access memory 1103 (RAM). Various programs and data required for system operation are also stored in the random access memory 1103. The central processing unit 1101, the read-only memory 1102 and the random access memory 1103 are connected to each other through a bus 1104. An input / output interface 1105 (Input / Output interface, i.e., I / O interface) is also connected to the bus 1104.
[0166] The following components are connected to the input / output interface 1105: an input section 1106 including a keyboard, a mouse, etc.; an output section 1107 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1108 including a hard disk, etc.; and a communication section 1109 including a network interface card such as a LAN card, a modem, etc. The communication section 1109 performs communication processing via a network such as the Internet. A drive 1110 is also connected to the input / output interface 1105 as needed. A removable medium 1111, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1110 as needed so that a computer program read therefrom is installed into the storage section 1108 as needed.
[0167] In particular, according to an embodiment of the present application, the process described in each method flow chart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer readable medium, and the computer program contains a program code for executing the method shown in the flow chart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1109, and / or installed from the removable medium 1111. When the computer program is executed by the central processor 1101, various functions defined in the system of the present application are executed.
[0168] According to another aspect of the embodiment of the present application, an electronic device for implementing the above data comparison method is also provided. The electronic device may be Figure 1 The terminal device or server shown in the figure. This embodiment is described by taking the electronic device as a terminal device as an example. Fig.12 As shown, the electronic device includes a memory 1202 and a processor 1204. The memory 1202 stores a computer program, and the processor 1204 is configured to execute the steps in any of the above method embodiments through the computer program.
[0169] Optionally, in this embodiment, the electronic device may be located in at least one network device among a plurality of network devices of a computer network.
[0170] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:
[0171] S1, dividing the first data source file and the second data source file into a first group of data shards and a second group of data shards respectively, wherein the first group of data shards and the second group of data shards have the same number of shards, and the first data source file and the second data source file are data source files to be compared from the same batch;
[0172] S2, in response to the first comparison task, respectively performing comparison operations on the first group of data shards and the second group of data shards according to the corresponding relationship between the shards, to obtain a first group of comparison results, wherein the first comparison task is used to instruct to compare the first data shard and the second data shard on the first device, and to compare the third data shard and the fourth data shard on the second device, the first data shard and the second data shard have a corresponding relationship, the third data shard and the fourth data shard have a corresponding relationship, the first data source file includes the first data shard and the third data shard, and the second data source file includes the second data shard and the fourth data shard;
[0173] S3, canceling the first group of comparison results and the second group of comparison results to generate a target comparison result, wherein the data source files used by the second group of comparison results and the first group of comparison results belong to different batches, and the target comparison result is used to indicate whether there is a difference between the first group of comparison results and the second group of comparison results.
[0174] Alternatively, a person skilled in the art may understand that: Fig.12 The structure shown is for illustration only, and the electronic device may also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (MID), a PAD, and other terminal devices. Fig.12 The electronic device and the electronic equipment described above are not limited in structure. Fig.12 More or fewer components (such as network interfaces, etc.) as shown in, or with Fig.12 Different configurations are shown.
[0175] Among them, the memory 1202 can be used to store software programs and modules, such as the program instructions / modules corresponding to the data comparison method and device in the embodiments of the present application. The processor 1204 executes various functional applications and data processing by running the software programs and modules stored in the memory 1202, that is, to implement the above-mentioned data comparison method. The memory 1202 may include a high-speed random access memory, and may also include a 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 1202 may further include a memory remotely located relative to the processor 1204, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. Among them, the memory 1202 can be specifically, but not limited to, used for information such as data. As an example, such as Fig.12As shown, the above-mentioned memory 1202 may include but is not limited to the division module 1002, the comparison module 1004, and the cancellation module 1006 in the above-mentioned data comparison device. In addition, it may also include but is not limited to other module units in the above-mentioned data comparison device, which will not be repeated in this example.
[0176] Optionally, the transmission device 1206 is used to receive or send data via a network. Specific examples of the network may include a wired network and a wireless network. In one example, the transmission device 1206 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices and routers via a network cable so as to communicate with the Internet or a local area network. In one example, the transmission device 1206 is a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0177] In addition, the electronic device further includes: a display 1208 for displaying the slice summary information; and a connection bus 1210 for connecting various module components in the electronic device.
[0178] In other embodiments, the terminal device or server may be a node in a distributed system, wherein the distributed system may be a blockchain system, and the blockchain system may be a distributed system formed by connecting the multiple nodes through network communication. Among them, the nodes may form a peer-to-peer (P2P, Peer To Peer) network, and any form of computing device, such as a server, terminal and other electronic devices, may become a node in the blockchain system by joining the peer-to-peer network.
[0179] According to one aspect of the present application, a computer-readable storage medium is provided, and a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the data comparison method provided in various optional implementations of the above-mentioned data comparison aspects.
[0180] Optionally, in this embodiment, the computer-readable storage medium may be configured to store a computer program for performing the following steps:
[0181] S1, dividing the first data source file and the second data source file into a first group of data shards and a second group of data shards respectively, wherein the first group of data shards and the second group of data shards have the same number of shards, and the first data source file and the second data source file are data source files to be compared from the same batch;
[0182] S2, in response to the first comparison task, respectively performing comparison operations on the first group of data shards and the second group of data shards according to the corresponding relationship between the shards, to obtain a first group of comparison results, wherein the first comparison task is used to instruct to compare the first data shard and the second data shard on the first device, and to compare the third data shard and the fourth data shard on the second device, the first data shard and the second data shard have a corresponding relationship, the third data shard and the fourth data shard have a corresponding relationship, the first data source file includes the first data shard and the third data shard, and the second data source file includes the second data shard and the fourth data shard;
[0183] S3, canceling the first group of comparison results and the second group of comparison results to generate a target comparison result, wherein the data source files used by the second group of comparison results and the first group of comparison results belong to different batches, and the target comparison result is used to indicate whether there is a difference between the first group of comparison results and the second group of comparison results.
[0184] Optionally, in this embodiment, a person of ordinary skill in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by instructing hardware related to the terminal device through a program, and the program may be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc.
[0185] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0186] If the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above computer-readable storage medium. Based on this understanding, the technical solution of the present application, 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, which is stored in a storage medium and includes several instructions for enabling one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application.
[0187] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0188] In the several embodiments provided in the present application, it should be understood that the disclosed client can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0189] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0190] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0191] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A data comparison method, characterized in that: include: Divide the first data source file and the second data source file into a first group of data shards and a second group of data shards respectively, wherein the first group of data shards and the second group of data shards have the same number of shards, and the first data source file and the second data source file are data source files to be compared from the same batch; In response to a first comparison task, a comparison operation is performed on the first group of data shards and the second group of data shards respectively according to the correspondence between the shards to obtain a first group of comparison results, wherein the first comparison task is used to instruct to compare the first data shard and the second data shard on the first device, and to compare the third data shard and the fourth data shard on the second device, the first data shard and the second data shard have the correspondence, the third data shard and the fourth data shard have the correspondence, the first data source file includes the first data shard and the third data shard, and the second data source file includes the second data shard and the fourth data shard; A cancel operation is performed on the first group of comparison results and the second group of comparison results to generate a target comparison result, wherein the second group of comparison results and the data source file used by the first group of comparison results belong to different batches, and the target comparison result is used to indicate whether there is a difference between the first group of comparison results and the second group of comparison results.
2. The method according to claim 1, characterized in that In response to the first comparison task, the comparison operation is performed on the first group of data shards and the second group of data shards according to the corresponding relationship between the shards to obtain a first group of comparison results, including: Obtain a first document identifier for each data in the first data shard and a second document identifier for each data in the second data shard; In the case where there are first data and second data having the same first document identifier as the second document identifier, comparing comparison fields of the first data and the second data; When the comparison fields of the first data and the second data are the same, and there are multiple first data and multiple second data, the multiple first data and multiple second data are merged respectively to generate third data and fourth data, wherein the third data corresponds to the first data slice, the fourth data corresponds to the second data slice, the value of the comparison field of the third data is the sum of the values of the comparison fields of the multiple first data, and the value of the comparison field of the fourth data is the sum of the values of the comparison fields of the multiple second data.
3. The method according to claim 2, characterized in that The method further comprises: when the comparison fields of the first data and the second data are the same, and there are multiple first data and multiple second data, merging the multiple first data and the multiple second data to generate the third data and the fourth data, including: When the comparison fields of the first data and the second data are the same, and there are multiple first data and multiple second data, obtain multiple first merged fields of the first data and multiple second merged fields of the second data, wherein the first merged field indicates the account book category and batch of the first data, and the second merged field indicates the account book category and batch of the second data; When the first merged fields of a plurality of the first data are all the same and the second merged fields of a plurality of the second data are all the same, the plurality of the first data and the plurality of the second data are merged respectively to generate third data and fourth data.
4. The method according to claim 2, characterized in that: After obtaining the first document identifier of each data in the first data slice and the second document identifier of each data in the second data slice, the method further includes: Sort the data in the first data shard and the second data shard according to the first document identifier and the second document identifier to obtain a first repeated data set and a second repeated data set, wherein the first repeated data set represents a data set consisting of data with the same first document identifier in the first data shard, and the second repeated data set represents a data set consisting of data with the same second document identifier in the second data shard; The first data shard and the second data shard are traversed, and comparison abnormal data is determined according to the first duplicate data set and the second duplicate data set, wherein the target comparison result includes the comparison abnormal data.
5. The method according to claim 1, characterized in that The step of dividing the first data source file and the second data source file into a first group of data fragments and a second group of data fragments respectively comprises: Obtaining a first parameter of each data file in the first data source file and a second parameter of each data file in the second data source file, wherein the first parameter and the second parameter are unique identifiers of the data files; Obtaining the number of shards of a target shard set, wherein the target shard set includes shards that are currently allowed to store data shards; According to the first parameter, the second parameter and the number of shards, the first data source file and the second data source file are divided into a first group of data shards and a second group of data shards respectively, and compressed and stored in the first shard and the second shard, wherein the first shard is determined by the first parameter and the remainder of the number of shards, the second shard is determined by the second parameter and the remainder of the number of shards, and the target shard set includes the first shard and the second shard.
6. The method according to claim 5, characterized in that After dividing the first data source file and the second data source file into a first group of data shards and a second group of data shards respectively according to the first parameter, the second parameter and the number of shards, the method further includes: In the case where the first data shard includes data shard details and data shard summary, the data shard details are uploaded to the first cluster and the second cluster, and then the data shard summary is uploaded, wherein the first data shard is deemed to have been successfully uploaded when any one of the first cluster and the second cluster has received the data shard summary, wherein the data shard details include the value of each field of each data in the first data shard, and the data shard summary includes the summary of the target field value of each data in the first data shard; Before performing comparison operations on the first group of data shards and the second group of data shards according to the correspondence between the shards to obtain a first group of comparison results, download the data shard summary, and if the data shard summary is downloaded successfully, download the data shard details.
7. The method according to claim 6, characterized in that In response to the first comparison task, performing a comparison operation on the first group of data slices and the second group of data slices includes: In response to the first comparison task, when the data shard summary includes a signature field, verifying the signature field to obtain a target verification result; When the target verification result indicates that the verification is successful, a comparison operation is performed on the first set of data shards and the second set of data shards.
8. The method according to claim 1, characterized in that: The method further comprises: In response to the first comparison task, the comparison operation is performed on the first group of data shards and the second group of data shards respectively according to the corresponding relationship between the shards, and before or after the first group of comparison results are obtained, the third data source file and the fourth data source file are respectively divided into a third group of data shards and a fourth group of data shards, wherein the third group of data shards and the fourth group of data shards have the same number of shards, the third data source file and the fourth data source file are from the same batch, and are data source files to be compared from different batches than the first data source file and the second data source file; In response to the second comparison task, the comparison operation is respectively performed on the third group of data shards and the fourth group of data shards according to the correspondence between the shards to obtain the second group of comparison results, wherein the second comparison task is used to instruct to compare the fifth data shard and the sixth data shard on the third device, and to compare the seventh data shard and the eighth data shard on the fourth device, the fifth data shard and the seventh data shard have the correspondence, the sixth data shard and the eighth data shard have the correspondence, the third data source file includes the fifth data shard and the seventh data shard, and the fourth data source file includes the sixth data shard and the eighth data shard; A cancellation operation is performed on the first group of comparison results and the second group of comparison results to generate the target comparison result.
9. The method according to claim 8, characterized in that The performing a cancel operation on the first group of comparison results and the second group of comparison results to generate the target comparison result includes: Determine a comparison result set and a third document identifier of each data in the comparison result set according to the first group of comparison results and the second group of comparison results; Marking the data with the same third document identifier in any comparison result in the comparison result set as canceled abnormal data, wherein the target comparison result includes the canceled abnormal data; Marking the data with the same third document identifier and the same comparison field in different comparison results as successfully cancelled data, wherein the target comparison result includes the successfully cancelled data; Mark the data that any comparison result in the comparison result set has but other comparison results do not have as data to be cancelled, wherein the target comparison result includes the data to be cancelled.
10. The method according to claim 1, characterized in that In response to the first comparison task, the method further comprises: performing a comparison operation on the first group of data shards and the second group of data shards according to the corresponding relationship between the shards, before obtaining a first group of comparison results. Presetting the first comparison task, wherein the first comparison task includes a preset scheduling time; When the preset scheduling time is reached, multiple devices are controlled to obtain the first comparison task, and when the first device and the second device obtain the first comparison task, in response to the first comparison task, the first data slice and the second data slice are compared on the first device, and the third data slice and the fourth data slice are compared on the second device to obtain the first set of comparison results.
11. A data comparison device, characterized in that: include: a partitioning module, configured to partition the first data source file and the second data source file into a first group of data shards and a second group of data shards, respectively, wherein the first group of data shards and the second group of data shards have the same number of shards, and the first data source file and the second data source file are data source files to be compared from the same batch; a comparison module, configured to, in response to a first comparison task, respectively perform a comparison operation on the first group of data shards and the second group of data shards according to a correspondence between the shards to obtain a first group of comparison results, wherein the first comparison task is used to instruct to compare the first data shard and the second data shard on the first device, and to compare the third data shard and the fourth data shard on the second device, the first data shard and the second data shard have the correspondence, the third data shard and the fourth data shard have the correspondence, the first data source file includes the first data shard and the third data shard, and the second data source file includes the second data shard and the fourth data shard; A cancellation module is used to cancel the first group of comparison results and the second group of comparison results to generate a target comparison result, wherein the data source file used by the second group of comparison results and the first group of comparison results belongs to different batches, and the target comparison result is used to indicate whether there is a difference between the first group of comparison results and the second group of comparison results.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein the program can be executed by a terminal device or a computer to execute the method described in any one of claims 1 to 10.
13. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method described in any one of claims 1 to 10 are implemented.
14. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 10 through the computer program.
