WO2012041110A1 - 数据比对方法和装置 - Google Patents

数据比对方法和装置 Download PDF

Info

Publication number
WO2012041110A1
WO2012041110A1 PCT/CN2011/076964 CN2011076964W WO2012041110A1 WO 2012041110 A1 WO2012041110 A1 WO 2012041110A1 CN 2011076964 W CN2011076964 W CN 2011076964W WO 2012041110 A1 WO2012041110 A1 WO 2012041110A1
Authority
WO
WIPO (PCT)
Prior art keywords
hash
information
file
memory
source file
Prior art date
Application number
PCT/CN2011/076964
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 WO2012041110A1 publication Critical patent/WO2012041110A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/31Indexing; Data structures therefor; Storage structures
    • G06F16/316Indexing structures

Definitions

  • the present invention relates to the field of communications, and in particular to a data comparison method and apparatus.
  • BACKGROUND With the continuous development of the current communication industry, related software systems are becoming more and more complex. These systems generally include many subsystems and peripheral systems. In order to ensure the consistency of data of these systems, it is often necessary to compare the systems. The same type of data, to make it consistent, to ensure the normal operation of the entire system. Because in the communications industry, the amount of such data is usually very large, and it is easy to make mistakes by using general text comparison tools.
  • third-party tools such as Ue, merge and other tools and software are used in combination to compare;
  • Hash a commonly used data storage structure, also known as hash table or hash table
  • the above method 1) can be used to compare file data of a small amount of data, but if it is used to process a large amount of data, the operator will often lose sight of it and generate many errors, which also makes the efficiency of the comparison very low; 2)
  • the way to use is to use the characteristics of the database to handle the completion of the comparison work, which is a simple way to deal with, but its shortcomings are brought by the database itself: high dependence on the system software and hardware environment, processing The speed is also very slow;
  • Method 3) is a commonly used comparison method.
  • the main object of the present invention is to provide a data comparison method and apparatus to solve at least the above problems.
  • a data comparison method including: comparing first hash HASH information of a source file with second HASH information of a target file; generating the above according to the comparison result The result of the comparison between the source file and the above target file.
  • Comparing the first hash HASH information of the source file with the second HASH information of the target file includes: establishing a memory index table corresponding to the source file in the memory, where the memory index table includes the first hash HASH An index record corresponding to all the HASH values in the information; searching for the index record corresponding to the second HASH information in the memory index table, where the HASH value in the index record is equal to the HASH value in the second HASH information .
  • the data comparison method further includes: establishing a conflict list in the memory, wherein the conflict list is a continuous storage space, and is set to be saved in the comparison with the source file.
  • the conflicting element generated when the above object file is generated.
  • the comparison result the result of the comparison between the source file and the target file: if the index record corresponding to the second HASH information is found in the memory index table, generating the first indication information, where the first The indication information is set to indicate that the source file and the target file have data information corresponding to the HASH value in the searched index record; if the index corresponding to the second HASH information does not exist in the memory index table Recording, the second indication information is generated, wherein the second indication information is set to indicate that the source file does not have data information corresponding to the HASH value in the second HASH information.
  • the result of the comparison between the source file and the target file is generated according to the comparison result, and if the index record corresponding to the second HASH information is found in the memory index table, the target file is corresponding to the second HASH information.
  • the record information is compared with the record information corresponding to the index record in the source file; if the two are the same, the third indication information is generated, wherein the third indication information is set to indicate that the source file and the target file have the same Data information corresponding to the HASH value in the searched index record; if the index record corresponding to the second HASH information does not exist in the memory index table, generating fourth indication information, where the fourth The indication information is set to indicate that the source file does not have data information corresponding to the HASH value in the second HASH information.
  • a data comparison apparatus comprising: a comparison unit configured to compare a first hash HASH information of a source file with a second HASH information of a target file And a generating unit, configured to generate a comparison result of the source file and the target file according to the comparison result.
  • the comparison unit includes: a first establishing module, configured to establish a memory index table corresponding to the source file in the memory, where the memory index table includes an index record corresponding to all HASH values in the first hash HASH information
  • the search module is configured to search for the index record corresponding to the second HASH information in the memory index table, where the HASH value in the index record is equal to the HASH value in the second HASH information.
  • the comparison unit further includes: a second establishing module, configured to establish a conflict list in the memory when the memory index table corresponding to the source file is established in the memory, where the conflict list is set to be saved in the comparison source file The conflicting element that is generated when the target file is above.
  • the generating unit further includes: a first generating module, configured to: when the index record corresponding to the second HASH information exists in the memory index table, generate first indication information, where the first indication information is set as an indication The source file and the target file have data information corresponding to the HASH value in the searched index record; the second generation module is configured to find that the second HASH information does not exist in the memory index table.
  • the second indication information is generated to indicate that the source file does not have data information corresponding to the HASH value in the second HASH information.
  • the comparison unit further includes: a comparison module, configured to: when the index record corresponding to the second HASH information is found in the memory index table, record information corresponding to the second HASH information in the target file, and the source file The record information corresponding to the above index record is compared.
  • the generating unit further includes: a third generating module, configured to generate third indication information when the two are the same, wherein the third indication information is set to indicate that the source file and the target file have the index that is found together
  • the data information corresponding to the HASH value in the record The invention solves the problem that the data comparison method in the prior art leads to high memory occupancy rate by comparing the HASH information of the source file and the target file, instead of the data itself, thereby achieving the reduction of execution time and processing efficiency. effect.
  • the present invention is capable of processing different kinds of formatted data by comparing the HASH information such that the alignment process does not depend on the characteristics of the data, wherein no features can be extracted when formatting the data.
  • FIG. 1 is a preferred flow chart of a data comparison method according to an embodiment of the present invention
  • FIG. 2 is another preferred flow chart of a data comparison method according to an embodiment of the present invention
  • FIG. 4 is a preferred schematic diagram of a data comparison apparatus according to an embodiment of the present invention
  • FIG. 5 is another preferred schematic diagram of a data comparison apparatus according to an embodiment of the present invention.
  • comparing the first hash HASH information of the source file with the second HASH information of the target file includes: establishing a memory index table corresponding to the source file in the memory, where the memory index table includes An index record corresponding to all the HASH values in the first hash HASH information; searching, in the memory index table, whether there is an index record corresponding to the second HASH information, where the HASH value in the index record is equal to The HASH value in the second HASH information.
  • the memory index table established in the preferred embodiment the location of the HASH information of the source file can be quickly located, and the processing efficiency is improved.
  • the method further includes: establishing a conflict list in the memory, where the conflict list is a continuous storage space, and is used to save the comparison The conflicting element that occurs when the source file is associated with the target file.
  • the conflict list is a continuous storage space, and is used to save the comparison The conflicting element that occurs when the source file is associated with the target file.
  • the result of the comparison between the source file and the target file according to the comparison result is: if the presence and the second HASH are found in the memory index table, And the first indication information is used to indicate that the source file and the target file have data corresponding to the HASH value in the searched index record.
  • the second indication information is generated if the index record corresponding to the second HASH information does not exist in the memory index table, where the second indication information is used to indicate that the source file is not There is data information corresponding to the HASH value in the second HASH information.
  • the generation manner of the preferred embodiment can facilitate the user to view the comparison result.
  • the comparison result generated by the comparison result of the source file and the target file includes:
  • the memory index table includes: multiple levels
  • FIG. 2 is another preferred flowchart of a data comparison method according to an embodiment of the present invention. The method includes the following steps: Step S201: Acquire a system configuration parameter provided by a user and perform corresponding analysis. If an abnormality occurs, go to step S205, otherwise, go to step S202.
  • Step S202 The source file is read into the memory, and the HASH value information and the file offset information of the source file data are saved.
  • the abnormal data appears to step S203, otherwise it jumps to step S204.
  • Step S203 The abnormal data is written to the log, and then the flow jumps to step S201.
  • Step S204 Establish a memory index model of the source file information, which mainly includes a three-layer HASH index and a corresponding conflict list. If an abnormality occurs to step S205, otherwise to step S206.
  • Step S205 Write the memory model failure to the log, and the process goes to step S214.
  • Step S206 Extract target data from the target file, and perform parsing and processing.
  • Step S207 The HASH information of the target file data is calculated, and if an abnormality occurs, the process proceeds to step S208. Otherwise, the mega-transfer to step 4 gathers S209.
  • Step S208 Write the target file abnormality record to the log, and then jump to step S206.
  • Step S209 The source file information is cyclically searched in the memory index model by the HASH value of the target file data. For example, the HASH value is used to find whether there is an offset position of the corresponding record in the source file.
  • Step S210 If there is a record with the same HASH value, the process goes to step S211, otherwise it jumps to step 4 to S212.
  • Step S211 Comparing the record information corresponding to the target file with the record information at the offset position of the source file.
  • Step 4 S212: Write the comparison result of step 4 to S211 into the result file.
  • Step S213 It is judged whether there is still an object file for which the comparison is not completed. If there is, then jump to step M1 S206, otherwise step 4 to S214.
  • Step S214 End the file comparison.
  • the system parameters are dynamically acquired, and the bottom layer comparison method is implemented by using the c code.
  • the HASH value information and the file offset information of the stored data are used instead of the entire record, and then the memory index model is established, which is extremely Optimized alignment performance, the system performs well when processing massive amounts of data.
  • the time for processing 40 million and 40 million processing on a normal PC is controlled within 20 minutes.
  • FIG. 3 is a schematic diagram of a memory indexing model in accordance with the preferred embodiment.
  • the memory index model is used to describe the data structure of the storage comparison data, and is described by taking "CP_CODE
  • the first hash table ( FIRST HASH TABL ) in FIG. 3 is stored.
  • Embodiment 3 This embodiment provides a source file a.txt and an object file b.txt, where a.txt contains the following two records:
  • the a txt is first loaded into the memory, and the corresponding memory model is established. Then by reading the b.txt file, calculate the HASH value, search in the memory model, and then read the corresponding record in the a.txt file for comparison. Generate a result file.
  • FIG. 4 is according to the present invention
  • a preferred schematic diagram of the data comparison device of the embodiment comprising: a comparing unit 402, configured to compare the first hash HASH information of the source file with the second HASH information of the target file; generating unit 404, and comparing unit 402, configured to generate a comparison result of the source file and the target file according to the comparison result.
  • the comparing unit 402 includes: a first establishing module 4021, configured to establish, in a memory, a memory index table corresponding to the source file, where the memory index table includes the first hash HASH information An index record corresponding to all the HASH values in the search module 4022, configured to search, in the memory index table, whether there is an index record corresponding to the second HASH information, where the HASH value in the index record is equal to The HASH value in the second HASH information.
  • the comparing unit 402 further includes: a second establishing module 4023, configured to: when a memory index table corresponding to the source file is established in the memory, establish a conflict list in the memory, where The list of conflicts established in the embodiment, the use of memory can be optimized.
  • the generating unit 404 further includes: a first generating module 4041, configured to generate first indication information when the index record corresponding to the second HASH information exists in the memory index table, where The first indication information is used to indicate that the source file and the target file have data information corresponding to the HASH value in the searched index record; the second generation module 4042, And generating, by the memory index table, the second indication information is generated when the index record corresponding to the second HASH information does not exist, where the second indication information is used to indicate that the source file does not have Data information corresponding to the HASH value in the second HASH information.
  • the generation manner of the preferred embodiment can facilitate the user to view the comparison result.
  • the comparison unit 402 may further include: a comparison module 4024, configured to find, in the memory index table, that an index record corresponding to the second HASH information exists And recording the record information corresponding to the second HASH information in the target file with the record information corresponding to the index record in the source file.
  • the generating unit 404 further includes: a third generating module 4043, configured to generate third indication information when the two are the same, where the third indication information is used to indicate the source file Together with the target file, there is data information corresponding to the HASH value in the found index record. The generation manner of the preferred embodiment can facilitate the user to view the comparison result.
  • the memory index table includes: a multi-level HASH structure, a conflict list, and record offset information of the source file (for example, one record in the source file is in the source file) Offset position), as shown in Figure 3.
  • the search efficiency can be further improved.
  • the source file has the same file format as the target file.
  • the efficiency of the alignment can be further improved.
  • FIG. 5 is another preferred schematic diagram of a data comparison apparatus according to an embodiment of the present invention, which includes: a system parameter parsing module 502 connected in sequence, a source file loading and parsing module 504, a memory index creating module 506, and data.
  • the lookup and comparison module 508 and the result file generation module 510 implements the comparison between the source file and the target file by the following main steps: Step A: The system parameter parsing module 502 acquires dynamic system parameters provided by the user, and initializes system environment variables; Step B, source file loading Loading the comparison data with the parsing module 504, and reading the offset information and the HASH information of the file where the data is located into the memory; Step C, the memory index creating module 506 establishes a memory index model of the memory data; Step D, the data search and comparison module 508 starts the comparison program, and compares the data files.
  • Step A The system parameter parsing module 502 acquires dynamic system parameters provided by the user, and initializes system environment variables; Step B, source file loading Loading the comparison data with the parsing module 504, and reading the offset information and the HASH information of the file where the data is located into the memory; Step C, the memory index creating module 506 establishes a memory index model of the memory data; Step D, the
  • Step E The result file generation module 510 generates a comparison result, so that the user can view the log and the data result, and the risk comparison result.
  • the configuration information is dynamically obtained through interaction with the user; the entire data is completely added to the memory by storing the offset information and the HASH information, and a large linear conflict list is established to save the conflict element and use the memory.
  • a memory index model it is possible to quickly locate the source file location of the data to improve processing performance.
  • the above embodiment is also highly popular, and is suitable for the comparison of massive data of any formatted text data, and does not require any characteristics of the data.
  • the formatted text data described in this document means that each line of data in a text file follows the following form:
  • the present invention can process formatted text data without any features, which can greatly improve performance and data ratio Accuracy; and the ability to dynamically access system operating parameters to achieve complex data logic, which makes it useful in current industry to troubleshoot some standard file data such as bills, reports, order relationships, user information, etc. Big. It should be noted that the steps shown in the flowchart of the accompanying drawings may be performed in a computer system such as a set of computer executable instructions, and, although the logical order is shown in the flowchart, in some cases, The steps shown or described may be performed in an order different from that herein.
  • 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, or they may be separately fabricated into individual integrated circuit modules, or they may be Multiple modules or steps are made into a single integrated circuit module.
  • the invention is not limited to any specific combination of hardware and software.
  • the above is only the preferred embodiment of the present invention, and is not intended to limit the present invention, and various modifications and changes can be made to the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the scope of the present invention are intended to be included within the scope of the present invention.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (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 ) 釆用第三方工具, 诸如 ue、 merge等工具软件结合使用来比对;
2 ) 在数据库中通过存储过程釆用游标的方式来比对;
3 ) 釆用 hash ( Hash, —种常用的数据存储结构, 又叫哈希表或散列表) 表存储数据的方式来比对。 上述方法 1 ) 用来比较小数据量的文件数据时还可以胜任, 但如果用来处 理大量数据的时候, 往往操作者会顾此失彼, 产生很多错误, 这样也致使比对 的效率十分氏下; 方法 2 ) 所釆用的方式是借助数据库的特性来处理完成比对 工作, 这不失为一个简便的处理方式, 但是其缺点正是数据库本身带来的: 对 系统软、 硬件环境的依赖性高, 处理速度也很慢; 方法 3 ) 是当前被普遍釆用 的一种比对方法, 相对于前面的两种方式, 其拥有处理效率较高的优势, 但是 发明人经过测试发现其在处理海量数据的时候, 对计算机的软、 硬件的要求艮 高, 对内存的占用率特别大。 通过上述分析, 根据现有技术中的数据比对方法, 内存占用率较高, 执行 时间较长、 效率较低。 发明内容 针对现有技术中的数据比对方法导致内存占用率较高的问题而提出本发 明, 为此, 本发明的主要目的在于提供一种数据比对方法和装置, 以解决上述 问题至少之一。 为了实现上述目的, 根据本发明的一个方面, 提供了一种数据比对方法, 其包括: 将源文件的第一哈希 HASH信息与目标文件的第二 HASH信息进行 比较; 根据比较结果生成上述源文件与上述目标文件的比对结果。 将源文件的第一哈希 HASH信息与目标文件的第二 HASH信息进行比较 包括: 在内存中建立与上述源文件对应的内存索引表, 其中, 上述内存索引表 包括与上述第一哈希 HASH信息中的所有 HASH值对应的索引记录; 在上述 内存索引表中查找是否存在与上述第二 HASH信息对应的索引记录, 其中, 上 述索引记录中的 HASH值等于上述第二 HASH信息中的 HASH值。 在内存中建立与上述源文件对应的内存索引表时, 数据比对方法还包括: 在上述内存中建立冲突列表, 其中, 上述冲突列表为连续存储空间, 设置为保 存在比对上述源文件与上述目标文件时产生的冲突元素。 根据比较结果生成上述源文件与上述目标文件的比对结果包括: 若在上述 内存索引表中查找出存在与上述第二 HASH信息对应的索引记录,则生成第一 指示信息, 其中, 上述第一指示信息设置为指示上述源文件与上述目标文件共 同具有与查找出的上述索引记录中的 HASH值对应的数据信息;若在上述内存 索引表中查找出不存在与上述第二 HASH信息对应的索引记录,则生成第二指 示信息, 其中, 上述第二指示信息设置为指示上述源文件中不具有与上述第二 HASH信息中的 HASH值对应的数据信息。 根据比较结果生成上述源文件与上述目标文件的比对结果包括: 若在上述 内存索引表中查找出存在与上述第二 HASH信息对应的索引记录,则将上述目 标文件中与第二 HASH 信息对应的记录信息与上述源文件中与上述索引记录 对应的记录信息进行比较; 若两者相同, 则生成第三指示信息, 其中, 上述第 三指示信息设置为指示上述源文件与上述目标文件共同具有与查找出的上述 索引记录中的 HASH值对应的数据信息;若在上述内存索引表中查找出不存在 与上述第二 HASH信息对应的索引记录, 则生成第四指示信息, 其中, 上述第 四指示信息设置为指示上述源文件中不具有与上述第二 HASH信息中的 HASH 值对应的数据信息。 上述源文件与上述目标文件具有相同的文件格式。 为了实现上述目的, 根据本发明的另一方面, 提供了一种数据比对装置, 其包括: 比较单元, 设置为将源文件的第一哈希 HASH信息与目标文件的第二 HASH信息进行比较; 生成单元, 设置为根据比较结果生成上述源文件与上述 目标文件的比对结果。 上述比较单元包括: 第一建立模块, 设置为在内存中建立与上述源文件对 应的内存索引表, 其中, 上述内存索引表包括与上述第一哈希 HASH信息中的 所有 HASH值对应的索引记录; 查找模块, 设置为在上述内存索引表中查找是 否存在与上述第二 HASH信息对应的索引记录,其中,上述索引记录中的 HASH 值等于上述第二 HASH信息中的 HASH值。 上述比较单元还包括: 第二建立模块, 设置为在内存中建立与上述源文件 对应的内存索引表时, 在上述内存中建立冲突列表, 其中, 上述冲突列表设置 为保存在比对上述源文件与上述目标文件时产生的冲突元素。 上述生成单元还包括: 第一生成模块, 设置为在上述内存索引表中查找出 存在与上述第二 HASH信息对应的索引记录时, 生成第一指示信息, 其中, 上 述第一指示信息设置为指示上述源文件与上述目标文件共同具有与查找出的 上述索引记录中的 HASH值对应的数据信息; 第二生成模块, 设置为在上述内 存索引表中查找出不存在与上述第二 HASH信息对应的索引记录时,生成第二 指示信息, 其中, 上述第二指示信息设置为指示上述源文件中不具有与上述第 二 HASH信息中的 HASH值对应的数据信息。 上述比较单元还包括: 比较模块, 设置为在上述内存索引表中查找出存在 与上述第二 HASH信息对应的索引记录时, 将上述目标文件中与第二 HASH 信息对应的记录信息与上述源文件中与上述索引记录对应的记录信息进行比 较。 上述生成单元还包括: 第三生成模块, 设置为在两者相同, 则生成第三指 示信息, 其中, 上述第三指示信息设置为指示上述源文件与上述目标文件共同 具有与查找出的上述索引记录中的 HASH值对应的数据信息。 本发明通过比对源文件与目标文件的 HASH信息, 而不是数据本身, 解决 了现有技术中的数据比对方法导致内存占用率较高的问题, 进而达到了减少执 行时间和提高处理效率的效果。 此外, 本发明通过比较 HASH信息, 使得比对 过程不依赖于数据的特征, 能够处理不同种类的格式化数据, 其中, 格式化数 据时没有任何特征可以提取。 本发明的其它特征和优点将在随后的说明书中阐述, 并且, 部分地从说明 书中变得显而易见, 或者通过实施本发明而了解。 本发明的目的和其他优点可 通过在所写的说明书、 权利要求书、 以及附图中所特别指出的结构来实现和获 得。 附图说明 此处所说明的附图用来提供对本发明的进一步理解, 构成本申请的一部 分, 本发明的示意性实施例及其说明用于解释本发明, 并不构成对本发明的不 当限定。 在附图中: 图 1是根据本发明实施例的数据比对方法的一种优选流程图; 图 2是根据本发明实施例的数据比对方法的另一种优选流程图; 图 3是根据本发明实施例的内存索引模型的示意图; 图 4是根据本发明实施例的数据比对装置的一种优选示意图; 图 5是根据本发明实施例的数据比对装置的另一种优选示意图。 具体实施方式 下文中将参考附图并结合实施例来详细说明本发明。 需要说明的是, 在不 冲突的情况下, 本申请中的实施例及实施例中的特征可以相互组合。 实施例 1 图 1是根据本发明实施例的数据比对方法的一种优选流程图, 其包括:
S 102 , 将源文件的第一哈希 HASH信息与目标文件的第二 HASH信息进 行比较;
S 104, 才艮据比较结果生成上述源文件与上述目标文件的比对结果。 本实施例通过比对源文件与目标文件的 HASH信息, 而不是数据本身, 解 决了现有技术中的数据比对方法导致内存占用率较高的问题, 进而达到了减少 执行时间和提高处理效率的效果。 优选的, 将源文件的第一哈希 HASH信息与目标文件的第二 HASH信息 进行比较包括: 在内存中建立与所述源文件对应的内存索引表, 其中, 所述内 存索引表包括与所述第一哈希 HASH信息中的所有 HASH值对应的索引记录; 在所述内存索引表中查找是否存在与所述第二 HASH信息对应的索引记录,其 中, 所述索引记录中的 HASH值等于所述第二 HASH信息中的 HASH值。 通 过本优选实施例中建立的内存索引表,能够快速的定位源文件的 HASH信息的 位置, 提高了处理效率。 优选的, 在内存中建立与所述源文件对应的内存索引表时, 还包括: 在所 述内存中建立冲突列表, 其中, 所述冲突列表为连续存储空间, 用于保存在比 对所述源文件与所述目标文件时产生的冲突元素。 通过本优选实施例中建立的 冲突列表, 内存的使用可以达到最优化。 优选的, 在上述几个优选实施例的基础上, 根据比较结果生成所述源文件 与所述目标文件的比对结果包括: 若在所述内存索引表中查找出存在与所述第 二 HASH信息对应的索引记录, 则生成第一指示信息, 其中, 所述第一指示信 息用于指示所述源文件与所述目标文件共同具有与查找出的所述索引记录中 的 HASH值对应的数据信息;若在所述内存索引表中查找出不存在与所述第二 HASH信息对应的索引记录, 则生成第二指示信息, 其中, 所述第二指示信息 用于指示所述源文件中不具有与所述第二 HASH信息中的 HASH值对应的数 据信息。 通过本优选实施例的生成方式, 可以便于用户查看比对结果。 优选的, 居比较结果生成所述源文件与所述目标文件的比对结果包括:
1 )若在所述内存索引表中查找出存在与所述第二 HASH信息对应的索引记录, 则将所述目标文件中与第二 HASH 信息对应的记录信息与所述源文件中与所 述索引记录对应的记录信息进行比较; 若两者相同, 则生成第三指示信息, 其 中, 所述第三指示信息用于指示所述源文件与所述目标文件共同具有与查找出 的所述索引记录中的 HASH值对应的数据信息; 2 ) 若在所述内存索引表中查 找出不存在与所述第二 HASH信息对应的索引记录, 则生成第四指示信息, 其 中,所述第四指示信息用于指示所述源文件中不具有与所述第二 HASH信息中 的 HASH值对应的数据信息。 通过本优选实施例的生成方式, 可以便于用户查 看比对结果。 优选的, 在上述几个优选实施例的基础上, 所述内存索引表包括: 多级
HASH结构、 冲突列表以及源文件的记录偏移信息 (例如, 源文件中的一条记 录在源文件中的偏移位置), 如图 3 所示。 通过本优选实施例的内存索引表, 可以使得查找效率进一步提高。 优选的, 所述源文件与所述目标文件具有相同的文件格式。 通过本优选实 施例的格式限定, 可以进一步提高比对的效率。 实施例 2 图 2是根据本发明实施例的数据比对方法的另一种优选流程图, 其包括: 步骤 S201 : 获取用户提供的系统配置参数并进行相应解析。 出现异常, 则 转到步骤 S205 , 否则跳转到步骤 S202。 步骤 S202: 读取源文件进入内存, 保存源文件数据的 HASH值信息和文 件偏移信息。 出现异常数据到步骤 S203 , 否则跳转到步骤 S204。 步骤 S203 : 将异常数据写入到日志, 然后跳转至步骤 S201。 步骤 S204: 建立源文件信息的内存索引模型, 主要包括三层 HASH索引 和对应的冲突列表。 如果出现异常到步骤 S205 , 否则到步骤 S206。 步骤 S205: 将内存模型失败写入日志, 跳转到步骤 S214。 步骤 S206: 从目标文件提取目标数据, 进行解析和处理。 步骤 S207: 计算目标文件数据的 HASH信息, 如果发生异常, 跳转到步 骤 S208。 否则, 兆转至步 4聚 S209。 步骤 S208: 将目标文件异常记录写入日志, 然后跳转至步骤 S206。 步骤 S209: 通过目标文件数据的 HASH值去内存索引模型中循环搜索源 文件信息。例如,通过 HASH值查找源文件中是否存在对应的记录的偏移位置。 步骤 S210: 如果存在 HASH值相同的记录, 跳转到步骤 S211 , 否则跳转 到步 4聚 S212。 步骤 S211 :将目标文件对应的记录信息和源文件的上述偏移位置上的记录 信息进行比较。 步 4聚 S212: 将步 4聚 S211的比较结果写入到结果文件中。 步骤 S213: 判断是否还有未完成比较的目标文件。 如果还有, 则跳转到步 Ml S206 , 否则到步 4聚 S214。 步骤 S214: 结束文件比对。 在本实施例中, 系统参数通过动态的获取, 底层比对方法使用 c代码来实 现, 通过釆用存储数据的 HASH值信息和文件偏移信息代替整个记录, 然后建 立内存索引模型, 极大的优化的比对性能, 系统在处理海量数据的时候性能表 现优异。普通 PC机上比对 4000万条和 4000万条处理的时间控制在 20分钟以 内。 图 3是根据本优选实施例的内存索引模型的示意图。 如图 3所示, 该内存 索 引 模型 用 于描 述存储比对数据 的 数据结构 , 以 "CP_CODE |APP_CODE|USER" 为 例 来 进行说 明 , 图 3 中 的 第 一 哈 希 表 ( FIRST HASH TABL ) 存储的是 HASH 函数 funl 对字符串" CP CODE |APP CODE|USER"进行 HASH后所得值再对 FIRST HASH TABLE SIZE (第 一哈希表大小)进行取模后得到的值, 第二哈希表 ( SECOND HASH TABLE ) 存储的是 HASH函数 fun2对字符串 "CP CODE | APP CODE|USER"进行 HASH 后所得值再对 SECOND HASH TABLE SIZE (第二哈希表大小) 进行取模后 得到的值, 冲突列表( COLLISION QUEUE )存储的是冲突元素, 偏移位置信 息 ( SRC RECORD ARRAY )存储的是" CP CODE |APP CODE|USER"这行记 录所在文件的文件偏移信息, 优选的, 还包括上述 HASH值信息。 实施例 3 本实施例提供了源文件 a.txt和目标文件 b.txt, 其中 a.txt含有如下两条记 录:
2013|950112345| 13012345678 2013|950112345| 13098765432 b.txt 有^口下两 ΐ己录:
2013|950112345| 13012345678 2014|950112345| 13098765432 用户分别指定按照全部字段比较。 按照以上步骤 S201〜步骤 S214, 首先通过将 a txt加载到内存中, 并建立 好相应的内存模型。 然后通过读取 b.txt文件, 计算 HASH值, 在内存模型中 搜索, 然后到 a.txt文件中读取相应记录进行比较。 生成结果文件。 a txt独有的记录: 2013|950112345| 13098765432 b.txt独有的记录: 2014|950112345| 13098765432 a txt和 b.txt文件共有的记录: 2013|950112345| 13012345678 实施例 4 图 4是根据本发明实施例的数据比对装置的一种优选示意图, 其包括: 比 较单元 402 ,用于将源文件的第一哈希 HASH信息与目标文件的第二 HASH信 息进行比较; 生成单元 404 , 与比较单元 402连接, 用于根据比较结果生成所 述源文件与所述目标文件的比对结果。 本实施例通过比对源文件与目标文件的 HASH信息, 而不是数据本身, 解 决了现有技术中的数据比对方法导致内存占用率较高的问题, 进而达到了减少 执行时间和提高处理效率的效果。 优选的, 所述比较单元 402包括: 第一建立模块 4021 , 用于在内存中建立 与所述源文件对应的内存索引表, 其中, 所述内存索引表包括与所述第一哈希 HASH信息中的所有 HASH值对应的索引记录; 查找模块 4022 , 用于在所述 内存索引表中查找是否存在与所述第二 HASH信息对应的索引记录, 其中, 所 述索引记录中的 HASH值等于所述第二 HASH信息中的 HASH值。 通过本优 选实施例中建立的内存索引表,能够利用源文件中的 HASH信息快速地定位源 文件的记录信息的位置, 提高了处理效率。 优选的, 所述比较单元 402还包括: 第二建立模块 4023 , 用于在内存中建 立与所述源文件对应的内存索引表时, 在所述内存中建立冲突列表, 其中, 所 过本优选实施例中建立的冲突列表, 内存的使用可以达到最优化。 优选的, 所述生成单元 404还包括: 第一生成模块 4041 , 用于在所述内存 索引表中查找出存在与所述第二 HASH信息对应的索引记录时,生成第一指示 信息, 其中, 所述第一指示信息用于指示所述源文件与所述目标文件共同具有 与查找出的所述索引记录中的 HASH值对应的数据信息; 第二生成模块 4042 , 用于在所述内存索引表中查找出不存在与所述第二 HASH 信息对应的索引记 录时, 生成第二指示信息, 其中, 所述第二指示信息用于指示所述源文件中不 具有与所述第二 HASH信息中的 HASH值对应的数据信息。 通过本优选实施 例的生成方式, 可以便于用户查看比对结果。 优选的,在上述几个优选实施例的基础上,所述比较单元 402还可以包括: 比较模块 4024 , 用于在所述内存索引表中查找出存在与所述第二 HASH信息 对应的索引记录时,将所述目标文件中与第二 HASH信息对应的记录信息与所 述源文件中与所述索引记录对应的记录信息进行比较。 在本优选实施例中, 所 述生成单元 404还包括: 第三生成模块 4043 , 用于在两者相同, 则生成第三指 示信息, 其中, 所述第三指示信息用于指示所述源文件与所述目标文件共同具 有与查找出的所述索引记录中的 HASH值对应的数据信息。通过本优选实施例 的生成方式, 可以便于用户查看比对结果。 优选的, 在上述几个优选实施例的基础上, 所述内存索引表包括: 多级 HASH结构、 冲突列表以及源文件的记录偏移信息 (例如, 源文件中的一条记 录在源文件中的偏移位置), 如图 3 所示。 通过本优选实施例的内存索引表, 可以使得查找效率进一步提高。 优选的, 所述源文件与所述目标文件具有相同的文件格式。 通过本优选实 施例的格式限定, 可以进一步提高比对的效率。 实施例 5 图 5是根据本发明实施例的数据比对装置的另一种优选示意图, 其包括: 依次连接的系统参数解析模块 502 , 源文件加载与解析模块 504、 内存索引创 建模块 506、 数据查找与比对模块 508以及结果文件生成模块 510。 本发明实施例的数据比对装置通过以下主要步骤实现源文件与目标文件 的比对: 步骤 A、 系统参数解析模块 502获取用户提供的动态系统参数, 初始化系 统环境变量; 步骤 B、 源文件加载与解析模块 504加载比对数据, 将数据所在文件的偏 移信息和 HASH信息读入内存; 步骤 C、 内存索引创建模块 506建立内存数据的内存索引模型; 步骤 D、 数据查找与比对模块 508启动比对程序, 对数据文件进行比对; 步骤 E、 结果文件生成模块 510生成比对结果, 以便用户查看日志和数据 结果, -险证比对结果。 本实施例通过与用户的交互动态获取配置信息; 通过对数据的偏移信息和 HASH信息的存储代替整个数据的完整加入到内存, 并且建立大块线性的冲突 列表来保存冲突元素, 使内存使用达到最优化, 通过建立内存索引模型, 能够 快速的定位数据的源文件位置, 以提升处理的性能。 此外, 上述实施例还具有很大的推广性, 适合于任何格式化文本数据的海 量数据的比对工作, 不要求数据有任何的特征。 文中所述的格式化文本数据指 的是文本文件中的每行数据都遵从以下形式:
"字段 1 分隔符 字段 2 分隔符 ... ...字段 n-1 分隔符 字段 n 换行符" 此外, 本发明可以处理没有任何特征的格式化文本数据, 能极大的提升性 能以及数据比对准确率; 而且能通过动态获取系统运行参数的方式实现复杂的 数据逻辑, 这使得在当前各行业在排查诸如话单、 报表、 订购关系、 用户信息 等一些标准文件数据时的应用价值 4艮大。 需要说明的是, 在附图的流程图示出的步骤可以在诸如一组计算机可执行 指令的计算机系统中执行, 并且, 虽然在流程图中示出了逻辑顺序, 但是在某 些情况下, 可以以不同于此处的顺序执行所示出或描述的步 4聚。 显然, 本领域的技术人员应该明白, 上述的本发明的各模块或各步骤可以 用通用的计算装置来实现, 它们可以集中在单个的计算装置上, 或者分布在多 个计算装置所组成的网络上, 可选地, 它们可以用计算装置可执行的程序代码 来实现, 从而, 可以将它们存储在存储装置中由计算装置来执行, 或者将它们 分别制作成各个集成电路模块, 或者将它们中的多个模块或步骤制作成单个集 成电路模块来实现。 这样, 本发明不限制于任何特定的硬件和软件结合。 以上所述仅为本发明的优选实施例而已, 并不用于限制本发明, 对于本领 域的技术人员来说, 本发明可以有各种更改和变化。 凡在本发明的 ^"神和原则 之内, 所作的任何修改、 等同替换、 改进等, 均应包含在本发明的保护范围之 内。

Claims

权 利 要 求 书
1. 一种数据比对方法, 包括:
将源文件的第一哈希 HASH信息与目标文件的第二 HASH信息进行 比较;
根据比较结果生成所述源文件与所述目标文件的比对结果。
2. 根据权利要求 1所述的方法, 其中, 将源文件的第一哈希 HASH信息与 目标文件的第二 HASH信息进行比较包括: 在内存中建立与所述源文件对应的内存索引表, 其中, 所述内存索 引表包括与所述第一哈希 HASH信息中的所有 HASH值对应的索引记 录;
在所述内存索引表中查找是否存在与所述第二 HASH信息对应的索 引记录, 其中, 所述索引记录中的 HASH值等于所述第二 HASH信息中 的 HASH值。
3. 根据权利要求 2所述的方法, 其中, 在内存中建立与所述源文件对应的 内存索引表时, 还包括:
在所述内存中建立冲突列表, 其中, 所述冲突列表为连续存储空间,
4. 根据权利要求 2所述的方法, 其中, 根据比较结果生成所述源文件与所 述目标文件的比对结果包括:
若在所述内存索引表中查找出存在与所述第二 HASH信息对应的索 引记录, 则生成第一指示信息, 其中, 所述第一指示信息用于指示所述 源文件与所述目标文件共同具有与查找出的所述索引记录中的 HASH值 对应的数据信息;
若在所述内存索引表中查找出不存在与所述第二 HASH信息对应的 索引记录, 则生成第二指示信息, 其中, 所述第二指示信息用于指示所 述源文件中不具有与所述第二 HASH信息中的 HASH值对应的数据信 息。
5. 根据权利要求 2所述的方法, 其中, 根据比较结果生成所述源文件与所 述目标文件的比对结果包括:
若在所述内存索引表中查找出存在与所述第二 HASH信息对应的索 引记录, 则将所述目标文件中与第二 HASH信息对应的记录信息与所述 源文件中与所述索引记录对应的记录信息进行比较; 若两者相同, 则生 成第三指示信息, 其中, 所述第三指示信息用于指示所述源文件与所述 目标文件共同具有与查找出的所述索引记录中的 HASH值对应的数据信 息;
若在所述内存索引表中查找出不存在与所述第二 HASH信息对应的 索引记录, 则生成第四指示信息, 其中, 所述第四指示信息用于指示所 述源文件中不具有与所述第二 HASH信息中的 HASH值对应的数据信 息。
6. 居权利要求 1所述的方法, 其中, 所述源文件与所述目标文件具有相 同的文件格式。
7. —种数据比对装置, 包括:
比较单元, 设置为将源文件的第一哈希 HASH信息与目标文件的第 二 HASH信息进行比较;
生成单元, 设置为根据比较结果生成所述源文件与所述目标文件的 比对结果。
8. 根据权利要求 7所述的装置, 其中, 所述比较单元包括:
第一建立模块, 设置为在内存中建立与所述源文件对应的内存索引 表, 其中, 所述内存索引表包括与所述第一哈希 HASH 信息中的所有 HASH值对应的索引记录;
查找模块, 设置为在所述内存索引表中查找是否存在与所述第二 HASH信息对应的索引记录, 其中, 所述索引记录中的 HASH值等于所 述第二 HASH信息中的 HASH值。
9. 根据权利要求 8所述的装置, 其中, 所述比较单元还包括:
第二建立模块, 设置为在内存中建立与所述源文件对应的内存索引 表时, 在所述内存中建立冲突列表, 其中, 所述冲突列表设置为保存在 比对所述源文件与所述目标文件时产生的冲突元素。
10. 根据权利要求 8所述的装置, 其中, 所述生成单元还包括:
第一生成模块, 设置为在所述内存索引表中查找出存在与所述第二 HASH信息对应的索引记录时, 生成第一指示信息, 其中, 所述第一指 示信息设置为指示所述源文件与所述目标文件共同具有与查找出的所述 索引记录中的 HASH值对应的数据信息;
第二生成模块, 设置为在所述内存索引表中查找出不存在与所述第 二 HASH信息对应的索引记录时, 生成第二指示信息, 其中, 所述第二 指示信息设置为指示所述源文件中不具有与所述第二 HASH 信息中的 HASH值对应的数据信息。
11. 根据权利要求 8所述的装置, 其中,
所述比较单元还包括:
比较模块, 设置为在所述内存索引表中查找出存在与所述第二 HASH信息对应的索引记录时, 将所述目标文件中与第二 HASH信息对 应的记录信息与所述源文件中与所述索引记录对应的记录信息进行比 较;
所述生成单元还包括:
第三生成模块, 设置为在两者相同, 则生成第三指示信息, 其中, 所述第三指示信息设置为指示所述源文件与所述目标文件共同具有与查 找出的所述索引记录中的 HASH值对应的数据信息。
PCT/CN2011/076964 2010-09-27 2011-07-07 数据比对方法和装置 WO2012041110A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN2010105070303A CN101957858A (zh) 2010-09-27 2010-09-27 数据比对方法和装置
CN201010507030.3 2010-09-27

Publications (1)

Publication Number Publication Date
WO2012041110A1 true WO2012041110A1 (zh) 2012-04-05

Family

ID=43485187

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2011/076964 WO2012041110A1 (zh) 2010-09-27 2011-07-07 数据比对方法和装置

Country Status (2)

Country Link
CN (1) CN101957858A (zh)
WO (1) WO2012041110A1 (zh)

Families Citing this family (18)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101957858A (zh) * 2010-09-27 2011-01-26 中兴通讯股份有限公司 数据比对方法和装置
CN103729342B (zh) * 2012-10-12 2016-09-28 中国银联股份有限公司 文件比对方法及装置
CN103970728A (zh) * 2013-02-01 2014-08-06 中国银联股份有限公司 一种文件的比对方法和系统
CN104123280B (zh) * 2013-04-24 2017-08-25 中国银联股份有限公司 文件比对方法和设备
CN104021132B (zh) * 2013-12-08 2017-08-22 郑州正信科技发展股份有限公司 主备数据库数据一致性核查备份方法及其系统
CN103678583B (zh) * 2013-12-11 2017-07-21 北京华胜天成科技股份有限公司 结构化数据比较的方法及系统
CN104750743A (zh) * 2013-12-31 2015-07-01 中国银联股份有限公司 一种交易文件勾对系统和方法
CN104079581B (zh) * 2014-07-16 2017-07-11 金红宇 身份认证方法及设备
CN105653554B (zh) * 2014-11-14 2019-07-16 卓望数码技术(深圳)有限公司 一种文件数据比对方法和系统
CN108733674B (zh) * 2017-04-14 2021-10-08 宁德时代新能源科技股份有限公司 一种a2l文件合并方法及装置
CN107247749B (zh) * 2017-05-25 2020-08-25 创新先进技术有限公司 一种数据库状态确定方法、一致性验证方法及装置
CN109886801A (zh) * 2019-01-28 2019-06-14 上海孚厘金融信息服务有限公司 一种电子银行流水真伪鉴别方法及装置
CN110109920B (zh) * 2019-03-19 2022-03-22 咪咕文化科技有限公司 数据比对方法及服务器
CN110262885A (zh) * 2019-06-20 2019-09-20 北京奇艺世纪科技有限公司 一种数据请求处理方法、装置、存储介质及计算机设备
CN110991065B (zh) * 2019-12-11 2021-10-29 清华大学 一种建筑信息模型中设计变更自动识别方法
CN111158590B (zh) * 2019-12-17 2021-07-06 苏州浪潮智能科技有限公司 一种解决哈希冲突的方法和设备
CN111191436A (zh) * 2020-01-03 2020-05-22 北大方正集团有限公司 版式文档的比对方法、装置、设备及计算机存储介质
CN114118008B (zh) * 2022-01-21 2022-05-10 西安羚控电子科技有限公司 一种基于bs架构的数据对比系统及方法

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0991303A (ja) * 1995-09-22 1997-04-04 Fujitsu Ltd データ管理装置
CN1979516A (zh) * 2005-12-10 2007-06-13 腾讯科技(深圳)有限公司 一种图像文件的验证及使用方法
CN101398837A (zh) * 2008-10-23 2009-04-01 深圳市奇迹通讯有限公司 一种快速匹配短信文本的方法
CN101957858A (zh) * 2010-09-27 2011-01-26 中兴通讯股份有限公司 数据比对方法和装置

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060212426A1 (en) * 2004-12-21 2006-09-21 Udaya Shakara Efficient CAM-based techniques to perform string searches in packet payloads

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0991303A (ja) * 1995-09-22 1997-04-04 Fujitsu Ltd データ管理装置
CN1979516A (zh) * 2005-12-10 2007-06-13 腾讯科技(深圳)有限公司 一种图像文件的验证及使用方法
CN101398837A (zh) * 2008-10-23 2009-04-01 深圳市奇迹通讯有限公司 一种快速匹配短信文本的方法
CN101957858A (zh) * 2010-09-27 2011-01-26 中兴通讯股份有限公司 数据比对方法和装置

Also Published As

Publication number Publication date
CN101957858A (zh) 2011-01-26

Similar Documents

Publication Publication Date Title
WO2012041110A1 (zh) 数据比对方法和装置
US11281531B2 (en) Serial storage node processing of data functions
JP6419319B2 (ja) 共有フォルダ及び共有ファイルの同期
US11783114B2 (en) Techniques for view capture and storage for mobile applications
WO2017201977A1 (zh) 一种数据写、读方法、装置及分布式对象存储集群
WO2021077745A1 (zh) 一种分布式存储系统的数据读写方法
CN109522283B (zh) 一种重复数据删除方法及系统
CN105468642A (zh) 数据的存储方法及装置
GB2518158A (en) Method and system for data access in a storage infrastructure
WO2021057164A1 (zh) 一种块链式账本中的查询方法、装置及设备
WO2015027731A1 (zh) 布隆过滤器生成方法和装置
WO2021057127A1 (zh) 一种基于多条业务属性的数据存储方法、装置及设备
WO2016029441A1 (zh) 一种文件扫描方法及装置
US10990324B2 (en) Storage node processing of predefined data functions
KR101797483B1 (ko) 데이터베이스 관리 시스템에서 쿼리를 프로세싱하기 위한 기법
CN111930684A (zh) 基于hdfs的小文件处理方法、装置、设备及存储介质
WO2018210178A1 (zh) 文件存储方法和存储装置
US10762139B1 (en) Method and system for managing a document search index
US20160292168A1 (en) File retention
CN108021562B (zh) 应用于分布式文件系统的存盘方法、装置及分布式文件系统
CN111444194B (zh) 一种块链式账本中索引的清除方法、装置及设备
US20130218851A1 (en) Storage system, data management device, method and program
US11055018B2 (en) Parallel storage node processing of data functions
US11314593B2 (en) Storage node processing of data functions using overlapping symbols
CN109543079B (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: 11828006

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: 11828006

Country of ref document: EP

Kind code of ref document: A1