JPS60142734A - Character string comparator - Google Patents

Character string comparator

Info

Publication number
JPS60142734A
JPS60142734A JP58246703A JP24670383A JPS60142734A JP S60142734 A JPS60142734 A JP S60142734A JP 58246703 A JP58246703 A JP 58246703A JP 24670383 A JP24670383 A JP 24670383A JP S60142734 A JPS60142734 A JP S60142734A
Authority
JP
Japan
Prior art keywords
character string
hash
data
register
section
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP58246703A
Other languages
Japanese (ja)
Inventor
Takeshi Shinoki
剛 篠木
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.)
Fujitsu Ltd
Original Assignee
Fujitsu Ltd
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 Fujitsu Ltd filed Critical Fujitsu Ltd
Priority to JP58246703A priority Critical patent/JPS60142734A/en
Publication of JPS60142734A publication Critical patent/JPS60142734A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

PURPOSE:To attain dissidence of a character string at high speed by detecting the dissidence of the character string through the comparison of hash values. CONSTITUTION:A character string data I functioning as a reference is inputted to input data. The data I is applied with hash processing with the 1st hash processing section 3 and the hash value obtained as the result is set to a section 5-2 of a character string data register 5. On the other hand, a character string data IIcompared with the identity is inputted to the input register 2, the data II is applied with has processing by the 2nd hash processing section 4 and the hash value obtained is set to a section 6-2 of a character string data register 6. The set hash value to sections 5-2, 6-2 is compared by the comparator 7 and when the hash value is different, the comparator 7 outputs 0 and an inverter 8 outputs logical 1. Thus, when the hash value is effective and dissident with each other, a dissident signal is outputted from an AND gate 9.

Description

【発明の詳細な説明】 〔発明の技術分野〕 本発明は文字列比較装置に係り、特に比較すべき文字列
が不一致であることを高速に見出すことにより一致性を
検出するための前処理を高速に行うことができる文字列
比較装置に関する。
[Detailed Description of the Invention] [Technical Field of the Invention] The present invention relates to a character string comparison device, and in particular to a preprocessing method for detecting coincidence by quickly finding out whether character strings to be compared are inconsistent. The present invention relates to a character string comparison device that can perform high-speed comparison.

〔技術の背景〕[Technology background]

データ処理装置では数値の処理のみならず、文字に関す
る処理をも行う。例えば2つの文字列が一致するか否か
を検出したり、あるいは文字列の中より特定の文字を抽
出するような処理が行われている。そしてrI AM 
A BOY、jのrAMJをj”WASJに変えるよう
な処理等も行われる。このような場合にrAMJを抽出
するため、各文字列を比較することが必要となる。
A data processing device not only processes numbers, but also processes characters. For example, processing is performed to detect whether two character strings match or to extract specific characters from a character string. and rI AM
Processing such as changing rAMJ of A BOY, j to j"WASJ is also performed. In order to extract rAMJ in such a case, it is necessary to compare each character string.

ところで文字を処理する場合、1文字を例えば1バイト
のコードで表現しているため、文字列が一致するか否か
を比較するには、各文字列を構成する文字コードを比較
しなければならない。ところが比較すべき文字列が多い
場合には、各文字コード同志の比較により一致性を検出
するとき、全体の処理に非常に長い時間を必要とするの
で高速処理ができない。
By the way, when processing characters, each character is represented by a 1-byte code, so to compare whether strings match or not, you must compare the character codes that make up each string. . However, when there are many character strings to be compared, high-speed processing is not possible because the entire process requires a very long time when matching is detected by comparing each character code.

〔従来技術と問題点〕[Conventional technology and problems]

それで、まず比較対象の中から一致しないものを検出し
て文字コード同志の比較対象数を減少させ、比較すべき
候補数の削減をはかることが行われている。
Therefore, the number of candidates to be compared is reduced by first detecting those that do not match among the comparison targets and reducing the number of comparison targets for character codes.

従来、このような文字列データ同志の比較の際、不一致
性の検出の高速化のために文字列が有する文字列の長さ
の情報を用いて文字列自体の比較を行う前に長さの比較
を行なってその比較候補を選択していた。しかしこのよ
うな方式では、文字列の長さが等しくかつ文字列自体が
異なる場合が多いため、比較対象をしぼり込むことが不
充分であり、この方式ではなおその処理にかなりの時間
がかかるという欠点があった。
Conventionally, when comparing string data like this, in order to speed up the detection of inconsistencies, the length information of the strings is used to calculate the length before comparing the strings themselves. A comparison was made and a comparison candidate was selected. However, with this method, the lengths of the strings are the same and the strings themselves are often different, so it is insufficient to narrow down the comparison targets, and this method still takes a considerable amount of time to process. There were drawbacks.

〔発明の目的〕[Purpose of the invention]

本発明の目的は、このような欠点を改善して文字列の不
一致性をより正確に検出することができる文字列比較装
置を提供することである。
SUMMARY OF THE INVENTION An object of the present invention is to provide a character string comparison device that can improve such drawbacks and more accurately detect inconsistencies in character strings.

〔発明の構成〕[Structure of the invention]

この目的を達成するため、本発明の文字列比較装置では
、 文字列データ処理を行うデータ処理装置において、
文字列のハツシュ値を出力するハツシュ処理部と、ハツ
シュ値が有効か否かを示す有効指示データ保持手段と、
複数の文字列のハツシュ値が一致するか否かを検出する
比較手段を設け、各文字列のハツシュ値が有効でかつ各
文字列のハツシュ値が異なることを検出する。
In order to achieve this purpose, in the character string comparison device of the present invention, in a data processing device that processes character string data,
a hash processing unit that outputs a hash value of a character string; a validity indication data holding unit that indicates whether or not the hash value is valid;
Comparing means for detecting whether the hash values of a plurality of character strings match is provided, and it is detected that the hash values of each character string are valid and that the hash values of each character string are different.

〔発明の実施例〕[Embodiments of the invention]

本発明の一実施例を添付図面にもとづき説明する。図中
、■は第1人力レジスタ、2は第2人力レジスタ、3は
第1ハツシュ処理部、4は第2ハツシュ処理部、5は第
1文字列データ・レジスタ、6は第2文字列データ・レ
ジスタ、7は比較器、8はインバータ、9はアンド・ゲ
ートである。
An embodiment of the present invention will be described based on the accompanying drawings. In the figure, ■ is the first manual register, 2 is the second manual register, 3 is the first hash processing section, 4 is the second hash processing section, 5 is the first character string data register, and 6 is the second character string data. - Register, 7 is a comparator, 8 is an inverter, 9 is an AND gate.

第1人力レジスタ1には比較のとき基準となる文字列の
内部表現データ、例えば文字コードの如き文字列データ
が入力されるレジスタであり、第2人力レジスタ2は基
準となる文字列と同一のハツシュ値を有する文字列かど
うかを検出される比較文字列が入力されるレジスタであ
る。第1ハツシュ処理部3は第1人力レジスタ1にセッ
トされた文字列データに対して、例えば各文字コードの
和をめるというようなハツシュ関数にもとづく処理を行
ってその演算結果のハツシュ値を出力するものであり、
第2ハツシュ処理部4は第1バツジ゛ユ処理部3と同様
な処理を行うものである。第1文字列データ・レジスタ
5は基準となる文字列の種々のデータが記入されるレジ
スタであり、その文字列の長さが記入される区分5−1
、第1ハツシュ処理部3で演算されたハツシュ値が記入
される区分5−2、このハツシュ値が有効か、無効かを
示す有効フラグVlが記入される区分5−3、文字列自
体の文字列データが記入される区分5−4等を有する。
The first human input register 1 is a register into which internal representation data of a character string to be used as a reference at the time of comparison, such as character string data such as a character code, is input. This is a register into which a comparison character string is input to detect whether or not the character string has a hash value. The first hash processing unit 3 performs processing based on a hash function, such as adding up the sum of each character code, on the character string data set in the first manual register 1, and calculates the hash value of the calculation result. It outputs
The second hash processing section 4 performs the same processing as the first batch processing section 3. The first character string data register 5 is a register in which various data of a standard character string is written, and the length of the character string is written in a section 5-1.
, a section 5-2 in which the hash value calculated by the first hash processing unit 3 is entered, a section 5-3 in which a validity flag Vl indicating whether this hash value is valid or invalid is entered, and the characters of the character string itself. It has sections 5-4, etc. in which column data is entered.

第2文字列データ・レジスタ6も上記第1文字列データ
・レジスタ5と同様に区分6−1.6−2.6−3.6
−4、等により構成されている。
Similarly to the first character string data register 5, the second character string data register 6 also has a division 6-1.6-2.6-3.6.
-4, etc.

なお有効フラグVl、V2は次のような作用を有する。Note that the valid flags Vl and V2 have the following effects.

すなわち文字列データが、頻繁に書き替えられる処理が
行われる場合、ハツシュ値の演算が何回も起こりオーバ
ーヘッドになることに対処するために、有効フラグを設
け、すでに計算されたハツシュ値の文字列データが書き
替えられたときそのハツシュ値が無効であることを示す
ものである。これにより処理対象に応じて柔軟に対処す
ることができる。
In other words, when processing is performed where string data is frequently rewritten, a valid flag is provided to deal with the overhead of hash value calculations occurring many times. This indicates that the hash value is invalid when the data is rewritten. This allows for flexible handling depending on the processing target.

比較器7は区分5−2および区分6−2に記入されたハ
ツシュ値を比較するもので、ハツシュ値が同一のとき「
1」、異なるときrOJを出力する。
Comparator 7 compares the hash values entered in section 5-2 and section 6-2, and when the hash values are the same, "
1”, outputs rOJ when different.

次に本発明の動作について説明する。Next, the operation of the present invention will be explained.

まず、第1人力レジスタ1に基準になる文字列の文字列
データが入力される。この文字列データは第1文字列デ
ータ・レジスタ5の区分5−4にセントされるとともに
第1ハツシュ処理部3によりハツシュ処理され、その演
算結果得られたハツシュ値が第1文字列データ・レジス
タ5の区分5−2にセットされる。なお上記文字列デー
タは図示省略した長さ検出手段により文字列データの長
さがめられ、この長さが区分5−1にセットされる。
First, character string data of a reference character string is input into the first manual register 1 . This character string data is sent to section 5-4 of the first character string data register 5 and hashed by the first hash processing section 3, and the hash value obtained as a result of the operation is stored in the first character string data register. 5, section 5-2. The length of the character string data is determined by a length detecting means (not shown), and this length is set in the section 5-1.

第2人力レジスタ2には基準になる文字列と同一性が比
較される文字列の文字列データが入力され、この文字列
データが第2ハツシュ処理部4にてハツシュ処理されて
得られたハツシュ値が第2文字列データ・レジスタ6の
区分6−2にセットされ、また文字列データ自身も区分
6−4にセットされる。この比較される文字列の長さの
データもこれまた同様に区分6−1にセットされる。そ
れから区分5−2.6−2にセットされたハツシュ値が
比較器7にて比較され、これらのハツシュ値が異なると
き比較器7は「0」を出力し、インバータ8は「1」を
出力する。したがってこれらのハツシュ値が有効のとき
で不一致のとき、アンド・ゲート9よりハツシュ値の不
一致を示す不一致信号が出力されるので、上記第2文字
列データ・レジスタ6にセットされた文字列は第1文字
列データ・レジスタ5にセットされた文字列とは異なる
ことが簡単にわかる。
The character string data of the character string to be compared for identity with the reference character string is inputted to the second human input register 2, and the character string data is hash-processed in the second hash processing section 4 to obtain a hash. The value is set in section 6-2 of second string data register 6, and the string data itself is also set in section 6-4. Data regarding the length of the character strings to be compared is also similarly set in section 6-1. Then, the hash values set in section 5-2.6-2 are compared in comparator 7, and when these hash values are different, comparator 7 outputs "0" and inverter 8 outputs "1". do. Therefore, when these hash values are valid and do not match, the AND gate 9 outputs a mismatch signal indicating the mismatch of the hash values, so that the character string set in the second character string data register 6 is It is easy to see that this character string is different from the character string set in the 1 character string data register 5.

もしこれらのハツシュ値が一致すれば比較器7は「1」
を出力し、インバータ8はrOJを出力するのでアンド
・ゲート9から不一致信号が出力されない。したがって
このとき各有効フラグv1、■2が有効状態を示す「1
」であれば、第2文字列データ・レジスタ6にセットさ
れている文字列データは第1文字列データ・レジスタ5
にセットされている文字列データと一致する可能性があ
ることになる。
If these hash values match, the comparator 7 will be "1"
Since the inverter 8 outputs rOJ, the AND gate 9 does not output a mismatch signal. Therefore, at this time, each valid flag v1, ■2 is "1" indicating the valid state.
”, the string data set in the second string data register 6 is transferred to the first string data register 5.
This means that there is a possibility that it will match the string data set in .

このようにして文字列の不一致性の検出を精度よく高速
化することができるので、多数の比較すべき文字列があ
る場合、文字コードによりその同一性を正確に比較すべ
き対象数を大幅に、高速に削減することができその結果
として一致性の判断を高速に行うことができる。
In this way, it is possible to speed up the detection of inconsistency between strings with high accuracy, so when there are many strings to be compared, the number of strings that need to be accurately compared for identity can be greatly reduced by character codes. , can be reduced quickly, and as a result, consistency can be determined quickly.

なお上記説明ではハツシュ関数として各文字コードの和
をめる例について説明したが、ハツシュ関数は勿論これ
のみに限定されるものではない。
In the above description, an example has been described in which the sum of each character code is calculated as a hash function, but the hash function is of course not limited to this.

そして入力レジスタ、ハツシュ処理部をそれぞれ2個設
けた例について説明したが勿論これらを1個ずつにする
こともできる。
Although an example has been described in which two input registers and two hash processing sections are provided, it is of course possible to provide one each.

〔発明の効果〕〔Effect of the invention〕

本発明によれば、文字列の不一致性の検出を、それらの
ハツシュ値の比較を行うことにより高速に行うことがで
きるのみならず、また文字列データが頻繁に書き替えら
れる処理の場合に有効フラグを使用することによりハツ
シュ値の再針算を抑止することができるので、処理対象
に応じて柔軟に対処することができる。
According to the present invention, inconsistency in character strings can not only be detected quickly by comparing their hash values, but also effective in cases where character string data is frequently rewritten. By using the flag, recalculation of the hash value can be suppressed, so it can be handled flexibly depending on the processing target.

【図面の簡単な説明】[Brief explanation of the drawing]

図は本発明の一実施例構成図である。 図中、1は第1人力レジスタ、2は第2人力レジスタ、
3は第1ハツシュ処理部、4は第2ハツシュ処理部、5
は第1文字列データ・レジスタ、6は第2文字列データ
・レジスタ、7は比較器、8はインバータ、9はアンド
・ゲートを示す。 特許出願人 富士通株式会社 代理人弁理士 山 谷 晧 榮 千−銖係号
The figure is a configuration diagram of an embodiment of the present invention. In the figure, 1 is the first manual register, 2 is the second manual register,
3 is a first hash processing section, 4 is a second hash processing section, 5
is a first string data register, 6 is a second string data register, 7 is a comparator, 8 is an inverter, and 9 is an AND gate. Patent Applicant: Fujitsu Ltd. Representative Patent Attorney Akira Yamatani

Claims (1)

【特許請求の範囲】[Claims] 文字列データ処理を行うデータ処理装置において、文字
列のハツシュ値を出力するハツシュ処理部と、ハツシュ
値が有効か否かを示す有効指示データ保持手段と、複数
の文字列のハツシュ値が一致するか否かを検出する比較
手段を設け、各文字列のハツシュ値が有効でかつ各文字
列のハツシュ値が異なることを検出する文字列比較装置
In a data processing device that processes character string data, a hash processing unit that outputs hash values of character strings, a validity indication data holding means that indicates whether or not the hash values are valid, and hash values of a plurality of character strings match. A character string comparison device includes a comparison means for detecting whether the hash values of each character string are valid and that the hash values of each character string are different.
JP58246703A 1983-12-29 1983-12-29 Character string comparator Pending JPS60142734A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP58246703A JPS60142734A (en) 1983-12-29 1983-12-29 Character string comparator

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP58246703A JPS60142734A (en) 1983-12-29 1983-12-29 Character string comparator

Publications (1)

Publication Number Publication Date
JPS60142734A true JPS60142734A (en) 1985-07-27

Family

ID=17152375

Family Applications (1)

Application Number Title Priority Date Filing Date
JP58246703A Pending JPS60142734A (en) 1983-12-29 1983-12-29 Character string comparator

Country Status (1)

Country Link
JP (1) JPS60142734A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH01134644A (en) * 1987-11-12 1989-05-26 Internatl Business Mach Corp <Ibm> Memory addressing error detection circuit
JP2002233704A (en) * 2001-02-06 2002-08-20 Takehara:Kk Oil-water separation auxiliary
CN103309893A (en) * 2012-03-15 2013-09-18 阿里巴巴集团控股有限公司 Character string comparing method and device

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH01134644A (en) * 1987-11-12 1989-05-26 Internatl Business Mach Corp <Ibm> Memory addressing error detection circuit
JP2002233704A (en) * 2001-02-06 2002-08-20 Takehara:Kk Oil-water separation auxiliary
CN103309893A (en) * 2012-03-15 2013-09-18 阿里巴巴集团控股有限公司 Character string comparing method and device
CN103309893B (en) * 2012-03-15 2016-12-28 阿里巴巴集团控股有限公司 The comparative approach of a kind of character string and device

Similar Documents

Publication Publication Date Title
EP0155211A2 (en) System for by-pass control in pipeline operation of computer
US6983274B2 (en) Multiple alignment genome sequence matching processor
GB1516220A (en) Apparatus for verifying a signature
EP0151136A1 (en) Symbol matching methods and apparatus
JPH063584B2 (en) Information processing equipment
US4670836A (en) Device for detecting an overlap of operands to be accessed
US11586956B2 (en) Searching apparatus utilizing sub-word finite state machines
JPS60142734A (en) Character string comparator
JPH0527142B2 (en)
KR900002436B1 (en) Bypass control system for pipeline processing
US6598066B1 (en) Fast carry-out generation
JP2728434B2 (en) Address translation device
JP2835065B2 (en) String search method
JPH07113894B2 (en) Common character string search processor
JPS60583A (en) Word recognition system
JPS583032A (en) Tree structure access processing system
JP2752220B2 (en) String processing unit
SU1223225A2 (en) Device for exrtacting n-th root
SU796840A1 (en) Device for determining number position on numerical axis
SU754051A2 (en) Apparatus for rerecording of logging charts
JPS61282925A (en) Normalizing circuit
KR100724988B1 (en) Noise removal in multibyte text encodings using statistical models
JPH06202849A (en) Information processor
JPH03214316A (en) Condition code generating system
JPS63103393A (en) Word recognizing device