WO2014180398A1 - 数据差异分析方法及装置 - Google Patents

数据差异分析方法及装置 Download PDF

Info

Publication number
WO2014180398A1
WO2014180398A1 PCT/CN2014/078564 CN2014078564W WO2014180398A1 WO 2014180398 A1 WO2014180398 A1 WO 2014180398A1 CN 2014078564 W CN2014078564 W CN 2014078564W WO 2014180398 A1 WO2014180398 A1 WO 2014180398A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
difference
hash table
comparison
source device
Prior art date
Application number
PCT/CN2014/078564
Other languages
English (en)
French (fr)
Inventor
刘美霞
魏霄鹏
程敏
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2014180398A1 publication Critical patent/WO2014180398A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

Definitions

  • the present invention relates to the field of computer software technologies, and in particular, to a data difference analysis method and apparatus.
  • BACKGROUND With the rapid development of the software industry, the interaction between systems becomes more and more frequent, the amount of interactive data is getting larger and larger, and the data consistency check and processing of participating parties becomes more and more important. Due to the systematic differences of the parties involved in the interaction, the diversity of data storage and the consistency of the data consistency check function are determined.
  • the existing data consistency test methods have the following problems: (1) Low test efficiency and long running time; (2) There is no unified reusable module, and data consistency check for each application is New development, wasting human resources.
  • the present invention provides a data difference analysis method and apparatus to solve at least the problems of low efficiency, long running time, and high development cost of the above data consistency check method.
  • a data difference analysis method including: acquiring first alignment data from a first data source device, acquiring second alignment data from a second data source device, and acquiring a first comparison And storing the first difference data in the first HASH table, and storing the second difference data in the second HASH table, where the first difference data is in the first comparison data
  • the data other than the common data, the second difference data is data other than the common data in the second comparison data.
  • the method before acquiring the first comparison data from the first data source device and acquiring the second comparison data from the second data source device, the method includes: reading the configuration information and performing an initialization process; wherein, the configuration information includes: the data difference The task startup time, the task end time of the data difference analysis, the device information of the first data source device, the device information of the second data source device, the data acquisition mode, the maximum storage space of the HASH table, the difference data storage mode, and the alarm mode And the difference data processing manner; the initialization program includes: constructing the first HASH table and the first HASH function according to the first KEY, and constructing the second HASH table and the second HASH function according to the second KEY, The structure of the first HASH table and the second HASH table are the same, and the first KEY and the second KEY have the same KEY value.
  • the configuration information includes: the data difference The task startup time, the task end time of the data difference analysis, the device information of the first data source device, the device information of the second data source device,
  • the method includes: acquiring first data from the first data source device, acquiring second data from the second data source device, and determining whether the first data and the second data are both required The complete data of the comparison is performed.
  • the result is YES, the first data is used as the first comparison data, and the second data is used as the second comparison data.
  • acquiring the common data of the first comparison data and the second comparison data comprises: inserting the first comparison data into the first HASH table according to the first KEY; reading the second comparison data one by one, according to the second KEY Determining whether the first identical data that is the same as the currently read data exists in the first HASH table, and if the determination result is yes, deleting the first identical data from the first HASH table, if the determination result is no , storing the current read data in the second HASH table; determining whether the second comparison data has been read, if it has been read, determining that all the first identical data is common data, if not, continue Perform a read operation.
  • the method includes: determining whether the first difference data exceeds the first difference data threshold, and determining the second difference Whether the data exceeds the second difference data threshold, and if at least one of the determination results is yes, the alarm is used to perform the alarm.
  • the method includes: performing difference when the difference data processing mode is that differential data processing is required The data processing includes: synchronizing the second difference data with the first difference data as a reference, or synchronizing the first difference data with the second difference data as a reference.
  • the device information of the first data source device includes: a first file transfer protocol FTP address, a first user name, a first user password, a first database type, a first database name, a first database address, and a first database password.
  • the device information of the second data source device includes: a second file transfer protocol FTP address, a second user name, a second user password, a second database type, a second database name, a second database address, and a second database password.
  • the data acquisition manner includes one of the following: an FTP active acquisition mode and an FTP passive acquisition mode.
  • the alarm mode includes one of the following: a short message alarm, a voice alarm, and a network management platform alarm.
  • a data difference analysis apparatus including: an obtaining module, configured to acquire first alignment data from a first data source device, and obtain second alignment data from a second data source device, And won Taking the common data of the first comparison data and the second comparison data; the storage module is configured to store the first difference data in the first HASH table, and store the second difference data in the second HASH table, where A difference data is data other than the common data in the first comparison data, and the second difference data is data other than the common data in the second comparison data.
  • data in the data of the first data source device that is different from the data of the second data source device is stored in the HASH table constructed for the first data source device, and the data in the second data source device is The data of different data source devices is stored in the HASH table constructed for the second data source device, which solves the problems of low efficiency, long running time and high development cost of the data consistency check method in the related art. Improve the efficiency of data consistency check, avoid duplication of development, and be practical.
  • FIG. 1 is a flowchart of a data difference analysis method according to an embodiment of the present invention
  • FIG. 2 is a structural block diagram of a data difference analysis apparatus according to an embodiment of the present invention
  • FIG. 3 is a HASH based on a preferred embodiment of the present invention.
  • FIG. 1 is a flowchart of a data difference analysis method according to an embodiment of the present invention. As shown in FIG. 1, the method mainly includes the following steps (step S102-step S104).
  • Step S102 Acquire first alignment data from the first data source device, acquire second alignment data from the second data source device, and acquire common data of the first comparison data and the second comparison data.
  • the first difference data is stored in the first HASH table
  • the second difference data is stored in the second HASH table, where the first difference data is data other than the common data in the first comparison data.
  • the second difference data is data other than the common data in the second comparison data.
  • the data different from the data of the first data source device is stored in the HASH table constructed for the second data source device, and the HASH table is used to find the time complexity is small, which can improve the efficiency of data consistency check, and can avoid Repeated development, practical.
  • the configuration information may be read and the initialization process may be performed.
  • the configuration information may include at least one of the following: a task start time of the data difference analysis, a task end time of the data difference analysis, Device information of the first data source device, device information of the second data source device, data acquisition mode, maximum storage space of the HASH table, difference data storage mode, alarm mode, and difference data processing mode; the initialization process may include: according to the first KEY constructs a first HASH table and a first HASH function, and constructs a second HASH table and a second HASH function according to the second KEY, wherein the structure of the first HASH table and the second HASH table are the same, the first KEY and the first The two KEYs have the same KEY value.
  • the first data may be further acquired from the first data source device, and the second data is obtained from the second data source device, and then determined. Whether the first data and the second data are complete data that need to be compared, if the result is YES, the first data may be used as the first comparison data, and the second data may be used as the second comparison data.
  • the process of acquiring the common data of the first comparison data and the second comparison data may be implemented in the following manner: first inserting the first comparison data into the first HASH table according to the first KEY Reading the second comparison data one by one, determining whether the first identical data in the first HASH table is the same as the current read data according to the second KEY, and if the determination result is yes, the first identical data is Deleted from the first HASH table, if the judgment result is no, the current read data is stored in the second HASH table; judge whether the second comparison data has been read, if it has been read, determine all The first identical data is the common data, and if the reading is not completed, the reading operation is continued.
  • step S104 after performing step S104, it may further determine whether the first difference data exceeds the first difference data threshold, and determine whether the second difference data exceeds the second difference data threshold, and at least one of the determination results is yes.
  • the alarm is generated using the alarm mode.
  • the difference data processing may be performed in the case where the difference data processing mode is required to perform the difference data processing, and may be implemented in the following manner: According to the reference, the second difference data is synchronously processed, or the first difference data is synchronized according to the second difference data.
  • the device information of the first data source device may include: a first file transfer protocol FTP address, a first user name, a first user password, a first database type, a first database name, a first database address, and The first database password;
  • the device information of the second data source device may include: a second file transfer protocol FTP address, a second user name, a second user password, a second database type, a second database name, a second database address, and a Second database password.
  • the data acquisition manner may include one of the following: an FTP active acquisition mode and an FTP passive acquisition mode.
  • the alarm mode may include one of the following: a short message alarm, a voice alarm, and a network management platform alarm.
  • FIG. 2 is a structural block diagram of a data difference analysis apparatus according to an embodiment of the present invention.
  • the apparatus mainly includes: an acquisition module 10 and a storage module 20.
  • the obtaining module 10 is configured to acquire first alignment data from the first data source device, acquire second alignment data from the second data source device, and obtain common data of the first comparison data and the second comparison data.
  • the storage module 20 is configured to store the first difference data in the first HASH table, and store the second difference data in the second HASH table, where the first difference data is the common data in the first comparison data.
  • the outer data, the second difference data is data other than the common data in the second comparison data.
  • the data difference analysis method and device provided by the above embodiments solve the problems of low efficiency, long running time and high development cost of the data consistency check method in the related art, and improve the efficiency of data consistency check, and The secondary development time can be saved by the packaging of the universal module.
  • the data difference analysis method and apparatus provided in the above embodiments are described and illustrated in more detail below with reference to FIG. 3 to FIG. 4 and the preferred embodiment.
  • 3 is a structural block diagram of a data difference analysis apparatus based on a HASH table according to a preferred embodiment of the present invention. As shown in FIG. 3, the apparatus includes: a configuration module 10, a data acquisition module 11, a data difference comparison module 12, and HASH storage.
  • the configuration module 10 is configured to configure adjustable data of each module, including a storage device that needs to compare data between the two parties, a data acquisition manner, a maximum record data of the HASH table, and a difference data storage manner after the comparison;
  • the alarm mode of the module such as SMS alarm, voice alarm, etc.
  • the processing method of the difference data such as calling the stored procedure, sending the message to the device business logic processing, etc.
  • the configuration data of the configuration module can be file or stored in a database.
  • the data obtaining module 11 is configured to obtain original comparison data to the data comparison parties, including an FTP method, a method for directly exporting data to the database, and the like.
  • the data difference comparison module 12 and the HASH storage module 13 the two modules are combined with each other for the core module of the device, and the raw data of the two parties are compared, and the final difference data is obtained through HASH insertion, fast search and deletion operations. recording.
  • the difference data storage module 14 stores the final difference data according to the configuration, and the storage manner may be a difference file, or may be stored in a database or the like.
  • the alarm module 15 is configured to set an alarm for the number of difference data records exceeding a threshold, and the alarm mode may be a short message, a voice, and a network management system.
  • the difference data processing module 16 performs the credit processing (i.e., the above-described synchronization processing) on the difference data based on the configuration based on one of the data.
  • Step S400 reading configuration information and initializing the program, and the read configuration information includes a timing task startup time and an end time.
  • the startup time and the end time may be some time of the day or some time of the month.
  • the configuration information may include: comparing the data of the two parties to store device information (such as an FTP address, a username, a password; a database type, a database name, an address, Passwords, etc.) and access methods (such as FTP passive mode, active mode, etc.); HASH table maximum number of records; differential data storage mode; alarm mode (sms alert, voice alarm, etc.);
  • the initialization mainly includes constructing a HASH table and a HASH function according to the KEY of the uniqueness of the data of both parties. Step S401, determining whether the current time is within the time limit of the scheduled task, if yes, proceeding to step S402, otherwise starting a timer, and when the timer arrives, re-entering step S401.
  • step S402 the data of the comparison parties is obtained locally.
  • step S403 judging whether the acquired data is complete data of the comparison parties according to the agreement logic of both parties, if yes, proceeding to step S404, otherwise proceeding to step S401.
  • step S404 the data of one of the two parties (abbreviated as A) is inserted into the HASH table A according to the KEY value.
  • step S405 the data of the other party (abbreviated as B) is read one by one, and the record is referred to as record B for short.
  • step S406 it is judged according to the KEY whether the record B is in the HASH table A. If yes, the process proceeds to step S407, otherwise, the process proceeds to step S408.
  • step S407 the same data as the record B in the HASH table A is deleted.
  • step S408 the record B is inserted into the 11 811 table: 6.
  • step S409 it is judged whether all the records of B have been read. If yes, the process proceeds to step S410, and the process proceeds to step S405.
  • Step S410 The difference record is stored in the final storage medium according to the configuration requirement, wherein the HASH table A is a record in which the data A is more than the data B, and the HASH table B is a record in which the data B is more than the data A.
  • Step 411 according to the threshold configuration, determine whether the difference record exceeds the threshold, and the process proceeds to step S412, otherwise proceeds to step S413.
  • step S412 according to the configuration, the corresponding alarm mode alarm is activated, including a short message alarm, a voice alarm, and a network management platform alarm.
  • step S413 according to the configuration, it is determined whether the difference record needs to be processed, and the process proceeds to step S414, otherwise the process proceeds to step S415.
  • step S414 according to the system requirement, the other party's system is used for the accounting process based on one party data.
  • the processing method includes directly calling the stored procedure to perform differential data logical synchronization processing, or sending a message to the system that needs to be synchronized, and is processed by the internal business logic of the system.
  • Step S415 determining, according to the configuration, whether to start the next data consistency check task.
  • step S401 the data consistency check and the processing task are periodically processed according to the task time period. Otherwise, the process ends.
  • the data consistency check can be made universal, and the similar function engineering can be directly inherited, avoiding repeated development, and having strong practicability.
  • each of the above modules can be implemented by hardware.
  • a processor including the above modules, or each of the above modules is located in one processor.
  • software is also provided for performing the technical solutions described in the above embodiments and preferred embodiments.
  • a storage medium is provided, the software being stored, including but not limited to: an optical disk, a floppy disk, a hard disk, a rewritable memory, and the like.
  • the present invention achieves the following technical effects:
  • the HASH table is used to find the feature of minimum time complexity, and the efficiency of data consistency check is improved, and experimental data shows that On the SUSE machine (for example, SUSE9, single CPU2.3G, MEMRY2G), it takes about 10 seconds to compare the 100W records of each of the two sides of the interaction, and the linked list method used in the previous project has no result in 20 minutes.
  • each module can be independently packaged, has low coupling degree, is easy to maintain and inherits, especially a data acquisition module, a HASH storage module, a data difference comparison module and an alarm module, and has a complete package and strong versatility, and can be used for similar functions.
  • modules or steps of the present invention can be implemented by a general-purpose computing device, which can be concentrated on a single computing device or distributed over a network composed of multiple computing devices. Alternatively, they may be implemented by program code executable by the computing device, such that they may be stored in the storage device by the computing device and, in some cases, may be different from the order herein.
  • the steps shown or described are performed, or they are separately fabricated into individual integrated circuit modules, or a plurality of modules or steps are fabricated as a single integrated circuit module.
  • the invention is not limited to any specific combination of hardware and software.

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

公开了一种数据差异分析方法及装置。其中,该方法包括:从第一数据源设备获取第一比对数据,从第二数据源设备获取第二比对数据,并获取第一比对数据与第二比对数据的共同数据;将第一差异数据存储到第一HASH表中,将第二差异数据存储到第二HASH表中,其中,第一差异数据是第一比对数据中除共同数据之外的数据,第二差异数据是第二比对数据中除共同数据之外的数据。通过本方法及装置,达到了提高数据一致性检査的效率,可以避免重复开发,实用性强的效果。

Description

数据差异分析方法及装置 技术领域 本发明涉及计算机软件技术领域, 具体而言,涉及一种数据差异分析方法及装置。 背景技术 随着软件行业的快速发展, 系统之间的交互变得越来越频繁, 交互的数据量越来 越大, 参与交互各方的数据一致性检验及处理变得越来越重要。 由于交互各方的系统差异性, 决定了其数据存储的多样性及数据一致性检验功能 的差异性。 在大量工程案例开发实施中, 现有的数据一致性检验方法存在如下问题: ( 1 )检验效率低下, 运行时间长; (2)没有统一的可重用模块, 各个应用的数据一致 性检查都是全新开发, 浪费人力资源。 针对相关技术中数据一致性检验方法存在的检验效率低下、 运行时间长以及开发 成本较高的问题, 目前尚未提出有效的解决方案。 发明内容 本发明提供了一种数据差异分析方法及装置, 以至少解决上述数据一致性检验方 法存在的检验效率低下、 运行时间长以及开发成本较高的问题。 根据本发明的一个方面, 提供了一种数据差异分析方法, 包括: 从第一数据源设 备获取第一比对数据, 从第二数据源设备获取第二比对数据, 并获取第一比对数据与 第二比对数据的共同数据; 将第一差异数据存储到第一 HASH表中, 将第二差异数据 存储到第二 HASH表中, 其中, 第一差异数据是第一比对数据中除共同数据之外的数 据, 第二差异数据是第二比对数据中除共同数据之外的数据。 优选地, 在从第一数据源设备获取第一比对数据, 从第二数据源设备获取第二比 对数据之前, 包括: 读取配置信息并进行初始化程序; 其中, 配置信息包括: 数据差 异分析的任务启动时间、数据差异分析的任务结束时间、第一数据源设备的设备信息、 第二数据源设备的设备信息、 数据获取方式、 HASH表的最大存储空间、 差异数据保 存方式、告警方式以及差异数据处理方式; 初始化程序包括: 根据第一 KEY构建第一 HASH表和第一 HASH函数,和根据第二 KEY构建第二 HASH表和第二 HASH函数, 其中,第一 HASH表与第二 HASH表的结构是相同的,第一 KEY与第二 KEY具有相 同的 KEY值。 优选地, 在读取配置信息并进行初始化程序之后, 包括: 从第一数据源设备获取 第一数据, 从第二数据源设备获取第二数据; 判断第一数据和第二数据是否均是需要 进行比对的完整数据, 在判结果为是的情况下, 将第一数据作为第一比对数据, 将第 二数据作为第二比对数据。 优选地, 获取第一比对数据与第二比对数据的共同数据包括: 将第一比对数据按 照第一 KEY插入第一 HASH表中; 逐条读取第二比对数据, 根据第二 KEY判断第一 HASH表中是否存在与当前读取数据相同的第一相同数据,在判断结果为是的情况下, 将第一相同数据从第一 HASH表中删除, 在判断结果为否的情况下, 将当前读取数据 存储到第二 HASH表中; 判断第二比对数据是否已经读取完毕, 如果已经读取完毕, 确定所有的第一相同数据为共同数据, 如果没有读取完毕, 继续执行读取操作。 优选地, 在将第一差异数据存储到第一 HASH表中, 将第二差异数据存储到第二 HASH表中之后, 包括: 判断第一差异数据是否超过第一差异数据阈值, 判断第二差 异数据是否超过第二差异数据阈值, 在至少存在一个判断结果为是的情况下, 使用告 警方式进行告警。 优选地, 在将第一差异数据存储到第一 HASH表中, 将第二差异数据存储到第二 HASH表中之后, 包括: 在差异数据处理方式为需要进行差异数据处理的情况下, 进 行差异数据处理, 包括: 以第一差异数据为基准, 对第二差异数据进行同步处理, 或 者, 以第二差异数据为基准, 对第一差异数据进行同步处理。 优选地, 第一数据源设备的设备信息包括: 第一文件传输协议 FTP地址、 第一用 户名、 第一用户密码、 第一数据库类型、 第一数据库名称、 第一数据库地址及第一数 据库密码; 第二数据源设备的设备信息包括: 第二文件传输协议 FTP地址、 第二用户 名、 第二用户密码、 第二数据库类型、 第二数据库名称、 第二数据库地址及第二数据 库密码。 优选地, 数据获取方式包括以下之一: FTP主动获取方式、 FTP被动获取方式。 优选地, 告警方式包括以下之一: 短信告警、 语音告警、 网管平台告警。 根据本发明的另一方面, 提供了一种数据差异分析装置, 包括: 获取模块, 设置 为从第一数据源设备获取第一比对数据, 从第二数据源设备获取第二比对数据, 并获 取第一比对数据与第二比对数据的共同数据; 存储模块, 设置为将第一差异数据存储 到第一 HASH表中, 将第二差异数据存储到第二 HASH表中, 其中, 第一差异数据是 第一比对数据中除共同数据之外的数据, 第二差异数据是第二比对数据中除共同数据 之外的数据。 通过本发明, 将第一数据源设备的数据中与第二数据源设备的数据不相同的数据 存储在为第一数据源设备构建的 HASH表中, 将第二数据源设备的数据中与第一数据 源设备的数据不相同的数据存储在为第二数据源设备构建的 HASH表中, 解决了相关 技术中数据一致性检验方法存在的检验效率低下、 运行时间长以及开发成本较高的问 题, 提高数据一致性检查的效率, 可以避免重复开发, 实用性强。 附图说明 此处所说明的附图用来提供对本发明的进一步理解, 构成本申请的一部分, 本发 明的示意性实施例及其说明用于解释本发明, 并不构成对本发明的不当限定。 在附图 中: 图 1是根据本发明实施例的数据差异分析方法流程图; 图 2是根据本发明实施例的数据差异分析装置的结构框图; 图 3是根据本发明优选实施例的基于 HASH表的数据差异分析装置的结构框图; 图 4是根据本发明优选实施例的基于 HASH表的数据差异分析方法的执行流程 图。 具体实施方式 下文中将参考附图并结合实施例来详细说明本发明。 需要说明的是, 在不冲突的 情况下, 本申请中的实施例及实施例中的特征可以相互组合。 本发明实施例提供了一种数据差异分析方法。 图 1是根据本发明实施例的数据差 异分析方法流程图, 如图 1所示, 该方法主要包括以下步骤 (步骤 S102-步骤 S104)。 步骤 S102, 从第一数据源设备获取第一比对数据, 从第二数据源设备获取第二比 对数据, 并获取第一比对数据与第二比对数据的共同数据。 步骤 S104,将第一差异数据存储到第一 HASH表中,将第二差异数据存储到第二 HASH表中, 其中, 第一差异数据是第一比对数据中除共同数据之外的数据, 第二差 异数据是第二比对数据中除共同数据之外的数据。 通过上述各个步骤, 可以将第一数据源设备的数据中与第二数据源设备的数据不 相同的数据存储在为第一数据源设备构建的 HASH表中, 将第二数据源设备的数据中 与第一数据源设备的数据不相同的数据存储在为第二数据源设备构建的 HASH表中, 利用 HASH表查找时间复杂度较小的特点, 可以提高数据一致性检查的效率, 而且可 以避免重复开发, 实用性强。 在本实施例中, 在执行步骤 S102之前, 还可以读取配置信息并进行初始化程序; 其中, 配置信息可以包括以下至少之一: 数据差异分析的任务启动时间、 数据差异分 析的任务结束时间、 第一数据源设备的设备信息、 第二数据源设备的设备信息、 数据 获取方式、 HASH表的最大存储空间、 差异数据保存方式、 告警方式以及差异数据处 理方式; 初始化程序可以包括:根据第一 KEY构建第一 HASH表和第一 HASH函数, 和根据第二 KEY构建第二 HASH表和第二 HASH函数, 其中, 第一 HASH表与第二 HASH表的结构是相同的, 第一 KEY与第二 KEY具有相同的 KEY值。 在本实施例中,在执行步骤 S102之前,且在读取配置信息并进行初始化程序之后, 可以进一步从第一数据源设备获取第一数据, 从第二数据源设备获取第二数据, 再判 断第一数据和第二数据是否均是需要进行比对的完整数据, 在判结果为是的情况下, 可以将第一数据作为第一比对数据, 将第二数据作为第二比对数据。 在本实施例的步骤 S102中,获取第一比对数据与第二比对数据的共同数据的过程 可以采用以下的方式来实现: 先将第一比对数据按照第一 KEY插入第一 HASH表中, 再逐条读取第二比对数据, 根据第二 KEY判断第一 HASH表中是否存在与当前读取 数据相同的第一相同数据, 在判断结果为是的情况下, 将第一相同数据从第一 HASH 表中删除, 在判断结果为否的情况下, 将当前读取数据存储到第二 HASH表中; 判断 第二比对数据是否已经读取完毕, 如果已经读取完毕, 确定所有的第一相同数据为共 同数据, 如果没有读取完毕, 继续执行读取操作。 在本实施例中,在执行步骤 S104之后,还可以判断第一差异数据是否超过第一差 异数据阈值, 判断第二差异数据是否超过第二差异数据阈值, 在至少存在一个判断结 果为是的情况下, 使用告警方式进行告警。 在本实施例中,在执行步骤 S104之后,还可以在差异数据处理方式为需要进行差 异数据处理的情况下, 进行差异数据处理, 可以以这样的方式来实现: 以第一差异数 据为基准, 对第二差异数据进行同步处理, 或者, 以第二差异数据为基准, 对第一差 异数据进行同步处理。 在本实施例中, 第一数据源设备的设备信息可以包括: 第一文件传输协议 FTP地 址、 第一用户名、 第一用户密码、 第一数据库类型、 第一数据库名称、 第一数据库地 址及第一数据库密码; 第二数据源设备的设备信息可以包括: 第二文件传输协议 FTP 地址、 第二用户名、 第二用户密码、 第二数据库类型、 第二数据库名称、 第二数据库 地址及第二数据库密码。 优选地, 数据获取方式可以包括以下之一: FTP主动获取方式、 FTP被动获取方 式。 优选地, 告警方式可以包括以下之一: 短信告警、 语音告警、 网管平台告警。 本发明实施例提供了一种数据差异分析装置, 该装置用以实现上述实施例提供的 数据差异分析方法。 图 2是根据本发明实施例的数据差异分析装置的结构框图, 如图 2所示, 该装置主要包括: 获取模块 10和存储模块 20。 其中, 获取模块 10, 设置为 从第一数据源设备获取第一比对数据, 从第二数据源设备获取第二比对数据, 并获取 第一比对数据与第二比对数据的共同数据; 存储模块 20, 设置为将第一差异数据存储 到第一 HASH表中, 将第二差异数据存储到第二 HASH表中, 其中, 第一差异数据是 第一比对数据中除共同数据之外的数据, 第二差异数据是第二比对数据中除共同数据 之外的数据。 采用上述实施例提供的数据差异分析方法及装置, 解决了相关技术中数据一致性 检验方法存在的检验效率低下、 运行时间长以及开发成本较高的问题, 提高了数据一 致性检查的效率, 并可以通过通用模块的封装节约了二次开发时间。 下面结合图 3至图 4以及优选实施例对上述实施例提供的数据差异分析方法及装 置进行更加详细的描述和说明。 图 3是根据本发明优选实施例的基于 HASH表的数据差异分析装置的结构框图, 如图 3所示, 该装置包括: 配置模块 10、 数据获取模块 11、 数据差异比对模块 12、 HASH存储模块 13、 差异数据存储模块 14、 告警模块 15及差异数据处理模块 16。 下 面对各个模块进行详细描述。 配置模块 10, 设置为配置各个模块的可调节数据, 包括需要比对双方数据的存放 设备、 数据获取方式; HASH表的最大记录数据; 比对后的差异数据存储方式; 告警 模块的告警方式(如短信告警、语音告警等); 差异数据的处理方式(如调用存储过程 方式、发消息给设备业务逻辑处理方式等)。配置模块的配置数据可以是文件方式, 也 可以存放于数据库。 数据获取模块 11, 设置为到数据比对双方获取原始比对数据, 包括 FTP方式、直 接到数据库导出数据方式等。 数据差异比对模块 12及 HASH存储模块 13, 此两模块构为此装置的核心模块, 相互结合使用, 将比对双方的原始数据通过 HASH插入、 快速查找及删除等操作, 获 得最终的差异数据记录。 差异数据存储模块 14, 根据配置, 存放最终的差异数据, 存储方式可以为差异文 件, 也可以存放于数据库等。 告警模块 15, 设置为对差异数据记录数超过阈值告警, 告警方式可以为短信、 语 音及网管系统等。 差异数据处理模块 16, 根据配置, 以一方数据为基准, 对差异数据进行平账处理 (即上述同步处理)。 图 4是根据本发明优选实施例的基于 HASH表的数据差异分析方法的执行流程 图, 如图 4所示, 该流程包括以下步骤 S400-步骤 S415。 步骤 S400, 读取配置信息并初始化程序, 读取的配置信息包括定时任务启动时间 及结束时间。 其中, 启动时间及结束时间可以是每天某些时间或者每月某些时间, 配 置信息可以包括: 比对双方数据存放设备信息 (如 FTP地址、 用户名、 密码; 数据库 类型、 数据库名称、 地址、 密码等) 及获取方式 (如 FTP的被动方式、 主动方式等); HASH表最大记录数; 差异数据保存方式; 告警方式(短信告警, 语音告警等); 差异 数据处理方式等。初始化主要包括根据双方数据唯一性的 KEY构建 HASH表及 HASH 函数。 步骤 S401 , 判断当前时间是否在定时任务时间范围内, 如果是, 进入步骤 S402, 否则启动一个定时器, 在定时器到达时, 重新进入步骤 S401。 步骤 S402, 根据配置, 获取比对双方的数据到本地。 步骤 S403 , 根据比对双方的约定逻辑, 判断获取的数据是否是比对双方的完整数 据, 如果是, 进入步骤 S404, 否则进入步骤 S401。 步骤 S404, 将比对双方中一方 (简称 A) 的数据按照 KEY值插入 HASH表 A。 步骤 S405, 逐条读取比对另一方 (简称 B) 数据, 简称此条记录为记录 B。 步骤 S406, 根据 KEY判断记录 B是否在 HASH表 A, 如果在, 进入步骤 S407, 否则进入步骤 S408。 步骤 S407, 删除 HASH表 A内的与记录 B相同的数据。 步骤 S408, 将记录 B插入 11 811表:6。 步骤 S409, 判断 B的所有记录是否读取完毕, 如果是, 进入骤 S410, 没有处理 完毕进入步骤 S405。 步骤 S410, 根据配置要求将差异记录存入最终的存储介质, 其中 HASH表 A中 为数据 A多于数据 B的记录, HASH表 B为数据 B多于数据 A的记录。 步骤 411, 根据阈值配置, 判断差异记录是否超过阈值, 超过进入步骤 S412, 否 则进入步骤 S413。 步骤 S412, 根据配置, 启动对应的告警方式告警, 包括短信告警、 语音告警、 网 管平台告警等。 步骤 S413 , 根据配置, 判断是否需要处理差异记录, 需要进入步骤 S414, 否则 进入步骤 S415。 步骤 S414, 根据系统要求, 以一方数据为基准, 到另一方系统进行平账处理。 处 理方式包括直接调用存储过程进行差异数据逻辑同步处理, 或者是发送消息给需要同 步的系统, 由系统内部的业务逻辑处理。 步骤 S415, 根据配置判断是否需要启动下一次数据一致性检查任务。 需要进入步 骤 S401 ,实现根据任务时间段定期处理数据一致性检查及处理任务。否则,流程结束。 通过本优选实施例, 可以使数据一致性检查通用性强, 对相似功能的工程可以直 接继承使用, 避免重复开发, 实用性强。 需要说明的是, 上述各个模块是可以通过硬件来实现的。 例如: 一种处理器, 包 括上述各个模块, 或者, 上述各个模块分别位于一个处理器中。 在另外一个实施例中, 还提供了一种软件, 该软件用于执行上述实施例及优选实 施方式中描述的技术方案。 在另外一个实施例中, 还提供了一种存储介质, 该存储介质中存储有上述软件, 该存储介质包括但不限于: 光盘、 软盘、 硬盘、 可擦写存储器等。 从以上的描述中, 可以看出, 本发明实现了如下技术效果: 通过使用 HASH表, 利用 HASH表查找时间复杂度最小的特点, 提高了数据一致性检查的效率, 通过实验 数据表明, 在普通的 SUSE机器上(例如, SUSE9, 单 CPU2.3G, MEMRY2G), 比对 交互双方各 100W条记录,所花时间大约为 10秒,而使用以前工程中常用的链表方式, 20分钟没有出结果。 而且, 可以将各个模块独立封装, 耦合度低, 容易维护及继承使 用, 尤其是数据获取模块、 HASH存储模块、 数据差异对比模块及告警模块, 封装完 整, 通用性强, 对相似功能的工程可以直接继承使用, 避免重复开发, 实用性强。 显然, 本领域的技术人员应该明白, 上述的本发明的各模块或各步骤可以用通用 的计算装置来实现, 它们可以集中在单个的计算装置上, 或者分布在多个计算装置所 组成的网络上, 可选地, 它们可以用计算装置可执行的程序代码来实现, 从而, 可以 将它们存储在存储装置中由计算装置来执行, 并且在某些情况下, 可以以不同于此处 的顺序执行所示出或描述的步骤, 或者将它们分别制作成各个集成电路模块, 或者将 它们中的多个模块或步骤制作成单个集成电路模块来实现。 这样, 本发明不限制于任 何特定的硬件和软件结合。 以上所述仅为本发明的优选实施例而已, 并不用于限制本发明, 对于本领域的技 术人员来说, 本发明可以有各种更改和变化。 凡在本发明的精神和原则之内, 所作的 任何修改、 等同替换、 改进等, 均应包含在本发明的保护范围之内。 工业实用性 本发明实施例中, 将第一数据源设备的数据中与第二数据源设备的数据不相同的 数据存储在为第一数据源设备构建的 HASH表中, 将第二数据源设备的数据中与第一 数据源设备的数据不相同的数据存储在为第二数据源设备构建的 HASH表中, 利用 HASH表查找时间复杂度较小的特点, 可以提高数据一致性检查的效率, 而且可以避 免重复开发, 实用性强。 具有工业实用性。

Claims

权 利 要 求 书
1. 一种数据差异分析方法, 包括:
从第一数据源设备获取第一比对数据, 从第二数据源设备获取第二比对数 据, 并获取所述第一比对数据与所述第二比对数据的共同数据;
将第一差异数据存储到第一哈希 HASH表中,将第二差异数据存储到第二 HASH表中, 其中, 所述第一差异数据是所述第一比对数据中除所述共同数据 之外的数据, 所述第二差异数据是所述第二比对数据中除所述共同数据之外的 数据。
2. 根据权利要求 1所述的方法, 其中, 在从第一数据源设备获取第一比对数据, 从第二数据源设备获取第二比对数据之前, 包括:
读取配置信息并进行初始化程序;
其中, 所述配置信息包括以下至少之一: 数据差异分析的任务启动时间、 数据差异分析的任务结束时间、 所述第一数据源设备的设备信息、 所述第二数 据源设备的设备信息、 数据获取方式、 HASH表的最大存储空间、 差异数据保 存方式、 告警方式以及差异数据处理方式;
所述初始化程序包括: 根据第一 KEY构建第一 HASH表和第一 HASH函 数, 和根据第二 KEY构建第二 HASH表和第二 HASH函数, 其中, 所述第一 HASH表与所述第二 HASH表的结构是相同的,所述第一 KEY与第二 KEY具 有相同的 KEY值。
3. 根据权利要求 2所述的方法, 其中, 在读取配置信息并进行初始化程序之后, 包括:
从所述第一数据源设备获取第一数据, 从所述第二数据源设备获取第二数 据;
判断所述第一数据和所述第二数据是否均是需要进行比对的完整数据, 在 判结果为是的情况下, 将所述第一数据作为所述第一比对数据, 将所述第二数 据作为所述第二比对数据。
4. 根据权利要求 2所述的方法, 其中, 获取所述第一比对数据与所述第二比对数 据的共同数据包括: 将所述第一比对数据按照所述第一 KEY插入所述第一 HASH表中; 逐条读取所述第二比对数据, 根据所述第二 KEY判断所述第一 HASH表 中是否存在与当前读取数据相同的第一相同数据, 在判断结果为是的情况下, 将所述第一相同数据从第一 HASH表中删除, 在判断结果为否的情况下, 将所 述当前读取数据存储到所述第二 HASH表中; 判断所述第二比对数据是否已经读取完毕, 如果已经读取完毕, 确定所有 的所述第一相同数据为所述共同数据,如果没有读取完毕,继续执行读取操作。 根据权利要求 2所述的方法,其中,在将第一差异数据存储到第- HASH表中, 将第二差异数据存储到第二 HASH表中之后, 包括: 判断所述第一差异数据是否超过第一差异数据阈值, 判断所述第二差异数 据是否超过第二差异数据阈值, 在至少存在一个判断结果为是的情况下, 使用 所述告警方式进行告警。 根据权利要求 2所述的方法,其中,在将第一差异数据存储到第一 HASH表中, 将第二差异数据存储到第二 HASH表中之后, 包括: 在所述差异数据处理方式为需要进行差异数据处理的情况下, 进行差异数 据处理, 包括: 以所述第一差异数据为基准, 对所述第二差异数据进行同步处 理, 或者, 以所述第二差异数据为基准, 对所述第一差异数据进行同步处理。 根据权利要求 2至 6中任一项所述的方法,
所述第一数据源设备的设备信息包括: 第一文件传输协议 FTP地址、 第一 用户名、 第一用户密码、 第一数据库类型、 第一数据库名称、 第一数据库地址 及第一数据库密码;
所述第二数据源设备的设备信息包括: 第二文件传输协议 FTP地址、 第二 用户名、 第二用户密码、 第二数据库类型、 第二数据库名称、 第二数据库地址 及第二数据库密码。 根据权利要求 2至 6中任一项所述的方法, 其中, 所述数据获取方式包括以下 之一: FTP主动获取方式、 FTP被动获取方式。 根据权利要求 2至 6中任一项所述的方法,其中,所述告警方式包括以下之一: 短信告警、 语音告警、 网管平台告警。
10. 一种数据差异分析装置, 包括: 获取模块, 设置为从第一数据源设备获取第一比对数据, 从第二数据源设 备获取第二比对数据, 并获取所述第一比对数据与所述第二比对数据的共同数 据;
存储模块, 设置为将第一差异数据存储到第一哈希 HASH表中, 将第二差 异数据存储到第二 HASH表中, 其中, 所述第一差异数据是所述第一比对数据 中除所述共同数据之外的数据, 所述第二差异数据是所述第二比对数据中除所 述共同数据之外的数据。
PCT/CN2014/078564 2013-12-03 2014-05-27 数据差异分析方法及装置 WO2014180398A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201310642441.7 2013-12-03
CN201310642441.7A CN104679794A (zh) 2013-12-03 2013-12-03 数据差异分析方法及装置

Publications (1)

Publication Number Publication Date
WO2014180398A1 true WO2014180398A1 (zh) 2014-11-13

Family

ID=51866778

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/078564 WO2014180398A1 (zh) 2013-12-03 2014-05-27 数据差异分析方法及装置

Country Status (2)

Country Link
CN (1) CN104679794A (zh)
WO (1) WO2014180398A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110287182A (zh) * 2019-05-05 2019-09-27 浙江吉利控股集团有限公司 一种大数据的数据对比方法、装置、设备及终端

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105956005B (zh) * 2016-04-20 2019-06-07 曹屹 一种数据处理方法和设备
CN107832336A (zh) * 2017-10-10 2018-03-23 北京京东尚科信息技术有限公司 数据处理方法及其系统
CN108388610B (zh) * 2018-02-07 2021-04-27 新华三大数据技术有限公司 数据etl处理方法及装置

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101051307A (zh) * 2006-04-07 2007-10-10 鸿富锦精密工业(深圳)有限公司 应用文件更新系统及方法
CN101963944A (zh) * 2010-09-30 2011-02-02 用友软件股份有限公司 对象存储方法和系统
CN101963961A (zh) * 2009-07-23 2011-02-02 高德软件有限公司 兴趣点数据关联方法及装置
CN102542057A (zh) * 2011-12-29 2012-07-04 北京大学 基于固态硬盘的高维数据索引结构设计方法

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101719143A (zh) * 2009-12-01 2010-06-02 北京中科创元科技有限公司 并行处理比对式增量数据抽取方法
CN102184190A (zh) * 2011-04-19 2011-09-14 北京神州数码思特奇信息技术股份有限公司 数据比对方法
CN103186624B (zh) * 2011-12-31 2017-10-20 亿阳信通股份有限公司 一种数据同步方法和数据同步装置

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101051307A (zh) * 2006-04-07 2007-10-10 鸿富锦精密工业(深圳)有限公司 应用文件更新系统及方法
CN101963961A (zh) * 2009-07-23 2011-02-02 高德软件有限公司 兴趣点数据关联方法及装置
CN101963944A (zh) * 2010-09-30 2011-02-02 用友软件股份有限公司 对象存储方法和系统
CN102542057A (zh) * 2011-12-29 2012-07-04 北京大学 基于固态硬盘的高维数据索引结构设计方法

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110287182A (zh) * 2019-05-05 2019-09-27 浙江吉利控股集团有限公司 一种大数据的数据对比方法、装置、设备及终端

Also Published As

Publication number Publication date
CN104679794A (zh) 2015-06-03

Similar Documents

Publication Publication Date Title
WO2021169277A1 (zh) 数据同步方法、装置、设备及计算机可读存储介质
CN108734028B (zh) 基于区块链的数据管理方法、区块链节点及存储介质
WO2020211496A1 (zh) 一种块链式账本中的签名验证方法、系统、装置及设备
TW202001656A (zh) 基於區塊鏈的智能合約調用方法及裝置、電子設備
CN106375404B (zh) 数据存储控制方法、数据存储方法、数据获取方法及装置
US11562812B2 (en) Computer implemented method for secure management of data generated in an EHR during an episode of care and a system therefor
BR112016018070B1 (pt) Métodos e sistemas para deletar informação solicitada
WO2018201887A1 (zh) 数据响应方法、装置、终端设备及介质
CN110543448A (zh) 数据同步方法、装置、设备及计算机可读存储介质
US20220004334A1 (en) Data Storage Method, Apparatus and System, and Server, Control Node and Medium
US20160179836A1 (en) Method for updating data table of keyvalue database and apparatus for updating table data
WO2017113694A1 (zh) 文件同步方法、装置及系统
WO2014180398A1 (zh) 数据差异分析方法及装置
WO2020224238A1 (zh) 区块链节点的部署方法、装置、设备及存储介质
WO2016045548A1 (zh) 一种数据同步方法及装置
JP2021514510A (ja) 物流追跡および配送元特定のための方法、アプリケーションサーバ、ブロックチェーンノードおよび媒体
WO2021164462A1 (zh) 一种数据加密方法、数据解密方法、计算机设备和介质
CN113595788A (zh) 一种基于插件的api网关管理方法及装置
CN111339551B (zh) 数据的验证方法及相关装置、设备
Pedrosa et al. A performant protocol for distributed health records databases
CN111881209A (zh) 异构数据库的数据同步方法、装置、电子设备及介质
CN109299116B (zh) 一种数据同步方法、装置、设备及可读存储介质
CN107609197B (zh) 一种数据同步方法、数据同步装置及移动终端
CN114020340A (zh) 一种服务器系统及其数据处理方法
WO2019214071A1 (zh) 区块链上用户通信方法、装置、终端设备及存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 14794924

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 14794924

Country of ref document: EP

Kind code of ref document: A1