CN110162509A - File comparison method, device, computer equipment and storage medium - Google Patents
File comparison method, device, computer equipment and storage medium Download PDFInfo
- Publication number
- CN110162509A CN110162509A CN201910345020.5A CN201910345020A CN110162509A CN 110162509 A CN110162509 A CN 110162509A CN 201910345020 A CN201910345020 A CN 201910345020A CN 110162509 A CN110162509 A CN 110162509A
- Authority
- CN
- China
- Prior art keywords
- file
- comparison
- value
- benchmark
- key
- Prior art date
- Legal status (The legal status 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 status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 39
- 238000003860 storage Methods 0.000 title claims abstract description 18
- 230000008859 change Effects 0.000 claims description 40
- 238000006243 chemical reaction Methods 0.000 claims description 34
- 238000013515 script Methods 0.000 claims description 30
- 238000004590 computer program Methods 0.000 claims description 16
- 238000012986 modification Methods 0.000 claims description 12
- 230000004048 modification Effects 0.000 claims description 12
- 238000004422 calculation algorithm Methods 0.000 claims description 10
- 238000010586 diagram Methods 0.000 description 10
- 238000012544 monitoring process Methods 0.000 description 8
- 230000006870 function Effects 0.000 description 7
- 238000012217 deletion Methods 0.000 description 6
- 230000037430 deletion Effects 0.000 description 6
- 230000008569 process Effects 0.000 description 4
- 238000007792 addition Methods 0.000 description 3
- 230000005540 biological transmission Effects 0.000 description 2
- 238000012545 processing Methods 0.000 description 2
- 230000001960 triggered effect Effects 0.000 description 2
- 238000004364 calculation method Methods 0.000 description 1
- 230000010485 coping Effects 0.000 description 1
- 238000013075 data extraction Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 235000013399 edible fruits Nutrition 0.000 description 1
- 230000002708 enhancing effect Effects 0.000 description 1
- 230000014759 maintenance of location Effects 0.000 description 1
- 238000002360 preparation method Methods 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 230000001360 synchronised effect Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/16—File or folder operations, e.g. details of user interfaces specifically adapted to file systems
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/17—Details of further file system functions
- G06F16/1734—Details of monitoring file system events, e.g. by the use of hooks, filter drivers, logs
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/10—Text processing
- G06F40/194—Calculation of difference between files
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Physics & Mathematics (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Human Computer Interaction (AREA)
- Health & Medical Sciences (AREA)
- Artificial Intelligence (AREA)
- Audiology, Speech & Language Pathology (AREA)
- Computational Linguistics (AREA)
- General Health & Medical Sciences (AREA)
- Debugging And Monitoring (AREA)
Abstract
The invention discloses a kind of file comparison method, device, computer equipment and storage mediums, and after obtaining file and changing trigger request, according to changing, file identification obtains variation file and benchmark compares file;File will be changed and reference file is transformed into map data structure, obtained file and benchmark to be compared and compare file;File finally is compared to file to be compared and benchmark and carries out recursive traversal, obtains different information.It after getting corresponding comparison file, is converted into map data result and carries out recursive traversal, guarantee that different information obtains efficient, accurate, preferably to prompt file variation.
Description
Technical field
The present invention relates to system monitoring field more particularly to a kind of file comparison method, device, computer equipment and storages
Medium.
Background technique
With the development of computer technology, the file data that personal user or enterprise customer need to manage is more and more,
Type is more and more abundant.However, as the frequency that file data is more and more and file content changes is also higher and higher, very
It needs in real time to respond the variation of file under more scenes, but does not have to the monitoring and comparison of file variation much currently
Standby too high efficiency and real-time.
Summary of the invention
The embodiment of the present invention provides a kind of file comparison method, device, computer equipment and storage medium, to solve file
The lower problem of comparison efficiency.
A kind of file comparison method, comprising:
It obtains file and changes trigger request, it includes changing file identification that the file, which changes trigger request,;
It is obtained according to the variation file identification and changes file and benchmark comparison file;
The variation file and the reference file are transformed into map data structure, obtain file and benchmark to be compared
Compare file;
File is compared to the file to be compared and the benchmark and carries out recursive traversal, obtains different information.
A kind of file comparison device, comprising:
File changes trigger request and obtains module, changes trigger request for obtaining file, the file, which changes triggering, asks
It asks including changing file identification;
File acquisition module changes file and benchmark comparison file for obtaining according to the variation file identification;
File conversion module is obtained for the variation file and the reference file to be transformed into map data structure
File and benchmark to be compared compare file;
Different information obtains module, carries out recursive traversal for comparing file to the file to be compared and the benchmark,
Obtain different information.
A kind of computer equipment, including memory, processor and storage are in the memory and can be in the processing
The computer program run on device, the processor realize above-mentioned file comparison method when executing the computer program.
A kind of computer readable storage medium, the computer-readable recording medium storage have computer program, the meter
Calculation machine program realizes above-mentioned file comparison method when being executed by processor.
In above-mentioned file comparison method, device, computer equipment and storage medium, obtain file change trigger request it
Afterwards, according to changing, file identification obtains variation file and benchmark compares file;File will be changed and reference file is transformed into map
Data structure obtains file and benchmark to be compared and compares file;File finally is compared to file to be compared and benchmark and carries out recurrence
Traversal, obtains different information.After getting corresponding comparison file, it is converted into map data result and carries out recursive traversal, protect
The efficient, accurate of different information acquisition is demonstrate,proved, preferably to prompt file variation.
Detailed description of the invention
In order to illustrate the technical solution of the embodiments of the present invention more clearly, below by institute in the description to the embodiment of the present invention
Attached drawing to be used is needed to be briefly described, it should be apparent that, the accompanying drawings in the following description is only some implementations of the invention
Example, for those of ordinary skill in the art, without any creative labor, can also be according to these attached drawings
Obtain other attached drawings.
Fig. 1 is an application environment schematic diagram of file comparison method in one embodiment of the invention;
Fig. 2 is an exemplary diagram of file comparison method in one embodiment of the invention;
Fig. 3 is another exemplary diagram of file comparison method in one embodiment of the invention;
Fig. 4 is another exemplary diagram of file comparison method in one embodiment of the invention;
Fig. 5 is another exemplary diagram of file comparison method in one embodiment of the invention;
Fig. 6 is another exemplary diagram of file comparison method in one embodiment of the invention;
Fig. 7 is another exemplary diagram of file comparison method in one embodiment of the invention;
Fig. 8 is a functional block diagram of file comparison device in one embodiment of the invention;
Fig. 9 is another functional block diagram of file comparison device in one embodiment of the invention;
Figure 10 is a schematic diagram of computer equipment in one embodiment of the invention.
Specific embodiment
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete
Site preparation description, it is clear that described embodiments are some of the embodiments of the present invention, instead of all the embodiments.Based on this hair
Embodiment in bright, every other implementation obtained by those of ordinary skill in the art without making creative efforts
Example, shall fall within the protection scope of the present invention.
File comparison method provided in an embodiment of the present invention can be applicable in the application environment such as Fig. 1, wherein client
(computer equipment) is communicated by network with server-side.Client sends file and changes trigger request to server-side, service
End obtains file and changes trigger request, and according to changing, file identification acquisition changes file and benchmark compares file;File will be changed
It is converted to map data structure respectively with reference file, obtains file and benchmark to be compared and compare file;To file to be compared and institute
It states benchmark and compares file progress recursive traversal, obtain different information.Wherein, client (computer equipment) can be, but not limited to respectively
Kind personal computer, laptop, smart phone, tablet computer and portable wearable device.Server can be with independently
The server cluster of server-side either multiple servers composition realize.
In one embodiment, as shown in Fig. 2, providing a kind of file comparison method, the service in Fig. 1 is applied in this way
It is illustrated, includes the following steps: for end
S10: it obtains file and changes trigger request, it includes changing file identification that file, which changes trigger request,.
Wherein, file changes trigger request and refers to when corresponding file changes (such as: adding, modifying or deleting)
When triggered a prompt request.It includes changing file identification that this document, which changes trigger request, which is used for
Different files is identified, specifically, which can be by least one in number, letter, text or symbol
Composition.It is alternatively possible to using file path as variation file identification.
Specifically, this document change trigger request can by the timing to specified folder or specified file monitor come
Triggering.Specified folder or specified file are scanned to determine whether that file changes, if it exists by timing
File changes, then obtains and change file identification and generate file variation trigger request.It is to be appreciated that this changed
File can be for one or a plurality of, if the file to change is a plurality of, corresponding variation file identification
It is a plurality of.
It is possible to further be monitored by introducing monitor specified folder or specified file, as long as monitoring
To thering is file or file to change, so that it may change trigger request according to changing file identification and generating this document.
It is to be appreciated that this document, which changes trigger request, may be set to be client to trigger.Illustratively, if it is a certain
Client is edited (such as: adding, modifying or deleting) to a certain file being stored in server-side, then is being edited
At later, which can change trigger request to server-side with active transmission file, and server-side gets this document variation
Trigger request.
S20: file and reference file are changed according to changing file identification and obtaining.
It changes file and refers to and change the corresponding text that variation (such as: adding, modifying or deleting) has occurred of file identification
Part.And reference file be this variation file identification is corresponding change before file.Optionally, a pattern library is preset,
Each file is stored in the pattern library as reference file, it is possible to understand that ground, the reference file be can carry out in real time or
Person's timing updates.It is alternatively possible to be carried out after obtaining different information in the present embodiment to the reference file in pattern library
It updates, alternatively, one update cycle of setting, often reaches a update cycle, i.e., to the file to change in the update cycle
Corresponding reference file is updated, and obtains new reference file.
In this step, variation text is got from corresponding file or file path by changing file identification
Part, and corresponding benchmark comparison file is obtained from pattern library by changing file identification.
S30: will change file and reference file be transformed into map data structure, obtains file and benchmark to be compared and compares
File.
Wherein, map is an associated container of STL, its offer is one-to-one, and (wherein first is properly termed as keyword, often
A keyword can only occur once in map, and second may be known as the value of the keyword) data-handling capacity.Due to this
A characteristic, it is possible to provide express passway in programming when we handle one-to-one data.Therefore, by that will become
Dynamic file and reference file are converted to map data structure respectively, are conducive to subsequent quickly and accurately be compared.
Specifically, changing file and reference file can be the files such as json, xml or yaml, can write in advance by
Various formatted files (json, xml or yaml etc.) are converted to the class or function of map data structure, and are packaged into conversion foot
This, will change file and reference file and be converted to map data structure respectively, obtain file and benchmark to be compared and compare file.
When carrying out file conversion, corresponding conversion script is first got according to the file format for changing file and reference file respectively,
Then corresponding conversion script is executed respectively will change file and reference file and be transformed into map data structure, obtain to be compared
File and benchmark compare file.Wherein, file to be compared is will to change file to be converted to the file obtained after map data structure,
And it is the file that reference file is converted to map data structure respectively and is obtained that benchmark, which compares file,.
S40: file is compared to file to be compared and benchmark and carries out recursive traversal, obtains different information.
After the file and benchmark to be compared for obtaining map data structure compare file, to file to be compared and benchmark ratio
Recursive traversal is carried out to file, to obtain having differences place, i.e. different information in two files.Specifically, can by by
One compares the content of corresponding key-value pair in two files, to obtain different information.Optionally, different information may include difference
The information such as content, difference type, differential position.Wherein, difference content refers to that there are in different specific texts in two files
Hold, difference content may include two parts of difference section in difference section and benchmark comparison file in file to be compared.
Difference type can be the type of difference section in two files, and difference type may include adding, modifying or deleting, can be with
Understand ground, adds, modifies or deletes both for for benchmark compares file.Differential position embodies difference content two
The location of in file, optionally, differential position can be embodied by line number.
In the present embodiment, after obtaining file and changing trigger request, file is changed according to changing file identification and obtaining
File is compared with benchmark;File will be changed and reference file is transformed into map data structure, obtains file and benchmark ratio to be compared
To file;File finally is compared to file to be compared and benchmark and carries out recursive traversal, obtains different information.It is corresponding getting
It after comparing file, is converted into map data result and carries out recursive traversal, guarantee that different information obtains efficient, accurate, with more preferable
Ground prompts file variation.
In one embodiment, it as shown in figure 3, obtaining file changes trigger request, specifically includes:
S11: destination folder is monitored in real time using monitor.
Wherein, destination folder is the file for needing to monitor, which can preset to obtain, Huo Zhe
Monitor is obtained before opening by selection or input, it can presets the file for needing to monitor.Monitor is used for
The change conditions for monitoring destination folder can specifically be realized by the various monitors in JAVA to destination folder
It is monitored in real time.
It is alternatively possible to can be monitored to file using the associated class under the monitor of Commons-io.Specifically
Specified folder is monitored by monitor FileAlterationListenerAdaptor in ground, if recognized
File changes, so that it may the variation notice of file is triggered in monitor.
S12: if monitor detects that destination folder changes, variation file identification and variation file identification are obtained
Corresponding change type.
The variation that any file in destination folder can be monitored in real time by monitor, increase, modification including file
And deletion.By that the configuration of monitor, can be fed back in advance to the specific variation type of file in destination folder, example
Such as: file is newly-increased, file is deleted and file modification.Therefore, it after monitor detects that destination folder changes, obtains
Change file identification change type corresponding with variation file identification, to carry out corresponding processing.It is alternatively possible to by preparatory
Setting is monitored at least one of therein.Illustratively, only file modification this variation type is fed back or right
File modification and file, which increase newly, to be fed back etc..
S13: if change type is modification, file is generated according to variation file identification and changes trigger request.
In this step, if change type is modification, need further to determine specific modification content, therefore, root
File, which is generated, according to variation file identification changes trigger request.
In a specific embodiment, if change type is to delete or increase, according to the corresponding file identification changed
Generate prompt information.In this embodiment, if the variation in destination folder is for the newly-increased of entire file or to delete,
Then directly the file identification of respective file is recorded, and issues prompt information, to remind documentary newly-increased or delete.
In the present embodiment, destination folder is monitored in real time using monitor;If monitor detects target text
Part folder changes, then obtains variation file identification change type corresponding with variation file identification;If change type is modification,
File is then generated according to variation file identification and changes trigger request.Real-time response is carried out to change to file by monitor, and
When judging except change type to modify, file is generated according to variation file identification and changes trigger request, guarantees file variation touching
The timeliness that hair request generates.
In one embodiment, it as shown in figure 4, obtaining file changes trigger request, specifically includes:
S11 ': the file destination in destination folder is obtained according to prefixed time interval, each file destination includes target
File identification.
Wherein, prefixed time interval is a preset time value, periodically obtains mesh by the prefixed time interval
The file destination in file is marked, judges whether file destination is changed.It is to be appreciated that the numerical value of the prefixed time interval
What is set is lower, then more timely to the monitoring of the variation of file destination, correspondingly, also bigger to the consumption of system.Specifically may be used
The prefixed time interval is configured with being comprehensively considered in timeliness and efficiency.The destination folder can carry out pre-
First setting perhaps specifies the i.e. fixed file of finger to finger or file to be monitored.File destination mark is for different to distinguishing
File destination, optionally, file destination mark can by number, letter, text or symbol at least one of form.It can
Selection of land can be identified using file path as file destination.
S12 ': each file destination is calculated using md5 encryption algorithm, obtains the target character of each file destination
String.
Wherein, md5 encryption algorithm is also known as MD5 Message Digest 5 (English: MD5 Message-Digest
Algorithm), it is a kind of Cryptographic Hash Function being widely used, can produce out the hashed value of one 128 (16 byte)
(hash value), for ensuring that information transmission is complete consistent.Any one file, either executable program, image file,
Temporary file or other any kind of files, it is much regardless of its volume, have and only one unique MD5 believes
Breath value, and if this file is modified, its MD5 value will also change correspondingly.It therefore, can be by each target text
Part is calculated using md5 encryption algorithm, obtains the target string of each file destination.Target string is to pass through MD5
The character string that Encryption Algorithm obtains after calculating.
S13 ': corresponding benchmark character string is obtained from pattern library according to file destination mark.
Wherein, benchmark character string is after being calculated using md5 encryption algorithm different benchmark comparison files in advance
Obtained character string.File can be compared to each benchmark when different benchmark to be compared to file and is stored into pattern library
It is calculated using md5 encryption algorithm, obtains the benchmark character string that each benchmark in pattern library compares file.Then by benchmark ratio
Storage is associated in pattern library to file and corresponding benchmark character string.
In this step, the benchmark that corresponding benchmark compares file can be got from pattern library according to file destination mark
Character string.
S14 ': whether target string and the corresponding benchmark character string for comparing each file destination are consistent, according to different
The file destination mark of the file destination of cause generates file and changes trigger request.
Whether target string and corresponding benchmark character string by comparing file destination are consistent to judge file destination
Whether change.If the target string of file destination and corresponding benchmark character string are inconsistent, illustrate that file destination is sent out
Variation has been given birth to, therefore, has been identified according to the file destination of inconsistent file destination and generates file variation trigger request.
In the present embodiment, the file destination in destination folder, each target are obtained according to prefixed time interval first
File includes file destination mark;Each file destination is calculated using md5 encryption algorithm, obtains each file destination
Target string;Corresponding benchmark character string is obtained from pattern library according to file destination mark;Finally, each target text is compared
Whether the target string of part and corresponding benchmark character string are consistent, are identified and are given birth to according to the file destination of inconsistent file destination
Trigger request is changed at file.It does not need to introduce additional tool or plug-in unit and the variation of file destination is monitored, improve
The monitoring efficiency of file.
In one embodiment, it as shown in figure 5, will change file and reference file is transformed into map data structure, obtains
File and benchmark to be compared compare file, specifically include:
S31: the file type of the file type and reference file that change file is obtained.
Different variation files and reference file may be different file types, such as json, xml or yaml etc..
Specifically, the type of variation file can be judged by changing the extension name of file and reference file.Illustratively, json text
The extension name of part is just " json ".It is to be appreciated that variation file and reference file are generally same file type.
S32: the first conversion script obtained respectively according to the file type of the file type and reference file that change file
With the second conversion script.
Wherein, conversion script converts map data structure for the variation file of different file types to be pre-configured
Script.The script for converting the file of different file types to map data structure, and each conversion script are write in advance
With corresponding file type associations, in this way, corresponding conversion script can be got according to file type.In this step,
The first conversion script is got according to the file type for changing file, the second conversion is got according to the file type of reference file
Script.It is to be appreciated that the first conversion script and the second conversion script can be identical, and it can not also be identical, with specific reference to variation
The file type of file and the file type of reference file determine, if changing the file type of file and the files classes of reference file
Type is identical, then the first conversion script and the second conversion script are also identical, otherwise the first conversion script and second converts script not phase
Together.
S33: by the first conversion script and the second conversion script will change file respectively and reference file is packaged into map number
According to structure, obtains file and benchmark to be compared and compare file.
After obtaining the first conversion script and the second conversion script, by executing the two conversion scripts, so that it may will
It changes file and reference file is packaged into map data structure, obtain file and benchmark to be compared and compare file.
In the present embodiment, it first obtains and changes the file type of file and the file type of reference file;And according to variation
The the first conversion script and the second conversion script that the file type of file and the file type of reference file obtain respectively;Finally lead to
It crosses through the first conversion script and the second conversion script will change file respectively and reference file is packaged into map data structure, obtain
File is compared to file to be compared and benchmark.The variation file and benchmark comparison file that ensure that different file types can be fast
The conversion of data structure is carried out fastly.
In one embodiment, it as shown in fig. 6, comparing file to file to be compared and benchmark carries out recursive traversal, obtains
Different information specifically includes:
S41: key-value pairs in file and benchmark comparison file to be compared is obtained respectively, obtains key- to be compared
Value to and key-value pairs of benchmark.
In map data structure, data are all with the presence of key (key)-value (value) pair form.Therefore in map data knot
The file and benchmark to be compared of structure compare in file, compare respectively in key-value pairs of form to file to be compared and benchmark
File carry out data extraction, obtain key-value to be compared to and key-value pairs of benchmark.It is to be appreciated that key- to be compared
Value is at least one to the quantity with quasi- key-value pairs, and particular number is depending on real data.
S42: according to key value to key-value to be compared to and benchmark key-value to matching, obtain comparing logarithm
According to, each comparison data include a key-value to be compared to and one key-value pairs of benchmark.
Specifically, with key-value to be compared to and the key value of key-value pairs of benchmark key-value centering every one be
Label, search the identical key-value to be compared of key value to and key-value pairs of benchmark, and by key-value pairs to be compared
Identical a pair of key-value is to one comparison data of composition with benchmark key-value centering key value.
In a specific embodiment, by key-value to be compared to and benchmark key-value centering, it is unpaired at
The key-value of function is to being determined as additions and deletions key-value pair.If the additions and deletions key-value pair is key-value pairs to be compared, this is waited comparing
To key-value to being determined as newly-increased key-value pair.If the additions and deletions key-value pair is key-value pairs of benchmark, by the benchmark
Key-value to be determined as delete key-value pair.
S43: carrying out diversity ratio pair to each comparison data, exports comparison information according to comparison result.
After forming comparison data, to each comparison data carry out diversity ratio pair, with judge file to be compared relative to
Benchmark compares whether file has occurred the content of increase, deletion or modification, and changed particular content (has occurred
The content for increasing, deleting or modifying) it is indicated, comparison result is formed, comparison information is finally exported according to the comparison result.
Optionally, which may include differential position, difference content and difference type.
S44: different information is obtained according to the comparison information of each comparison data.
After the comparison information for obtaining each comparison data, comparison information is integrated to get different information is arrived.
In the present embodiment, file and benchmark to be compared are first obtained respectively and compares key-value pairs in file, obtain to
Compare key-value to and key-value pairs of benchmark;According to key value to key-value to be compared to and benchmark key-value
To matching, obtain comparison data, each comparison data include a key-value to be compared to and a benchmark key-
Value pairs;Diversity ratio pair is carried out to each comparison data, comparison information is exported according to comparison result, compares logarithm further according to each
According to comparison information obtain different information, ensure that different information obtain efficiency and accuracy.
In a specific embodiment, it as shown in fig. 7, carrying out diversity ratio pair to each comparison data, is tied according to comparing
Fruit exports comparison information, specifically comprises the following steps:
S431: if value value in comparison data is map data structure, carrying out next layer of key-value to comparison,
Export comparison information.
Wherein, the value value in comparison data is that map data structure refers to that the data in value value are one again
Key-value pairs, at this point, carrying out next layer of key-value comparison is by the key-value in value value to comparing again
It is right.Specifically, first judge whether the key in value is consistent, if inconsistent, directly export inconsistent comparison result.If one
It causes, then further key-value pairs of the value value is compared, corresponding step is selected according to the type of value value
Continue to execute (S431, S432 or S433).
S432: if the value value in comparison data is list data structure, traversing the list data, defeated
Comparison information out.
Wherein, list data structure is the data embodied with array or tabular form, such as newlist=[A, B, C, D,
E].And list data are traversed, it is each data (A, B, C, D, E) in list data to be carried out with a comparison, and root
Comparison information is exported according to comparison result.Wherein, as long as any one data has increase, deletion or modification in list data
Situation is accordingly to be regarded as inconsistent.
S433: if value value in comparison data is string character string, directly carrying out string matching, according to
Comparison information is exported with result.
If value value is string character string, character string directly is carried out to the string character string in two value values
Matching, sees whether two string character strings are identical, if they are the same, then exports and compares consistent comparison information.It is defeated if not identical
Inconsistent comparison information is compared out.
In this embodiment, if the value value in comparison data is map data structure, next layer of key- is carried out
Value exports comparison information to comparison;If the value value in comparison data is list data structure, to the list data
It is traversed, output comparison information is by judging value value;If the value value in comparison data is string character string, directly
Line character String matching is tapped into, comparison information is exported according to matching result.Different comparisons is made according to different data types
Journey better assures the accuracy of comparing.
It should be understood that the size of the serial number of each step is not meant that the order of the execution order in above-described embodiment, each process
Execution sequence should be determined by its function and internal logic, the implementation process without coping with the embodiment of the present invention constitutes any limit
It is fixed.
In one embodiment, a kind of file comparison device, file ratio in this document comparison device and above-described embodiment are provided
Method is corresponded.As shown in figure 8, this document comparison device includes that file changes trigger request acquisition module 10, file obtains
Modulus block 20, file conversion module 30 and different information obtain module 40.Detailed description are as follows for each functional module:
File changes trigger request and obtains module 10, changes trigger request for obtaining file, the file changes triggering
Request includes changing file identification.
File acquisition module 20 changes file and benchmark comparison file for obtaining according to the variation file identification.
File conversion module 30 is obtained for the variation file and the reference file to be transformed into map data structure
File is compared to file to be compared and benchmark.
Different information obtains module 40, carries out recurrence time for comparing file to the file to be compared and the benchmark
It goes through, obtains different information.
Preferably, as shown in figure 9, it includes key-value to acquiring unit 41, comparison data that different information, which obtains module 40,
Acquiring unit 42, comparison information output unit 43 and different information acquiring unit 44.
Key-value is to acquiring unit 41, for obtaining the key- in file and benchmark comparison file to be compared respectively
Value pairs, obtain key-value to be compared to and key-value pairs of benchmark.
Comparison data acquiring unit 42, for according to key value to key-value to be compared to and key-value pairs of benchmark
Matched, obtain comparison data, each comparison data include a key-value to be compared to and a benchmark key-
Value pairs.
Comparison information output unit 43, it is defeated according to comparison result for carrying out diversity ratio pair to each comparison data
Comparison information out.
Different information acquiring unit 44, for obtaining difference letter according to the comparison information of each comparison data
Breath.
Preferably, file change trigger request obtain module 10 include real-time monitoring unit, change type acquiring unit and
First changes trigger request generation unit.
Real-time monitoring unit, for being monitored in real time using monitor destination folder.
Change type acquiring unit, for when the monitor detects that the destination folder changes, then obtaining
Take the variation file identification and the corresponding change type of the variation file identification.
First changes trigger request generation unit, is used for when the change type is modification, then according to the variation text
Part mark generates file and changes trigger request.
Preferably, it includes file destination acquiring unit, target string calculating that file, which changes trigger request to obtain module 10,
Unit, benchmark character string acquiring unit and the second file change trigger request generation unit.
File destination acquiring unit, it is each for obtaining the file destination in destination folder according to prefixed time interval
File destination includes file destination mark.
Target string computing unit is obtained for being calculated each file destination using md5 encryption algorithm
The target string of each file destination.
Benchmark character string acquiring unit, for obtaining corresponding base from the pattern library according to file destination mark
Quasi- character string.
Second file changes trigger request generation unit, for comparing the target string of each file destination and right
Whether the benchmark character string answered is consistent, is identified according to the file destination of the inconsistent file destination and generates file variation triggering
Request.
Preferably, it is map data structure that comparison information output unit 43, which is also used to the value value in the comparison data,
When, then next layer of key-value is carried out to comparison, exports comparison information;Value value in the comparison data is list number
When according to structure, then the list data are traversed, exports comparison information;Value value in the comparison data is
When string character string, then string matching is directly carried out, comparison information is exported according to matching result.
Specific about file comparison device limits the restriction that may refer to above for file comparison method, herein not
It repeats again.Modules in above-mentioned file comparison device can be realized fully or partially through software, hardware and combinations thereof.On
Stating each module can be embedded in the form of hardware or independently of in the processor in computer equipment, can also store in a software form
In memory in computer equipment, the corresponding operation of the above modules is executed in order to which processor calls.
In one embodiment, a kind of computer equipment is provided, which can be server, internal junction
Composition can be as shown in Figure 10.The computer equipment include by system bus connect processor, memory, network interface and
Database.Wherein, the processor of the computer equipment is for providing calculating and control ability.The memory packet of the computer equipment
Include non-volatile memory medium, built-in storage.The non-volatile memory medium is stored with operating system, computer program and data
Library.The built-in storage provides environment for the operation of operating system and computer program in non-volatile memory medium.The calculating
The database of machine equipment is used to store the data used in the file comparison method in above-described embodiment.The computer equipment
Network interface is used to communicate with external terminal by network connection.To realize one kind when the computer program is executed by processor
File comparison method.
In one embodiment, a kind of computer equipment is provided, including memory, processor and storage are on a memory
And the computer program that can be run on a processor, processor realize the file ratio in above-described embodiment when executing computer program
To method.
In one embodiment, a kind of computer readable storage medium is provided, computer program is stored thereon with, is calculated
Machine program is executed by processor the file comparison method in above-described embodiment.
Those of ordinary skill in the art will appreciate that realizing all or part of the process in above-described embodiment method, being can be with
Relevant hardware is instructed to complete by computer program, the computer program can be stored in a non-volatile computer
In read/write memory medium, the computer program is when being executed, it may include such as the process of the embodiment of above-mentioned each method.Wherein,
To any reference of memory, storage, database or other media used in each embodiment provided herein,
Including non-volatile and/or volatile memory.Nonvolatile memory may include read-only memory (ROM), programming ROM
(PROM), electrically programmable ROM (EPROM), electrically erasable ROM (EEPROM) or flash memory.Volatile memory may include
Random access memory (RAM) or external cache.By way of illustration and not limitation, RAM is available in many forms,
Such as static state RAM (SRAM), dynamic ram (DRAM), synchronous dram (SDRAM), double data rate sdram (DDRSDRAM), enhancing
Type SDRAM (ESDRAM), synchronization link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM
(RDRAM), direct memory bus dynamic ram (DRDRAM) and memory bus dynamic ram (RDRAM) etc..
It is apparent to those skilled in the art that for convenience of description and succinctly, only with above-mentioned each function
Can unit, module division progress for example, in practical application, can according to need and by above-mentioned function distribution by different
Functional unit, module are completed, i.e., the internal structure of described device is divided into different functional unit or module, more than completing
The all or part of function of description.
Embodiment described above is merely illustrative of the technical solution of the present invention, rather than its limitations;Although referring to aforementioned reality
Applying example, invention is explained in detail, those skilled in the art should understand that: it still can be to aforementioned each
Technical solution documented by embodiment is modified or equivalent replacement of some of the technical features;And these are modified
Or replacement, the spirit and scope for technical solution of various embodiments of the present invention that it does not separate the essence of the corresponding technical solution should all
It is included within protection scope of the present invention.
Claims (10)
1. a kind of file comparison method characterized by comprising
It obtains file and changes trigger request, it includes changing file identification that the file, which changes trigger request,;
It is obtained according to the variation file identification and changes file and benchmark comparison file;
The variation file and the reference file are transformed into map data structure, file and benchmark to be compared is obtained and compares
File;
File is compared to the file to be compared and the benchmark and carries out recursive traversal, obtains different information.
2. file comparison method as described in claim 1, which is characterized in that the acquisition file changes trigger request, comprising:
Destination folder is monitored in real time using monitor;
If the monitor detects that the destination folder changes, the variation file identification and the variation are obtained
The corresponding change type of file identification;
If the change type is modification, file is generated according to the variation file identification and changes trigger request.
3. file comparison method as described in claim 1, which is characterized in that the acquisition file changes trigger request, comprising:
The file destination in destination folder is obtained according to prefixed time interval, each file destination includes file destination mark;
Each file destination is calculated using md5 encryption algorithm, obtains the target character of each file destination
String;
Corresponding benchmark character string is obtained from the pattern library according to file destination mark;
Whether target string and the corresponding benchmark character string for comparing each file destination are consistent, according to inconsistent institute
The file destination mark for stating file destination generates file and changes trigger request.
4. file comparison method as described in claim 1, which is characterized in that described by the variation file and benchmark text
Part is transformed into map data structure, obtains file and benchmark to be compared and compares file, comprising:
Obtain the file type of the file type for changing file and the reference file;
The the first conversion script obtained respectively according to the file type of the file type for changing file and the reference file
With the second conversion script;
The variation file and the reference file are sealed respectively by the first conversion script and the second conversion script
Map data structure is dressed up, file and benchmark to be compared is obtained and compares file.
5. file comparison method as described in claim 1, which is characterized in that described to the file to be compared and the benchmark
It compares file and carries out recursive traversal, obtain different information, comprising:
Obtain file and benchmark to be compared respectively and compare key-value pairs in file, obtain key-value to be compared to and base
Quasi- key-value pairs;
According to key value to key-value to be compared to and benchmark key-value to matching, obtain comparison data, Mei Yisuo
State comparison data include key-value to be compared to and one key-value pairs of benchmark;
Diversity ratio pair is carried out to each comparison data, comparison information is exported according to comparison result;
Different information is obtained according to the comparison information of each comparison data.
6. file comparison method as claimed in claim 5, which is characterized in that described to carry out diversity ratio to each comparison data
It is right, comparison information is exported according to comparison result, comprising:
If the value value in the comparison data is map data structure, next layer of key-value is carried out to comparison, exports ratio
To information;
If the value value in the comparison data is list data structure, the list data are traversed, output compares
Information;
If the value value in the comparison data is string character string, directly progress string matching, according to matching result
Export comparison information.
7. a kind of file comparison device characterized by comprising
File changes trigger request and obtains module, changes trigger request for obtaining file, the file changes trigger request packet
Include variation file identification;
File acquisition module changes file and benchmark comparison file for obtaining according to the variation file identification;
File conversion module, for the variation file and the reference file to be transformed into map data structure, obtain to than
File is compared to file and benchmark;
Different information obtains module, carries out recursive traversal for comparing file to the file to be compared and the benchmark, obtains
Different information.
8. file comparison device as claimed in claim 7, which is characterized in that the different information obtains module and includes:
Key-value is to acquiring unit, for obtaining key-value pairs in file and benchmark comparison file to be compared respectively,
Obtain key-value to be compared to and key-value pairs of benchmark;
Comparison data acquiring unit, for according to key value to key-value to be compared to and benchmark key-value to matching
It is right, obtain comparison data, each comparison data include a key-value to be compared to and a benchmark key-value
It is right;
Comparison information output unit is exported according to comparison result and is compared for carrying out diversity ratio pair to each comparison data
Information;
Different information acquiring unit, for obtaining different information according to the comparison information of each comparison data.
9. a kind of computer equipment, including memory, processor and storage are in the memory and can be in the processor
The computer program of upper operation, which is characterized in that the processor realized when executing the computer program as claim 1 to
Any one of 6 file comparison methods.
10. a kind of computer readable storage medium, the computer-readable recording medium storage has computer program, and feature exists
In realization file comparison method as described in any one of claim 1 to 6 when the computer program is executed by processor.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910345020.5A CN110162509A (en) | 2019-04-26 | 2019-04-26 | File comparison method, device, computer equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910345020.5A CN110162509A (en) | 2019-04-26 | 2019-04-26 | File comparison method, device, computer equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN110162509A true CN110162509A (en) | 2019-08-23 |
Family
ID=67640213
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910345020.5A Pending CN110162509A (en) | 2019-04-26 | 2019-04-26 | File comparison method, device, computer equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110162509A (en) |
Cited By (16)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110580243A (en) * | 2019-08-30 | 2019-12-17 | 深圳壹账通智能科技有限公司 | file comparison method and device, electronic equipment and storage medium |
CN110609984A (en) * | 2019-08-26 | 2019-12-24 | 深圳市亿道数码技术有限公司 | Method and system for automatically splitting Google key in Windows system |
CN110929500A (en) * | 2019-11-08 | 2020-03-27 | 腾讯科技(深圳)有限公司 | File comparison method and related device |
CN111090788A (en) * | 2019-12-03 | 2020-05-01 | 广州品唯软件有限公司 | Json file comparison method and device, storage medium and computer equipment |
CN111143368A (en) * | 2019-12-27 | 2020-05-12 | 瀚高基础软件股份有限公司 | Relational database data comparison method and system |
CN111309972A (en) * | 2020-02-25 | 2020-06-19 | 深圳市元征科技股份有限公司 | Data processing method and device, terminal equipment and storage medium |
CN111506608A (en) * | 2020-04-16 | 2020-08-07 | 泰康保险集团股份有限公司 | Method and device for comparing structured texts |
CN112256635A (en) * | 2020-10-19 | 2021-01-22 | 厦门天锐科技股份有限公司 | Method and device for identifying file type |
CN112632952A (en) * | 2020-12-08 | 2021-04-09 | 中国建设银行股份有限公司 | Method and device for comparing files |
CN113419739A (en) * | 2021-06-22 | 2021-09-21 | 网易(杭州)网络有限公司 | Node map difference detection method and device, electronic equipment and storage medium |
CN113489593A (en) * | 2021-06-30 | 2021-10-08 | 深圳前海微众银行股份有限公司 | JSON message checking method and JSON message checking device |
CN113688154A (en) * | 2021-07-29 | 2021-11-23 | 北京明略昭辉科技有限公司 | Data comparison method, system, storage medium and electronic equipment |
CN113806310A (en) * | 2021-09-13 | 2021-12-17 | 上海商汤科技开发有限公司 | Comparison method and related product |
CN113836092A (en) * | 2021-09-27 | 2021-12-24 | 北京来也网络科技有限公司 | File comparison method, device, equipment and storage medium based on RPA and AI |
CN113836096A (en) * | 2021-09-27 | 2021-12-24 | 北京来也网络科技有限公司 | File comparison method, device, equipment, medium and system based on RPA and AI |
CN113886332A (en) * | 2021-12-09 | 2022-01-04 | 广东睿江云计算股份有限公司 | Large file difference comparison method and device, computer equipment and storage medium |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20120185521A1 (en) * | 2011-01-14 | 2012-07-19 | Apple Inc. | Local backup |
CN103258018A (en) * | 2013-04-27 | 2013-08-21 | 北京金和软件股份有限公司 | File synchronization method capable of accurately monitoring file changes in catalog folder |
CN105279254A (en) * | 2015-10-12 | 2016-01-27 | 江苏中威科技软件系统有限公司 | Layout data stream file system, operation apparatus for system and realization method for apparatus |
CN105653554A (en) * | 2014-11-14 | 2016-06-08 | 卓望数码技术(深圳)有限公司 | File data comparison method and system |
CN107506265A (en) * | 2017-08-30 | 2017-12-22 | 安徽天达网络科技有限公司 | A kind of backup of otherness telefile and recovery system based on internet |
CN109492197A (en) * | 2018-09-18 | 2019-03-19 | 深圳壹账通智能科技有限公司 | The file information comparison method, device, computer equipment and storage medium |
-
2019
- 2019-04-26 CN CN201910345020.5A patent/CN110162509A/en active Pending
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20120185521A1 (en) * | 2011-01-14 | 2012-07-19 | Apple Inc. | Local backup |
CN103258018A (en) * | 2013-04-27 | 2013-08-21 | 北京金和软件股份有限公司 | File synchronization method capable of accurately monitoring file changes in catalog folder |
CN105653554A (en) * | 2014-11-14 | 2016-06-08 | 卓望数码技术(深圳)有限公司 | File data comparison method and system |
CN105279254A (en) * | 2015-10-12 | 2016-01-27 | 江苏中威科技软件系统有限公司 | Layout data stream file system, operation apparatus for system and realization method for apparatus |
CN107506265A (en) * | 2017-08-30 | 2017-12-22 | 安徽天达网络科技有限公司 | A kind of backup of otherness telefile and recovery system based on internet |
CN109492197A (en) * | 2018-09-18 | 2019-03-19 | 深圳壹账通智能科技有限公司 | The file information comparison method, device, computer equipment and storage medium |
Cited By (24)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110609984A (en) * | 2019-08-26 | 2019-12-24 | 深圳市亿道数码技术有限公司 | Method and system for automatically splitting Google key in Windows system |
CN110580243A (en) * | 2019-08-30 | 2019-12-17 | 深圳壹账通智能科技有限公司 | file comparison method and device, electronic equipment and storage medium |
CN110929500B (en) * | 2019-11-08 | 2022-07-08 | 腾讯科技(深圳)有限公司 | File comparison method and related device |
CN110929500A (en) * | 2019-11-08 | 2020-03-27 | 腾讯科技(深圳)有限公司 | File comparison method and related device |
CN111090788A (en) * | 2019-12-03 | 2020-05-01 | 广州品唯软件有限公司 | Json file comparison method and device, storage medium and computer equipment |
CN111090788B (en) * | 2019-12-03 | 2023-10-13 | 广州品唯软件有限公司 | json file comparison method and device, storage medium and computer equipment |
CN111143368A (en) * | 2019-12-27 | 2020-05-12 | 瀚高基础软件股份有限公司 | Relational database data comparison method and system |
CN111143368B (en) * | 2019-12-27 | 2023-05-12 | 瀚高基础软件股份有限公司 | Relational database data comparison method and system |
CN111309972A (en) * | 2020-02-25 | 2020-06-19 | 深圳市元征科技股份有限公司 | Data processing method and device, terminal equipment and storage medium |
CN111309972B (en) * | 2020-02-25 | 2023-06-30 | 深圳市元征科技股份有限公司 | Data processing method, device, terminal equipment and storage medium |
CN111506608A (en) * | 2020-04-16 | 2020-08-07 | 泰康保险集团股份有限公司 | Method and device for comparing structured texts |
CN112256635B (en) * | 2020-10-19 | 2022-06-17 | 厦门天锐科技股份有限公司 | Method and device for identifying file type |
CN112256635A (en) * | 2020-10-19 | 2021-01-22 | 厦门天锐科技股份有限公司 | Method and device for identifying file type |
CN112632952A (en) * | 2020-12-08 | 2021-04-09 | 中国建设银行股份有限公司 | Method and device for comparing files |
CN113419739A (en) * | 2021-06-22 | 2021-09-21 | 网易(杭州)网络有限公司 | Node map difference detection method and device, electronic equipment and storage medium |
CN113489593A (en) * | 2021-06-30 | 2021-10-08 | 深圳前海微众银行股份有限公司 | JSON message checking method and JSON message checking device |
WO2023273218A1 (en) * | 2021-06-30 | 2023-01-05 | 深圳前海微众银行股份有限公司 | Json packet checking method and json packet checking apparatus |
CN113688154A (en) * | 2021-07-29 | 2021-11-23 | 北京明略昭辉科技有限公司 | Data comparison method, system, storage medium and electronic equipment |
CN113806310A (en) * | 2021-09-13 | 2021-12-17 | 上海商汤科技开发有限公司 | Comparison method and related product |
CN113806310B (en) * | 2021-09-13 | 2024-08-09 | 上海商汤科技开发有限公司 | Contrast method and related products |
CN113836096A (en) * | 2021-09-27 | 2021-12-24 | 北京来也网络科技有限公司 | File comparison method, device, equipment, medium and system based on RPA and AI |
CN113836092A (en) * | 2021-09-27 | 2021-12-24 | 北京来也网络科技有限公司 | File comparison method, device, equipment and storage medium based on RPA and AI |
CN113886332A (en) * | 2021-12-09 | 2022-01-04 | 广东睿江云计算股份有限公司 | Large file difference comparison method and device, computer equipment and storage medium |
CN113886332B (en) * | 2021-12-09 | 2022-02-08 | 广东睿江云计算股份有限公司 | Large file difference comparison method and device, computer equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110162509A (en) | File comparison method, device, computer equipment and storage medium | |
CN108829727B (en) | Data storage method and device, computer equipment and storage medium | |
CN111258989B (en) | Database migration evaluation method and device, storage medium and computer equipment | |
CN110764700B (en) | Data storage method and device, computer equipment and storage medium | |
WO2019091016A1 (en) | Method and device for customizing data acquisition toolkit, terminal, and storage medium | |
CN109308285A (en) | Database script management method, device, computer equipment and storage medium | |
CN112861496A (en) | Report generation display method and device, computer equipment and readable storage medium | |
CN108512666A (en) | Encryption method, data interactive method and the system of API request | |
CN108363564A (en) | Entry modularization implementation method, device, terminal device and storage medium | |
CN110162510A (en) | Transcription comparison method, device, computer equipment and storage medium | |
CN111475376A (en) | Method and device for processing test data, computer equipment and storage medium | |
CN107659663A (en) | A kind of method, apparatus of data syn-chronization, equipment and storage medium | |
CN109885990A (en) | Script management method | |
WO2014207632A1 (en) | Logging device and log aggregation device | |
CN114041134A (en) | System and method for block chain based secure storage | |
CN112241298A (en) | Page display method and device, storage medium and electronic device | |
CA3138761A1 (en) | Method, device, computer equipment and storage medium for verifying inter-system data admission | |
CN109462661A (en) | Method of data synchronization, device, computer equipment and storage medium | |
CN111339566B (en) | Block summarization method, device, computer equipment and storage medium | |
CN109542501A (en) | Browser table compatibility method, device, computer equipment and storage medium | |
CN106990974A (en) | A kind of APP applications update method, device and electronic equipment | |
CN112783580A (en) | Routing control method and device based on sub-application and computer equipment | |
CN106557530B (en) | Operation system, data recovery method and device | |
CN114201370B (en) | Webpage file monitoring method and system | |
CN109857656A (en) | Adaptation method, device, computer equipment and storage medium based on test |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
WD01 | Invention patent application deemed withdrawn after publication | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20190823 |