JP2009266128A - Data comparison device and program - Google Patents

Data comparison device and program Download PDF

Info

Publication number
JP2009266128A
JP2009266128A JP2008117808A JP2008117808A JP2009266128A JP 2009266128 A JP2009266128 A JP 2009266128A JP 2008117808 A JP2008117808 A JP 2008117808A JP 2008117808 A JP2008117808 A JP 2008117808A JP 2009266128 A JP2009266128 A JP 2009266128A
Authority
JP
Japan
Prior art keywords
data
data string
word
matching
comparison
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.)
Granted
Application number
JP2008117808A
Other languages
Japanese (ja)
Other versions
JP5149063B2 (en
Inventor
Hiroki Minami
浩樹 南
Yutaka Kaneko
金子  豊
Yoshinori Izumi
吉則 和泉
Shinya Takeuchi
真也 竹内
Hiroshi Fujisawa
寛 藤沢
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Japan Broadcasting Corp
Original Assignee
Nippon Hoso Kyokai NHK
Japan Broadcasting Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nippon Hoso Kyokai NHK, Japan Broadcasting Corp filed Critical Nippon Hoso Kyokai NHK
Priority to JP2008117808A priority Critical patent/JP5149063B2/en
Publication of JP2009266128A publication Critical patent/JP2009266128A/en
Application granted granted Critical
Publication of JP5149063B2 publication Critical patent/JP5149063B2/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

<P>PROBLEM TO BE SOLVED: To provide a data comparison device for outputting difference information by comparing files in a short period of time or within a desired period of time even when the size of a target data file is large. <P>SOLUTION: A coincident part retrieving part sequentially compares a first coincident place retrieval target word obtained by skipping words included in a first data string for a predetermined first selection interval at a time with a second coincident place retrieval target word obtained by skipping words included in a second data string for a predetermined second selection interval at a time to find a coincident place. A common part retrieving part compares the first data string with the second data string about words located before and after the first data string and the second data string, respectively on the basis of a word of the coincident place detected by the coincident place retrieving part and detects a range where both the data strings are coincident. A difference information outputting part outputs difference information between the first data string and the second data string on the basis of range information of a common part detected by the common part retrieving part. <P>COPYRIGHT: (C)2010,JPO&INPIT

Description

本発明は、データ同士を比較し差分情報を出力するデータ比較装置およびそのプログラムに関する。   The present invention relates to a data comparison apparatus that compares data and outputs difference information, and a program thereof.

ソフトウェア開発段階では、機能向上やバグ修正などのファイル編集が頻繁に発生する。このとき、あるファイルを編集して新しいファイルができたとき、編集箇所を知るために、UNIX(登録商標)のdiffに代表される、新旧2つのファイルを比較して差分を出力するツールが用いられる。このようなファイル編集による変更の場合は、一般的には変更箇所が少ないため、差分のデータサイズは小さい。これら新旧両方のファイルの情報を残す必要がある場合は、それらのファイルを物理的に両方とも残すよりも、変更前のファイルとそれらの差分を表わす差分ファイルを残す方が保存領域の節約になるなどのメリットがあるため、差分ファイルの生成にもこのような差分出力ツールがよく用いられる。   In the software development stage, file editing such as function improvement and bug correction frequently occurs. At this time, when a new file is created by editing a certain file, a tool that compares the old and new two files and outputs a difference is used to represent the editing location, represented by diff of UNIX (registered trademark). It is done. In the case of such changes by file editing, since there are generally few changes, the difference data size is small. If you need to keep information about both the old and new files, saving the storage space is better if you leave the files before the change and the difference files that represent the differences between them, rather than physically leaving both of them. Such a difference output tool is often used for generating a difference file.

差分ファイルを生成するアルゴリズムとしては、差分データのサイズをできるだけ短くすることが求められていた。そのための代表的なアルゴリズムとして、LCS(Longest Common Subsequence:最長共通サブシーケンス)またはSED(Shortest Edit Distance:最小編集距離)がある。   As an algorithm for generating a difference file, it has been required to reduce the size of the difference data as much as possible. Typical algorithms for this include LCS (Longest Common Subsequence) or SED (Shortest Edit Distance).

また、この考え方をベースにして、高速化を図ったアルゴリズムが非特許文献1に記載されている。また、差分検索アルゴリズムとしてLCSやSEDの代わりに、サフィックス・ツリー(suffix tree)を用い、同時にデータ圧縮を行うことで差分データサイズを小さくするbdiffが非特許文献2に記載されている。   Also, Non-Patent Document 1 describes an algorithm for speeding up based on this concept. Non-Patent Document 2 describes bdiff, which uses a suffix tree instead of LCS or SED as a differential search algorithm and simultaneously reduces data size by performing data compression.

特許文献1に記載されている発明は、rsyncアルゴリズム(非特許文献3)とほぼ同様に、片方のファイルをあるブロックサイズに分割し、それぞれのブロックのチェックサムを求める。もう片方のファイルの先頭から同じブロックサイズのブロックのチェックサムを求め、相方のファイルの中でチェックサムが同じになるブロックがあるかどうか検索する。同じブロックが見つからない場合は、ブロックを後方に1バイトずらしてチェックサムを求め、同様の検索を行う。以降、これを繰り返す。検索の過程で同じブロックが見つかった場合、両方のファイルともブロックサイズ分だけ後方にずらしたブロック同士でチェックサムを比較し、同一か否かを判定する。このように、文字単位の比較とブロック単位の比較を組み合わせて、高速化を図っている。   The invention described in Patent Document 1 divides one file into a certain block size and obtains the checksum of each block in substantially the same manner as the rsync algorithm (Non-Patent Document 3). The checksum of the block having the same block size is obtained from the head of the other file, and a search is performed for a block having the same checksum in the other file. If the same block is not found, the block is shifted backward by 1 byte to obtain a checksum, and the same search is performed. This is repeated thereafter. When the same block is found in the search process, the checksums are compared between the blocks shifted backward by the block size in both files to determine whether or not they are the same. In this way, the comparison of character units and block units is combined to increase the speed.

特許文献2に記載されている発明は、2つのファイルのLCSを検索し、そのLCSを境に2つのファイルを論理的に前後に分断する。その分断したファイル同士で、同様に、LCSの検索および分断の作業を行い、LCSが予め与えられた長さよりも短くなるまで、この作業を階層的に繰り返す。この発明は、LCSの部分で前後に分断して検索範囲を限定することにより、高速化を図っている。
EUGENE W. MYERS,“An O(ND) difference algorithm and its variations”,Algorithmica,1986年,Vol.1,No.2,pp.251-266. Walter F. Tichy,“The string-to-string correction problem with block moves”,ACM Transactions on Computer Systems,1984年,volume 2,issue4,pp.309-321. Andrew Tridgell,Paul Mackerras,“The rsync algorithm”,[平成20年4月5日検索],インターネット<URL: http://rsync.samba.org/tech_report/> 特開2005−173726 特表2005−525641
In the invention described in Patent Document 2, the LCS of two files is searched, and the two files are logically divided back and forth with the LCS as a boundary. The divided files are similarly searched for LCS and divided, and this operation is hierarchically repeated until the LCS becomes shorter than a predetermined length. In the present invention, the LCS portion is divided back and forth to limit the search range, thereby increasing the speed.
EUGENE W. MYERS, “An O (ND) difference algorithm and its variations”, Algorithmica, 1986, Vol. 1, No. 2, pp. 251-266. Walter F. Tichy, “The string-to-string correction problem with block moves”, ACM Transactions on Computer Systems, 1984, volume 2, issue 4, pp.309-321. Andrew Tridgell, Paul Mackerras, “The rsync algorithm”, [Search April 5, 2008], Internet <URL: http://rsync.samba.org/tech_report/> JP-A-2005-173726 Special table 2005-525641

しかしながら、背景技術に属する上記のどの方法も、比較する2つのファイルの差分が少ないことを前提としたアルゴリズムであった。従って、差分が非常に少ない場合は短時間で結果を出力できるが、差分が大きくなると比較的時間がかかるという問題があった。特に、サイズの大きいファイル同士の比較の場合はこの時間の問題が顕著であった。   However, any of the above-described methods belonging to the background art is an algorithm on the premise that the difference between two files to be compared is small. Therefore, although the result can be output in a short time when the difference is very small, there is a problem that it takes a relatively long time when the difference is large. In particular, this problem of time is significant when comparing large files.

また、背景技術に属する方法では、ファイルを比較して差分を得るための処理時間がファイルのサイズや差分のサイズに依存しており、所望の時間内に処理を終えるようにすることはできなかった。   Also, in the method belonging to the background art, the processing time for comparing the files and obtaining the difference depends on the file size and the difference size, and the processing cannot be completed within the desired time. It was.

本発明は、上記の課題認識に基づいて行なわれたものであり、比較的短時間でファイルを比較して差分情報を出力するためのデータ比較装置およびプログラムを提供することを目的とする。また、それらのデータ比較装置およびプログラムが、ファイルのサイズに関わらず、所望時間内で処理を終えるようにすることを目的とする。   The present invention has been made based on the above problem recognition, and an object thereof is to provide a data comparison device and a program for comparing files in a relatively short time and outputting difference information. Another object of the present invention is to allow these data comparison devices and programs to finish processing within a desired time regardless of the file size.

[1]上記の課題を解決するための本発明の一態様は、それぞれ複数のワードからなる第1データ列および第2データ列を比較するデータ比較装置であって、前記第1データ列に含まれる前記ワードを所定の第1選択間隔(第1選択間隔は1以上の整数)の分ずつ飛ばして得られる第1一致箇所検索対象ワードと、前記第2データ列に含まれる前記ワードを所定の第2選択間隔(第2選択間隔は1以上の整数)の分ずつ飛ばして得られる第2一致箇所検索対象ワードとを、順次比較して両者が一致する箇所を探す一致箇所検索部と、前記一致箇所検索部が検出した一致箇所のワードを基に前記第1データ列および前記第2データ列のそれぞれ前および後に連なるワードについて、前記第1データ列と前記第2データ列との間で比較を行ない、両者が一致する範囲を共通部分の範囲として検出する共通部分検索部と、前記共通部分検索部によって検出された共通部分の範囲の情報に基づき、前記第1データ列と前記第2データ列との間の差分情報を出力する差分情報出力部とを具備することを特徴とする。   [1] One aspect of the present invention for solving the above-described problem is a data comparison device that compares a first data string and a second data string each consisting of a plurality of words, and is included in the first data string The first matching point search target word obtained by skipping the word by a predetermined first selection interval (the first selection interval is an integer of 1 or more) and the word included in the second data string A matching part search unit that sequentially compares the second matching part search target words obtained by skipping each second selection interval (the second selection interval is an integer equal to or greater than 1) to search for a part where both match, Comparison between the first data string and the second data string with respect to words preceding and following the first data string and the second data string, respectively, based on the word of the matching part detected by the matching part search unit Do A common part search unit that detects a matching range as a common part range, and based on information on the common part range detected by the common part search unit, the first data string and the second data string And a difference information output unit for outputting difference information between them.

この構成によれば、一致箇所検索部は、第1データ列中のワードのうち所定の第1選択間隔の分ずつ飛ばして得られる第1一致箇所検索対象ワードのみを比較対象とする。また同様に、第2データ列中のワードのうち所定の第2選択間隔の分ずつ飛ばして得られる第2一致箇所検索対象ワードのみを比較対象とする。従って、全ワードを比較対象とする場合に比べて、比較回数が少なくて済む。つまり、処理時間が短くて済む。また、共通部分検索部は、一致箇所検索部によって検出された一致箇所を基に、その前後に連なるワードについて第1データ列と第2データ列との間の値の比較を行うため、一致箇所を含む共通部分の範囲を求められる。共通部分検索部が求めた共通部分の範囲の情報に従い、差分情報出力部は、第1データ列と第2データ列の差分情報を出力できる。なお、共通部分の範囲の情報と差分情報とは、情報として互いに等価である。
また、この構成によれば、第1選択間隔と第2選択間隔を、適宜設定することが出来る。一致箇所検索対象ワードの数は、各々のデータ列の長さ(ワード数)をこの選択間隔で除した数にほぼ等しいため、第1選択間隔と第2選択間隔の設定により、ワードの値の比較回数を変化させることができる。つまり、たとえ第1データ列や第2データ列のサイズが膨大なものであっても、所望の比較回数(ひいては、所望の処理時間)となるように、第1選択間隔と第2選択間隔を設定でき、その代償は、一致箇所の検出機会の部分的損失に過ぎない。
なお、第1選択間隔および第2選択間隔は1以上の任意の整数として良いが、これらの数値を比較的大きくするほうが、処理時間を短くするという本発明の効果がより大きい。例えば、第1選択間隔および第2選択間隔の少なくともいずれか一方を2以上とすると処理時間の短縮が図れる。第1選択間隔および第2選択間隔をそれぞれ10以上とするとさらに処理時間の短縮が図れる。第1選択間隔および第2選択間隔をそれぞれ100以上とするとより一層処理時間の短縮が図れる。これらの値が大きな値であればあるほど処理時間の短縮が図れるが、検出が保証される共通部分の長さが長くなる。(それより短い共通部分は検出できなくなる可能性がある)。これらの間隔の設定の仕方については、後で述べる。
According to this configuration, the matching part search unit sets only the first matching part search target word obtained by skipping the first data string by a predetermined first selection interval as a comparison target. Similarly, only the second matching portion search target word obtained by skipping the predetermined second selection interval among the words in the second data string is set as a comparison target. Therefore, the number of comparisons can be reduced compared to the case where all words are to be compared. That is, the processing time is short. In addition, the common part search unit compares the values between the first data string and the second data string with respect to the consecutive words before and after the matching part detected by the matching part search unit. The range of common parts including The difference information output unit can output the difference information between the first data string and the second data string in accordance with the information on the range of the common part obtained by the common part search unit. Note that the information of the range of the common part and the difference information are equivalent to each other as information.
Further, according to this configuration, the first selection interval and the second selection interval can be set as appropriate. The number of matching portion search target words is approximately equal to the number of each data string (number of words) divided by this selection interval. Therefore, the value of the word is determined by setting the first selection interval and the second selection interval. The number of comparisons can be changed. That is, even if the size of the first data row or the second data row is enormous, the first selection interval and the second selection interval are set so that the desired number of comparisons (and thus the desired processing time) is achieved. It can be set and the price is only a partial loss of matching opportunities.
The first selection interval and the second selection interval may be arbitrary integers of 1 or more, but the effect of the present invention that the processing time is shortened is greater when these numerical values are relatively large. For example, if at least one of the first selection interval and the second selection interval is 2 or more, the processing time can be shortened. If the first selection interval and the second selection interval are each 10 or more, the processing time can be further shortened. When the first selection interval and the second selection interval are each 100 or more, the processing time can be further shortened. The larger these values are, the shorter the processing time can be, but the length of the common part that is guaranteed to be detected becomes longer. (Shorter common parts may not be detected). How to set these intervals will be described later.

[2]また、本発明の一態様は、上記のデータ比較装置において、前記第1選択間隔と前記第2選択間隔との最大公約数は1であることを特徴とするものである。   [2] Further, according to an aspect of the present invention, in the data comparison apparatus, the greatest common divisor between the first selection interval and the second selection interval is 1.

この構成により、第1一致箇所検索対象ワードと第2一致箇所検索対象ワードが徐々にずれていく。従って、共通部分の位置(各々のデータ列の先頭位置からのワード数)が第1データ列内と第2データ列内でずれていても、共通部分が大きければ、一致箇所検索対象ワードが重なる箇所が存在する可能性が高くなる。つまり、一致箇所検出の可能性が高くなる。また、共通部分のワード数が前記第1選択間隔と前記第2選択間隔の最小公倍数以上の場合は、一致箇所が必ず検出できる。   With this configuration, the first match location search target word and the second match location search target word gradually shift. Therefore, even if the position of the common part (the number of words from the head position of each data string) is shifted between the first data string and the second data string, if the common part is large, the matching portion search target words overlap. There is a high possibility that the location exists. That is, the possibility of detecting the coincidence portion increases. In addition, when the number of words in the common part is equal to or greater than the least common multiple of the first selection interval and the second selection interval, a coincident portion can be detected without fail.

[3]また、本発明の一態様は、上記のデータ比較装置において、前記第1一致箇所検索対象ワードの値をソートし、その結果得られる順序情報を順序情報記憶部に書き込む順序付処理部をさらに具備し、前記一致箇所検索部は、前記順序情報記憶部から前記順序情報を読み出すことにより、ある前記第2一致箇所検索対象ワードを、比較する必要のある前記第1一致箇所検索対象ワードのみと比較し、両者が一致する箇所を探すことを特徴とするものである。   [3] Further, according to one aspect of the present invention, in the data comparison apparatus described above, the ordered processing unit that sorts the values of the first matching portion search target words and writes the resulting order information in the order information storage unit The match location search unit reads the sequence information from the sequence information storage unit, so that the second match location search target word needs to be compared with the first match location search target word. It is characterized by searching for a place where both match with each other.

この構成により、一致箇所検索部が順序情報を利用できることによって、ある第2一致箇所検索対象ワードについて、すべての第1一致箇所検索対象ワードとの比較を行なう必要がなく、例えば二分木的に大小比較をすることにより、限定された数の第1一致箇所検索対象ワードとの比較をすれば充分である。つまり、第1一致箇所検索対象ワードとの比較を効率的に行える。よって、トータルでの比較回数が少なくて済み、従って全体の処理時間が短くて済む。
また、原理的に、第1一致箇所検索対象ワードの数について対数オーダーの比較回数で済む。つまり、第1一致箇所検索対象ワードの数が多いほど(第1データ列のワード数が多いほど)、この構成による時間短縮の効果が大きく得られる。
With this configuration, since the matching part search unit can use the order information, it is not necessary to compare a certain second matching part search target word with all the first matching part search target words. By comparing, it is sufficient to compare with a limited number of first matching part search target words. That is, the comparison with the first matching point search target word can be performed efficiently. Therefore, the total number of comparisons can be reduced, and therefore the overall processing time can be shortened.
Also, in principle, the number of first matching part search target words can be a logarithmic order comparison count. That is, the greater the number of first matching portion search target words (the greater the number of words in the first data string), the greater the effect of time reduction by this configuration.

[4]また、本発明の一態様は、上記のデータ比較装置において、前記第1データ列および前記第2データ列に含まれる前記ワードは、これらデータ列の元となる比較対象データを所定サイズに分割したブロックのデータにハッシュ関数を適用して得られたハッシュ値を有するものであることを特徴とする。   [4] Further, according to an aspect of the present invention, in the data comparison apparatus, the word included in the first data string and the second data string may be compared with a predetermined size of the comparison target data that is the source of these data strings. It has a hash value obtained by applying a hash function to the data of the block divided into two.

この構成により、元データにおけるブロックのデータが一致してない限り、第1データ列と第2データ列に含まれるワードの値が偶然に一致する可能性は非常に小さくなる。つまり、本来共通部分ではないのに偶々第1および第2の一致箇所検索対象ワードの値が同じになってしまう可能性は非常に小さくなる。つまり、元データそのものを比較することなく、データ比較における高い精度が得られることとなる。   With this configuration, unless the block data in the original data match, the possibility that the values of the words included in the first data string and the second data string coincide by chance is very small. That is, the possibility that the values of the first and second matching part search target words will accidentally become the same even though it is not a common part is very small. That is, high accuracy in data comparison can be obtained without comparing the original data itself.

[5]また、本発明の一態様は、それぞれ複数のワードからなる第1データ列および第2データ列を比較する処理をコンピュータに実行させるプログラムであって、前記第1データ列に含まれる前記ワードを所定の第1選択間隔(第1選択間隔は1以上の整数)の分ずつ飛ばして得られる第1一致箇所検索対象ワードと、前記第2データ列に含まれる前記ワードを所定の第2選択間隔(第2選択間隔は1以上の整数)の分ずつ飛ばして得られる第2一致箇所検索対象ワードとを、順次比較して両者が一致する箇所を探す一致箇所検索過程と、前記一致箇所検索過程で検出した一致箇所のワードを基に前記第1データ列および前記第2データ列のそれぞれ前および後に連なるワードについて、前記第1データ列と前記第2データ列との間で比較を行ない、両者が一致する範囲を共通部分の範囲として検出する共通部分検索過程と、前記共通部分検索過程において検出された共通部分の範囲の情報に基づき、前記第1データ列と前記第2データ列との間の差分情報を出力する差分情報出力過程との処理をコンピュータに実行させることを特徴とするものである。   [5] Further, according to one aspect of the present invention, there is provided a program for causing a computer to execute a process of comparing a first data string and a second data string each including a plurality of words, and the program included in the first data string A first matching point search target word obtained by skipping a word by a predetermined first selection interval (the first selection interval is an integer of 1 or more) and the word included in the second data string are set to a predetermined second A matching part search process for sequentially comparing the second matching part search target words obtained by skipping the selection intervals (the second selection interval is an integer of 1 or more) to find a matching part, and the matching part Comparing between the first data string and the second data string with respect to words preceding and following the first data string and the second data string, respectively, based on the matching word detected in the search process And performing a common part search process for detecting a range in which both coincide with each other as a common part range, and information on the range of the common part detected in the common part search process, and the first data string and the second data string. And a difference information output process for outputting difference information between and the computer.

本発明によれば、2つのデータ列の共通部分を高速に検出することができる。つまり、2つのデータ列の差分を出力する処理を高速化できる。また、パラメータ(第1選択間隔および第2選択間隔)を適宜設定することにより、ワード間の比較処理の回数を制御することができる。つまり、データ列のサイズがたとえ大きい場合にも、処理時間を所望の程度に抑えることが可能となる。つまり、全く異なる2つのデータ列について、予め設定された時間内に、それらが互いに全く異なるものであることを判定できる。   According to the present invention, a common part of two data strings can be detected at high speed. That is, the process of outputting the difference between the two data strings can be speeded up. Further, the number of comparison processing between words can be controlled by appropriately setting parameters (first selection interval and second selection interval). That is, even when the data string size is large, the processing time can be suppressed to a desired level. That is, it is possible to determine that two completely different data strings are completely different within a preset time.

以下、本発明の実施形態について図面を参照しながら説明する。
差分データを得るための処理としては、背景技術で述べた手法と同様に、データ比較装置が、与えられた2つのデータ列の間の共通部分(共通部分が複数箇所ある場合は、複数箇所の共通部分)を見つけ、共通部分を除外した部分を差分データとする。したがって、以下で説明する実施形態では、2つのデータ列の共通部分を探す処理を高速に行なえるようにする。
Hereinafter, embodiments of the present invention will be described with reference to the drawings.
As a process for obtaining the difference data, as in the method described in the background art, the data comparison apparatus can perform a common part between two given data strings (if there are a plurality of common parts, The common part) is found, and the part excluding the common part is set as difference data. Therefore, in the embodiment described below, a process for searching for a common part of two data strings can be performed at high speed.

従来の手法では、できるだけ多くの共通部分を見つけることによって差分データ量を小さくすることに主眼を置いていた。これに対し、本発明の実施形態では、ワード数の非常に多い2つのデータ列に対し、これらを比較しその差分を高速に出力することを目的とする。また、まったく異なるデータ列同士の比較を行った場合、共通部分がないと判断するのも高速に行えるようにする。代わりに、差分のデータ量は必ずしも最小である必要はなく、短い共通部分は見逃しても良いという戦略を基本とする。ここで、ワードとはデータ1個分である。ワードの長さは1バイト(=8ビット)程度であっても良いが、本実施形態では、典型的には4バイトから64バイト程度の長さを有するワードを想定する。また、64バイトを超える長さのワードであっても良い。   Conventional methods have focused on reducing the amount of difference data by finding as many common parts as possible. On the other hand, an object of the embodiment of the present invention is to compare two data strings having a very large number of words and output the difference at high speed. Further, when comparing completely different data strings, it is possible to determine at high speed that there is no common part. Instead, the data amount of the difference does not necessarily need to be the minimum, and a basic strategy is that a short common part may be missed. Here, the word is one piece of data. The length of the word may be about 1 byte (= 8 bits), but in the present embodiment, a word having a length of about 4 bytes to 64 bytes is typically assumed. Further, it may be a word having a length exceeding 64 bytes.

また、データ列を構成する各ワードは、一例としてはハッシュ関数が返す値である。良好なハッシュ関数を使えば、ハッシュ関数が適用される元のデータが全く同一でない限り、返されるハッシュ値が偶然に一致する可能性は非常に小さい。   Each word constituting the data string is, for example, a value returned by the hash function. With a good hash function, it is very unlikely that the returned hash values will coincide by chance unless the original data to which the hash function is applied is identical.

[第1の実施の形態]
図1は、本発明の第1の実施形態によるデータ比較装置の機能構成を示すブロック図である。図示するように、データ比較装置1は、共通部分検索部3と、一致箇所検索部4と、差分情報出力部5と、制御部6と、データファイル10Aと10Bと20Aと20Bと、ハッシュデータ生成部15とを含んで構成される。
[First Embodiment]
FIG. 1 is a block diagram showing a functional configuration of the data comparison apparatus according to the first embodiment of the present invention. As shown in the figure, the data comparison device 1 includes a common part search unit 3, a matching part search unit 4, a difference information output unit 5, a control unit 6, data files 10A, 10B, 20A, and 20B, and hash data. And a generation unit 15.

一致箇所検索部4は、制御部6の指示で、制御部6から受け取ったデータ列AとBの比較用ポインタが指す位置以降のデータ列を対象とし、後述するデータ列Aに含まれるワードを所定の第1選択間隔(n)の分ずつ飛ばして得られる一致箇所検索対象ワードと、データ列Bに含まれるワードを所定の第2選択間隔(n)の分ずつ飛ばして得られる一致箇所検索対象ワードとを、順次比較して両者が一致する箇所を探す機能を有する。得られた一致箇所のデータ列AとBの比較用ポインタを制御部6に返す。一致箇所がない場合は、データ列Bの比較用ポインタをデータ列Bの末尾に設定して、データ列AとBの比較用ポインタを制御部6に返す。 The matching part search unit 4 is directed to a data string after the position indicated by the comparison pointers of the data strings A and B received from the control unit 6 according to an instruction from the control unit 6, and a word included in the data string A described later is selected. Matching part search target word obtained by skipping by a predetermined first selection interval (n A ) and match obtained by skipping a word included in the data string B by a predetermined second selection interval (n B ) It has a function of sequentially comparing the location search target words to find a location where both match. The comparison pointers for the data strings A and B at the coincident part are returned to the control unit 6. If there is no match, the comparison pointer for the data string B is set at the end of the data string B, and the comparison pointer for the data strings A and B is returned to the control unit 6.

共通部分検索部3は、制御部6の指示で、制御部6から受け取ったデータ列AとBの比較用ポインタを起点とし、一致箇所検索部4が検出した一致箇所のワードを基にデータ列Aおよびデータ列Bのそれぞれ前および後に連なるワードについて、データ列Aとデータ列Bとの間の比較を行ない、両者が一致する範囲を共通部分の範囲として検出する機能を有する。共通部分のデータ列AとBの比較用ポインタの範囲を差分情報出力部5に出力し、共通部分の範囲の直後のデータ列AとBの比較用ポインタを制御部6に返す。   The common part search unit 3 starts from the comparison pointers of the data strings A and B received from the control unit 6 in accordance with an instruction from the control unit 6, and the data sequence based on the word of the matching part detected by the matching part search unit 4 For words that precede and follow A and data string B, respectively, a comparison is made between data string A and data string B, and a range in which both match is detected as a common part range. The range of the comparison pointers for the data strings A and B in the common part is output to the difference information output unit 5, and the comparison pointer for the data strings A and B immediately after the range of the common part is returned to the control unit 6.

差分情報出力部5は、共通部分検索部3によって検出された共通部分の範囲の情報に基づき、制御部6の指示で、データ列Aとデータ列Bとの間の差分情報を出力する機能を有する。   The difference information output unit 5 has a function of outputting difference information between the data string A and the data string B according to an instruction from the control unit 6 based on the information on the range of the common part detected by the common part search unit 3. Have.

また、制御部6は、一致箇所検索部4、共通部分検索部3、差分情報出力部5の実行を制御する。具体的には、データ列Aおよびデータ列Bそれぞれの比較用ポインタを初期化し、現在の比較用ポインタの位置を用いて共通部分検索部3に処理を実行させ、共通部分の直後のデータ列AとBの比較用ポインタを受け取り、比較用ポインタがデータ列の末尾を指しているかどうかを判断し、ポインタが末尾まで行っていなければ現在の比較用ポインタの位置を用いて一致箇所検索部4に処理を実行させ、一致箇所のデータ列AとBの比較用ポインタを受け取り、また比較用ポインタがデータ列の末尾を指しているかどうかを判断することにより、順次、共通部分3と一致箇所検索部4が処理を行なえるように制御する。また、ポインタが末尾を指すと(つまり、一致箇所検索および共通部分検索がすべて終了すると)、差分情報出力部5に処理を実行させる。   Further, the control unit 6 controls the execution of the matching part search unit 4, the common part search unit 3, and the difference information output unit 5. Specifically, the comparison pointers of the data string A and the data string B are initialized, the common part search unit 3 is executed using the current position of the comparison pointer, and the data string A immediately after the common part is processed. And the comparison pointer of B are received, and it is determined whether or not the comparison pointer points to the end of the data string. If the pointer does not reach the end, the current position of the comparison pointer is used for the matching part search unit 4. The process is executed to receive the comparison pointers of the data strings A and B at the coincidence portion, and by determining whether the comparison pointer points to the end of the data row, the common portion 3 and the coincidence portion search unit are sequentially 4 is controlled so that processing can be performed. Further, when the pointer points to the end (that is, when the matching part search and the common part search are all finished), the difference information output unit 5 is caused to execute the process.

データファイル20Aおよび20Bは、このデータ比較装置1が比較処理を行なう対象である2つのデータファイルである。また、データファイル10Aおよび10B(比較対象データ)は、別の、2つのデータファイルである。
ハッシュデータ生成部15は、所定のハッシュ関数の計算を行なう機能を有しており、データファイル10Aを基にそのハッシュ関数を適用してデータファイル20Aを生成するとともに、データファイル10Bを基に同じハッシュ関数を適用してデータファイル20Bを生成する。使用するハッシュ関数は、適宜選択すれば良いが、例えば、MD5やSHAやHAVALやチェックサムやCRC(巡回冗長符号)などを用いることができる。
なお、データファイル10Aと10Bと20Aと20Bは、半導体メモリやハードディスク装置(HDD)などの記録媒体に格納されている。
The data files 20A and 20B are two data files to which the data comparison device 1 is to perform comparison processing. The data files 10A and 10B (comparison target data) are two different data files.
The hash data generation unit 15 has a function of calculating a predetermined hash function. The hash data generation unit 15 applies the hash function based on the data file 10A to generate the data file 20A, and the same based on the data file 10B. A data file 20B is generated by applying a hash function. The hash function to be used may be appropriately selected. For example, MD5, SHA, HAVAL, checksum, CRC (cyclic redundancy code), or the like can be used.
The data files 10A, 10B, 20A, and 20B are stored in a recording medium such as a semiconductor memory or a hard disk device (HDD).

図2は、データファイル10Aと20Aとの関係を示す概略図である。図示するように、データファイル10Aと20Aは、いずれもシーケンシャルファイルである。   FIG. 2 is a schematic diagram showing the relationship between the data files 10A and 20A. As shown in the figure, the data files 10A and 20A are both sequential files.

データファイル10Aは、所定の長さを有するブロックをM個含んでいる。一例としては、ブロックサイズは4kバイト(1kバイトは、1024バイト)とする。この例の場合、データファイル10A全体の長さは、4k×M(バイト)である。この図では、各ブロックのデータの値を、先頭ブロックから順に、B(0),B(1),B(2),・・・・・・,B(M−1)と表わしている。Mの値はいかなる値であっても良いが、例えば、M=1048576(=2^20)とすると、データファイル10A全体の長さは4GB(ギガバイト)である。なお、ブロック長は、4kバイトに限らず、任意のサイズであって良い。 Data file 10A includes M A number of blocks having a predetermined length. As an example, the block size is 4 kbytes (1 kbyte is 1024 bytes). In this example, the length of the entire data file 10A is 4k × M A (bytes). In this figure, the data value of each block is expressed as B (0), B (1), B (2),..., B (M A −1) in order from the first block. . The value of M A may be any value. For example, if M A = 1048576 (= 2 ^ 20), the length of the entire data file 10A is 4 GB (gigabytes). The block length is not limited to 4 kbytes, and may be any size.

データファイル20Aは、ハッシュデータ生成部15によってデータファイル10Aを基に生成されるデータである。データファイル20Aは、ワード(ここでは、1ワードは16バイトとする)をM個含んでいる。つまり、データファイル20A全体の長さは、16×M(バイト)である。各々のワードは、上記のデータファイル10Aのブロックに対応しており、その順序も保存されている。例えば、データファイル10Aの先頭のブロックB(0)を基に、ハッシュデータ生成部15がハッシュ関数を適用し、その結果得られる値h(B(0))がデータファイル20Aの先頭のワードに格納されている。データファイル10Aの次のブロックB(1)には、データファイル20Aの次のワードの値h(B(1))が対応している。以下同様に続き、データファイル10Aの最後のブロックB(M−1)には、データファイル20Aの最後のワードの値h(B(M−1))が対応している。なお、ワード長は、16バイトに限らず任意のサイズであって良いが、現在一般によく使われるハッシュ関数が返す値は、16バイト(=128ビット)、20バイト(=160ビット)、28バイト(=224ビット)、32バイト(=256ビット)、48バイト(=384ビット)、64バイト(=512ビット)などである。データファイル20Aのワード長などを基に、適宜使用するハッシュ関数を選択して用いるようにする。 The data file 20A is data generated by the hash data generation unit 15 based on the data file 10A. Data file 20A, the word (in this case, one word is set to 16 bytes) contains M A number of. That is, the entire length of the data file 20A is 16 × M A (bytes). Each word corresponds to the block of the data file 10A and the order thereof is also stored. For example, based on the first block B (0) of the data file 10A, the hash data generation unit 15 applies a hash function, and the value h (B (0)) obtained as a result is the first word of the data file 20A. Stored. The next block B (1) of the data file 10A corresponds to the value h (B (1)) of the next word of the data file 20A. In the same manner, the last block B (M A −1) of the data file 10A corresponds to the last word value h (B (M A −1)) of the data file 20A. Note that the word length is not limited to 16 bytes, but may be any size. The values returned by hash functions that are generally used at present are 16 bytes (= 128 bits), 20 bytes (= 160 bits), and 28 bytes. (= 224 bits), 32 bytes (= 256 bits), 48 bytes (= 384 bits), 64 bytes (= 512 bits), and the like. Based on the word length of the data file 20A and the like, a hash function to be used is selected and used.

以上、図を参照しながらデータファイル10Aと20Aの関係について説明したが、データファイル10Bと20Bの関係についても同様である。但し、データファイル10Aの長さとデータファイル10Bの長さとが異なっていても良い。   While the relationship between the data files 10A and 20A has been described above with reference to the drawings, the same applies to the relationship between the data files 10B and 20B. However, the length of the data file 10A and the length of the data file 10B may be different.

次に、データ比較装置1がデータファイル20Aと20Bとを比較する処理の方法および手順について説明する。   Next, a method and procedure for processing in which the data comparison device 1 compares the data files 20A and 20B will be described.

図3は、データ比較装置1において、主として共通部分検索部3および一致箇所検索部4の機能によりデータファイル20Aと20Bとの間の共通部分を発見するための、処理の概要を示す概略図である。この図において、データ列A(第1データ列)は、データファイル20Aのデータを表わしており、データ列Aが含むワード数はNワード(Nは1以上の整数)である。データ列Aのうち、先頭からnワード(nは1以上の整数,第1選択間隔)毎に、一致箇所検索部4によって検索される一致箇所検索対象ワード51Aまたは52A(第1一致箇所検索対象ワード)が存在している。これらの一致箇所検索対象ワード51Aまたは52Aは、図中において、それぞれ固有のハッチングパターンで示している。つまり、データ列Aには、N/n個(但し、この場合の除算の剰余は切り上げ)の一致箇所検索対象ワードが含まれている。また同様に、データ列B(第2データ列)は、データファイル20Bのデータを表わしており、データ列Bが含むワード数はNワード(Nは1以上の整数)である。データ列Bのうち、先頭からnワード(nは1以上の整数,第2選択間隔)毎に、一致箇所検索部4によって検索される一致箇所検索対象ワード51Bまたは52B(第2一致箇所検索対象ワード)が存在している。これらの一致箇所検索対象ワード51Bまたは52Bは、図中において、それぞれ固有のハッチングパターンで示している。つまり、データ列Bには、N/n個(但し、この場合の除算の剰余は切り上げ)の一致箇所検索対象ワードが含まれている。
なお、nとn個の少なくともいずれか一方を、2以上とすることにより、処理の高速化が図れる。
FIG. 3 is a schematic diagram showing an outline of processing for finding a common part between the data files 20A and 20B mainly by the functions of the common part search unit 3 and the matching part search unit 4 in the data comparison device 1. is there. In this figure, data sequence A (first data row) represents the data of the data file 20A, the number of words that the data sequence A contains is N A word (N A is an integer of 1 or more). In the data string A, the match location search target word 51A or 52A (first match location) searched by the match location search unit 4 for every n A words (n A is an integer of 1 or more, first selection interval) from the beginning. Search word) exists. These matching part search target words 51A or 52A are each shown by a unique hatching pattern in the figure. In other words, the data string A includes N A / n A (in this case, the remainder of division is rounded up) matching point search target words. Similarly, the data sequence B (second data column) represents the data of the data file 20B, the number of words that the data sequence B contains is N B word (N B is an integer of 1 or more). In the data string B, the match location search target word 51B or 52B (second match location) searched by the match location search unit 4 for every n B words (n B is an integer of 1 or more, second selection interval) from the beginning. Search word) exists. These matching part search target words 51B or 52B are each shown by a unique hatching pattern in the figure. In other words, the data string B includes N B / n B (in this case, the remainder of division is rounded up) matching portion search target words.
Note that the processing speed can be increased by setting at least one of n A and n B to 2 or more.

図示するデータ列の例において、データ列AとBの共通部分として示している範囲は、その範囲に含まれるすべてのワードの値が、データ列AとBとの間で完全に一致する範囲である。つまり、この共通部分が、共通部分検索部3によって検出されるべき範囲である。従って、上述した一致箇所検索対象ワードのうち、この共通部分に含まれる一致箇所検索対象ワード52Aと52Bとは、互いに値が一致する。なお、データ列Aにおける当該共通部分のワード位置(データ列Aの先頭から当該共通部分の直前までのワード数)と、データ列Bにおける当該共通部分のワード位置(同様)とは、必ずしも一致する必要はない。   In the example of the data string shown in the figure, the range shown as the common part of the data strings A and B is a range in which the values of all the words included in the range completely match between the data strings A and B. is there. That is, this common part is a range to be detected by the common part search unit 3. Accordingly, among the above-described matching portion search target words, the matching portion search target words 52A and 52B included in this common portion have the same value. Note that the word position of the common part in the data string A (the number of words from the beginning of the data string A to the point immediately before the common part) and the word position of the common part in the data string B (similar) are not necessarily the same. There is no need.

共通部分検索部3と一致箇所検索部4とは協調しながら、制御部6の制御に従い、後述する手順によって、データ列AとBとの共通部分を検出する。そのとき、一致箇所検索部4は、データ列Aに含まれる一致箇所検索対象ワード(51A,52A)と、データ列Bに含まれる一致箇所検索対象ワード(51B,52B)のみを互いに比較する対象とする。また、一致箇所検索部4は、一致箇所検索対象ワード以外のワード(この図において、ハッチングがない部分のワード)は、比較対象とせずに読み飛ばす。   The common part search unit 3 and the coincidence part search unit 4 cooperate to detect a common part between the data strings A and B according to the procedure described later under the control of the control unit 6. At that time, the matching part search unit 4 compares only the matching part search target word (51A, 52A) included in the data string A and the matching part search target word (51B, 52B) included in the data string B. And In addition, the matching part search unit 4 skips words other than the matching part search target word (words in a portion without hatching in this figure) without being compared.

なお、このとき、nとnの最大公約数が1になるように設定し、それに従って一致箇所検索ワードを決定することが好適である。nとnの最大公約数が1になるようにすることにより、下で説明する処理においてデータ列Aとデータ列Bの一致箇所検索対象ワードが少しずつずれていくため、一致箇所を検出できる可能性が高まる。また、共通部分のワード数がnとnの最小公倍数以上の場合は、一致箇所が必ず検出できる。
なお、nとnとの最大公約数が1になるように設定することは必須ではないが、そうしない場合には一致箇所を検出できなくなる可能性もある。例えば、最も簡単な例で、n=n=2とした場合、仮にデータ列Aの0ワード目から9ワード目までとデータ列Bの1ワード目から10ワード目までが共通部分であったとしても(つまり両者が1ワード分ずれている状態)、データ列Aもデータ列Bとも、一致箇所検索対象ワードは偶数ワード目(0ワード目、2ワード目、4ワード目、・・・)のみとなってしまい、この共通部分に含まれる一致箇所を検出できない。
At this time, it is preferable to set the greatest common divisor of n A and n B to be 1, and to determine the matching portion search word accordingly. By making the greatest common divisor of n A and n B equal to 1, the matching point search target words of the data string A and the data string B are shifted little by little in the processing described below. The possibility of being able to be increased. In addition, when the number of words in the common part is greater than or equal to the least common multiple of n A and n B , a coincident part can be detected without fail.
Note that it is not essential to set the greatest common divisor of n A and n B to be 1. However, if this is not done, there is a possibility that a matching portion cannot be detected. For example, in the simplest case, when n A = n B = 2, the common part is the 0th to 9th words of the data string A and the 1st to 10th words of the data string B. Even if the data string A and the data string B are both shifted by one word, the matching portion search target word is the even word (0th word, 2nd word, 4th word,...). ), And a matching portion included in the common part cannot be detected.

一致箇所検索部4は、データ列Bに含まれる一致箇所検索対象ワードの各々について、データ列Aに含まれる一致箇所検索対象ワードの各々との比較を行う。この比較の結果、一致箇所検索部4が一致するワードを見つけた場合には、共通部分検索部3が、その場所から前方向(データ列全体の先頭に向かう方向)と後方向(データ列全体の末尾に向かう方向)に、1ワードずつスキャンし、両データ列の値が同じである範囲(共通部分)の先頭と末尾を探す。このようにして、一致箇所検索部4によって見つけられた一致ワードを含む共通部分の範囲が決定される。   The matching part search unit 4 compares each of the matching part search target words included in the data string B with each of the matching part search target words included in the data string A. As a result of the comparison, when the matching part search unit 4 finds a matching word, the common part search unit 3 moves forward (from the location toward the beginning of the entire data string) and backward (from the entire data string). Are scanned one word at a time, and the beginning and end of a range (common part) where the values of both data strings are the same are searched. In this way, the range of the common part including the matching word found by the matching part search unit 4 is determined.

共通部分検索部3によって共通部分の範囲が決定されたあとは、その共通部分の次のワードから、上記の作業をデータ列の最後まで繰り返す。nとnの最大公約数が1のときは、(n×n)ワード以上のサイズを有する共通部分の中のどこかには必ず、データ列AおよびデータBの両方の一致箇所検索対象ワードであるワードが含まれるため、上記のような処理手順により、(n×n)ワード以上のサイズの共通部分を必ず見つけることができる。 After the common part range is determined by the common part search unit 3, the above operation is repeated from the next word of the common part to the end of the data string. When the greatest common divisor of n A and n B is 1, there is always a coincidence place of both data string A and data B somewhere in the common part having a size of (n A × n B ) words or more. Since the search target word is included, a common part having a size of (n A × n B ) words or more can always be found by the processing procedure as described above.

また、上記のような処理手順をとる場合、データ列Aとデータ列Bとが全く異なる場合など、双方の一致箇所検索対象ワードが一つも一致しない場合であっても、一致箇所検索部4は、最大でも、(N/n)×(N/n)回の比較処理を行えば良い。つまり、サイズの大きなデータ列同士を比較する場合であっても、nおよびnの値を適宜設定することにより、一致個所の検出の機会を犠牲にすることになるものの、比較処理の回数を抑えることができ、つまりデータ列同士の比較処理にかかる処理時間を所定範囲内に抑えるようにすることができる。 Further, when the processing procedure as described above is taken, even when the data string A and the data string B are completely different, even when both the matching part search target words do not match, the matching part search unit 4 , at most, (n a / n a) × (n B / n B) may be carried out comparison processing times. That is, even when comparing large data strings, the value of n A and n B is appropriately set to sacrifice the opportunity to detect a coincidence, but the number of comparison processes In other words, the processing time required for the comparison process between data strings can be suppressed within a predetermined range.

この場合、言い換えれば、データ列のサイズNおよびNが与えられたとき、見つけるべき共通部分の長さの最小値((n×n)ワード)と検索回数(つまり、一致箇所検索部4による比較処理の回数(N/n)×(N/n)、即ち、(N×N)/(n×n))は反比例の関係になっている。つまり、検出すべき共通部分の長さの最小値が一定値である場合は、nとnの個別の値に関係なく、最大検索回数はほぼ同じである。nとnを比較的大きな値にすれば(n×nを比較的大きな値にすれば)、比較回数を少なくすることができるが、共通部分を見逃す確率(検出できない可能性)が増える。逆に、nとnとを比較的小さな値にすれば(n×nを比較的小さな値にすれば)、共通部分を見逃す確率は減るが、比較回数が増える。従って、本実施形態の方法によれば、最大検索時間や見つけるべき共通部分の長さの最小値といった要求条件に従って、nとnを適切に設定することができる。 In this case, in other words, when the sizes N A and N B of the data string are given, the minimum value of the length of the common part to be found ((n A × n B ) words) and the number of searches (that is, search for matching points) The number of comparison processes (N A / n A ) × (N B / n B ), that is, (N A × N B ) / (n A × n B )) is inversely proportional. That is, when the minimum value of the length of the common part to be detected is a constant value, the maximum number of searches is almost the same regardless of the individual values of n A and n B. If n A and n B are set to relatively large values (if n A × n B is set to a relatively large value), the number of comparisons can be reduced, but the probability of missing a common part (possibility of failure to detect) Will increase. Conversely, if n A and n B are set to relatively small values (if n A × n B is set to a relatively small value), the probability of missing a common portion decreases, but the number of comparisons increases. Therefore, according to the method of the present embodiment, n A and n B can be appropriately set according to the required conditions such as the maximum search time and the minimum value of the common part length to be found.

図4は、データ比較装置1による差分出力のための処理手順を示すフローチャートである。以下、このフローチャートに沿って、データ比較装置1の詳細な処理手順について説明する。   FIG. 4 is a flowchart showing a processing procedure for differential output by the data comparison device 1. Hereinafter, the detailed processing procedure of the data comparison device 1 will be described with reference to this flowchart.

まずステップS61において、データ比較装置1は、初期化処理を行う。この初期化処理では、データファイル20Aおよび20Bをオープンするとともに、比較するワードのポインタ(比較用ポインタ)をデータ列AおよびBのそれぞれの先頭にセットする。   First, in step S61, the data comparison apparatus 1 performs an initialization process. In this initialization process, the data files 20A and 20B are opened, and the pointers of the words to be compared (comparison pointers) are set at the heads of the data strings A and B, respectively.

また、この初期化処理は、パラメータnとnを適切な値に設定する処理を含む。このパラメータは、実施条件により設定の手順が異なる。 The initialization process includes a process of setting parameters n A and n B to appropriate values. The setting procedure of this parameter differs depending on the implementation conditions.

見つけるべき共通部分の最小値Lを基準に設定する場合は、nは、Lを超えない任意の正整数値と設定する。nは、nと互いに素であり且つL/nを超えない最大の正整数と設定する。このように設定した場合、n×n≦Lとなるので、Lワード以上のサイズを有する共通部分を必ず検出することができる。 When the minimum value L of the common part to be found is set as a reference, n A is set to an arbitrary positive integer value not exceeding L. n B is a relatively prime to n A and maximum setting a positive integer not exceeding L / n A. In such a setting, since n A × n B ≦ L, a common portion having a size of L words or more can always be detected.

一方、比較回数の上限Cを基準にnとnの値を設定する場合は、(N/n)×(N/n)≦Cを満たすようにnとnの値を選択する。これは、データ列AとBとが全く異なるものである場合であっても、両者の一致箇所検索対象ワードを総当り的に比較する回数がせいぜい(N/n)×(N/n)であるためである。 On the other hand, to set the value of n A and n B relative to the upper limit C of the comparison number, (N A / n A) × (N B / n B) ≦ C to meet the n A and n B to Select a value. This is because, even if the data strings A and B are completely different, the number of times that the matching point search target words of both are compared brute force is at most (N A / n A ) × (N B / This is because n B ).

具体的な一例として、nは、(N/C)を下回らない正整数値とする。また、nは、nと互いに素であり、且つ、(N×N)/(n×C)を下回らない最小の正整数値とする。このとき、(N/n)×(N/n)≦Cとなる。つまり総比較回数はC以下となる。 As a specific example, n A is a positive integer not less than (N A / C). Further, n B is relatively prime to n A, and is the smallest positive integer not less than (N A × N B) / (n A × C). At this time, (N A / n A ) × (N B / n B ) ≦ C. That is, the total number of comparisons is C or less.

次にステップS62において、共通部分検索部3が、共通部分の範囲を検索する。具体的には、まず、それぞれのデータ列上にある比較用ポインタが示すワードの値を比較し、一致するかどうか判定する。このとき、比較用ポインタは、それぞれのデータ列の現在の一致箇所検索対象ワードを指している。上記判定の結果、一致しない場合には、このステップの処理を終了して次のステップへ進む。上記判定の結果、一致する場合には、両方の比較用ポインタをそれぞれデータ列の前方向に1つずつずらしながら、順次、両方の比較用ポインタが指すワードの値を比較していく。そして、どちらかの比較用ポインタがデータ列の先頭に到達するか、ワードの値が一致しなくなるまで比較用ポインタを前方向に進める。このようにして、共通部分の先頭位置を検索する。次に、比較用ポインタを最初の位置(現在の一致箇所検索対象ワードの位置)に戻し、同様にして、比較用ポインタを後ろ方向に1つずつずらしながら両方のデータ列のワードの値を比較していくことにより、共通部分の末尾の位置を検索する。現在の一致箇所検索対象ワードの位置が共通部分の一部であった場合には、このようにして、その共通部分の先頭位置と末尾位置が求まる。つまり、その共通部分の範囲が決まる。共通部分検索部3は、その共通部分の先頭位置と末尾位置の情報を、制御部6に渡す。   Next, in step S62, the common part search unit 3 searches the range of the common part. Specifically, first, the values of the words indicated by the comparison pointers on the respective data strings are compared to determine whether or not they match. At this time, the comparison pointer points to the current matching point search target word of each data string. If the result of the determination is that they do not match, the process of this step is terminated and the process proceeds to the next step. If they match as a result of the above determination, the values of the words pointed to by both comparison pointers are sequentially compared while shifting both comparison pointers one by one in the forward direction of the data string. Then, the comparison pointer is advanced in the forward direction until one of the comparison pointers reaches the head of the data string or the word values do not match. In this way, the head position of the common part is searched. Next, return the comparison pointer to the first position (the position of the current matching point search target word), and similarly compare the word values of both data strings while shifting the comparison pointer backward one by one. By doing so, the end position of the common part is searched. When the current position of the search target word is a part of the common part, the head position and the tail position of the common part are obtained in this way. That is, the range of the common part is determined. The common part search unit 3 passes the information on the start position and the end position of the common part to the control unit 6.

次にステップS63において、制御部6は、AおよびBの両方のデータ列の比較用ポインタがファイルの末尾(ここで、ファイルの末尾とは、データ列が有する最後のワードのさらに後ろである)にあるかどうかを判定する。少なくとも片方の比較用ポインタがファイルの末尾にある場合は(比較すべき一致箇所検索対象ワードの比較をすべて終えた場合)(ステップS63:YES)、ステップS62からS65までのループを抜け出し、ステップS66に進む。判定の結果、比較用ポインタが末尾にない場合(まだ、比較すべき一致箇所検索対象ワードの組み合わせが残っている場合)(ステップS63:NO)、次のステップS64に進む。   In step S63, the control unit 6 determines that the comparison pointers for both the data strings A and B are the end of the file (here, the end of the file is further after the last word of the data string). It is determined whether or not. When at least one of the comparison pointers is at the end of the file (when all the comparisons of the matching point search target words to be compared have been completed) (step S63: YES), the loop from step S62 to S65 is exited, and step S66 is completed. Proceed to As a result of the determination, if the comparison pointer is not at the end (if there is still a combination of matching point search target words to be compared) (step S63: NO), the process proceeds to the next step S64.

次のステップS64に進んだ時点では、AおよびBの両方のデータ列の比較用ポインタは、直前に検索し範囲を確定した共通部分の次のワードを指している。つまり、比較用ポインタは、直前に検索した共通部分の外の位置を指している。このステップでは、必要に応じて比較用ポインタを各データ列の次の一致箇所検索対象ワードの位置に進めた上で、一致箇所検索部4が、そこから、データ列AおよびBの一致箇所検索対象ワードを検索し、一致する箇所を探す。本実施形態では、一致箇所検索部4は、データ列Bの比較用ポインタを固定して、データ列AおよびBの比較用ポインタが指す一致箇所検索対象ワードを比較しながら、一致するワードの組が見つかるまで、データ列Aの比較用ポインタが指す位置をnワードずつ順次進めていく。データ列Aの比較用ポインタが末尾まで行くと、データ列Aの比較用ポインタを一旦は元に戻し(戻す先は、直前に検索された共通部分がある場合はその共通部分より後ろであって且つその中で最初の一致箇所検索対象ワードの位置、あるいは、直前に検索された共通部分がない場合はデータ列Aの最初の一致箇所検索対象ワードの位置)、そしてデータ列B用の比較用ポインタを指す位置をnワード分進め(つまり、データ列Bの次の一致箇所検索対象ワードを指すようにする)、そのデータ列Bの一致箇所検索ワードについて、上と同様に、データ列Aの比較用ポインタを順次進めながら、比較を繰り返していく。このステップの処理が終了するのは、残っていた一致箇所検索対象ワードの比較を全ての組について終えた場合か、或いは、順次比較する途中で一致するワードが検出された場合である。 At the time of proceeding to the next step S64, the comparison pointers of the data strings of both A and B point to the next word of the common part which has been searched immediately before and the range is fixed. That is, the comparison pointer points to a position outside the common part searched immediately before. In this step, if necessary, the comparison pointer is advanced to the position of the next matching point search target word of each data string, and then the matching part search unit 4 searches for a matching part of the data strings A and B therefrom. Search for the target word and find the matching part. In the present embodiment, the matching part search unit 4 fixes the comparison pointer for the data string B and compares the matching part search target words pointed to by the comparison pointers for the data strings A and B while matching the set of matching words. The position pointed to by the comparison pointer in the data string A is sequentially advanced by n A words until the data is found. When the comparison pointer of the data string A reaches the end, the comparison pointer of the data string A is temporarily returned to the original position (the destination to be restored is after the common part when there is a common part searched immediately before). In addition, the position of the first matching part search target word among them, or the position of the first matching part search target word in the data string A if there is no common part searched immediately before), and for comparison for the data string B The position pointing to the pointer is advanced by n B words (that is, the next matching point search target word of the data string B is pointed), and the matching string search word of the data string B is the data string A in the same manner as above. The comparison is repeated while sequentially moving the comparison pointers. The processing in this step ends when the comparison of the remaining matching point search target words is completed for all the pairs or when matching words are detected during the sequential comparison.

次にステップS65において、制御部6は、データ列Bのポインタが末尾を指しているか否かを判定する。
データ列Bのポインタが末尾を指している場合とは、ステップS64での一致箇所検索処理において、ワードが一致する箇所が発見されなかった場合である。この場合(ステップS65:YES)には、ステップS62からS65までのループを抜け出して、ステップS66に進む。
一方で、データ列Bのポインタが末尾を指していない場合とは、ステップS64での一致箇所検索処理において、ワードが一致する箇所が発見された場合であり、この場合にはデータ列AおよびBそれぞれの比較用ポインタは、値の一致した一致箇所検索対象ワードをそれぞれ指している。この場合(ステップS65:NO)には、ステップS62の処理へ進む。
Next, in step S65, the control unit 6 determines whether or not the pointer of the data string B points to the end.
The case where the pointer of the data string B points to the end refers to the case where the word matching part is not found in the matching part search process in step S64. In this case (step S65: YES), the process exits the loop from step S62 to S65 and proceeds to step S66.
On the other hand, the case where the pointer of the data string B does not point to the end is a case where a matching part is found in the matching part search process in step S64. In this case, the data strings A and B are detected. Each comparison pointer points to a matching point search target word having a matching value. In this case (step S65: NO), the process proceeds to step S62.

なお、ステップS65での判断結果が「NO」であり、ステップS62に進んだ場合には、現在の比較用ポインタが差す位置をもとに、ステップS62の処理として、前述の通りの共通部分の範囲の検索を行なう。   If the determination result in step S65 is “NO” and the process proceeds to step S62, the common part as described above is processed as the process in step S62 based on the position indicated by the current comparison pointer. Perform a range search.

ステップS66に制御が移るのは、前述の通り、ステップS63あるいはS65のいずれかで「YES」と判定された場合、即ち、データ列AおよびBに含まれる一致箇所検索対象ワード同士の比較がすべて完了した場合である。そしてステップS66において、差分情報出力部5は、差分情報出力処理を行なう。このとき出力される差分情報とは、例えば、データ列Aに含まれていてデータ列Bに含まれていないデータ(ワードの並び)の情報およびデータ列Bに含まれていてデータ列Aに含まれていないデータの情報として表現される。このような差分情報は、ステップS62において共通部分検索部3が求めた共通部分の範囲の情報(各々の共通部分の先頭位置と末尾位置の情報)をメモリから読み出し、これに基づいて作成することができる。また、共通部分の範囲の情報そのものも、情報としては差分情報と等価である。共通部分の範囲の情報そのものや、共通部分の範囲の情報とデータ列Aとデータ列Bから作成できる情報は、表現としては様々なパターンがあり得るが、いずれも本質的にはここで言う差分情報である。   As described above, the control shifts to step S66 when it is determined “YES” in either step S63 or S65, that is, all of the comparisons between the matching portion search target words included in the data strings A and B are all performed. This is the case. In step S66, the difference information output unit 5 performs difference information output processing. The difference information output at this time is, for example, information on data (word arrangement) included in the data string A and not included in the data string B, and included in the data string A but included in the data string B. It is expressed as data information that is not available. Such difference information is created based on the information on the range of the common part obtained by the common part search unit 3 in step S62 (information on the start position and the end position of each common part) from the memory. Can do. In addition, the information in the range of the common part itself is equivalent to the difference information as information. The information of the common part range itself, or the information of the common part range and the information that can be created from the data string A and the data string B can be expressed in various patterns. Information.

図5は、簡単なデータ列の例を用いて、上述した一連の処理の概略を示している概略図である。図示する例は説明のためのものであるので、N=N=16と、それぞれのデータ列の長さを短くしている。また、データ列Aについてはn=2としているため、一致箇所検索対象ワード(51Aまたは52A)は2ワードおきに存在している。また、データ列Bについてはn=3としているため、一致箇所検索対象ワード(51Bまたは52B)は3ワードおきに存在している。また、この例では、データ列Aの6ワード目〜11ワード目までとデータ列Bの8ワード目〜13ワード目までを共通部分とが共通部分であり、この共通部分のサイズは6ワードである。従って、図示する一致箇所検索対象ワードのうち、データ列Aの10ワード目の一致箇所検索対象ワード52Aとデータ列Bの12ワード目の一致箇所検索対象ワード52Bは、互いに値が一致する。 FIG. 5 is a schematic diagram showing an outline of the above-described series of processing using an example of a simple data string. Since the example shown in the drawing is for explanation, N A = N B = 16 and the length of each data string is shortened. In addition, since n A = 2 is set for the data string A, the matching portion search target word (51A or 52A) exists every two words. In addition, since n B = 3 is set for the data string B, the matching portion search target word (51B or 52B) exists every three words. In this example, the common part is the 6th to 11th words of the data string A and the 8th to 13th words of the data string B. The common part has a size of 6 words. is there. Therefore, of the illustrated matching part search target words, the tenth matching part search target word 52A in the data string A and the twelfth matching part search target word 52B in the data string B have the same value.

以下、図4のフローチャートと図5の概略図を参照しながら説明する。
まずステップS61の初期化処理において、データ列AおよびBの比較用ポインタを、各々のデータ列の0ワード目に設定する。また、n=2、n=3と、パラメータを設定する。
次にステップS62の共通部分の範囲を検索する処理において、それぞれの比較用ポインタが指す一致箇所検索対象ワードの値同士を比較する。この場合、現在の比較用ポインタが指しているデータ列Aの0ワード目とデータ列Bの0ワード目の値は同一でないため、比較しても一致せず、このステップの処理はここで終了する。
そしてステップS63の判定において、比較用ポインタはデータ列AとBのいずれも、データ列の末尾にはないので(ステップS63:NO)、ステップS64に移る。
Hereinafter, description will be made with reference to the flowchart of FIG. 4 and the schematic diagram of FIG.
First, in the initialization process in step S61, the comparison pointers for the data strings A and B are set to the 0th word of each data string. In addition, parameters are set as n A = 2 and n B = 3.
Next, in the process of searching for the range of the common part in step S62, the values of the matching portion search target words pointed to by the respective comparison pointers are compared. In this case, since the values of the 0th word of the data string A and the 0th word of the data string B pointed to by the current comparison pointer are not the same, they do not match even if they are compared, and the process of this step ends here. To do.
In the determination in step S63, since neither of the data strings A and B is at the end of the data string (step S63: NO), the process proceeds to step S64.

次の、ステップS64においては、データ列Bの比較用ポインタの現在位置(0ワード目を指す)から、3ワード(nワード)ごとに、一致箇所検索対象ワードを選び、それらそれぞれの一致箇所検索対象ワードを順次、データ列A内の一致箇所検索対象ワード(0ワード目から、2ワード(nワード)ごと)と比較する。データ列Bの0ワード目、3ワード目、6ワード目、9ワード目について順次比較するところまでは、データ列Aの一致箇所検索対象ワードとの一致はない。さらに比較を続けると、データ列Bの12ワード目(一致箇所検索対象ワード52B)の値がデータ列Aの10ワード目(一致箇所検索対象ワード52A)の値と一致する。一致箇所が検出されたため、これでステップS64の処理を終える。 In the next step S64, a matching point search target word is selected every three words (n B words) from the current position of the comparison pointer of the data string B (pointing to the 0th word), and each matching point is selected. The search target words are sequentially compared with the matching point search target words in the data string A (from the 0th word, every 2 words (n A words)). Until the 0th word, the 3rd word, the 6th word, and the 9th word of the data string B are sequentially compared, there is no match with the matching portion search target word of the data string A. If the comparison is further continued, the value of the 12th word (matching part search target word 52B) of the data string B matches the value of the tenth word (matching part search target word 52A) of the data string A. Since the coincidence portion has been detected, the processing in step S64 is completed.

ステップS65において、この時点で、データ列Aの比較用ポインタは10ワード目の位置を指し、データ列Bの比較用ポインタは12ワード目の位置を指している。つまり、データ列Bの比較用ポインタはデータ列の末尾ではないため(ステップS65:NO)、ステップS62に戻る。   In step S65, at this time, the comparison pointer of the data string A points to the position of the tenth word, and the comparison pointer of the data string B points to the position of the twelfth word. That is, since the comparison pointer of the data string B is not the end of the data string (step S65: NO), the process returns to step S62.

次のステップS62の処理において、データ列Aの10ワード目とデータ列Bの12ワード目とを基点として、前方向および後方向にそれぞれ1ワードずつポインタをずらしながら、両者が一致するワードを検索する。その結果、当該共通部分の先頭位置はデータ列Aの6ワード目、即ちデータ列Bの8ワード目であり、当該共通部分の末尾位置はデータ列Aの11ワード目、即ちデータ列Bの13ワード目であることがわかる。
次のステップS63の判定では、この時点では、データ列Aの比較用ポインタは12ワード目の位置を指し、データ列Bの比較用ポインタは14ワード目の位置を指しているため、即ちデータ列Bの比較用ポインタはデータ列の末尾ではないため(ステップS63:NO)、次のステップS64に進む。
In the processing of the next step S62, using the 10th word of the data string A and the 12th word of the data string B as a base point, search for a word that matches both by moving the pointer forward and backward one word at a time. To do. As a result, the beginning position of the common part is the sixth word of the data string A, that is, the eighth word of the data string B, and the end position of the common part is the eleventh word of the data string A, that is, the 13th word of the data string B. It turns out that it is the word.
In the determination of the next step S63, since the comparison pointer of the data string A points to the position of the 12th word and the comparison pointer of the data string B points to the position of the 14th word at this time, that is, the data string Since the comparison pointer for B is not the end of the data string (step S63: NO), the process proceeds to the next step S64.

再び、ステップS64では、ワードが一致する箇所の検索を行なう。このとき、データ列Bの比較用ポインタは14ワード目の位置を指しているが、この比較用ポインタの現在の位置(14ワード目)から3ワードごとに一致箇所検索対象ワードを選んでいく。なお、比較用ポインタの位置を、直前の共通部分(データ列Bの8ワード目から13ワード目まで)より後の、当初予定していた一致箇所検索対象ワードのうちの最初のワード(15ワード目)の位置に移してから、3ワードごとに一致箇所検索対象ワードを選んでいくようにしても良い。いずれにしても図示する例では、データ列AとBとの間での一致箇所検索対象ワードの一致は検出されない。そして、データ列Bの比較用ポインタがデータの末尾に達すると、このステップの処理を終える。   Again, in step S64, a search is made for a place where the words match. At this time, the comparison pointer of the data string B points to the position of the 14th word, but the matching point search target word is selected every 3 words from the current position of the comparison pointer (the 14th word). Note that the position of the comparison pointer is the first word (15 words) of the match target search words originally planned after the immediately preceding common part (from the 8th word to the 13th word of the data string B). It is also possible to select a matching portion search target word every three words after moving to the position of (eye). In any case, in the example shown in the figure, the match of the search target word between the data strings A and B is not detected. When the comparison pointer of the data string B reaches the end of the data, the process of this step is finished.

次のステップS65の判定においては、データ列Bのポインタは末尾に達しているため(ステップS65:YES)、ループを抜けて、ステップS66に進む。
そして、ステップS66において、差分情報を出力し、このフローチャート全体の処理を終了する。
In the next step S65, since the pointer of the data string B has reached the end (step S65: YES), the process goes out of the loop and proceeds to step S66.
In step S66, the difference information is output, and the process of the entire flowchart ends.

[第2の実施の形態]
図6は、本発明の第2の実施形態によるデータ比較装置2の機能構成を示すブロック図である。図示するように、データ比較装置2は、共通部分検索部3と、一致箇所検索部24と、順序付処理部31と、順序情報記憶部32と、差分情報出力部5と、制御部6と、データファイル10Aと10Bと20Aと20Bと、ハッシュデータ生成部15とを含んで構成される。
この第2の実施形態は、より一層処理を高速化することを目的としている。以下では、第1の実施形態と同様の部分については説明を省略し、本実施形態特有の構成や処理手順等を中心に説明する。
[Second Embodiment]
FIG. 6 is a block diagram showing a functional configuration of the data comparison device 2 according to the second embodiment of the present invention. As shown in the figure, the data comparison device 2 includes a common part search unit 3, a matching part search unit 24, an ordered processing unit 31, an order information storage unit 32, a difference information output unit 5, and a control unit 6. The data files 10A, 10B, 20A and 20B, and the hash data generation unit 15 are configured.
This second embodiment is intended to further speed up the processing. In the following, description of the same parts as in the first embodiment will be omitted, and description will be made focusing on the configuration, processing procedure, and the like unique to this embodiment.

本実施形態において、処理をさらに高速化する手段は、次の通りである。即ち、本実施形態では、2つのデータ列のうちの片方のデータ列(ここでは説明の都合上、データ列Aとする)の一致箇所検索対象ワードをその値の順(昇順または降順)でソート(順序付け)し、ソート結果として得られる順序情報を利用しながら一致箇所の検索を行なうようにする。   In the present embodiment, means for further speeding up the processing is as follows. That is, in this embodiment, the matching point search target words of one of the two data strings (here, for convenience of explanation, the data string A) are sorted in the order of their values (ascending order or descending order). (Sequence) and search for matching points using the order information obtained as a result of sorting.

より具体的に言うと、順序付処理部31は、データ列Aに含まれる一致箇所検索対象ワードの値によるソートを行ない、その結果得られるデータ列Aに関する一致箇所検索対象ワードの順序情報を順序情報記憶部32に書き込む機能を有する。   More specifically, the ordering processing unit 31 sorts by the value of the matching part search target word included in the data string A, and orders the order information of the matching part search target word regarding the data string A obtained as a result. It has a function of writing in the information storage unit 32.

また、順序情報記憶部32は、データ列Aに含まれる一致箇所検索対象ワードの値に関する順序情報を保持する。これは具体的には、例えば、B−Tree(バランス木)構造によりデータ列Aに対するインデックス情報を保持する。これにより、データ列A自体の順序を変更せずにその順序情報を保持できるため、データ列Aの一致箇所検索対象ワードと一致するワードがあるかどうかを高速に判定できるようになる。   In addition, the order information storage unit 32 holds order information regarding the value of the matching part search target word included in the data string A. Specifically, for example, index information for the data string A is held by a B-Tree (balance tree) structure. Thereby, since the order information can be held without changing the order of the data string A itself, it is possible to determine at high speed whether there is a word that matches the matching portion search target word of the data string A.

一致箇所検索部24は、順序情報記憶部32から前記の順序情報を読み出すことによりデータ列Aに含まれる一致箇所検索対象ワードの値の順序を得られるため、これを用いて、データ列Bに含まれるある一致箇所検索対象ワードを、データ列Aに含まれる一致箇所検索対象ワードのうちの比較する必要のあるワードのみと比較し、両者が一致する箇所を探す機能を有する。つまり、本実施形態の一致箇所検索部24は、データ列AとBの一致箇所検索対象ワードを総当り的に比較する必要がなく、データ列Bに含まれるある一致箇所検索対象ワードについて、例えば二分木的にデータ列Aに含まれる一致箇所検索対象ワードとの比較を行なっていけば良い。   Since the matching part search unit 24 can obtain the order of the values of the matching part search target words included in the data string A by reading the order information from the order information storage unit 32, It has a function of comparing a certain matching part search target word included with only the words that need to be compared among the matching part search target words included in the data string A, and searching for a part where both match. In other words, the matching part search unit 24 of the present embodiment does not need to compare the matching part search target words of the data strings A and B brute force, and for a certain matching part search target word included in the data string B, for example, It is only necessary to compare with a matching point search target word included in the data string A in a binary tree.

データ列Aを1度だけソートするために、最大で(N/n)log(N/n)回のワードの比較を行うことが必要である。また、一旦ソートされた後は、データ列Bの1つあたりの一致箇所検索対象ワードにつき、およそlog(N/n)回の比較により、データ列Aの一致箇所検索対象ワードとの一致を検出できるか、あるいはデータ列Aのいずれの一致箇所検索対象ワードとも一致しないことを確認できる。つまり、データ列Bには(N/n)個の一致箇所検索対象ワードがあるため、比較回数の合計は(N/n)log(N/n)である。従ってこれら両者を合わせると、本実施形態の場合には、データ列Aとデータ列Bとが全く異なるデータ列である場合にも、最大で((N/n)+(N/n))×log(N/n)回の比較処理を行えば良い。第1の実施形態の場合と異なり、本実施形態の場合、見つけるべき共通部分の長さの最小値が一定値であっても、最大比較回数はnとnの値に依存する。相加・相乗平均の定理により、計算上は、N/nとN/nの値が同じぐらいの値になるnとnを選択すれば、最大比較回数を最小とすることができる。 In order to sort the data string A only once, it is necessary to perform word comparison of at most (N A / n A ) log 2 (N A / n A ) times. Further, once sorted, the matching point search target word for each data string B is compared with the matching point search target word of the data string A by approximately log 2 (N A / n A ) comparisons. It can be confirmed that a match can be detected or that it does not match any match location search target word in the data string A. That is, since there are (N B / n B ) matching portion search target words in the data string B, the total number of comparisons is (N B / n B ) log 2 (N A / n A ). Therefore, when these are combined, in the case of the present embodiment, even when the data string A and the data string B are completely different data strings, the maximum is ((N A / n A ) + (N B / n B )) × log 2 (N A / n A ) comparisons may be performed. Unlike the case of the first embodiment, in the case of this embodiment, the maximum number of comparisons depends on the values of n A and n B even if the minimum value of the common portion to be found is a constant value. According to the arithmetic and geometric mean theorem, the maximum number of comparisons can be minimized by selecting n A and n B where the values of N A / n A and N B / n B are approximately the same. be able to.

図7は、本実施形態のデータ比較装置2によるデータ比較処理の手順を示すフローチャートである。以下、このフローチャートに沿って説明する。   FIG. 7 is a flowchart showing a procedure of data comparison processing by the data comparison device 2 of the present embodiment. Hereinafter, it demonstrates along this flowchart.

まずステップS81の初期化処理は、第1の実施形態で説明したステップS61の処理と同様である。但し、比較回数の上限Cを基準にnとnの値を設定する場合の値の決め方は、次の通りである。つまり、((N/n)+(N/n))×log(N/n)≦Cを満たし、且つ、上述した通りN/nとN/nの値が同じぐらいの値になるようにnとnの値を選択する。
具体的な一例として、nは、2×(N/n)×log(N/n)≦Cを満たす最小の正整数値とする。また、nは、nと互いに素であり、且つ、n≧N/N×nを満たす正整数とする。なお、このような条件を満たすnのうち最小の整数数を選択することにより、所定の比較回数の制約の中で、共通部分を検出できる可能性を高めることができる。
First, the initialization process in step S81 is the same as the process in step S61 described in the first embodiment. However, how to determine the values for setting the value of n A and n B relative to the upper limit C of the number of comparisons are as follows. That is, ((N A / n A ) + (N B / n B )) × log 2 (N A / n A ) ≦ C is satisfied, and N A / n A and N B / n B are satisfied as described above. values to select the value of n a and n B to a value of about the same.
As a specific example, n A is the smallest positive integer that satisfies 2 × (N A / n A ) × log 2 (N A / n A) ≦ C. Further, n B is relatively prime to n A, and is a positive integer satisfying n B ≧ N B / N A × n A. Incidentally, by selecting the smallest integer number of satisfying such conditions n B, in a predetermined number of comparisons constraint, it is possible to increase the possibility of detecting the common portions.

ステップS82における共通部分の範囲を検索する処理は、第1の実施形態のステップS62の処理と同様である。
ステップS83における判定処理は、第1の実施形態のステップS63の処理と同様である。
The process of searching for the range of the common part in step S82 is the same as the process of step S62 of the first embodiment.
The determination process in step S83 is the same as the process in step S63 of the first embodiment.

次に、ステップS84において、一致箇所検索部24は、データ列Aがソート済であるか否か(つまり、順序情報記憶部32に既にデータ列Aの順序情報が書き込まれているか否か)を判定する。ソート済である場合は(ステップS84:YES)、ソート処理をさらに行なう必要はないので、ステップS85をスキップしてステップS86へ直接進む。ソート済でない場合は(ステップS84:NO)、ソート処理を行なうためにステップS85へ進む。   Next, in step S84, the matching part search unit 24 determines whether or not the data string A has been sorted (that is, whether or not the order information of the data string A has already been written in the order information storage unit 32). judge. If it has been sorted (step S84: YES), it is not necessary to perform further sorting, so step S85 is skipped and the process proceeds directly to step S86. If it has not been sorted (step S84: NO), the process proceeds to step S85 to perform the sort process.

ステップS85では、順序付処理部31が、上で決定されたパラメータnに基づき、データ列Aの一致箇所検索対象ワードを、その値の昇順に(降順でも良い)ソートする(順序付けする)処理を行なう。ソート処理自体は既存技術による手順で行なう。そして、順序付け処理部31は、その結果得られた順序情報(例えば、B−Tree構造で表現された、データ列Aの一致箇所検索対象ワードへのインデックス情報(このインデックス値としては、例えば、データ列Aにおけるワード位置を用いる))を順序情報記憶部32に書き込む。
なお、このソート処理は、この部分で実行する代わりに、例えばステップS81の初期化処理で行なっておくようにしても良い。
いずれの部分でソート処理を行なうにしても、ステップS82からS87までのループ部分の処理を2回目以降には、再度ソート処理を行なう必要はなく、順序情報記憶部32から順序情報を読み出して利用すれば良い。
At step S85, the the ordering processor 31, based on the parameter n A determined above, the matching points searched word data sequence A, (which may be a descending) sort (ordering) in ascending order of the value processing To do. The sorting process itself is performed by a procedure using existing technology. Then, the ordering processing unit 31 obtains the order information obtained as a result (for example, index information to the matching portion search target word of the data string A expressed in the B-Tree structure. The word position in the column A is used))) is written in the order information storage unit 32.
Note that this sort processing may be performed in, for example, the initialization processing in step S81 instead of being executed in this portion.
Regardless of which part of the sort process is performed, it is not necessary to perform the sort process again after the second loop from step S82 to S87, and the order information is read from the order information storage unit 32 and used. Just do it.

ステップS86では、一致箇所検索部24が、データ列AおよびBの一致箇所検索対象ワードの比較を行い、一致箇所を探す。このとき、本実施形態では、一致箇所検索部24は、順序情報記憶部32から順序情報を読み出して利用しながら、データ列Bのひとつの一致箇所検索対象ワードに対して、log(N/n)回程度の比較処理を行なう。つまり、B−Tree構造の根ノードから順次、値の大小比較をしながら枝を選択していき、データ列Aの一致箇所検索対象ワードの中で値の一致するものを探す。
つまり、一致箇所検索部24は、その時点でのデータ列Bの比較用ポインタ以降のデータ列からnワードごとに比較対象ワードを選択し、すべての比較対象ワードについて、ソートされたデータ列Aの比較対象ワードとの比較を行い、一致するワードがあるかどうかを判定する。
一致するワードが見つかるまで検索処理を行なう点などは、第1の実施形態のステップS64と同様である。
In step S86, the matching part search unit 24 compares the matching part search target words of the data strings A and B to search for a matching part. In this case, in the present embodiment, matching point detecting unit 24, while utilizing the sequence information storage unit 32 reads the order information, for one of the matching locations searched word data sequence B, log 2 (N A / N A ) About comparison processing is performed. That is, the branches are selected while sequentially comparing the values from the root node of the B-Tree structure, and the matching part search target words in the data string A are searched for the matching words.
That is, the matching part search unit 24 selects a comparison word for every n B words from the data string after the comparison pointer of the data string B at that time, and sorts the data string A sorted for all comparison words. Is compared with a comparison target word to determine whether there is a matching word.
The point that search processing is performed until a matching word is found is the same as step S64 of the first embodiment.

ステップS87における判定処理は、第1の実施形態のステップS65の処理と同様である。
そして、ステップS88における差分情報の出力処理は、第1の実施形態のステップS66の処理と同様である。
The determination process in step S87 is the same as the process in step S65 of the first embodiment.
The difference information output process in step S88 is the same as the process in step S66 of the first embodiment.

[第3の実施の形態]
図8は、本発明の第3の実施形態によるデータ比較装置1Aの機能構成を示すブロック図である。第1の実施形態では、データ比較装置1は、データファイル10Aおよび10Bと、ハッシュデータ生成部15を含んでいた。本実施形態によるデータ比較装置1Aはこれらを有さず、図8に示すように、共通部分検索部3と、一致箇所検索部4と、差分情報出力部5と、制御部6と、データファイル20Aと20Bとで構成される。データファイル20Aおよび20Bが所定の長さのワードからなるデータ列である点は第1の実施形態と同様である。データファイル20Aおよび20Bは、外部から与えられるデータ列を有するファイルである。共通部分検索部3と、一致箇所検索部4と、差分情報出力部5と、制御部6の動作等は、第1の実施形態と同様である。
[Third Embodiment]
FIG. 8 is a block diagram showing a functional configuration of a data comparison apparatus 1A according to the third embodiment of the present invention. In the first embodiment, the data comparison device 1 includes the data files 10A and 10B and the hash data generation unit 15. The data comparison apparatus 1A according to the present embodiment does not have these, and as shown in FIG. 8, the common part search unit 3, the matching part search unit 4, the difference information output unit 5, the control unit 6, and the data file It is composed of 20A and 20B. Similar to the first embodiment, the data files 20A and 20B are data strings composed of words having a predetermined length. The data files 20A and 20B are files having a data string given from the outside. The operations of the common part search unit 3, the matching part search unit 4, the difference information output unit 5, and the control unit 6 are the same as those in the first embodiment.

[第4の実施の形態]
図9は、本発明の第4の実施形態によるデータ比較装置2Aの機能構成を示すブロック図である。第2の実施形態では、データ比較装置2は、データファイル10Aおよび10Bと、ハッシュデータ生成部15を含んでいた。本実施形態によるデータ比較装置2Aはこれらを有さず、図9に示すように、共通部分検索部3と、一致箇所検索部24と、順序付処理部31と、順序情報記憶部32と、差分情報出力部5と、制御部6と、データファイル20Aと20Bとで構成される。データファイル20Aおよび20Bが所定の長さのワードからなるデータ列である点は第2の実施形態と同様である。データファイル20Aおよび20Bは、外部から与えられるデータ列を有するファイルである。共通部分検索部3と、一致箇所検索部24と、順序付処理部31と、順序情報記憶部32と、差分情報出力部5と、制御部6の動作等は、第2の実施形態と同様である。
[Fourth Embodiment]
FIG. 9 is a block diagram showing a functional configuration of a data comparison device 2A according to the fourth embodiment of the present invention. In the second embodiment, the data comparison device 2 includes the data files 10A and 10B and the hash data generation unit 15. The data comparison device 2A according to the present embodiment does not have these, and as shown in FIG. 9, the common part search unit 3, the matching part search unit 24, the ordered processing unit 31, the order information storage unit 32, It comprises a difference information output unit 5, a control unit 6, and data files 20A and 20B. Similar to the second embodiment, the data files 20A and 20B are data strings composed of words of a predetermined length. The data files 20A and 20B are files having a data string given from the outside. The operations of the common part search unit 3, the matching part search unit 24, the ordered processing unit 31, the order information storage unit 32, the difference information output unit 5, the control unit 6, and the like are the same as in the second embodiment. It is.

<<応用例>>
ここでは、上記各実施形態の応用例について、代表として第1実施形態の構成を示す図1を参照しながら、説明する。
<< Application example >>
Here, application examples of the above-described embodiments will be described with reference to FIG. 1 showing the configuration of the first embodiment as a representative.

本応用例において、データファイル10Aおよび10Bは、それぞれ数ギガバイトから数十ギガバイト程度のサイズを有する動画コンテンツファイルである。データファイル10Aおよび10Bは、ファイルシステムによってブロック単位で管理されており、1ブロックのサイズは、例えば、4kバイト(4096バイト)である。つまり、データファイル10Aおよび10Bは、それぞれ、数百万個から数千万個程度のブロックから成る。   In this application example, the data files 10A and 10B are moving image content files each having a size of about several gigabytes to several tens of gigabytes. The data files 10A and 10B are managed in units of blocks by the file system, and the size of one block is, for example, 4 kbytes (4096 bytes). That is, the data files 10A and 10B are each composed of several million to several tens of millions of blocks.

データファイル10Aや10Bは、ブロック単位で編集される。つまり、データファイル10Aや10Bに対する編集操作としては、ブロックの挿入と、ブロックの削除と、ブロック内に閉じた値の変更である。本発明の発明者らが別途開発したファイルシステムは、ブロックサイズの整数倍のサイズを有するデータを挿入したり削除したりするためのアプリケーションプログラムインタフェース(API)を提供する。なお、そのようなファイルシステムを用いる場合に、例えばアプリケーションプログラム側で工夫をすることによって、ブロック境界ではない途中の位置に挿入したり削除したりする際にも、挿入/削除に伴うデータのズレがブロック境界をまたがって波及することのないようすることができる。なお、そのファイルシステム自体の詳細な説明は、ここでは省略する。   The data files 10A and 10B are edited in units of blocks. In other words, the editing operations for the data files 10A and 10B are insertion of a block, deletion of a block, and change of a value closed in the block. The file system separately developed by the inventors of the present invention provides an application program interface (API) for inserting and deleting data having an integral multiple of the block size. When using such a file system, for example, by devising on the application program side, even when inserting or deleting in the middle of a position that is not a block boundary, data misalignment due to insertion / deletion is possible. Can be prevented from spreading across block boundaries. A detailed description of the file system itself is omitted here.

データファイル20Aは、データファイル10Aのハッシュ値を保持するファイルである。ハッシュデータ生成部15は、データファイル10Aが有する各ブロックのデータ(長さ4kバイト)の値を基に、所定のハッシュ関数を適用することにより、所定の長さ(例えば16バイト(=128ビット))のハッシュ値を得る。そのハッシュ値が、データファイル20Aの各ワードに相当する。
データファイル20Bと10Bの関係も、上述したデータファイル20Aと10Aの関係と同様である。
つまり、データファイル20Aおよび20Bのサイズは、これに限定されないが典型的には数百万ワードから数千万ワードである。つまり、1ワード=16バイトのとき、データファイル20Aおよび20Bのサイズは、それぞれ数十メガバイトから数百メガバイト程度である。このような大きなサイズのファイル同士を、従来の技術により比較して共通部分を見つけることは、非常に時間がかかり、効率が悪い。
The data file 20A is a file that holds the hash value of the data file 10A. The hash data generation unit 15 applies a predetermined hash function based on the value of the data (length 4 kbytes) of each block included in the data file 10A, thereby obtaining a predetermined length (for example, 16 bytes (= 128 bits). )) Hash value. The hash value corresponds to each word of the data file 20A.
The relationship between the data files 20B and 10B is the same as the relationship between the data files 20A and 10A described above.
That is, the size of the data files 20A and 20B is not limited to this, but is typically several million to tens of millions of words. That is, when 1 word = 16 bytes, the sizes of the data files 20A and 20B are about several tens of megabytes to several hundreds of megabytes, respectively. It is very time consuming and inefficient to find a common part by comparing such large files with conventional techniques.

ところで、ハッシュ関数の性質により、元データが全く一致していない限り、そのハッシュ値が偶々一致する確率は非常に小さい。例えば、ハッシュ値の長さが128ビットであり、ハッシュ関数が十分良好である場合、元データの異なる2つのハッシュ値が偶然一致する確率は2−128である。つまり、データファイル20Aおよび20Bがそれぞれ数百万ワードから数千万ワードのサイズを有するとはいえ、元データ(データファイル10Aおよび10Bに含まれるブロックのデータ)が異なっている限り、そのハッシュ値が偶然に一致する可能性は無視できるほどに、その確率は充分小さい。逆に言えば、ハッシュ値が一致するとき、元データも一致する可能性は充分大きい。 By the way, due to the nature of the hash function, unless the original data match at all, the probability that the hash values will coincide is very small. For example, when the length of the hash value is 128 bits and the hash function is sufficiently good, the probability that two hash values having different original data coincide by chance is 2-128 . That is, as long as the data files 20A and 20B each have a size of several million words to several tens of millions of words, the hash values of the data files 20A and 20B are as long as the original data (block data included in the data files 10A and 10B) are different. The probability is small enough to ignore the chance of coincidence. In other words, when the hash values match, the possibility of matching the original data is high enough.

本応用例の目的は、データファイル20Aと20Bとの間の差分情報を短時間で得ることであるが、その更なる目的は、データファイル10Aと10Bとの間で、どのあたりのブロックに差があるのかを短時間の比較処理で把握することである。上述したファイルシステムによって管理されている動画コンテンツファイルを編集し、その結果として複数の版の動画コンテンツファイルを保存した際に、それら複数の版の間の違いを把握するのは大変で時間のかかる作業であるが、本応用例を用いることにより、共通部分検出の精度をやや犠牲にする代わりに、短時間で(あるいは望みの範囲の時間内に)、版間の差分を把握することができるという大きなメリットが得られる。
なお、データファイル10Aおよび10Bを元に、データファイル20Aおよび20Bをそれぞれ生成する処理は、ファイル保存時に予め行なっておく。
The purpose of this application example is to obtain the difference information between the data files 20A and 20B in a short time, but the further purpose is to determine which block the data files 10A and 10B have. It is to grasp if there is a short-term comparison process. When editing a video content file managed by the file system described above and saving multiple versions of the video content file as a result, it is difficult and time-consuming to grasp the difference between the multiple versions. Although it is an operation, using this application example, it is possible to grasp the difference between the plates in a short time (or within the desired time) instead of sacrificing the accuracy of common part detection. A big merit is obtained.
The processing for generating the data files 20A and 20B based on the data files 10A and 10B is performed in advance when the file is saved.

なお、上述した実施形態におけるデータ比較装置の機能の全部または一部をコンピュータで実現するようにしても良い。その場合、上記実施形態で説明した各機能を実現するためのプログラムをコンピュータ読み取り可能な記録媒体に記録して、この記録媒体に記録されたプログラムをコンピュータシステムに読み込ませ、実行することによって実現しても良い。なお、ここでいう「コンピュータシステム」とは、OSや周辺機器等のハードウェアを含むものとする。また、「コンピュータ読み取り可能な記録媒体」とは、フレキシブルディスク、光磁気ディスク、ROM、フラッシュメモリ、CD−ROM等の可搬媒体、コンピュータシステムに内蔵されるハードディスク等の記憶装置のことをいう。さらに「コンピュータ読み取り可能な記録媒体」とは、インターネット等のネットワークや電話回線等の通信回線を介してプログラムを送信する場合の通信線のように、短時刻の間、動的にプログラムを保持するもの、その場合のサーバやクライアントとなるコンピュータシステム内部の揮発性メモリのように、一定時刻プログラムを保持しているものも含んでも良い。また上記プログラムは、前述した機能の一部を実現するためのものであっても良く、さらに前述した機能をコンピュータシステムにすでに記録されているプログラムとの組み合わせで実現できるものであっても良い。   Note that all or part of the functions of the data comparison apparatus in the above-described embodiment may be realized by a computer. In that case, it is realized by recording a program for realizing each function described in the above embodiment on a computer-readable recording medium, causing the computer system to read and execute the program recorded on the recording medium. May be. Here, the “computer system” includes an OS and hardware such as peripheral devices. The “computer-readable recording medium” refers to a storage device such as a flexible disk, a magneto-optical disk, a portable medium such as a ROM, a flash memory, and a CD-ROM, and a hard disk incorporated in a computer system. Further, the “computer-readable recording medium” dynamically holds a program for a short time, like a communication line when transmitting a program via a network such as the Internet or a communication line such as a telephone line. It is also possible to include those that hold a program for a certain time, such as a volatile memory inside a computer system serving as a server or client in that case. The program may be a program for realizing a part of the functions described above, and may be a program capable of realizing the functions described above in combination with a program already recorded in a computer system.

以上、この発明の実施形態について図面を参照して詳述してきたが、具体的な構成はこの実施形態に限られるものではなく、この発明の要旨を逸脱しない範囲の設計等も含まれる。   The embodiment of the present invention has been described in detail with reference to the drawings. However, the specific configuration is not limited to this embodiment, and includes designs and the like that do not depart from the gist of the present invention.

例えば、第2実施形態の順序情報記憶部32は、B−Tree構造のデータを用いて順序情報を記憶するようにしたが、用いるデータ構造はB−Treeに限らず、一般の木構造を用いても良い。また、各ワードのデータの値とデータ列Aへのインデックス(データ列Aの何ワード目のワードかを示す値)の組を要素とし、各ワードの値によってソートされた配列をデータ構造として用いても良い。いずれの場合にも、順序情報を利用することにより、総当り的な比較に比べて比較回数を削減することができる。   For example, the order information storage unit 32 of the second embodiment stores the order information using data of the B-Tree structure, but the data structure to be used is not limited to the B-Tree and uses a general tree structure. May be. In addition, a data value of each word and an index to the data string A (a value indicating the word number in the data string A) are used as elements, and an array sorted by the value of each word is used as a data structure. May be. In any case, the number of comparisons can be reduced by using the order information as compared with the brute force comparison.

本発明は、サイズの大きいデータファイルの管理に利用することができる。例えば、動画像コンテンツのファイルの版管理などに利用することができる。   The present invention can be used for managing large data files. For example, it can be used for version management of moving image content files.

本発明の第1の実施形態によるデータ比較装置の機能構成を示したブロック図である。It is the block diagram which showed the function structure of the data comparison apparatus by the 1st Embodiment of this invention. 同実施形態おいて、データファイル10A(元データ)とデータファイル20A(ハッシュ値のデータ)との関係を示す概略図である。In the embodiment, it is the schematic which shows the relationship between the data file 10A (original data) and the data file 20A (hash value data). 同実施形態によるデータ比較装置における、一致箇所検索および共通部分検索の処理の概要を示す概略図である。It is the schematic which shows the outline | summary of the process of a matching location search and a common part search in the data comparison apparatus by the embodiment. 同実施形態による共通部分範囲の決定および差分情報出力のための処理の手順を示すフローチャートである。It is a flowchart which shows the procedure of the process for determination of a common partial range and difference information output by the embodiment. 同実施形態によるデータ比較の実例を説明するための概略図である。It is the schematic for demonstrating the example of the data comparison by the embodiment. 本発明の第2の実施形態によるデータ比較装置の機能構成を示したブロック図である。It is the block diagram which showed the function structure of the data comparison apparatus by the 2nd Embodiment of this invention. 同実施形態によるデータ比較の処理手順を示したフローチャートである。It is the flowchart which showed the processing procedure of the data comparison by the same embodiment. 本発明の第3の実施形態によるデータ比較装置の機能構成を示したブロック図である。It is the block diagram which showed the function structure of the data comparison apparatus by the 3rd Embodiment of this invention. 本発明の第4の実施形態によるデータ比較装置の機能構成を示したブロック図である。It is the block diagram which showed the function structure of the data comparison apparatus by the 4th Embodiment of this invention.

符号の説明Explanation of symbols

1,1A,2,2A データ比較装置
3 共通部分検索部(共通部分検索過程)
4 一致箇所検索部(一致箇所検索過程)
5 差分情報出力部(差分情報出力過程)
6 制御部
10A,10B データファイル(比較対象データ)
15 ハッシュデータ生成部
20A,20B データファイル
24 一致箇所検索部
31 順序付処理部(順序付処理過程)
32 順序情報記憶部
1, 1A, 2, 2A Data comparison device 3 Common part search unit (common part search process)
4 Matching part search part (matching part search process)
5 Difference information output part (Difference information output process)
6 Control unit 10A, 10B Data file (comparison target data)
15 Hash data generation unit 20A, 20B Data file 24 Matched part search unit 31 Ordered processing unit (ordered processing process)
32 Order information storage unit

Claims (5)

それぞれ複数のワードからなる第1データ列および第2データ列を比較するデータ比較装置であって、
前記第1データ列に含まれる前記ワードを所定の第1選択間隔(第1選択間隔は1以上の整数)の分ずつ飛ばして得られる第1一致箇所検索対象ワードと、前記第2データ列に含まれる前記ワードを所定の第2選択間隔(第2選択間隔は1以上の整数)の分ずつ飛ばして得られる第2一致箇所検索対象ワードとを、順次比較して両者が一致する箇所を探す一致箇所検索部と、
前記一致箇所検索部が検出した一致箇所のワードを基に前記第1データ列および前記第2データ列のそれぞれ前および後に連なるワードについて、前記第1データ列と前記第2データ列との間で比較を行ない、両者が一致する範囲を共通部分の範囲として検出する共通部分検索部と、
前記共通部分検索部によって検出された共通部分の範囲の情報に基づき、前記第1データ列と前記第2データ列との間の差分情報を出力する差分情報出力部と、
を具備することを特徴とするデータ比較装置。
A data comparison device for comparing a first data string and a second data string each consisting of a plurality of words,
A first matching point search target word obtained by skipping the word included in the first data string by a predetermined first selection interval (the first selection interval is an integer of 1 or more); and the second data string A second matching point search target word obtained by skipping the included words by a predetermined second selection interval (the second selection interval is an integer of 1 or more) is sequentially compared to search for a point where both match. A matching point search section;
Based on the word of the coincidence portion detected by the coincidence portion search unit, between the first data row and the second data row, the words that are connected before and after the first data row and the second data row, respectively. A common part search unit that performs a comparison and detects a range in which both match as a common part range;
A difference information output unit that outputs difference information between the first data string and the second data string based on information on a range of the common part detected by the common part search unit;
A data comparison device comprising:
請求項1に記載のデータ比較装置において、
前記第1選択間隔と前記第2選択間隔との最大公約数は1である、
ことを特徴とするデータ比較装置。
The data comparison device according to claim 1,
The greatest common divisor of the first selection interval and the second selection interval is 1.
A data comparison apparatus characterized by that.
請求項1または請求項2に記載のデータ比較装置において、
前記第1一致箇所検索対象ワードの値をソートし、その結果得られる順序情報を順序情報記憶部に書き込む順序付処理部をさらに具備し、
前記一致箇所検索部は、前記順序情報記憶部から前記順序情報を読み出すことにより、ある前記第2一致箇所検索対象ワードを、比較する必要のある前記第1一致箇所検索対象ワードのみと比較し、両者が一致する箇所を探す、
ことを特徴とするデータ比較装置。
In the data comparison device according to claim 1 or 2,
Sorting the values of the first match location search target word, further comprising an ordering processing unit for writing the order information obtained as a result to the order information storage unit,
The matching part search unit compares the second matching part search target word with only the first matching part search target word that needs to be compared by reading the order information from the order information storage unit, Find a place where they match,
A data comparison apparatus characterized by that.
請求項1から3までのいずれか一項に記載のデータ比較装置において、
前記第1データ列および前記第2データ列に含まれる前記ワードは、これら各データ列の元となる比較対象データを所定サイズに分割したブロックのデータにハッシュ関数を適用して得られたハッシュ値を有するものである、
ことを特徴とするデータ比較装置。
In the data comparison device according to any one of claims 1 to 3,
The word included in the first data string and the second data string is a hash value obtained by applying a hash function to block data obtained by dividing the comparison target data that is the source of each data string into a predetermined size. Having
A data comparison apparatus characterized by that.
それぞれ複数のワードからなる第1データ列および第2データ列を比較する処理をコンピュータに実行させるプログラムであって、
前記第1データ列に含まれる前記ワードを所定の第1選択間隔(第1選択間隔は1以上の整数)の分ずつ飛ばして得られる第1一致箇所検索対象ワードと、前記第2データ列に含まれる前記ワードを所定の第2選択間隔(第2選択間隔は1以上の整数)の分ずつ飛ばして得られる第2一致箇所検索対象ワードとを、順次比較して両者が一致する箇所を探す一致箇所検索過程と、
前記一致箇所検索過程で検出した一致箇所のワードを基に前記第1データ列および前記第2データ列のそれぞれ前および後に連なるワードについて、前記第1データ列と前記第2データ列との間で比較を行ない、両者が一致する範囲を共通部分の範囲として検出する共通部分検索過程と、
前記共通部分検索過程において検出された共通部分の範囲の情報に基づき、前記第1データ列と前記第2データ列との間の差分情報を出力する差分情報出力過程と、
の処理をコンピュータに実行させることを特徴とするプログラム。
A program for causing a computer to execute a process of comparing a first data string and a second data string each consisting of a plurality of words,
A first matching point search target word obtained by skipping the word included in the first data string by a predetermined first selection interval (the first selection interval is an integer of 1 or more); and the second data string A second matching point search target word obtained by skipping the included words by a predetermined second selection interval (the second selection interval is an integer of 1 or more) is sequentially compared to search for a point where both match. The matching point search process,
Based on the word of the matching part detected in the matching part search process, the word connected before and after the first data string and the second data string, respectively, between the first data string and the second data string. A common part search process in which comparison is performed and a range in which both coincide with each other is detected as a common part range;
A difference information output process for outputting difference information between the first data string and the second data string based on information on a range of the common part detected in the common part search process;
A program for causing a computer to execute the process.
JP2008117808A 2008-04-28 2008-04-28 Data comparison apparatus and program Expired - Fee Related JP5149063B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2008117808A JP5149063B2 (en) 2008-04-28 2008-04-28 Data comparison apparatus and program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2008117808A JP5149063B2 (en) 2008-04-28 2008-04-28 Data comparison apparatus and program

Publications (2)

Publication Number Publication Date
JP2009266128A true JP2009266128A (en) 2009-11-12
JP5149063B2 JP5149063B2 (en) 2013-02-20

Family

ID=41391856

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2008117808A Expired - Fee Related JP5149063B2 (en) 2008-04-28 2008-04-28 Data comparison apparatus and program

Country Status (1)

Country Link
JP (1) JP5149063B2 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2011150428A (en) * 2010-01-19 2011-08-04 Nippon Hoso Kyokai <Nhk> File processing apparatus and program
JP2018018240A (en) * 2016-07-27 2018-02-01 富士ゼロックス株式会社 Data processing device and program

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2011150428A (en) * 2010-01-19 2011-08-04 Nippon Hoso Kyokai <Nhk> File processing apparatus and program
JP2018018240A (en) * 2016-07-27 2018-02-01 富士ゼロックス株式会社 Data processing device and program

Also Published As

Publication number Publication date
JP5149063B2 (en) 2013-02-20

Similar Documents

Publication Publication Date Title
US8838551B2 (en) Multi-level database compression
US10055216B2 (en) Minimizing image copying during partition updates
JP6596102B2 (en) Lossless data loss by deriving data from basic data elements present in content-associative sheaves
JP5372853B2 (en) Digital sequence feature amount calculation method and digital sequence feature amount calculation apparatus
US9798731B2 (en) Delta compression of probabilistically clustered chunks of data
KR100877063B1 (en) Apparatus and method for managing data
JP5886447B2 (en) Location independent files
US20010051954A1 (en) Data updating apparatus that performs quick restoration processing
WO2015139381A1 (en) Terminal software upgrade method and device
NL2011817C2 (en) A method of generating a reference index data structure and method for finding a position of a data pattern in a reference data structure.
CN111444192B (en) Method, device and equipment for generating Hash of global state in block chain type account book
KR20080080399A (en) Remotely repairing files by hierarchical and segmented cyclic redundancy checks
JP2009512099A (en) Method and apparatus for restartable hashing in a try
KR20140038441A (en) Compression match enumeration
JP5149063B2 (en) Data comparison apparatus and program
CN116150093B (en) Method for realizing object storage enumeration of objects and electronic equipment
CN115563116A (en) Database table scanning method, device and equipment
CN110941730B (en) Retrieval method and device based on human face feature data migration
JP4467965B2 (en) Differential file creation program and method
JP6273892B2 (en) Data search device, program, and data search system
US10037148B2 (en) Facilitating reverse reading of sequentially stored, variable-length data
CN112416431B (en) Source code segment pair comparison method based on coding sequence representation
CN117349236B (en) File reading method, device, equipment and storage medium
KR101816251B1 (en) Apparatus and Method for Synchronizing Metadata used for File Searching
CN117171109A (en) Data storage management method, device, system and storage medium

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20101201

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20121025

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20121030

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20121129

R150 Certificate of patent or registration of utility model

Free format text: JAPANESE INTERMEDIATE CODE: R150

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20151207

Year of fee payment: 3

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

LAPS Cancellation because of no payment of annual fees