File content difference identification method and device, equipment and storage medium

Through hash calculation and hash mapping table methods, the file content comparison is automated, which solves the problems of inefficient and insufficient accuracy of traditional comparisons, and realizes efficient and accurate file content differences identification, reducing testing costs.

CN119067092APending Publication Date: 2024-12-03PING AN BANK CO LTD
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202411045180.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-31
Publication Date
2024-12-03

AI Technical Summary

Technical Problem

Traditional file content comparison methods are inefficient, which can easily lead to human errors and affect the accuracy and reliability of test results. Especially in the context of rapid changes in the iteration of software application versions, it is difficult to meet the needs of efficient and accurate comparison.

Method used

Using hash calculation and hash mapping table methods, by receiving differential identification instructions, reading the baseline file and the current file, parsing and extracting data fields, calculating hash value and position information, building a hash mapping table, and comparing the tables in turn The key-value pairs in the file determine the difference locations of the file content and realize automated and efficient comparison.

Benefits of technology

It improves the efficiency and accuracy of file content comparison, reduces the work burden of testers, ensures the reliability of test results, and reduces the testing cost.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119067092A_ABST
    Figure CN119067092A_ABST
Patent Text Reader

Abstract

The invention discloses a file content difference identification method and device, equipment and a storage medium, and belongs to the technical field of big data. According to the application, the baseline file and the current file are read as comparison objects, the data fields needing to be compared are respectively extracted from the two files through file analysis, and meanwhile, the position information of each field in the file is recorded. The data fields are then subjected to a hash calculation to generate hash values. Thirdly, constructing a hash mapping table, and storing the hash value and the position information in a key value pair form, so as to facilitate subsequent quick retrieval; and finally, identifying Hash difference items by comparing the keys of the two Hash mapping tables, and accurately positioning the difference position of the file content according to the position information corresponding to the Hash difference items. The invention further relates to the technical field of block chains, and the baseline file and the current file can be stored on a block chain network. According to the scheme of the invention, accurate identification and efficient positioning of file content changes are realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of big data technology, and specifically relates to a method, device, equipment and storage medium for identifying file content differences. Background Art

[0002] In the current era of rapid development of Internet technology, the iteration cycle of software applications and data files is getting shorter and shorter, and the content is updated frequently. This trend has put forward unprecedented high requirements for software testing. Faced with the rapid changes of massive files, traditional file content comparison methods often rely on manual comparison of file contents one by one, which is not only inefficient and consumes a lot of human resources, but also easily leads to errors due to human negligence or fatigue, seriously affecting the accuracy and reliability of test results. Summary of the invention

[0003] The purpose of the embodiments of the present application is to propose a method, apparatus, computer equipment and storage medium for identifying file content differences, aiming to improve the efficiency and accuracy of file content comparison through automated tools and reduce the workload of testers.

[0004] In order to solve the above technical problems, the present application embodiment provides a method for identifying file content differences, which adopts the following technical solution:

[0005] A method for identifying differences in file content, comprising:

[0006] Receive the difference recognition instruction and read the baseline file and current file to be compared;

[0007] Parsing the baseline file to obtain a first data field, and parsing the current file to obtain a second data field;

[0008] Performing a hash calculation on the first data field to obtain a first hash value, and performing a hash calculation on the second data field to obtain a second hash value;

[0009] Acquire the position information of the first data field to obtain the first position information, and acquire the position information of the second data field to obtain the second position information;

[0010] The first hash value and the first position information are stored in the form of a key-value pair to obtain a first hash mapping table, and the second hash value and the second position information are stored in the form of a key-value pair to obtain a second hash mapping table, wherein the key position of the hash mapping table stores the hash value and the value position of the hash mapping table stores the position information;

[0011] The keys of the first hash mapping table and the second hash mapping table are compared in sequence to determine the difference hash value, and the file content difference position is determined based on the position information corresponding to the difference hash value.

[0012] Furthermore, before receiving the difference identification instruction and reading the baseline file to be compared and the current file, the method further includes:

[0013] A configuration file basic parameter table, wherein the file basic parameter table is used to configure basic parameters of the file to be compared, and the basic parameters of the file to be compared include storage file name, baseline file path, current file path, file date, file number and file owner information;

[0014] After receiving the difference recognition instruction, the baseline file and the current file to be compared are read, including:

[0015] After receiving the difference recognition instruction, obtaining the basic parameter table of the file to be compared carried in the difference recognition instruction;

[0016] Read the baseline file and the current file based on the basic parameter table of the file to be compared.

[0017] Furthermore, after the basic parameter table of the configuration file, it also includes:

[0018] Configure a parsing rule table, wherein the parsing rule table is used to store file parsing rules, and the parsing rule table is pre-set with a field name, a field start bit, and a field end bit corresponding to each file parsing rule;

[0019] Parse the baseline file to obtain the first data field, which specifically includes:

[0020] Determining a first file parsing rule that matches the baseline file;

[0021] Parsing the baseline file using the first file parsing rule to determine the field name, field start bit, and field end bit of the data field in the baseline file to obtain a first data field;

[0022] Parse the current file to obtain the second data field, which specifically includes:

[0023] Determine a second file parsing rule that matches the current file;

[0024] The current file is parsed using the second file parsing rule to determine the field name, field start bit and field end bit of the data field in the current file to obtain a second data field.

[0025] Furthermore, a whitelist corresponding to each file parsing rule is pre-set in the parsing rule table. After the baseline file is parsed using the first file parsing rule to determine the field name, field start bit, and field end bit of the data field in the baseline file and obtaining the first data field, the following is further included:

[0026] The data fields in the baseline file are screened based on the whitelist of the first file parsing rule to obtain a first data field screening result;

[0027] Based on the first data field screening result, the data fields in the baseline file that match the whitelist of the first file parsing rule are removed;

[0028] The current file is parsed using the second file parsing rule to determine the field name, field start bit and field end bit of the data field in the current file, and after obtaining the second data field, the method further includes:

[0029] The data fields in the current file are screened based on the whitelist of the second file parsing rule to obtain a second data field screening result;

[0030] Based on the second data field screening result, the data fields in the current file that match the whitelist of the second file parsing rule are removed.

[0031] Further, storing the first hash value and the first position information in the form of a key-value pair to obtain a first hash mapping table, and storing the second hash value and the second position information in the form of a key-value pair to obtain a second hash mapping table specifically includes:

[0032] Storing the first hash value and the first position information in a pre-established first temporary bucket file;

[0033] storing the second hash value and the second location information in a pre-established second temporary bucket file;

[0034] Parse the first temporary bucket file to obtain a first hash mapping table, and parse the second temporary bucket file to obtain a second hash mapping table;

[0035] The first hash mapping table and the second hash mapping table are mapping tables of Key and Value of the same structure, the first hash mapping table stores the first hash value in the Key, stores the first position information in the Value, the second hash mapping table stores the second hash value in the Key, and stores the second position information in the Value of the second hash mapping table;

[0036] Further, the key positions of the first hash mapping table and the second hash mapping table are sequentially compared to determine the difference hash value, and the file content difference position is determined based on the position information corresponding to the difference hash value, specifically including:

[0037] Traversing each first hash value stored in the Key of the first hash mapping table, and comparing each first hash value stored in the Key of the first hash mapping table with the second hash value stored in the Key of the second hash mapping table in a one-to-one correspondence, to obtain a first hash value comparison result;

[0038] Based on the comparison result of the first hash value, determine a second hash value that is inconsistent with the first hash value to obtain a first difference hash value;

[0039] Searching the second hash mapping table for the first Value corresponding to the Key of the first difference hash value by searching for a key-value pair, and obtaining the file content difference position stored in the first Value to obtain the first file content difference position;

[0040] Further, searching the second hash mapping table for the first Value corresponding to the Key of the first difference hash value by searching for a key-value pair, and obtaining the file content difference position stored in the first Value, after obtaining the first file content difference position, further comprising:

[0041] Traversing each second hash value stored in the Key of the second hash mapping table, and comparing each second hash value stored in the Key of the second hash mapping table with the first hash value stored in the Key of the first hash mapping table one by one, to obtain a second hash value comparison result;

[0042] Based on the comparison result of the second hash value, determine the first hash value that is inconsistent with the second hash value, and obtain a second difference hash value;

[0043] The second Value corresponding to the Key of the second difference hash value is searched in the first hash mapping table by searching for a key-value pair, and the file content difference position stored in the second Value is obtained to obtain the second file content difference position.

[0044] In order to solve the above technical problems, the embodiment of the present application further provides a file content difference identification device, which adopts the following technical solution:

[0045] A device for identifying differences in file content, comprising:

[0046] The file reading module is used to receive the difference recognition instruction and read the baseline file and the current file to be compared;

[0047] A file parsing module, used to parse the baseline file to obtain the first data field, and to parse the current file to obtain the second data field;

[0048] A hash calculation module, used to perform a hash calculation on the first data field to obtain a first hash value, and perform a hash calculation on the second data field to obtain a second hash value;

[0049] A position acquisition module, used to acquire the position information of the first data field to obtain the first position information, and to acquire the position information of the second data field to obtain the second position information;

[0050] A hash mapping module, used to store the first hash value and the first position information in the form of a key-value pair to obtain a first hash mapping table, and to store the second hash value and the second position information in the form of a key-value pair to obtain a second hash mapping table, wherein the key position of the hash mapping table stores the hash value, and the value position of the hash mapping table stores the position information;

[0051] The difference identification module is used to sequentially compare the key positions of the first hash mapping table and the second hash mapping table to determine the difference hash value, and determine the file content difference position based on the position information corresponding to the difference hash value.

[0052] In order to solve the above technical problems, the embodiment of the present application further provides a computer device, which adopts the following technical solution:

[0053] A computer device comprises a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of any of the above-mentioned file content difference identification methods when executing the computer-readable instructions.

[0054] In order to solve the above technical problems, the embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solution:

[0055] A computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the steps of the file content difference identification method as described in any one of the above.

[0056] Compared with the prior art, the embodiments of the present application have the following beneficial effects:

[0057] The present application discloses a method, device, equipment and storage medium for identifying differences in file content, and belongs to the field of big data technology. The present application first receives a difference identification instruction, and reads a baseline file and a current file to be compared. Then, the two files are parsed respectively to extract a first data field and a second data field. And the location information of the first data field and the second data field is obtained, and recorded as the first location information and the second location information respectively. Then, a hash calculation is performed on the two data fields to generate a first hash value and a second hash value. Next, the first hash value and its corresponding location information are stored as a first hash mapping table, and the second hash value and its location information are stored as a second hash mapping table, wherein the mapping table uses the form of a key-value pair, the key is a hash value, and the value is the location information. Finally, the keys in the first hash mapping table and the second hash mapping table are compared in sequence to identify the difference hash value, and the content difference position in the file is determined according to the location information corresponding to the difference hash value. This application parses the corresponding data fields of the two files to be compared, and generates a hash value of the data field through hash calculation. The content differences between the two files are determined by comparing the hash values, thereby achieving accurate identification and efficient positioning of file content changes, improving comparison efficiency and accuracy, and reducing testing costs. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0059] Figure 1 An exemplary system architecture diagram is shown in which the present application can be applied;

[0060] Figure 2 A flowchart of an embodiment of a method for identifying differences in file content according to the present application is shown;

[0061] Figure 3 A schematic diagram showing the structure of an embodiment of a device for identifying differences in file content according to the present application is shown;

[0062] Figure 4 A schematic structural diagram of an embodiment of a computer device according to the present application is shown. DETAILED DESCRIPTION

[0063] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.

[0064] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0065] 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 accompanying drawings.

[0066] like Figure 1 As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0067] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0068] Terminal devices 101, 102, 103 can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III), MP4 (Moving Picture Experts Group Audio Layer IV) players, laptop computers, desktop computers, etc.

[0069] Server 105 can be a server that provides various services, such as a background server that provides support for pages displayed on terminal devices 101, 102, and 103. The server can be an independent server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.

[0070] It should be noted that the file content difference identification method provided in the embodiment of the present application is generally executed by a server, and accordingly, the file content difference identification device is generally set in the server.

[0071] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.

[0072] Continue to refer Figure 2 , shows a flow chart of an embodiment of a method for identifying differences in file content according to the present application. The method for identifying differences in file content includes the following steps:

[0073] S201, receiving a difference recognition instruction, and reading a baseline file to be compared and a current file.

[0074] The server receives instructions from the user or system to determine the files that need to be compared. The baseline file is usually a reference file, and the current file is the file that needs to be compared with the baseline file.

[0075] Furthermore, before receiving the difference identification instruction and reading the baseline file to be compared and the current file, the method further includes:

[0076] A configuration file basic parameter table, wherein the file basic parameter table is used to configure basic parameters of the file to be compared, and the basic parameters of the file to be compared include storage file name, baseline file path, current file path, file date, file number and file owner information;

[0077] After receiving the difference recognition instruction, the baseline file and the current file to be compared are read, including:

[0078] After receiving the difference recognition instruction, obtaining the basic parameter table of the file to be compared carried in the difference recognition instruction;

[0079] Read the baseline file and the current file based on the basic parameter table of the file to be compared.

[0080] The configuration file basic parameter table (file_compare_template) is mainly used to configure the basic parameters of the required comparison files. It contains the basic information required for file comparison. This information must be clear before performing the comparison operation. Specifically, the functions of the file basic parameter table include:

[0081] Storage file name (file_name): records the file name that needs to be compared to ensure that the system can accurately identify and process the target file.

[0082] Baseline file path (env_path1): The storage path of the baseline file (i.e., reference file or old version file) used for comparison. This is an important reference point in the comparison process and is used to compare with the current file.

[0083] Current file path (env_path2): stores the storage path of the file that currently needs to be compared (ie, the new version file or the test file).

[0084] File date (path_time): records the date information of the file, which helps to track the version and modification time of the file, and is very useful for version control and historical comparison.

[0085] File number (template_id): It is the unique identifier of the file and is used to find the corresponding file parsing rules in table B (i.e. flat_file_parse). This number ensures the accurate association between the file and its parsing rules.

[0086] File owner information (team): records the team or department to which the file belongs, which helps manage file access permissions and responsibilities.

[0087] In the application embodiment, after receiving the difference identification instruction, the server obtains the basic parameter table of the file to be compared carried in the difference identification instruction. The basic parameter table of the file to be compared records information such as the storage file name, baseline file path, current file path, file date, file number and file owner. Then the server reads the baseline file and the current file based on the basic parameter table of the file to be compared.

[0088] In the above embodiment, the present application records information such as the storage file name, baseline file path, current file path, file date, file number and file owner of the file to be compared through a configuration file basic parameter table, so that the server can quickly find the files that need to be compared.

[0089] It should be noted that the files to be compared can be stored in an FTP file storage server. The system obtains the specified files from the FTP file storage server through SFTP and downloads them to the local server. This method ensures the security and efficiency of file transmission and supports the processing of large-scale files.

[0090] S202, parsing the baseline file to obtain a first data field, and parsing the current file to obtain a second data field.

[0091] The process of parsing files requires converting the file contents into data structures (such as data fields) that can be compared. This can be achieved through preset file parsing rules. The accuracy of this process directly affects the results of subsequent hash calculations and difference identification.

[0092] Furthermore, after the basic parameter table of the configuration file, it also includes:

[0093] Configure a parsing rule table, wherein the parsing rule table is used to store file parsing rules, and the parsing rule table is pre-set with a field name, a field start bit, and a field end bit corresponding to each file parsing rule;

[0094] Parse the baseline file to obtain the first data field, which specifically includes:

[0095] Determining a first file parsing rule that matches the baseline file;

[0096] Parsing the baseline file using the first file parsing rule to determine the field name, field start bit, and field end bit of the data field in the baseline file to obtain a first data field;

[0097] Parse the current file to obtain the second data field, which specifically includes:

[0098] Determine a second file parsing rule that matches the current file;

[0099] The current file is parsed using the second file parsing rule to determine the field name, field start bit and field end bit of the data field in the current file to obtain a second data field.

[0100] The configuration parsing rule table (flat_file_parse) is mainly used to store file parsing rules. These rules are the basis for parsing file content, extracting fields, and performing comparisons. Specifically, the functions of the configuration parsing rule table include:

[0101] Define field names (field_name): Assign a name to each field so that the meaning and purpose of each field can be clearly understood when parsing the file.

[0102] Field start bit (field_start_index) and field end bit (field_end_index): define the starting and ending positions of each field in the file.

[0103] Is_business_index: Identifies which fields are business primary keys. Business primary key fields can be specially processed during the comparison process.

[0104] Is_exclude: Specifies which fields should be excluded or ignored during the comparison process, which helps reduce unnecessary comparison work and improve comparison efficiency.

[0105] In the embodiment of the present application, the file basic parameter table and the configuration parsing rule table play a complementary role in the file content difference comparison process. The file basic parameter table provides the basic file information and parameters required for the comparison, while the configuration parsing rule table provides the parsing rules and comparison logic of the file content. The combination of the two jointly supports efficient and accurate file content difference comparison operations.

[0106] Furthermore, a whitelist corresponding to each file parsing rule is pre-set in the parsing rule table. After the baseline file is parsed using the first file parsing rule to determine the field name, field start bit, and field end bit of the data field in the baseline file and obtaining the first data field, the following is further included:

[0107] Screening the data fields in the baseline file based on the whitelist of the first file parsing rule to obtain a first data field screening result;

[0108] Based on the first data field screening result, the data fields in the baseline file that match the whitelist of the first file parsing rule are removed;

[0109] The current file is parsed using the second file parsing rule to determine the field name, field start bit and field end bit of the data field in the current file, and after obtaining the second data field, the method further includes:

[0110] The data fields in the current file are screened based on the whitelist of the second file parsing rule to obtain a second data field screening result;

[0111] Based on the second data field screening result, the data fields in the current file that match the whitelist of the second file parsing rule are removed.

[0112] On the basis of file content difference recognition, a data field screening mechanism is added to filter out data fields that do not need to be compared through a pre-set whitelist. When parsing the baseline file and the current file, the data fields are screened according to their respective file parsing rules and the corresponding whitelist, ensuring that only fields that meet the rules and are not in the whitelist are retained for subsequent hash calculations and difference comparisons. Data fields in the whitelist do not need to be compared. This mechanism effectively improves the accuracy of difference recognition, avoids unnecessary fields from participating in comparisons, reduces the amount of calculations, and also avoids false positives caused by differences in irrelevant fields.

[0113] Through this screening step, the system can identify the data fields that have undergone key modifications in the file, and users can focus more on the difference analysis of key content, improving the efficiency and value of the entire difference identification process.

[0114] S203, performing a hash calculation on the first data field to obtain a first hash value, and performing a hash calculation on the second data field to obtain a second hash value.

[0115] The hash algorithm is used to perform hash calculation on the parsed data field to generate a unique hash value. The hash value is an efficient means of identifying differences in file content. The hash value can reflect the content characteristics of the data field, and for data fields with the same content, their hash values ​​must be the same, and for data fields with any different content, their hash values ​​must be different. Identifying differences in file content by comparing hash values ​​greatly simplifies the subsequent comparison process and improves the efficiency of difference identification.

[0116] S204, acquiring position information of the first data field to obtain first position information, and acquiring position information of the second data field to obtain second position information.

[0117] After obtaining the hash value of the data field, the system also needs to record the location information of these fields in the file. The acquisition of location information is crucial for ultimately locating the difference in file content. By associating the hash value with the location information, the system can quickly point out the specific location when a difference is found, providing users with a more detailed difference report.

[0118] S205, storing the first hash value and the first location information in the form of a key-value pair to obtain a first hash mapping table, and storing the second hash value and the second location information in the form of a key-value pair to obtain a second hash mapping table, wherein the key position of the hash mapping table stores the hash value, and the value position of the hash mapping table stores the location information.

[0119] By constructing a hash map, the hash value and location information are stored in the form of key-value pairs. This key-value pair data structure not only facilitates the quick search for the location information corresponding to the hash value, but also simplifies the subsequent comparison process. By constructing the hash map of the baseline file and the current file respectively, the system is fully prepared for the subsequent difference comparison.

[0120] Further, storing the first hash value and the first position information in the form of a key-value pair to obtain a first hash mapping table, and storing the second hash value and the second position information in the form of a key-value pair to obtain a second hash mapping table specifically includes:

[0121] Storing the first hash value and the first position information in a pre-established first temporary bucket file;

[0122] storing the second hash value and the second location information in a pre-established second temporary bucket file;

[0123] Parse the first temporary bucket file to obtain a first hash mapping table, and parse the second temporary bucket file to obtain a second hash mapping table;

[0124] The first hash mapping table and the second hash mapping table are mapping tables of Key and Value of the same structure, the first hash mapping table stores the first hash value in the Key, stores the first position information in the Value, the second hash mapping table stores the second hash value in the Key, and stores the second position information in the Value of the second hash mapping table;

[0125] The first temporary bucket file is master, which is also called "master version temporary data file" or "baseline temporary data file". Here, "master" usually refers to the base, main or original version, and "temporary bucket file" refers to a file used to temporarily store processing results.

[0126] The second temporary bucket file is slave. The slave temporary bucket file is also called "slave version temporary data file" or "current temporary data file". The "slave" here refers to another version or state relative to the "master", usually referring to a copy or derived version that needs to be compared or synchronized with the master version.

[0127] The master temporary bucket file and the slave temporary bucket file are both temporary bucket files configured for file comparison. The master temporary bucket file is used to store the first hash value and the first location information, and the slave temporary bucket file is used to store the second hash value and the second location information.

[0128] In a specific embodiment of the present application, the system reads the baseline file and the current file respectively according to the configuration in the file basic parameter table. Then, the file parsing rules corresponding to the baseline file and the current file are determined according to the configuration parsing rule table, and the baseline file and the current file are parsed according to the file parsing rules. During the file parsing process, the file content is read in a loop through the file stream, each line of data is processed according to the parsing rules, the fields that do not need to be compared are removed, the remaining fields are hashed, and the results and line numbers are stored in a temporary bucket file, wherein the first hash value and the first position information are stored in the master temporary bucket file, and the second hash value and the second position information are stored in the slave temporary bucket file, which effectively reduces the amount of calculation for directly comparing the file content and improves the comparison efficiency.

[0129] Then, the master temporary bucket file and the slave temporary bucket file are parsed into two hash mapping tables Map respectively. The first hash mapping table masterMap is obtained by parsing the master temporary bucket file, and the second hash mapping table slaveMap is obtained by parsing the slave temporary bucket file.

[0130] Parsing these temporary files into two Maps means storing the data in the form of key-value pairs into two Map data structures.

[0131] The key of the Map stores the hash value of the data field. The hash value is a numerical value calculated by a hash function. The hash value is unique to the input data field. Using the hash value as the key can quickly find and compare whether the data rows are the same, because the same data rows will generate the same hash value.

[0132] The Value of the Map stores the line number of the data row in the original file. This line number is used to identify the position of the data row in the file so that the specific row can be quickly located when a difference is found.

[0133] In this way, the contents of two files can be converted into two Maps, and then the two Maps can be efficiently compared to find the differences. Specifically, you can traverse one of the Maps (such as the masterMap), and for each Key (Hash value), check whether the same Key exists in the other Map (slaveMap). If not, it means that there is no row in the slave file with the same Hash value as the corresponding Hash value in the master file, that is, there is a difference between the two rows of data fields. If it exists, the two rows of data fields are considered to be the same, and the Key is removed from the two Maps so that only the difference items can be processed later.

[0134] S206: Compare the keys of the first hash mapping table and the second hash mapping table in sequence to determine the difference hash value, and determine the file content difference position based on the position information corresponding to the difference hash value.

[0135] The system compares the keys (i.e. hash values) of the two hash maps to find the mismatched hash values ​​(i.e. difference hash values). Then, based on the location information corresponding to these difference hash values, the system can accurately locate the difference position of the file content, which not only improves the accuracy of difference identification, but also provides users with an intuitive difference display.

[0136] Further, the key positions of the first hash mapping table and the second hash mapping table are sequentially compared to determine the difference hash value, and the file content difference position is determined based on the position information corresponding to the difference hash value, specifically including:

[0137] Traversing each first hash value stored in the Key of the first hash mapping table, and comparing each first hash value stored in the Key of the first hash mapping table with the second hash value stored in the Key of the second hash mapping table in a one-to-one correspondence, to obtain a first hash value comparison result;

[0138] Based on the comparison result of the first hash value, determine a second hash value that is inconsistent with the first hash value to obtain a first difference hash value;

[0139] Searching the second hash mapping table for the first Value corresponding to the Key of the first difference hash value by searching for a key-value pair, and obtaining the file content difference position stored in the first Value to obtain the first file content difference position;

[0140] Further, searching the second hash mapping table for the first Value corresponding to the Key of the first difference hash value by searching for a key-value pair, and obtaining the file content difference position stored in the first Value, after obtaining the first file content difference position, further comprising:

[0141] Traversing each second hash value stored in the Key of the second hash mapping table, and comparing each second hash value stored in the Key of the second hash mapping table with the first hash value stored in the Key of the first hash mapping table one by one, to obtain a second hash value comparison result;

[0142] Based on the comparison result of the second hash value, determine the first hash value that is inconsistent with the second hash value, and obtain a second difference hash value;

[0143] The second Value corresponding to the Key of the second difference hash value is searched in the first hash mapping table by searching for a key-value pair, and the file content difference position stored in the second Value is obtained to obtain the second file content difference position.

[0144] By using hash mapping tables to efficiently compare differences in file content, we first compare the hash values ​​stored in the two hash mapping tables one by one. These hash values ​​represent specific fragments of the file content. Through a sophisticated comparison process, inconsistent hash values ​​(i.e., difference hash values) are quickly identified, and the location information corresponding to these difference hash values ​​directly points to the specific difference locations in the file content. Subsequently, the file content location information corresponding to the difference hash value is quickly located using the key-value pair relationship stored in the hash mapping table. This hash-based comparison method not only greatly improves the efficiency of difference identification, but also ensures the accuracy of positioning, providing strong support for subsequent file content modification or synchronization.

[0145] In a specific embodiment of the present application, the masterMap is traversed, and for each Key in the masterMap, it is checked in turn whether the same Key exists in the slaveMap. If the same Key exists, it means that the two rows of data fields are the same, and the Key and its corresponding row number are removed from the masterMap, indicating that the two rows of data are consistent. If the same Key does not exist, it means that the two rows of data fields are different, that is, it means that the row of data fields may be a data field that has been updated or an error has occurred. The Key and its corresponding row number are retained as the file content difference and position. In the same way, for each Key in the slaveMap, it is checked in turn whether the same Key exists in the masterMap, and finally the remaining Keys and their corresponding row numbers in the masterMap are merged with the remaining Keys and their corresponding row numbers in the slaveMap to obtain the final file content difference result of the comparison of the two files.

[0146] In this embodiment, the electronic device (eg Figure 1 The server shown) can be connected by wire or by wireless connection. It should be noted that the wireless connection method may include but is not limited to 3G / 4G connection, WiFi connection, Bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultrawideband) connection, and other wireless connection methods currently known or to be developed in the future.

[0147] It should be emphasized that in order to further ensure the privacy and security of the above-mentioned files to be compared, the above-mentioned files to be compared can also be stored in a node of a blockchain.

[0148] The blockchain referred to in this application is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.

[0149] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware through computer-readable instructions, and the computer-readable instructions can be stored in a computer-readable storage medium. When the computer-readable instructions are executed, they can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

[0150] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.

[0151] Further references Figure 3 , as a response to the above Figure 2 The present application provides an embodiment of a device for identifying differences in file content. Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0152] like Figure 3 As shown, the file content difference identification device 300 described in this embodiment includes:

[0153] The file reading module 301 is used to receive a difference recognition instruction and read the baseline file and the current file to be compared;

[0154] A file parsing module 302, configured to parse the baseline file to obtain a first data field, and parse the current file to obtain a second data field;

[0155] A hash calculation module 303, configured to perform a hash calculation on the first data field to obtain a first hash value, and perform a hash calculation on the second data field to obtain a second hash value;

[0156] The position acquisition module 304 is used to acquire the position information of the first data field to obtain the first position information, and acquire the position information of the second data field to obtain the second position information;

[0157] A hash mapping module 305 is used to store the first hash value and the first position information in the form of a key-value pair to obtain a first hash mapping table, and to store the second hash value and the second position information in the form of a key-value pair to obtain a second hash mapping table, wherein the key position of the hash mapping table stores the hash value, and the value position of the hash mapping table stores the position information;

[0158] The difference identification module 306 is used to sequentially compare the key positions of the first hash mapping table and the second hash mapping table to determine the difference hash value, and determine the file content difference position based on the position information corresponding to the difference hash value.

[0159] Furthermore, the file content difference identification device 300 further includes:

[0160] The first table configuration module is used to configure a file basic parameter table, wherein the file basic parameter table is used to configure basic parameters of the file to be compared, and the basic parameters of the file to be compared include storage file name, baseline file path, current file path, file date, file number and file owner information;

[0161] The file reading module 301 specifically includes:

[0162] A parameter table acquisition unit, configured to, upon receiving a difference recognition instruction, acquire a basic parameter table of a file to be compared carried in the difference recognition instruction;

[0163] The file reading unit is used to read the baseline file and the current file based on the basic parameter table of the file to be compared.

[0164] Furthermore, the file content difference identification device 300 further includes:

[0165] The second table configuration module is used to configure a parsing rule table, wherein the parsing rule table is used to store file parsing rules, and the parsing rule table is pre-set with a field name, a field start bit, and a field end bit corresponding to each file parsing rule;

[0166] The file parsing module 302 specifically includes:

[0167] A first rule matching unit, used to determine a first file parsing rule that matches the baseline file;

[0168] A baseline file parsing unit, used to parse the baseline file using a first file parsing rule to determine a field name, a field start bit, and a field end bit of a data field in the baseline file, and obtain a first data field;

[0169] A second rule matching unit, used to determine a second file parsing rule that matches the current file;

[0170] The current file parsing unit is used to parse the current file using the second file parsing rule to determine the field name, field start bit and field end bit of the data field in the current file to obtain the second data field.

[0171] Furthermore, the file content difference identification device 300 further includes:

[0172] A first field screening module, used to screen the data fields in the baseline file based on the whitelist of the first file parsing rule to obtain a first data field screening result;

[0173] A first field elimination module is used to eliminate data fields in the baseline file that match the whitelist of the first file parsing rule based on the first data field screening result;

[0174] A second field screening module, used to screen the data fields in the current file based on the whitelist of the second file parsing rule to obtain a second data field screening result;

[0175] The second field elimination module is used to eliminate the data fields in the current file that match the whitelist of the second file parsing rule based on the second data field screening result.

[0176] Furthermore, the hash mapping module 305 specifically includes:

[0177] A first storage unit, used to store the first hash value and the first position information in a pre-established first temporary bucket file;

[0178] A second storage unit, used to store the second hash value and the second location information in a pre-established second temporary bucket file;

[0179] A temporary bucket file parsing unit, configured to parse the first temporary bucket file to obtain a first hash mapping table, and parse the second temporary bucket file to obtain a second hash mapping table;

[0180] The first hash mapping table and the second hash mapping table are mapping tables of Key and Value of the same structure, the first hash mapping table stores the first hash value in the Key, stores the first position information in the Value, the second hash mapping table stores the second hash value in the Key, and stores the second position information in the Value of the second hash mapping table;

[0181] Furthermore, the difference identification module 306 specifically includes:

[0182] A first hash value comparison unit, used to traverse each first hash value stored in the Key of the first hash mapping table, and compare each first hash value stored in the Key of the first hash mapping table with the second hash value stored in the Key of the second hash mapping table in a one-to-one correspondence, to obtain a first hash value comparison result;

[0183] A first hash value screening unit is used to determine a second hash value inconsistent with the first hash value based on the first hash value comparison result, and obtain a first difference hash value;

[0184] A first file content difference identification unit is used to find a first Value corresponding to the Key of the first difference hash value in the second hash mapping table by searching for a key-value pair, and obtain a file content difference position stored in the first Value to obtain the first file content difference position;

[0185] Furthermore, the difference identification module 306 also includes:

[0186] A second hash value comparison unit, used to traverse each second hash value stored in the Key of the second hash mapping table, and compare each second hash value stored in the Key of the second hash mapping table with the first hash value stored in the Key of the first hash mapping table in a one-to-one correspondence, to obtain a second hash value comparison result;

[0187] A second hash value screening unit is used to determine the first hash value inconsistent with the second hash value based on the second hash value comparison result, and obtain a second difference hash value;

[0188] The second file content difference identification unit is used to find the second Value corresponding to the Key of the second difference hash value in the first hash mapping table by searching the key-value pair, and obtain the file content difference position stored in the second Value to obtain the second file content difference position.

[0189] In the above embodiment, the present application parses the corresponding data fields of the two files to be compared, generates hash values ​​of the data fields through hash calculation, and determines the content differences between the two files by comparing the hash values, thereby achieving accurate identification and efficient positioning of file content changes, improving comparison efficiency and accuracy, and reducing testing costs.

[0190] The present application discloses a file content difference identification device, which belongs to the field of big data technology. The present application first receives a difference identification instruction, and reads a baseline file to be compared and a current file. Then, the two files are parsed respectively to extract a first data field and a second data field. And the location information of the first data field and the second data field is obtained, and recorded as the first location information and the second location information respectively. Then, the two data fields are hashed to generate a first hash value and a second hash value. Next, the first hash value and its corresponding location information are stored as a first hash mapping table, and the second hash value and its location information are stored as a second hash mapping table, wherein the mapping table uses a key-value pair, the key is a hash value, and the value is the location information. Finally, the keys in the first hash mapping table and the second hash mapping table are sequentially compared to identify the difference hash value, and the content difference position in the file is determined according to the location information corresponding to the difference hash value. The present application parses the corresponding data fields of the two files to be compared, generates the hash value of the data field by hash calculation, and determines the content difference of the two files by comparing the hash values, thereby realizing accurate identification and efficient positioning of file content changes, improving comparison efficiency and accuracy, and reducing testing costs.

[0191] To solve the above technical problems, the present application also provides a computer device. Figure 4 , Figure 4 This is a basic structural block diagram of the computer device in this embodiment.

[0192] The computer device 4 includes a memory 41, a processor 42, and a network interface 43 that are interconnected through a system bus. It should be noted that the figure only shows a computer device 4 with components 41-43, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.

[0193] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.

[0194] The memory 41 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 41 can be an internal storage unit of the computer device 4, such as a hard disk or memory of the computer device 4. In other embodiments, the memory 41 can also be an external storage device of the computer device 4, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), etc. equipped on the computer device 4. Of course, the memory 41 can also include both the internal storage unit of the computer device 4 and its external storage device. In this embodiment, the memory 41 is generally used to store the operating system and various application software installed on the computer device 4, such as computer-readable instructions of the file content difference recognition method, etc. In addition, the memory 41 can also be used to temporarily store various types of data that have been output or are to be output.

[0195] The processor 42 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor 42 is generally used to control the overall operation of the computer device 4. In this embodiment, the processor 42 is used to run the computer-readable instructions stored in the memory 41 or process data, such as running the computer-readable instructions of the file content difference identification method.

[0196] The network interface 43 may include a wireless network interface or a wired network interface. The network interface 43 is generally used to establish a communication connection between the computer device 4 and other electronic devices.

[0197] The present application discloses a computer device, belonging to the field of big data technology. The present application first receives a difference identification instruction, and reads a baseline file to be compared and a current file. Then, the two files are parsed respectively to extract a first data field and a second data field. And the location information of the first data field and the second data field is obtained, and recorded as the first location information and the second location information respectively. Then, the two data fields are hashed to generate a first hash value and a second hash value. Next, the first hash value and its corresponding location information are stored as a first hash mapping table, and the second hash value and its location information are stored as a second hash mapping table, wherein the mapping table uses the form of a key-value pair, the key is a hash value, and the value is the location information. Finally, the keys in the first hash mapping table and the second hash mapping table are sequentially compared to identify the difference hash value, and the content difference position in the file is determined according to the location information corresponding to the difference hash value. The present application parses the corresponding data fields of the two files to be compared, generates the hash value of the data field by hash calculation, and determines the content difference of the two files by comparing the hash values, thereby realizing accurate identification and efficient positioning of file content changes, improving comparison efficiency and accuracy, and reducing testing costs.

[0198] The present application also provides another implementation, namely, providing a computer-readable storage medium, wherein the computer-readable storage medium stores computer-readable instructions, and the computer-readable instructions can be executed by at least one processor to enable the at least one processor to perform the steps of the file content difference identification method as described above.

[0199] The present application discloses a computer-readable storage medium, belonging to the field of big data technology. The present application first receives a difference identification instruction, and reads a baseline file to be compared and a current file. Then, the two files are parsed respectively to extract a first data field and a second data field. And the location information of the first data field and the second data field is obtained, and recorded as the first location information and the second location information respectively. Then, the two data fields are hashed to generate a first hash value and a second hash value. Next, the first hash value and its corresponding location information are stored as a first hash mapping table, and the second hash value and its location information are stored as a second hash mapping table, wherein the mapping table uses a key-value pair, the key is a hash value, and the value is the location information. Finally, the keys in the first hash mapping table and the second hash mapping table are sequentially compared to identify the difference hash value, and the content difference position in the file is determined according to the location information corresponding to the difference hash value. The present application parses the corresponding data fields of the two files to be compared, generates the hash value of the data field by hash calculation, and determines the content difference of the two files by comparing the hash values, thereby realizing accurate identification and efficient positioning of file content changes, improving comparison efficiency and accuracy, and reducing testing costs.

[0200] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0201] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.

[0202] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.

Claims

1. A method for identifying differences in file content, characterized in that: include: Receive the difference recognition instruction and read the baseline file and current file to be compared; Parsing the baseline file to obtain a first data field, and parsing the current file to obtain a second data field; Performing a hash calculation on the first data field to obtain a first hash value, and performing a hash calculation on the second data field to obtain a second hash value; Acquire the position information of the first data field to obtain first position information, and acquire the position information of the second data field to obtain second position information; The first hash value and the first location information are stored in the form of a key-value pair to obtain a first hash mapping table, and the second hash value and the second location information are stored in the form of a key-value pair to obtain a second hash mapping table, wherein the key position of the hash mapping table stores the hash value and the value position of the hash mapping table stores the location information; The keys of the first hash mapping table and the second hash mapping table are sequentially compared to determine a difference hash value, and a file content difference position is determined based on the position information corresponding to the difference hash value.

2. The method for identifying file content differences according to claim 1, characterized in that: Before receiving the difference recognition instruction and reading the baseline file to be compared and the current file, the following steps are also included: A file basic parameter table is configured, wherein the file basic parameter table is used to configure basic parameters of the file to be compared, and the basic parameters of the file to be compared include storage file name, baseline file path, current file path, file date, file number and file owner information; After receiving the difference recognition instruction, the baseline file and the current file to be compared are read, including: After receiving the difference recognition instruction, obtaining the basic parameter table of the file to be compared carried in the difference recognition instruction; The baseline file and the current file are read based on the basic parameter table of the file to be compared.

3. The method for identifying file content differences according to claim 1, characterized in that: After the basic parameter table of the configuration file, it also includes: Configure a parsing rule table, wherein the parsing rule table is used to store file parsing rules, and the parsing rule table is pre-set with a field name, a field start bit, and a field end bit corresponding to each file parsing rule; The parsing of the baseline file to obtain the first data field specifically includes: Determining a first file parsing rule that matches the baseline file; Parsing the baseline file using the first file parsing rule to determine a field name, a field start bit, and a field end bit of a data field in the baseline file, and obtaining the first data field; The current file is parsed to obtain a second data field, which specifically includes: Determine a second file parsing rule that matches the current file; The current file is parsed using the second file parsing rule to determine the field name, field start bit, and field end bit of the data field in the current file to obtain the second data field.

4. The method for identifying file content differences according to claim 3, characterized in that: The parsing rule table also pre-sets a whitelist corresponding to each file parsing rule. After the baseline file is parsed using the first file parsing rule to determine the field name, field start bit, and field end bit of the data field in the baseline file and obtaining the first data field, the method further includes: Filter the data fields in the baseline file based on the whitelist of the first file parsing rule to obtain a first data field filtering result; Based on the first data field screening result, remove the data fields in the baseline file that match the whitelist of the first file parsing rule; The current file is parsed using the second file parsing rule to determine the field name, field start bit, and field end bit of the data field in the current file, and after obtaining the second data field, the method further includes: Filter the data fields in the current file based on the whitelist of the second file parsing rule to obtain a second data field filtering result; Based on the second data field screening result, the data fields in the current file that match the whitelist of the second file parsing rule are removed.

5. The method for identifying file content differences according to claim 1, characterized in that: Storing the first hash value and the first location information in the form of a key-value pair to obtain a first hash mapping table, and storing the second hash value and the second location information in the form of a key-value pair to obtain a second hash mapping table, specifically includes: Storing the first hash value and the first location information in a pre-established first temporary bucket file; storing the second hash value and the second location information in a pre-established second temporary bucket file; Parsing the first temporary bucket file to obtain a first hash mapping table, and parsing the second temporary bucket file to obtain a second hash mapping table; Among them, the first hash mapping table and the second hash mapping table are mapping tables of Key and Value with the same structure, the first hash value is stored in the Key of the first hash mapping table, the first location information is stored in the Value of the first hash mapping table, the second hash value is stored in the Key of the second hash mapping table, and the second location information is stored in the Value of the second hash mapping table.

6. The method for identifying file content differences according to claim 5, characterized in that: Comparing the key positions of the first hash mapping table and the second hash mapping table in sequence to determine a difference hash value, and determining a file content difference position based on position information corresponding to the difference hash value, specifically includes: Traversing each first hash value stored in the Key of the first hash mapping table, and comparing each first hash value stored in the Key of the first hash mapping table with the second hash value stored in the Key of the second hash mapping table in a one-to-one correspondence, to obtain a first hash value comparison result; Based on the comparison result of the first hash value, determine a second hash value inconsistent with the first hash value to obtain a first difference hash value; The first Value corresponding to the Key of the first difference hash value is searched in the second hash mapping table by searching for a key-value pair, and the file content difference position stored in the first Value is obtained to obtain the first file content difference position.

7. The method for identifying file content differences according to claim 6, characterized in that: After searching the second hash mapping table for the first Value corresponding to the Key of the first difference hash value by searching for a key-value pair and obtaining the file content difference position stored in the first Value, and obtaining the first file content difference position, the method further includes: Traversing each second hash value stored in the Key of the second hash mapping table, and comparing each second hash value stored in the Key of the second hash mapping table with the first hash value stored in the Key of the first hash mapping table one by one, to obtain a second hash value comparison result; Based on the comparison result of the second hash value, determine a first hash value inconsistent with the second hash value to obtain a second difference hash value; The second Value corresponding to the Key of the second difference hash value is searched in the first hash mapping table by searching for a key-value pair, and the file content difference position stored in the second Value is obtained to obtain the second file content difference position.

8. A device for identifying differences in file content, characterized in that: include: The file reading module is used to receive the difference recognition instruction and read the baseline file and the current file to be compared; A file parsing module, used to parse the baseline file to obtain a first data field, and to parse the current file to obtain a second data field; A hash calculation module, configured to perform a hash calculation on the first data field to obtain a first hash value, and perform a hash calculation on the second data field to obtain a second hash value; A position acquisition module, used to acquire the position information of the first data field to obtain first position information, and to acquire the position information of the second data field to obtain second position information; a hash mapping module, configured to store the first hash value and the first location information in the form of a key-value pair to obtain a first hash mapping table, and to store the second hash value and the second location information in the form of a key-value pair to obtain a second hash mapping table, wherein the key position of the hash mapping table stores the hash value, and the value position of the hash mapping table stores the location information; The difference identification module is used to sequentially compare the key positions of the first hash mapping table and the second hash mapping table to determine the difference hash value, and determine the file content difference position based on the position information corresponding to the difference hash value.

9. A computer device, characterized in that: The method comprises a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of the file content difference identification method according to any one of claims 1 to 7 when executing the computer-readable instructions.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the steps of the file content difference identification method according to any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • File processing method and optimization method

    CN119759847A

  • Bill data difference comparison method and device, equipment and storage medium

    CN120634747A

  • Bill data difference comparison method and device, equipment and storage medium

    CN120634747B

  • Asset warehousing method, device and equipment, readable storage medium and program product

    CN121658548A