JP2001117929A - Data retrieving method, data aligning method and data retrieving device - Google Patents

Data retrieving method, data aligning method and data retrieving device

Info

Publication number
JP2001117929A
JP2001117929A JP29441199A JP29441199A JP2001117929A JP 2001117929 A JP2001117929 A JP 2001117929A JP 29441199 A JP29441199 A JP 29441199A JP 29441199 A JP29441199 A JP 29441199A JP 2001117929 A JP2001117929 A JP 2001117929A
Authority
JP
Japan
Prior art keywords
data
digit
search
stored
tree structure
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
JP29441199A
Other languages
Japanese (ja)
Inventor
Yasunori Tsukamoto
康則 塚本
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.)
Toshiba Corp
Original Assignee
Toshiba 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 Toshiba Corp filed Critical Toshiba Corp
Priority to JP29441199A priority Critical patent/JP2001117929A/en
Publication of JP2001117929A publication Critical patent/JP2001117929A/en
Pending legal-status Critical Current

Links

Abstract

PROBLEM TO BE SOLVED: To perform completely coincident retrieval without dispersion in retrieval time and high-speed ambiguously coincident retrieval to a data structure, which defines key data in records as retrieval data. SOLUTION: This device is provided with a retrieval object data storage part 4 for storing data to become a retrieval object for each digit in a bisected tree structure on a memory and a data retrieving part 5 for retrieving the target data from the route of the stored data in the bisected tree structure by comparing the data of respective nodes with the retrieval data.

Description

【発明の詳細な説明】DETAILED DESCRIPTION OF THE INVENTION

【0001】[0001]

【発明の属する技術分野】本発明は、検索対象となるデ
ータをメモリ上に桁毎に2分木構造で格納し検索データ
を桁毎に比較しながら、文字列を高速に検索し、整列す
るするデータ検索方法、データ整列方法およびデータ検
索装置に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a high-speed search and sorting of character strings while storing data to be searched in a memory in a binary tree structure for each digit and comparing the search data digit by digit. The present invention relates to a data search method, a data alignment method, and a data search device.

【0002】[0002]

【従来の技術】よく知られているように、2分木検索
は、検索対象となるデータを2分木構造で表現し、根と
なるデータから検索データを順次比較して該当するデー
タを検索するものである。
2. Description of the Related Art As is well known, in a binary tree search, data to be searched is expressed in a binary tree structure, and search data is sequentially compared from root data to search for corresponding data. Is what you do.

【0003】ここで、木構造とは、データの階層関係を
表現するためのデータ構造である。階層関係では、ある
要素(ノード)Aの下に要素Bが存在する場合に、その
要素間に上下関係をつけて親と子を表現する。親と子の
つながりを枝(パス)、親を持たない要素を根(ルー
ト)、子を持たない要素を葉(リーフ)、親も子も持た
ない要素を節と定義すると、図9に示すような階層関係
を作成することができる。また、2分木構造とは、ある
親に対する子の要素が2つある木構造をいう。
Here, the tree structure is a data structure for expressing a hierarchical relationship of data. In the hierarchical relationship, when an element B exists below a certain element (node) A, a parent and a child are expressed by giving a vertical relationship between the elements. If the connection between parent and child is defined as a branch (path), an element without a parent is defined as a root (root), an element without a child is defined as a leaf, and an element without a parent or child is defined as a node, as shown in FIG. Such a hierarchical relationship can be created. Further, the binary tree structure refers to a tree structure having two child elements for a certain parent.

【0004】この木構造に対して、ある要素を根とし
て、根より小さいデータを左に、大きいデータを右に格
納する。各データの大小関係をデータ『a,b,c,
d,e,f,g』で表現すると、a<b<c<d<e<
f<gより、図10すような木構造になる。
[0004] With respect to this tree structure, with a certain element as a root, data smaller than the root is stored on the left and large data is stored on the right. The magnitude relation of each data is represented by data "a, b, c,
d, e, f, g], a <b <c <d <e <
From f <g, the tree structure is as shown in FIG.

【0005】一般にこの2分木での検索時のデータ比較
回数は、データの個数をnとすると、以下のとおりとな
る。すなわち、 ・平均比較回数…log n ・最大比較回数…n また、検索には、完全一致検索と曖昧検索(部分一致検
索ともいう)とがある。完全一致検索では、例えば、1
0バイトのデータであれば、検索データと検索対象デー
タとで10バイト全てを比較して検索している。曖昧検
索では、検索データが20バイトであれば、10バイト
のデータが一致していればヒットとするというものであ
る。
In general, the number of data comparisons at the time of retrieval in this binary tree is as follows, where n is the number of data. The average number of comparisons: log 2 n The maximum number of comparisons: n There are two types of searches: perfect match search and fuzzy search (also called partial match search). In an exact match search, for example, 1
If the data is 0 bytes, the search data and the search target data are searched by comparing all 10 bytes. In the fuzzy search, if the search data is 20 bytes, a hit is made if the 10-byte data matches.

【0006】[0006]

【発明が解決しようとする課題】しかしながら、完全一
致検索では、データの最大比較回数がデータの個数nと
同じn回となってしまい、データの個数に応じて検索時
間にばらつきが生じてしまうという問題があった。
However, in a perfect match search, the maximum number of data comparisons becomes n, which is the same as the number n of data, and the search time varies depending on the number of data. There was a problem.

【0007】また、曖昧検索においては、文字列のよう
な複数バイトサイズで成り立つデータの検索をしようと
すると、単純な2分木構造では検索に時間がかかってし
ますという問題があった。
[0007] In addition, in the fuzzy search, if it is attempted to search for data such as a character string which has a plurality of byte sizes, it takes a long time to search using a simple binary tree structure.

【0008】本発明は上記事情に鑑みてなされたもの
で、レコード中のキーデータを検索データとするような
データ構造に対して検索時間にばらつきのない完全一致
検索および高速な曖昧一致検索を実現することのできる
データ検索方法および装置を提供することを目的として
いる。
The present invention has been made in view of the above circumstances, and realizes a perfect match search and a high-speed fuzzy match search with no variation in search time for a data structure in which key data in a record is used as search data. It is an object of the present invention to provide a data search method and device capable of performing the data search.

【0009】また、データの整列処理を簡単かつ短時間
に実行することができるデータ整列方法を提供すること
を目的としている。
It is another object of the present invention to provide a data alignment method capable of executing data alignment processing easily and in a short time.

【0010】[0010]

【課題を解決するための手段】上記の目的を達成するた
めに請求項1の発明は、検索対象となるデータを桁毎に
メモリ上に2分木構造で格納し、格納された2分木構造
のデータに対して検索データを桁毎に比較して目的のデ
ータを検索することを特徴としている。
In order to achieve the above object, according to the first aspect of the present invention, data to be searched is stored in a memory in a binary tree structure for each digit, and the stored binary tree is stored. It is characterized in that search data is compared digit by digit with respect to structured data to search for target data.

【0011】請求項2の発明は、請求項1に記載のデー
タ検索方法において、曖昧検索を実行する場合には、格
納された2分木構造のデータに対して検索データを桁毎
に比較して目的のデータを検索し、次いで、桁を1桁ず
らして再度検索する処理を最後の桁まで繰り返して実行
することを特徴としている。
According to a second aspect of the present invention, in the data search method according to the first aspect, when performing an ambiguous search, the search data is compared with the stored binary tree structure data digit by digit. Then, the process of retrieving the target data and then retrieving the data by shifting the digit by one digit is repeated until the last digit is executed.

【0012】請求項3の発明は、整列対象となるデータ
を桁毎にメモリ上に2分木構造で格納し、格納された2
分木構造のデータ上位桁または下位桁から順に後方検索
または前方検索を実行して、前記整列対象となるデータ
を降順または昇順に整列することを特徴としている。
According to a third aspect of the present invention, data to be sorted is stored in a memory in a binary tree structure for each digit, and the stored binary data is stored.
A backward search or a forward search is performed in order from the upper digit or lower digit of the data of the branch tree structure, and the data to be sorted is sorted in descending order or ascending order.

【0013】請求項4の発明は、検索対象となるデータ
を桁毎にメモリ上に2分木構造で格納する検索対象デー
タ格納手段と、格納された2分木構造のデータのルート
から各ノードのデータと検索データとを比較して目的の
データを検索するデータ検索手段とを備えることを特徴
としている。
According to a fourth aspect of the present invention, there is provided a search target data storage means for storing data to be searched in a memory for each digit in a binary tree structure, and each node from a root of the stored binary tree structure data. And data search means for searching for target data by comparing the data with the search data.

【0014】請求項5の発明は、請求項4に記載のデー
タ検索装置において、前記2分木を構成する各ノードの
データ構造は、前記検索対象となるデータを桁毎に格納
する桁データと、この桁データ部に格納された自データ
よりも小さい桁データへのポインタと、前記自データよ
りも大きい桁データへのポインタと、前記自データの次
の桁データへのポインタと、データの終端を示すフラグ
とから成ることを特徴としている。
According to a fifth aspect of the present invention, in the data search apparatus according to the fourth aspect, the data structure of each node constituting the binary tree includes digit data for storing the data to be searched for each digit. A pointer to digit data smaller than the own data stored in the digit data portion, a pointer to digit data larger than the own data, a pointer to the next digit data of the own data, and an end of data. And a flag indicating the flag.

【0015】請求項6の発明は、請求項4または5に記
載のデータ検索装置において、前記データ検索手段は、
曖昧検索を実行する場合には、格納された2分木構造の
データに対して検索データを桁毎に比較して目的のデー
タを検索するとともに、桁を1桁ずらして再度検索する
処理を最後の桁まで繰り返して実行する機能を含むこと
を特徴としている。
According to a sixth aspect of the present invention, in the data search device according to the fourth or fifth aspect, the data search means comprises:
When performing an ambiguous search, the search data is compared digit by digit with respect to the stored binary tree structure data to search for the target data, and the process of searching again by shifting the digit by one digit is performed last. It is characterized by including a function of repeatedly executing up to the digit.

【0016】上記の構成によれば、検索対象となるデー
タを桁毎にメモリ上に2分木構造で格納し、格納された
2分木構造のデータに対して検索データを桁毎に比較し
て目的のデータを検索することにより、レコード中のキ
ーデータを検索データとするようなデータ構造に対して
検索時間にばらつきのない完全一致検索および高速な曖
昧一致検索を実現する。
According to the above arrangement, the data to be searched is stored in the memory for each digit in a binary tree structure, and the search data is compared with the stored binary tree structure data for each digit. By searching for the target data by using the key data in the record as the search data, it is possible to realize a complete match search and a high-speed ambiguous match search with no variation in search time for a data structure in which key data in a record is used as search data.

【0017】また、整列対象となるデータを桁毎にメモ
リ上に2分木構造で格納し、格納された2分木構造のデ
ータ上位桁または下位桁から順に後方検索または前方検
索を実行して、前記整列対象となるデータを降順または
昇順に整列することにより、データの整列処理を簡単か
つ短時間に実行する。
The data to be sorted is stored in the memory in a binary tree structure for each digit, and a backward search or a forward search is executed in order from the upper digit or lower digit of the stored data of the binary tree structure. By arranging the data to be sorted in descending order or ascending order, the data sorting process can be executed easily and in a short time.

【0018】[0018]

【発明の実施の形態】図1は本発明によるデータ検索装
置の実施の形態の構成を示すブロック図である。
FIG. 1 is a block diagram showing a configuration of an embodiment of a data search apparatus according to the present invention.

【0019】同図に示すデータ検索装置1は、例えば、
パソコンで構成されており、データ検索を実行するCP
U2と、ハードディスク等の外部記憶媒体で構成され、
検索対象となるデータを格納したデータ記憶部3とを備
えている。
The data search device 1 shown in FIG.
CP consisting of a personal computer and executing a data search
U2 and an external storage medium such as a hard disk,
A data storage unit 3 for storing data to be searched.

【0020】CPU2は、検索対象となるデータを桁毎
にメモリ上に2分木構造で格納する検索対象データ格納
部4と、この検索対象データ格納部に格納された2分木
構造のデータのルートから各ノードのデータと検索デー
タとを比較して目的のデータを検索するデータ検索部3
を備えている。
The CPU 2 stores a search target data storage unit 4 for storing data to be searched in a memory for each digit in a binary tree structure, and stores a binary tree structure data stored in the search target data storage unit. A data search unit 3 that compares the data of each node with the search data from the root and searches for the target data
It has.

【0021】検索対象データ格納部2は、図2に示すよ
うに、検索対象データが、 An−1・・・A ・ ・ ・ ・ Xn−1・・・Xn−1・・・Y である場合に、次に示すように、各桁毎のデータを抽出
して各桁毎に2分木構造でメモリ内に格納する。
The retrieval target data storage unit 2, as shown in FIG. 2, the search target data is, A n A n-1 ··· A 2 A 1 · · · · X n X n-1 ··· X In the case of 2 X 1 Y n Y n-1 ... Y 2 Y 1 , as shown below, data for each digit is extracted and stored in the memory in a binary tree structure for each digit. .

【0022】 1桁目………A・・・X 2桁目………A・・・X ・ ・ n−1桁目…Anー1・・・Xnー1nー1 n桁目………A・・・X この場合、図3にC言語の構造体で示すように、検索対
象データ格納部2のメモリ内には、各桁毎に、桁データ
と、その桁データよりも小さい桁データが格納されたバ
ッファのアドレスを示すポインタと、前記桁データより
も大きい桁データが格納されたバッファのアドレスを示
すポインタと、前記桁データの次の桁データが格納され
たバッファのアドレスを示すポインタと、前記桁データ
が終端データ(桁の終わりで、次にリンクする桁が無い
もの)である場合には“ON”、終端でない場合には
“OF”となるフラグをそれぞれ格納する領域が設けら
れる。
[0022] 1 digit ......... A 1 ··· X 1 Y 1 2 digit ......... A 2 ··· X 2 Y 2 · · n-1 digit ... A n over 1 ··· X n over 1 Y n over 1 n-th digit ......... a n ··· X n Y n in this case, as shown in C language structures in Figure 3, the search target data storage unit 2 of the memory, each For each digit, a pointer indicating the address of a buffer storing digit data, digit data smaller than the digit data, a pointer indicating a buffer address storing digit data larger than the digit data, and A pointer indicating the address of the buffer in which the next digit data of the data is stored, and "ON" if the digit data is end data (the end of the digit and no digit to be linked next), not the end In this case, there are provided areas for storing flags that are “OF”.

【0023】次に本実施の形態の動作を説明する。Next, the operation of this embodiment will be described.

【0024】図4に示すように、検索対象データとし
て、“142”,“a42”,“942”,“13”,“8
3”,“b3”,“33”,“2”,“5”の9個のデータ
があるものとする。検索対象データ格納部4は、これら
の9個のデータを桁毎に2分木構造でメモリ上に格納し
ていく。具体的には、図4に示すように、1桁目のバッ
ファアドレス1には、桁データとして“3”、小さい桁
データへのポインタとして“アドレス2”、大きい桁デ
ータのポインタとして“アドレス3”、次の桁データへ
のポインタとして“アドレス4”、そしてデータの終端
を示すフラグとして“OF(OFFの略)”が格納され
る。なお、木構造はデータの格納順によっても異なる構
造となるが、図4の例では、“3”から格納する場合を
示している。
As shown in FIG. 4, "142", "a42", "942", "13", "8"
It is assumed that there are nine data of “3”, “b3”, “33”, “2”, and “5.” The search target data storage unit 4 stores these nine data in a binary tree for each digit. As shown in Fig. 4, the buffer address 1 of the first digit is "3" as digit data and "address 2" is a pointer to small digit data, as shown in Fig. 4. In addition, “address 3” is stored as a pointer to the large digit data, “address 4” is a pointer to the next digit data, and “OF (abbreviation of OFF)” is stored as a flag indicating the end of the data. Has a different structure depending on the data storage order, but the example of FIG. 4 shows a case where data is stored starting from “3”.

【0025】同様に、アドレス2には、桁データとして
“2”、小さい桁データへのポインタとして“NL”、
大きい桁データのポインタとして“NL(NULLポイ
ンタの略)”、次の桁データへのポインタとして“アド
レス4”、終端フラグとして“ON”がそれぞれ格納さ
れていく。また、アドレス3には、桁データとして
“5”、小さい桁データへのポインタとして“NL”、
大きい桁データのポインタとして“NL”、次の桁デー
タへのポインタとして“NL”、終端フラグとして“O
N”がそれぞれ格納されていく。
Similarly, address 2 has "2" as digit data, "NL" as a pointer to smaller digit data,
“NL (abbreviation of NULL pointer)” is stored as a pointer for large digit data, “address 4” is stored as a pointer to the next digit data, and “ON” is stored as a termination flag. Address 3 has "5" as digit data, "NL" as a pointer to small digit data,
“NL” as a pointer for the large digit data, “NL” as a pointer to the next digit data, and “O” as a termination flag
N "are stored.

【0026】次に、2桁目のバッファのアドレス3に
は、桁データとして“8”、小さい桁データへのポイン
タとして“アドレス5”、大きい桁データのポインタと
して“アドレス6”、次の桁データへのポインタとして
“NL”、終端フラグとして“ON”がそれぞれ格納さ
れていく。また、2桁目のアドレス5には、桁データと
して“3”、小さい桁データへのポインタとして“アド
レス7”、大きい桁データのポインタとして“NL”、
次の桁データへのポインタとして“NL”、終端フラグ
として“ON”がそれぞれ格納されていく。さらに、2
桁目のアドレス6には、桁データとして“b”、小さい
桁データへのポインタとして“NL”、大きい桁データ
のポインタとして“NL”、次の桁データへのポインタ
として“NL”、終端フラグとして“ON”がそれぞれ
格納されていく。さらに、アドレス7には、桁データと
して“1”、小さい桁データへのポインタとして“N
L”、大きい桁データのポインタとして“NL”、次の
桁データへのポインタとして“NL”、終端フラグとし
て“ON”がそれぞれ格納されていく。さらに、アドレ
ス9には、桁データとして“4”、小さい桁データへの
ポインタとして“NL”、大きい桁データのポインタと
して“NL”、次の桁データへのポインタとして“アド
レス10”、終端フラグとして“OF”がそれぞれ格納
されていく。
Next, at address 3 of the second digit buffer, "8" is used as digit data, "address 5" is used as a pointer to small digit data, "address 6" is used as a pointer to large digit data, and the next digit is used. “NL” is stored as a pointer to data, and “ON” is stored as a termination flag. The address 5 of the second digit has “3” as digit data, “address 7” as a pointer to small digit data, “NL” as a pointer to large digit data,
“NL” is stored as a pointer to the next digit data, and “ON” is stored as a termination flag. In addition, 2
The address 6 of the digit has “b” as digit data, “NL” as a pointer to small digit data, “NL” as a pointer to large digit data, “NL” as a pointer to the next digit data, and a termination flag. Are stored as “ON”. Further, the address 7 has "1" as digit data and "N" as a pointer to small digit data.
"L", "NL" as a pointer to the large digit data, "NL" as a pointer to the next digit data, and "ON" as a termination flag, respectively. , "NL" as a pointer to small digit data, "NL" as a pointer to large digit data, "Address 10" as a pointer to the next digit data, and "OF" as an end flag.

【0027】次に、3桁目のバッファアドレス10に
は、桁データとして“9”、小さい桁データへのポイン
タとして“アドレス11”、大きい桁データのポインタ
として“アドレス12”、次の桁データへのポインタと
して“NL”、終端フラグとして“ON”がそれぞれ格
納されていく。また、アドレス11には、桁データとし
て“1”、小さい桁データへのポインタとして“N
L”、大きい桁データのポインタとして“NL”、次の
桁データへのポインタとして“NL”、終端フラグとし
て“ON”がそれぞれ格納されていく。さらに、アドレ
ス12には、桁データとして“a”、小さい桁データへ
のポインタとして“NL”、大きい桁データのポインタ
として“NL”、次の桁データへのポインタとして“N
L”、終端フラグとして“ON”がそれぞれ格納されて
いくのである。
Next, the buffer address 10 of the third digit has "9" as digit data, "address 11" as a pointer to small digit data, "address 12" as a pointer to large digit data, and the next digit data. "NL" is stored as a pointer to "", and "ON" is stored as a termination flag. The address 11 has "1" as digit data and "N" as a pointer to small digit data.
"L", "NL" as a pointer to the next digit data, "NL" as a pointer to the next digit data, and "ON" as a termination flag, respectively. , "NL" as a pointer to small digit data, "NL" as a pointer to large digit data, and "N" as a pointer to the next digit data.
L, and “ON” are stored as the termination flag.

【0028】こうして検索対象データが各桁毎に2分木
構造で格納されると、データ検索部5では、検索データ
と検索対象データとを各桁毎に比較して根から順に検索
を実行して、目的のデータを検索して出力する。以下
に、データ検索部5で実行される検索を完全一致検索
と、曖昧検索(部分一致検索)とに分けて説明する。
When the search target data is stored in a binary tree structure for each digit in this way, the data search unit 5 compares the search data and the search target data for each digit and executes the search in order from the root. Search and output the desired data. Hereinafter, the search performed by the data search unit 5 will be described by dividing it into a perfect match search and an ambiguous search (partial match search).

【0029】(1)完全一致検索 <本実施形態における完全一致検索の方法>完全一致検
索の方法は、下位桁の2分木構造の根から順次、検索を
実行する。該当する文字が見つかった場合は、その文字
にリンクされた次の列の文字の検索を開始する。以後、
この処理を繰り返し、検索対象データの最上位桁まで実
行する。データがヒットしない場合には、処理を終了す
る。
(1) Exact Match Search <Exact Match Search Method in the Present Embodiment> In the exact match search method, the search is executed sequentially from the root of the binary tree structure of the lower digit. If the character is found, it starts searching for the next column of characters linked to that character. Since then
This process is repeated until the most significant digit of the search target data is executed. If no data is hit, the process ends.

【0030】図5には、データを順に2分木構造で格納
する様子が示されている。このようにデータが格納され
た場合には、例えば、“ahd”を検索データとして、
図5のデータ構造から検索する場合には、まず、キーデ
ータの1桁目“d”を検索対象データの1桁目の根
“c”と比較することから検索を開始する。データ
“d”は根のデータ“c”より大きいので、右の枝に進
み、データ“e”と比較される。キーデータ“d”は、
データ“e”よりも小さいので、左のデータ“d”と比
較され、ここで、1桁目のデータがヒットしたことにな
る。
FIG. 5 shows how data is stored in a binary tree structure in order. When data is stored in this manner, for example, “ahd” is used as search data.
When searching from the data structure of FIG. 5, first, the search is started by comparing the first digit "d" of the key data with the root "c" of the first digit of the search target data. Since the data “d” is larger than the root data “c”, the process proceeds to the right branch and is compared with the data “e”. The key data “d” is
Since it is smaller than the data "e", it is compared with the left data "d", and here, the data of the first digit is hit.

【0031】次に、2桁目のキーデータ“h”の検索が
開始され、根のデータ“g”と比較され、その結果、左
の枝に進んでデータ“h”がヒットされることになる。
Next, the search for the key data "h" of the second digit is started and compared with the root data "g". As a result, the data proceeds to the left branch and the data "h" is hit. Become.

【0032】さらに、3桁目のキーデータ“a”の検索
では、2桁目のデータ“h”にリンクしたデータ“b”
と比較され、その結果、左の枝に進んでデータ“a”が
ヒットされる。このようにして、桁毎に格納された2分
木構造の検索対象データ中から検索データ“ahd”が
高速に検索される。
In the search for the third digit key data "a", the data "b" linked to the second digit data "h" is retrieved.
As a result, the data "a" is hit by proceeding to the left branch. In this way, the search data "ahd" is searched at high speed from the binary tree structure search target data stored for each digit.

【0033】<本実施形態における完全一致検索の効果
>完全一致検索では、比較回数はデータの個数ではな
く、各桁のデータの種類に比例する。
<Effects of Perfect Match Search in the Present Embodiment> In perfect match search, the number of comparisons is not proportional to the number of data but to the type of data of each digit.

【0034】一般にXn−1・・・Xのデー
タがそれぞれMn−1・・・M の種類のデー
タで構成される場合、データの個数はM×Mn−1×
・・・×M×Mで表せられ、比較回数は次の通りで
ある。
In general, XnXn-1... X2X1Day of
Is MnMn-1... M 2M1Kind of day
Data, the number of data is Mn× Mn-1×
... × M2× M1And the number of comparisons is
is there.

【0035】[0035]

【表1】 対数は、logXY=logX+logYという
性質を持つことから、従来の2分木の場合と本実施形態
の場合の平均比較回数は同一回数となる。
[Table 1] Since the logarithm has the property of log a XY = log a X + log a Y, the average number of comparisons in the case of the conventional binary tree and the case of the present embodiment is the same.

【0036】大量のデータが存在する場合は、Mの値
は、一様に存在すると考えられるので、M=Mn−1
=・・・=M=M=Mとすると、次のようになる。
When a large amount of data exists, the value of M is considered to exist uniformly, so that Mn = Mn-1
=== M 2 = M 1 = M

【0037】[0037]

【表2】 最大比較回数は、この実施の形態の場合の方が少なくて
済むため、検索時間にばらつきが無く、安定した検索が
可能となる。
[Table 2] Since the maximum number of comparisons in this embodiment can be smaller, a stable search can be performed without variation in search time.

【0038】(2)曖昧検索 <本実施の形態における曖昧検索の方法>次に、n桁の
データの一部にk桁の検索文字(列)が存在するか否か
を検索する曖昧検索について説明する。曖昧検索では、
検索対象となる全てのデータに対して検索を行い、検索
データを全て抽出する。今、 検索対象データ:Xn−1・・・Xk+1・・・X 検索データ : Yk+1・・・Y として、各桁毎に2分木構造で検索データをメモリ上に
格納すると、図6に示すような木構造となる。このデー
タの格納処理については、完全一致検索の場合と同じで
ある。また、図6において、四角で囲んだ部分は、各桁
の木構造のまとまりを示している。
(2) Fuzzy Search <Fuzzy Search Method in the Present Embodiment> Next, a fuzzy search for searching whether or not a k-digit search character (string) exists in a part of n-digit data. explain. In fuzzy search,
A search is performed for all data to be searched, and all search data is extracted. Now, the search target data: X n X n-1 ··· X k + 1 X k ··· X 3 X 2 X 1 search data: as Y k + 1 Y k ··· Y 3 Y 2 Y 1, each digit When the search data is stored in the memory in a binary tree structure, a tree structure as shown in FIG. 6 is obtained. The processing for storing this data is the same as in the case of the perfect match search. In FIG. 6, a portion surrounded by a square indicates a united tree structure of each digit.

【0039】この曖昧検索では、例えば、検索データ1
0バイトであり、検索対象データが20バイトである場
合、10バイトがヒットすれば、全て検索される。従っ
て、最初に、10バイトヒットしても、次の10バイト
にもヒットするものが存在する可能性がある。このた
め、検索データがk桁ある場合、図6に一点鎖線で示す
ように、最初にk桁の検索を実行し、その後に、桁を1
桁ずらして図中の破線で囲む範囲をデータを検索してい
く。このように、順次桁をずらして検索対象データの最
後の桁まで検索を実行する。
In this fuzzy search, for example, search data 1
If it is 0 bytes and the search target data is 20 bytes, if 10 bytes are hit, all are searched. Therefore, even if a 10-byte hit occurs first, there is a possibility that there is a hit in the next 10 bytes. For this reason, when the search data has k digits, as shown by the dashed line in FIG.
The data is searched in a range shifted by a digit and surrounded by a broken line in the figure. In this manner, the search is executed by shifting the digits sequentially to the last digit of the search target data.

【0040】具体的に説明すると、今、n桁のデータが
それぞれXn−1・・・X で表現され、M
n−1・・・Mの種類のデータで構成される場
合を考える。但し、Xは任意の値である。
More specifically, the data of n digits is now
Each XnXn-1... X2X 1, And Mn
Mn-1... M2M1Field composed of different types of data
Think about a match. However, X is an arbitrary value.

【0041】2分木での曖昧検索を実現する場合には、
全データを検索する必要があるため、逐次検索と同様の
検索回数となる。
In order to realize a fuzzy search using a binary tree,
Since all data must be searched, the number of searches is the same as in the sequential search.

【0042】本発明の曖昧検索では、図7に示すような
検索範囲および検索順により検索を行う。
In the fuzzy search of the present invention, a search is performed according to a search range and a search order as shown in FIG.

【0043】すなわち、検索対象データ:Xn−1
・・・Xk+1kー1・・・Xおいて、第
1回目の検索では、1桁からk桁(X・・・X
)までのデータが検索され、第2回目の検索で
は、1桁ずらして2桁からk+1桁(Xk+1
kー1・・・X)までの検索が実行される。このよう
にして、第(n−k+1)回目までの検索が実行される
のである。
[0043] In other words, the search target data: X n X n-1
.., X k + 1 X k X k−1 ... X 2 X 1 In the first search, 1 to k digits (X k.
2 X 1 ) is searched, and in the second search, the data is shifted by one digit from 2 digits to k + 1 digits (X k + 1 X k X
The search up to k-1 ... X 2 ) is executed. In this manner, the search up to the (n−k + 1) th search is executed.

【0044】<本実施の形態における曖昧検索の効果>
上述のような曖昧検索の場合、各検索範囲での比較回数
は、以下のようになる。
<Effect of Fuzzy Search in the Present Embodiment>
In the case of the fuzzy search described above, the number of comparisons in each search range is as follows.

【0045】すなわち、第1回目の検索では“KM”
回、第2回目の検索では“M・KM(=KM)、・・
・、第(n−K+1)回目の検索では“Mn−KKM
(=KM −K+1)”となる。
That is, in the first search, "KM"
Times, the second search is “M · KM (= KM 2 ),
・ In the (n−K + 1) -th search, “M n−K KM
(= KM n -K + 1) becomes ".

【0046】大量のデータが存在する場合には、Mの値
は一様に存在すると考えられるので、M=Mn−1
・・・=M=M=Mとすると、検索データがk桁の
場合に、比較回数は次のようになる。
When a large amount of data exists, the value of M is considered to exist uniformly, so that Mn = Mn-1 =
.. = M 2 = M 1 = M, and the number of comparisons is as follows when the search data has k digits.

【0047】[0047]

【表3】 上記表3からも理解されるように、本実施の形態におけ
る曖昧検索では、従来の2分木の検索に比べて高速に検
索できる。
[Table 3] As can be understood from Table 3 above, the fuzzy search in the present embodiment can perform a search faster than the conventional binary tree search.

【0048】(3)データの整列処理(ソート) 検索対象となるデータを桁毎にメモリ上に2分木構造で
格納し、格納された2分木構造のデータを上位桁から検
索するという手法を用いることにより、データの整列処
理が実現できる。
(3) Data Sorting Process (Sort) A method of storing data to be searched for each digit in a memory in a binary tree structure and searching the stored binary tree structure data from the upper digit. , Data alignment processing can be realized.

【0049】今、木構造に格納されるデータを、 とし、これらのデータを上位桁から順に図8に示すよう
に木構造に格納する。図8は、データを昇順に整列する
場合と、データを降順に整列する場合を示している。
Now, the data stored in the tree structure is These data are stored in a tree structure as shown in FIG. FIG. 8 shows a case where data is sorted in ascending order and a case where data is sorted in descending order.

【0050】先ず、データを昇順に整列する場合には、
図中1で示す走査路に従って、後方検索を実行する。こ
れにより、データの格納位置がわかるので、図中に黒丸
で示すように、1桁目から順にデータを取得していく。
First, in order to arrange data in ascending order,
A backward search is executed according to the scanning path indicated by 1 in the figure. As a result, since the storage position of the data can be known, the data is acquired sequentially from the first digit, as indicated by the black circles in the figure.

【0051】一方、データを降順に検索する場合には、
図中2で示す走査路に従って、前方検索を実行する。こ
れにより、データの格納位置がわかるので、図中に黒丸
で示すように、上位桁から順にデータを取得していけば
良い。
On the other hand, when searching for data in descending order,
A forward search is executed according to the scanning path indicated by 2 in the figure. As a result, since the storage position of the data can be known, the data may be obtained in order from the upper digit, as indicated by a black circle in the figure.

【0052】このように本実施の形態によれば、データ
の整列処理を簡単かつ短時間に実行することができる。
As described above, according to the present embodiment, the data alignment process can be executed easily and in a short time.

【0053】[0053]

【発明の効果】以上説明したように本発明のデータ検索
方法、およびデータ検索装置によれば、レコード中のキ
ーデータを検索データとするようなデータ構造に対して
検索時間にばらつきのない完全一致検索および高速な曖
昧一致検索を実現することができる。
As described above, according to the data search method and the data search apparatus of the present invention, perfect match without variation in search time is obtained for a data structure in which key data in a record is used as search data. A search and a high-speed fuzzy match search can be realized.

【0054】また、本発明のデータ整列方法によれば、
データの整列処理を簡単かつ短時間に実行することがで
きる。
According to the data alignment method of the present invention,
The data sorting process can be executed easily and in a short time.

【図面の簡単な説明】[Brief description of the drawings]

【図1】本発明によるデータ検索装置の実施形態の構成
を示すブロック図である。
FIG. 1 is a block diagram showing a configuration of an embodiment of a data search device according to the present invention.

【図2】多数ある検索対象データを桁毎にまとめる様子
を示す説明図である。
FIG. 2 is an explanatory diagram showing a state in which a large number of search target data are grouped for each digit.

【図3】桁毎に2分木構造で格納される各要素をC言語
の構造体で示す説明図である。
FIG. 3 is an explanatory diagram showing each element stored in a binary tree structure for each digit in a C language structure.

【図4】桁毎に2分木に格納されるデータ構造を示す説
明図である。
FIG. 4 is an explanatory diagram showing a data structure stored in a binary tree for each digit.

【図5】桁毎に格納された2分木構造の一例を示す説明
図である。
FIG. 5 is an explanatory diagram showing an example of a binary tree structure stored for each digit.

【図6】桁毎に格納された2分木構造において曖昧検索
を実行する場合の説明図である。
FIG. 6 is an explanatory diagram of a case where an ambiguous search is executed in a binary tree structure stored for each digit.

【図7】曖昧検索における検索範囲と検索順を示す説明
図である。
FIG. 7 is an explanatory diagram showing a search range and a search order in an ambiguous search.

【図8】本発明におけるデータ整列方法を示す説明図で
ある。
FIG. 8 is an explanatory diagram showing a data alignment method according to the present invention.

【図9】木構造の説明図である。FIG. 9 is an explanatory diagram of a tree structure.

【図10】木構造におけるデータ検索を示す説明図であ
る。
FIG. 10 is an explanatory diagram showing a data search in a tree structure.

【符号の説明】[Explanation of symbols]

1 データ検索装置 2 CPU 3 データ記憶部 4 検索対象データ格納部 5 データ検索部 DESCRIPTION OF SYMBOLS 1 Data search device 2 CPU 3 Data storage part 4 Search target data storage part 5 Data search part

Claims (6)

【特許請求の範囲】[Claims] 【請求項1】 検索対象となるデータを桁毎にメモリ上
に2分木構造で格納し、 格納された2分木構造のデータに対して検索データを桁
毎に比較して目的のデータを検索する、 ことを特徴とするデータ検索方法。
1. A data to be searched is stored in a memory in a binary tree structure for each digit, and search data is compared digit by digit with respect to the stored binary tree structure data to obtain target data. A data search method characterized by searching.
【請求項2】 請求項1に記載のデータ検索方法におい
て、 曖昧検索を実行する場合には、格納された2分木構造の
データに対して検索データを桁毎に比較して目的のデー
タを検索し、次いで、桁を1桁ずらして再度検索する処
理を最後の桁まで繰り返して実行する、 ことを特徴とするデータ検索方法。
2. The data search method according to claim 1, wherein when performing an ambiguous search, the search data is compared digit by digit with respect to the stored binary tree structure data, and the target data is determined. A data search method comprising: performing a search, then shifting the digit by one digit, and performing a search again to the last digit.
【請求項3】 整列対象となるデータを桁毎にメモリ上
に2分木構造で格納し、 格納された2分木構造のデータ上位桁または下位桁から
順に後方検索または前方検索を実行して、前記整列対象
となるデータを降順または昇順に整列する、 ことを特徴とするデータ整列方法。
3. The data to be sorted is stored in a memory in a binary tree structure for each digit, and a backward search or a forward search is executed in order from the upper digit or the lower digit of the stored data of the binary tree structure. And sorting the data to be sorted in descending order or ascending order.
【請求項4】 検索対象となるデータを桁毎にメモリ上
に2分木構造で格納する検索対象データ格納手段と、 格納された2分木構造のデータのルートから各ノードの
データと検索データとを比較して目的のデータを検索す
るデータ検索手段と、 を備えることを特徴とするデータ検索装置。
4. Search target data storage means for storing data to be searched in a memory in a binary tree structure for each digit, data of each node from a root of the stored data of the binary tree structure, and search data. And a data searching means for searching for target data by comparing the data with the data.
【請求項5】 請求項4に記載のデータ検索装置におい
て、 前記2分木を構成する各ノードのデータ構造は、前記検
索対象となるデータを桁毎に格納する桁データと、この
桁データ部に格納された自データよりも小さい桁データ
へのポインタと、前記自データよりも大きい桁データへ
のポインタと、前記自データの次の桁データへのポイン
タと、データの終端を示すフラグと、 から成ることを特徴とするデータ検索装置。
5. The data search device according to claim 4, wherein the data structure of each node forming the binary tree includes digit data for storing the data to be searched for each digit, and a digit data portion. A pointer to digit data smaller than the own data stored in the pointer, a pointer to digit data larger than the own data, a pointer to the next digit data of the own data, a flag indicating the end of the data, A data search device comprising:
【請求項6】 請求項4または5に記載のデータ検索装
置において、 前記データ検索手段は、曖昧検索を実行する場合には、
格納された2分木構造のデータに対して検索データを桁
毎に比較して目的のデータを検索するとともに、桁を1
桁ずらして再度検索する処理を最後の桁まで繰り返して
実行する機能を含む、 ことを特徴とするデータ検索装置。
6. The data search device according to claim 4, wherein the data search unit executes an ambiguous search,
The search data is compared digit by digit with respect to the stored binary tree structure data to search for the target data, and the digit is set to 1
A data search device, including a function of repeatedly executing a process of performing a search by shifting digits to the last digit.
JP29441199A 1999-10-15 1999-10-15 Data retrieving method, data aligning method and data retrieving device Pending JP2001117929A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP29441199A JP2001117929A (en) 1999-10-15 1999-10-15 Data retrieving method, data aligning method and data retrieving device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP29441199A JP2001117929A (en) 1999-10-15 1999-10-15 Data retrieving method, data aligning method and data retrieving device

Publications (1)

Publication Number Publication Date
JP2001117929A true JP2001117929A (en) 2001-04-27

Family

ID=17807413

Family Applications (1)

Application Number Title Priority Date Filing Date
JP29441199A Pending JP2001117929A (en) 1999-10-15 1999-10-15 Data retrieving method, data aligning method and data retrieving device

Country Status (1)

Country Link
JP (1) JP2001117929A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007537626A (en) * 2004-04-19 2007-12-20 ザ・リージェンツ・オブ・ザ・ユニバーシティ・オブ・カリフォルニア Programmable hardware for deep packet filtering
CN100418090C (en) * 2005-08-31 2008-09-10 国际商业机器公司 Data storage method and data storage structure
JP2020077236A (en) * 2018-11-08 2020-05-21 富士通株式会社 Search program, search method and search device

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007537626A (en) * 2004-04-19 2007-12-20 ザ・リージェンツ・オブ・ザ・ユニバーシティ・オブ・カリフォルニア Programmable hardware for deep packet filtering
JP4755175B2 (en) * 2004-04-19 2011-08-24 ザ・リージェンツ・オブ・ザ・ユニバーシティ・オブ・カリフォルニア Programmable hardware for deep packet filtering
CN100418090C (en) * 2005-08-31 2008-09-10 国际商业机器公司 Data storage method and data storage structure
JP2020077236A (en) * 2018-11-08 2020-05-21 富士通株式会社 Search program, search method and search device
JP7087931B2 (en) 2018-11-08 2022-06-21 富士通株式会社 Search program, search method and search device

Similar Documents

Publication Publication Date Title
US10055439B2 (en) Fast, scalable dictionary construction and maintenance
JP3672242B2 (en) PATTERN SEARCH METHOD, PATTERN SEARCH DEVICE, COMPUTER PROGRAM, AND STORAGE MEDIUM
JP2670383B2 (en) Prefix search tree with partial key branch function
US7103536B1 (en) Symbol dictionary compiling method and symbol dictionary retrieving method
Baeza-Yates Introduction to Data Structures and Algorithms Related to Information Retrieval.
EP3435256B1 (en) Optimal sort key compression and index rebuilding
JP2003044267A (en) Data sorting method, data sorting device and data sorting program
US20220005546A1 (en) Non-redundant gene set clustering method and system, and electronic device
CN102867049A (en) Chinese PINYIN quick word segmentation method based on word search tree
Irving et al. The suffix binary search tree and suffix AVL tree
Andersson et al. Suffix trees on words
Alanko et al. Succinct k-mer sets using subset rank queries on the spectral burrows-wheeler transform
US20030187856A1 (en) Database and method for storing a searchable set of keywords
JP2001527240A (en) Management in data structures
Kärkkäinen et al. Full-text indexes in external memory
JP2001117929A (en) Data retrieving method, data aligning method and data retrieving device
JP3370787B2 (en) Character array search method
JP4208326B2 (en) Information indexing device
JP2675958B2 (en) Information retrieval computer system and method of operating storage device thereof
JPH10162013A (en) Digital searching device
JPH10240741A (en) Managing method for tree structure type data
CN115801020B (en) Definite finite state automaton compression method, matching method, device and medium
Kwon et al. Compressed key sort and fast index reconstruction
JP2772124B2 (en) Dictionary search method
JPH1115836A (en) Table for searching character string, generation method therefor and character string searching method