JP2008287533A - Longest conformity/shortest conformity retrieval method for coupled node tree, and program - Google Patents

Longest conformity/shortest conformity retrieval method for coupled node tree, and program Download PDF

Info

Publication number
JP2008287533A
JP2008287533A JP2007132289A JP2007132289A JP2008287533A JP 2008287533 A JP2008287533 A JP 2008287533A JP 2007132289 A JP2007132289 A JP 2007132289A JP 2007132289 A JP2007132289 A JP 2007132289A JP 2008287533 A JP2008287533 A JP 2008287533A
Authority
JP
Japan
Prior art keywords
node
search
key
tree
bit position
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
JP2007132289A
Other languages
Japanese (ja)
Other versions
JP4514771B2 (en
JP2008287533A5 (en
Inventor
Toshio Shinjo
敏男 新庄
Mitsuhiro Kokubu
光裕 國分
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.)
S Grants Co Ltd
Original Assignee
S Grants Co 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 S Grants Co Ltd filed Critical S Grants Co Ltd
Priority to JP2007132289A priority Critical patent/JP4514771B2/en
Priority to CN2008800122779A priority patent/CN101657818B/en
Priority to EP08738589.4A priority patent/EP2149845B1/en
Priority to PCT/JP2008/000983 priority patent/WO2008132806A1/en
Priority to TW097114278A priority patent/TW200846955A/en
Publication of JP2008287533A publication Critical patent/JP2008287533A/en
Priority to US12/588,523 priority patent/US8214405B2/en
Publication of JP2008287533A5 publication Critical patent/JP2008287533A5/ja
Application granted granted Critical
Publication of JP4514771B2 publication Critical patent/JP4514771B2/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/903Querying
    • G06F16/90335Query processing
    • G06F16/90344Query processing by using string matching techniques

Abstract

<P>PROBLEM TO BE SOLVED: To provide a method for the longest comformity/shortest comformity retrieval with a coupled node tree as the object of retrieval. <P>SOLUTION: A coupled node tree is comprised of: a root node; a branch node disposed between neighboring memory areas; and a pair of leaf nodes or branch nodes or a pair of a leaf node and a branch node. The branch node includes information indicating the discriminating bit position of a retrieval key and the position of one node of the pair of nodes to be linked. The leaf node includes an index key comprised of a retrieval subject bit sequence. The coupled node tree is retrieved by using the longest comformity/shortest comformity retrieval key, and the longest comformity/shortest comformity node is determined based on the comparison of the difference bit position of the index key of the retrieval result and the longest comformity/shortest comformity retrieval key and the discriminating bit position of the branch node on a retrieval path from the route node stored upon retrieval. <P>COPYRIGHT: (C)2009,JPO&INPIT

Description

本発明は、ビット列を記憶するツリー状のデータ構造を用いてビット列の集合から所望のビット列を検索する検索方法に関するものであり、特に本出願人が特願2006−187827において提案したカップルドノードツリーの最長一致検索/最短一致検索方法及びそのプログラムに関するものである。   The present invention relates to a search method for searching for a desired bit string from a set of bit strings using a tree-like data structure for storing bit strings, and in particular, a coupled node tree proposed by the present applicant in Japanese Patent Application No. 2006-187827. The longest match search / shortest match search method and its program.

近年、社会の情報化が進展し、大規模なデータベースが各所で利用されるようになってきている。このような大規模なデータベースからレコードを検索するには、各レコードの記憶されたアドレスと対応づけられたレコード内の項目をインデックスキーとして検索をし、所望のレコードを探し出すことが通例である。また、全文検索における文字列も、文書のインデックスキーと見なすことができる。   In recent years, with the progress of informatization of society, large-scale databases are being used in various places. In order to search for a record from such a large database, it is usual to search for an item in the record associated with the stored address of each record using an index key to find a desired record. A character string in full-text search can also be regarded as a document index key.

そして、それらのインデックスキーはビット列で表現されることから、データベースの検索はビット列の検索に帰着されるということができる。
上記ビット列の検索を高速に行うために、ビット列を記憶するデータ構造を種々に工夫することが従来から行われている。このようなものの1つとして、パトリシアツリーという木構造が知られている。
Since these index keys are expressed by bit strings, it can be said that a database search is reduced to a bit string search.
In order to search the bit string at high speed, various data structures for storing the bit string have been conventionally devised. As one of such things, a tree structure called a Patricia tree is known.

図13は、上述の従来の検索処理に用いられているパトリシアツリーの一例を示すものである。パトリシアツリーのノードは、インデックスキー、検索キーの検査ビット位置、左右のリンクポインタを含んで構成される。明示はされていないが、ノードにはインデックスキーに対応するレコードにアクセスするための情報が含まれていることは勿論である。   FIG. 13 shows an example of a Patricia tree used in the above-described conventional search process. The Patricia tree node includes an index key, a check bit position of the search key, and left and right link pointers. Although not explicitly shown, it goes without saying that the node includes information for accessing the record corresponding to the index key.

図13の例では、インデックスキー“100010”を保持するノード1750aがルートノードとなっており、その検査ビット位置1730aは0である。ノード1750aの左リンク1740aにはノード1750bが接続され、右リンク1741aにはノード1750fが接続されている。   In the example of FIG. 13, the node 1750a holding the index key “100010” is the root node, and its check bit position 1730a is 0. A node 1750b is connected to the left link 1740a of the node 1750a, and a node 1750f is connected to the right link 1741a.

ノード1750bの保持するインデックスキーは“010011”であり、検査ビット位置1730bは1である。ノード1750bの左リンク1740bにはノード1750cが、右リンク1741bにはノード1750dが接続されている。ノード1750cが保持するインデックスキーは“000111”、検査ビット位置は3である。ノード1750dが保持するインデックスキーは“011010”、検査ビット位置は2である。   The index key held by the node 1750b is “010011”, and the check bit position 1730b is 1. A node 1750c is connected to the left link 1740b of the node 1750b, and a node 1750d is connected to the right link 1741b. The index key held by the node 1750c is “000111”, and the check bit position is 3. The index key held by the node 1750d is “011010”, and the check bit position is 2.

ノード1750cから実線で接続された部分はノード1750cの左右のリンクポインタを示すものであり、点線の接続されていない左ポインタ1740cは、その欄が空欄であることを示している。点線の接続された右ポインタ1741cの点線の接続先は、ポインタの示すアドレスを表しており、今の場合ノード1750cを右ポインタ1741cが指定していることを表している。   The portion connected by a solid line from the node 1750c indicates the left and right link pointers of the node 1750c, and the left pointer 1740c not connected by the dotted line indicates that the column is blank. The connection destination of the dotted line of the right pointer 1741c connected to the dotted line represents the address indicated by the pointer. In this case, the right pointer 1741c specifies the node 1750c.

ノード1750dの右ポインタ1741dはノード1750d自身を指しており、左リンク1740dにはノード1750eが接続されている。ノード1750eの保持するインデックスキーは“010010”、検査ビット位置1730eは5である。ノード1750eの左ポインタ1740eはノード1750bを、右ポインタ1741eはノード1750eを指している。   The right pointer 1741d of the node 1750d points to the node 1750d itself, and the node 1750e is connected to the left link 1740d. The index key held by the node 1750e is “010010”, and the check bit position 1730e is 5. The left pointer 1740e of the node 1750e points to the node 1750b, and the right pointer 1741e points to the node 1750e.

また、ノード1750fの保持するインデックスキーは“101011”であり、検査ビット位置1730fは2である。ノード1750fの左リンク1740fにはノード1750gが、右リンク1741fにはノード1750hが接続されている。   Further, the index key held by the node 1750f is “101101”, and the check bit position 1730f is 2. A node 1750g is connected to the left link 1740f of the node 1750f, and a node 1750h is connected to the right link 1741f.

ノード1750gの保持するインデックスキーは“100011”であり、検査ビット位置1730gは5である。ノード1750gの左ポインタ1740gはノード1750aを、右ポインタ1741gはノード1750gを指している。   The index key held by the node 1750g is “1000011”, and the check bit position 1730g is 5. The left pointer 1740g of the node 1750g points to the node 1750a, and the right pointer 1741g points to the node 1750g.

ノード1750hの保持するインデックスキーは“101100”であり、検査ビット位置1730hは3である。ノード1750hの左ポインタ1740hはノード1750fを、右ポインタ1741hはノード1750hを指している。   The index key held by the node 1750h is “101100”, and the check bit position 1730h is 3. The left pointer 1740h of the node 1750h points to the node 1750f, and the right pointer 1741h points to the node 1750h.

図13の例では、ルートノード1750aからツリーを降りるにしたがって、各ノードの検査ビット位置が大きくなるように構成されている。
ある検索キーで検索を行うとき、ルートノードから順次各ノードに保持される検索キーの検査ビット位置を検査していき、検査ビット位置のビット値が1であるか0であるか判定を行い、1であれば右リンクをたどり、0であれば左リンクをたどる。そして、リンク先のノードの検査ビット位置がリンク元のノードの検査ビット位置より大きくなければ、すなわち、リンク先が下方でなく上方に戻れば(図13において点線で示されたこの逆戻りのリンクをバックリンクという)、リンク先のノードのインデックスキーと検索キーの比較を行う。比較の結果、等しければ検索成功であり、等しくなければ検索失敗であることが保証されている。
In the example of FIG. 13, the check bit position of each node is configured to increase as the tree descends from the root node 1750a.
When performing a search with a certain search key, the check bit position of the search key held in each node is sequentially checked from the root node, and it is determined whether the bit value of the check bit position is 1 or 0, If it is 1, follow the right link, if it is 0, follow the left link. If the check bit position of the link destination node is not larger than the check bit position of the link source node, that is, if the link destination returns upward rather than downward (the reverse link indicated by the dotted line in FIG. The index key of the link destination node and the search key are compared. As a result of the comparison, it is guaranteed that the search is successful if they are equal and the search is unsuccessful if they are not equal.

上記のように、パトリシアツリーを用いた検索処理では、必要なビットの検査だけで検索できること、キー全体の比較は1回ですむことなどのメリットがあるが、各ノードからの2つのリンクが必ずあることにより記憶容量が増大することや、バックリンクの存在による判定処理の複雑化、バックリンクにより戻ることで初めてインデックスキーと比較することによる検索処理の遅延及び追加削除等データメンテナンスの困難性などの欠点がある。   As described above, search processing using the Patricia tree has advantages such as being able to search only by checking the necessary bits and comparing the entire key only once, but there are always two links from each node. Increase in storage capacity due to the presence of the data, complicating judgment processing due to the presence of a back link, difficulty in data maintenance such as search processing delay and addition / deletion by comparing with an index key for the first time by returning by a back link, etc. There are disadvantages.

これらのパトリシアツリーの欠点を解消しようとするものとして、例えば下記特許文献1に開示された技術がある。下記特許文献1に記載されたパトリシアツリーにおいては、下位の左右のノードは連続した領域に記憶することによりポインタの記憶容量を削減するとともに、次のリンクがバックリンクであるか否かを示すビットを各ノードに設けることにより、バックリンクの判定処理を軽減している。   As a technique for overcoming the disadvantages of these Patricia trees, for example, there is a technique disclosed in Patent Document 1 below. In the Patricia tree described in the following Patent Document 1, the lower left and right nodes are stored in a continuous area, thereby reducing the storage capacity of the pointer, and a bit indicating whether or not the next link is a back link Is provided at each node to reduce the back link determination process.

しかしながら、下記特許文献1に開示されたものにおいても、1つのノードは必ずインデックスキーの領域とポインタの領域を占めること、下位の左右のノードを連続した領域に記憶するようにしてポインタを1つとしたため、例えば図13に示したパトリシアツリーの最下段の部分である左ポインタ1740c、右ポインタ1741h等の部分にもノードと同じ容量の記憶領域を割り当てる必要があるなど、記憶容量の削減効果はあまり大きいものではない。また、バックリンクによる検索処理の遅延の問題や追加削除等の処理が困難であることも改善されていない。   However, in the one disclosed in Patent Document 1 below, one node always occupies the index key area and the pointer area, and the lower left and right nodes are stored in a continuous area, and one pointer is used. Therefore, for example, it is necessary to allocate a storage area having the same capacity as the node to the left pointer 1740c and the right pointer 1741h, which are the lowermost parts of the Patricia tree shown in FIG. It's not big. In addition, the problem of delay in search processing due to the back link and the difficulty of processing such as additional deletion have not been improved.

上述の従来の検索手法における問題点を解決するものとして、本出願人は、特願2006−187827において、ルートノードと、隣接した記憶領域に配置されるブランチノードとリーフノードまたはブランチノード同士またはリーフノード同士のノード対からなるビット列検索に用いるツリーであって、ルートノードはツリーの始点を表すノードであって、該ツリーのノードが1つのときはリーフノード、ツリーのノードが2つ以上のとき
は前記ブランチノードであり、前記ブランチノードは、ビット列検索を行う検索キーの弁別ビット位置とリンク先のノード対の一方のノードの位置を示す位置情報を含み、前記リーフノードは検索対象のビット列からなるインデックスキーを含むカップルドノードツリーを用いたビット列検索を提案した。
In order to solve the above-described problems in the conventional search method, the present applicant has disclosed in Japanese Patent Application No. 2006-187827 that the root node, the branch node arranged in the adjacent storage area, the leaf node, the branch nodes, or the leaf. A tree used for bit string search consisting of node pairs between nodes, where the root node is a node representing the starting point of the tree, and when there is one node in the tree, it is a leaf node, and when there are two or more nodes in the tree Is a branch node, and the branch node includes a discrimination bit position of a search key for performing a bit string search and position information indicating a position of one node of a link destination node pair, and the leaf node is obtained from a bit string to be searched. A bit string search using a coupled node tree with an index key It was.

上記出願においては、与えられたインデックスキーの集合からカップルドノードツリーを生成する方法と、カップルドノードツリーから単一のインデックスキーを検索する手法等の、カップルドノードツリーを用いた基本的な検索手法が示されている。   In the above application, a basic method using a coupled node tree, such as a method for generating a coupled node tree from a given set of index keys and a method for retrieving a single index key from the coupled node tree. A search technique is shown.

また、ビット列の検索には、最小値、最大値を求めたり、ある範囲の値のものを求める等の各種の検索要求が存在する。そこで、本出願人は、特願2006−293619において、カップルドノードツリーの任意の部分木に含まれるインデックスキーの最大値/最小値を求める手法等を提案した。   In the search for bit strings, there are various search requests such as obtaining a minimum value, a maximum value, and obtaining a value within a certain range. In view of this, the present applicant proposed in Japanese Patent Application No. 2006-293619 a method for obtaining the maximum value / minimum value of an index key included in an arbitrary subtree of a coupled node tree.

さらに、ビット列の検索には、検索キーと完全に一致する値の検索の他に、検索キーと少なくとも一部が一致する値の検索がある。最上位のビットから1ビット以上が検索キーと一致し、その一致する範囲がなるべく大きい(あるいは小さい)インデックスキーを検索しようとする最長一致(あるいは最短一致)検索がその例である。   Furthermore, the bit string search includes a search for a value that at least partially matches the search key, in addition to a search for a value that completely matches the search key. An example is the longest match (or shortest match) search in which one or more bits from the most significant bit match the search key and the matching range tries to search for an index key that is as large (or as small) as possible.

最長一致検索は、ルーティングテーブルの検索や、上位ビットが共通の複数のアドレス宛にデータを同報送信する場合の、同報アドレスの検索などに利用可能である。また、最短一致検索は、正規表現による文字列検索や検索対象の絞り込みなどに利用可能である。したがって、これらの検索を高速化し、様々な応用分野における処理効率を向上させることが望まれている。   The longest match search can be used for searching a routing table or for searching for a broadcast address when data is broadcast to a plurality of addresses having the same high-order bit. The shortest match search can be used for a character string search using a regular expression, a search target narrowing down, or the like. Therefore, it is desired to speed up these searches and improve the processing efficiency in various application fields.

特許文献2にはパトリシアツリーを用いた最長一致検索を高速化する技術が記載されているが、カップルドノードツリーは本出願人が発明した新規なデータ構造であるため、従来の最長一致検索手法を使うことはできない。
特開2001−357070号公報 特開2003−224581号公報
Patent Document 2 describes a technique for speeding up the longest match search using a Patricia tree. However, since the coupled node tree is a new data structure invented by the present applicant, a conventional longest match search method is disclosed. Cannot be used.
JP 2001-357070 A Japanese Patent Laid-Open No. 2003-224581

本発明の目的は、カップルドノードツリーを検索対象として最長一致/最短一致検索を行う方法およびプログラムを提供することである。   An object of the present invention is to provide a method and a program for performing a longest match / shortest match search using a coupled node tree as a search target.

本発明が検索対象とするカップルドノードツリーは、ルートノードと、隣接した記憶領域に配置されるブランチノードとリーフノードまたはブランチノード同士またはリーフノード同士のノード対、からなるビット列検索に用いるツリーである。前記ルートノードは、ツリーの始点を表すノードであって、該ツリーのノードが1つのときは前記リーフノード、ツリーのノードが2つ以上のときは前記ブランチノードである。前記ブランチノードは、ビット列検索を行う検索キーの弁別ビット位置とリンク先のノード対の一方のノードである代表ノードの位置を示す位置情報を含み、前記リーフノードは検索対象のビット列からなるインデックスキーを含む。   The coupled node tree to be searched by the present invention is a tree used for a bit string search including a root node, a branch node arranged in an adjacent storage area and a leaf node or a node pair between branch nodes or a leaf node. is there. The root node is a node that represents the starting point of a tree. When there is one node in the tree, the root node is the leaf node, and when there are two or more nodes in the tree, the root node is the branch node. The branch node includes position information indicating a discrimination bit position of a search key for performing a bit string search and a representative node that is one node of a link destination node pair, and the leaf node is an index key including a bit string to be searched including.

前記カップルドノードツリーは、前記ツリーの任意のノードを検索開始ノードとして、前記ブランチノードにおいて該ブランチノードに含まれる弁別ビット位置の検索キーのビット値に応じてリンク先のノード対の代表ノードかあるいはそれと隣接した記憶領域に配置されたノードにリンクすることを順次前記リーフノードに至るまで繰り返すことにより
、前記リーフノードに格納されたインデックスキーを、前記検索開始ノードをルートノードとする前記ツリーの任意の部分木の前記検索キーによる検索の結果である検索結果キーとするように構成されている。
The coupled node tree is a representative node of a link destination node pair according to a bit value of a search key of a discrimination bit position included in the branch node, with an arbitrary node of the tree as a search start node. Alternatively, by sequentially linking to a node arranged in a storage area adjacent to the leaf node, the index key stored in the leaf node is used as an index key of the tree having the search start node as a root node. A search result key that is a result of a search by the search key of an arbitrary partial tree is configured.

本発明による前記カップルドノードツリーを用いた最長一致検索方法は、前記カップルドノードツリーの前記ルートノードを前記検索開始ノードとし、指定された最長一致検索キーを前記検索キーとして、前記ルートノードからの経路を記憶しながら前記検索を行って前記検索結果キーを取得する検索ステップと、前記最長一致検索キーと前記検索結果キーのビット列を比較して、ビット値が一致しない不一致ビットの位置のうち最も上位の位置である差分ビット位置を取得する差分ビット位置取得ステップと、前記差分ビット位置がビット列の最上位以外の位置のとき、記憶された前記経路を参照して最長一致ノードを設定する最長一致ノード設定ステップであって、前記ルートノードが前記リーフノードの場合または前記ルートノードが前記ブランチノードであり該ルートノードの前記弁別ビット位置が前記差分ビット位置よりも下位の位置の場合は、前記ルートノードを前記最長一致ノードとして設定し、その他の場合は、前記経路上のノードであって前記弁別ビット位置が前記差分ビット位置よりも上位にある前記ブランチノードのうち前記弁別ビット位置が最下位の前記ブランチノードの次に前記検索ステップにおいて記憶された前記ブランチノードまたは前記リーフノードを前記最長一致ノードとして設定する最長一致ノード設定ステップと、を備える。   In the longest match search method using the coupled node tree according to the present invention, the root node of the coupled node tree is used as the search start node, and the specified longest match search key is used as the search key. A search step of acquiring the search result key by performing the search while storing the path of the search, and comparing the bit string of the longest match search key and the search result key, and out of the positions of the mismatch bit where the bit values do not match A difference bit position acquisition step for acquiring a difference bit position that is the highest position, and a longest match node that sets a longest matching node with reference to the stored path when the difference bit position is a position other than the highest position of a bit string A matching node setting step, wherein the root node is the leaf node or the root node is If the discrimination bit position of the root node is a position lower than the difference bit position, the root node is set as the longest match node; otherwise, it is a node on the path. The branch node or the leaf node stored in the search step next to the branch node having the lowest discrimination bit position among the branch nodes having the discrimination bit position higher than the difference bit position. And a longest matching node setting step for setting as the longest matching node.

本発明による前記カップルドノードツリーを用いた最短一致検索方法は、前記最長一致検索キーのかわりに最短一致検索キーを用いる以外は上記と同様の検索ステップおよび差分ビット位置取得ステップと、前記差分ビット位置がビット列の最上位以外の位置のとき、記憶された前記経路を参照して最短一致ノードを設定する最短一致ノード設定ステップであって、前記経路が、前記ルートノードと、該ルートノードのリンク先の前記ノード対の一方の前記ブランチノードである第一のノードとを含み、前記ルートノードの前記弁別ビット位置が前記差分ビット位置よりも上位の位置の場合は、前記第一のノードのリンク先の前記ノード対のうち、前記経路に記憶されていない方のノードである第二のノードを前記最短一致ノードとして設定する最短一致ノード設定ステップと、を備える。   The shortest match search method using the coupled node tree according to the present invention includes a search step and a difference bit position acquisition step similar to the above except that a shortest match search key is used instead of the longest match search key, and the difference bit A shortest match node setting step for setting a shortest match node with reference to the stored route when the position is a position other than the highest bit of the bit string, wherein the route is a link between the root node and the root node; A first node that is one of the branch nodes of the previous node pair, and when the discrimination bit position of the root node is higher than the difference bit position, the link of the first node The second node that is the node that is not stored in the route of the previous node pair is set as the shortest matching node. Comprising the shortest match node setting step that, a.

本発明によれば、カップルドノードツリーを検索対象として最長一致/最短一致検索を行うことが可能となる。よって、最長一致/最短一致検索が必要な各種応用分野にカップルドノードツリーを用いることが可能となる。カップルドノードツリーは、検索を高速化するよう構成されているため、カップルドノードツリーを用いた最長一致/最短一致検索は高速である。よって、各種応用分野における最長一致/最短一致検索の処理の高速化が実現される。   According to the present invention, it is possible to perform a longest match / shortest match search using a coupled node tree as a search target. Therefore, the coupled node tree can be used in various application fields that require the longest match / shortest match search. Since the coupled node tree is configured to speed up the search, the longest match / shortest match search using the coupled node tree is fast. Therefore, the processing speed of the longest match / shortest match search in various application fields can be increased.

以下、本発明の実施形態について、図面を参照しながら詳細に説明する。
最初に、本出願人により先の上記出願において提案された、本発明の前提となるカップルドノードツリーについて、カップルドノードツリーを配列に格納する例を説明する。ブランチノードが保持するリンク先の位置を示すデータとして、記憶装置のアドレス情報とすることもできるが、ブランチノードあるいはリーフノードのうち占有する領域の記憶容量の大きい方を格納可能な配列要素からなる配列を用いることにより、ノードの位置を配列番号で表すことができ、位置情報の情報量を削減することができる。
Hereinafter, embodiments of the present invention will be described in detail with reference to the drawings.
First, an example of storing a coupled node tree in an array will be described with respect to the coupled node tree proposed by the present applicant in the above-mentioned application and serving as a premise of the present invention. The address information of the storage device can be used as the data indicating the link destination position held by the branch node, but it consists of an array element that can store the larger storage capacity of the area occupied by the branch node or leaf node. By using the array, the position of the node can be represented by an array number, and the amount of information on the position information can be reduced.

図1は、配列に格納されたカップルドノードツリーの構成例を説明する図である。
図1を参照すると、ノード101が配列100の配列番号10の配列要素に配置されている。ノード101はノード種別102、弁別ビット位置103及び代表ノード番号10
4で構成されている。ノード種別102は0であり、ノード101がブランチノードであることを示している。弁別ビット位置103には1が格納されている。代表ノード番号104にはリンク先のノード対の代表ノードの配列番号20が格納されている。なお、以下では表記の簡略化のため、代表ノード番号に格納された配列番号を代表ノード番号ということもある。また、代表ノード番号に格納された配列番号をそのノードに付した符号あるいはノード対に付した符号で表すこともある。
FIG. 1 is a diagram for explaining a configuration example of a coupled node tree stored in an array.
Referring to FIG. 1, the node 101 is arranged in the array element of the array element number 10 in the array 100. The node 101 has a node type 102, a discrimination bit position 103, and a representative node number 10
4 is configured. The node type 102 is 0, indicating that the node 101 is a branch node. 1 is stored in the discrimination bit position 103. The representative node number 104 stores the array element number 20 of the representative node of the link destination node pair. Hereinafter, for simplification of the notation, the array element number stored in the representative node number may be referred to as a representative node number. Further, the array element number stored in the representative node number may be represented by a code attached to the node or a code attached to the node pair.

配列番号20の配列要素には、ノード対111の代表ノードであるノード[0]112が格納されている。そして隣接する次の配列要素(配列番号20+1)に代表ノードと対になるノード[1]113が格納されている。ノード[0]112のノード種別114には0が、弁別ビット位置115には3が、代表ノード番号116には30が格納されている。またノード[1]113のノード種別117には1が格納されており、ノード[1]113がリーフノードであることを示している。インデックスキー118には、“0001”が格納されている。パトリシアツリーについて先に述べたと同様に、リーフノードにインデックスキーと対応するレコードにアクセスする情報が含まれることは当然であるが、表記は省略している。   The array element with the array element number 20 stores the node [0] 112 that is the representative node of the node pair 111. Then, node [1] 113 paired with the representative node is stored in the next adjacent array element (array number 20 + 1). 0 is stored in the node type 114 of the node [0] 112, 3 is stored in the discrimination bit position 115, and 30 is stored in the representative node number 116. Further, 1 is stored in the node type 117 of the node [1] 113, indicating that the node [1] 113 is a leaf node. The index key 118 stores “0001”. As described above for the Patricia tree, it is natural that the leaf node includes information for accessing the record corresponding to the index key, but the description is omitted.

なお、代表ノードをノード[0]で表し、それと対になるノードをノード[1]で表すことがある。また、ある配列番号の配列要素に格納されたノードを、その配列番号のノードということがあり、ノードの格納された配列要素の配列番号を、ノードの配列番号ということもある。   A representative node may be represented by a node [0] and a node paired therewith may be represented by a node [1]. In addition, a node stored in an array element having a certain array number may be referred to as a node having the array number, and an array number of the array element in which the node is stored may be referred to as a node array number.

配列番号30及び31の配列要素に格納されたノード122とノード123からなるノード対121の内容は省略されている。
ノード[0]112、ノード[1]113、ノード122、及びノード123の格納された配列要素にそれぞれ付された0あるいは1は、検索キーで検索を行う場合にノード対のどちらのノードにリンクするかを示すものである。前段のブランチノードの弁別ビット位置にある検索キーのビット値である0か1を代表ノード番号に加えた配列番号のノードにリンクする。
The contents of the node pair 121 composed of the node 122 and the node 123 stored in the array elements of the array element numbers 30 and 31 are omitted.
The 0 or 1 added to the array elements stored in the node [0] 112, the node [1] 113, the node 122, and the node 123 are linked to either node of the node pair when searching with the search key. It shows what to do. The search key bit value 0 or 1 at the discrimination bit position of the preceding branch node is linked to the node of the array element number obtained by adding the representative node number.

したがって、前段のブランチノードの代表ノード番号に、検索キーの弁別ビット位置のビット値を加えることにより、リンク先のノードが格納された配列要素の配列番号を求めることができる。   Therefore, by adding the bit value of the discrimination bit position of the search key to the representative node number of the preceding branch node, the array element number of the array element storing the link destination node can be obtained.

なお、上記の例では代表ノード番号をノード対の配置された配列番号のうち小さい方を採用しているが、大きいほうを採用することも可能であることは明らかである。
図2は、カップルドノードツリーのツリー構造を概念的に示す図である。図示の6ビットのインデックスキーは、図13に例示されたパトリシアツリーのものと同じである。
In the above example, the representative node number is the smaller of the array element numbers where the node pairs are arranged. However, it is obvious that the larger one can be adopted.
FIG. 2 is a diagram conceptually showing a tree structure of a coupled node tree. The 6-bit index key shown is the same as that of the Patricia tree illustrated in FIG.

符号210aで示すのがルートノードである。図示の例では、ルートノード210aは配列番号220に配置されたノード対201aの代表ノードとしている。
ツリー構造としては、ルートノード210aの下にノート対201bが、その下層にノード対201cとノード対201fが配置され、ノード対201fの下層にはノード対201hとノード対201gが配置されている。ノード対201cの下にはノード対201dが、さらにその下にはノード対201eが配置されている。
A reference numeral 210a indicates a root node. In the illustrated example, the root node 210a is a representative node of the node pair 201a arranged at the array element number 220.
As a tree structure, a note pair 201b is arranged below the root node 210a, a node pair 201c and a node pair 201f are arranged below it, and a node pair 201h and a node pair 201g are arranged below the node pair 201f. A node pair 201d is disposed below the node pair 201c, and a node pair 201e is disposed below the node pair 201d.

各ノードの前に付された0あるいは1の符号は、図1において説明した配列要素の前に付された符号と同じである。検索キーの弁別ビット位置のビット値に応じてツリーをたどり、検索対象のリーフノードを見つけることになる。   The code of 0 or 1 added before each node is the same as the code assigned before the array element described in FIG. The tree is traversed according to the bit value of the discrimination bit position of the search key, and the leaf node to be searched is found.

図示された例では、ルートノード210aのノード種別260aは0でブランチノードであることを示し、弁別ビット位置230aは0を示している。代表ノード番号は220aであり、それはノード対201bの代表ノード210bの格納された配列要素の配列番号である。   In the illustrated example, the node type 260a of the root node 210a is 0, indicating that it is a branch node, and the discrimination bit position 230a indicates 0. The representative node number is 220a, which is the array element number of the array element stored in the representative node 210b of the node pair 201b.

ノード対201bはノード210bと211bで構成され、それらのノード種別260b、261bはともに0であり、ブランチノードであることを示している。ノード210bの弁別ビット位置230bには1が格納され、リンク先の代表ノード番号にはノード対201cの代表ノード210cの格納された配列要素の配列番号220bが格納されている。   The node pair 201b is composed of nodes 210b and 211b, and the node types 260b and 261b are both 0, indicating that they are branch nodes. 1 is stored in the discrimination bit position 230b of the node 210b, and the array element number 220b of the array element stored in the representative node 210c of the node pair 201c is stored in the link representative node number.

ノード210cのノード種別260cには1が格納されているので、このノードはリーフノードであり、したがって、インデックスキー250cを含んでいる。インデックスキー250cには“000111”が格納されている。一方ノード211cのノード種別261cは0、弁別ビット位置231cは2であり、代表ノード番号にはノード対201dの代表ノード210dの格納された配列要素の配列番号221cが格納されている。   Since 1 is stored in the node type 260c of the node 210c, this node is a leaf node and therefore includes the index key 250c. “000111” is stored in the index key 250c. On the other hand, the node type 261c of the node 211c is 0, the discrimination bit position 231c is 2, and the array element number 221c of the array element stored in the representative node 210d of the node pair 201d is stored in the representative node number.

ノード210dのノード種別260dは0、弁別ビット位置230dは5であり、代表ノード番号にはノード対201eの代表ノード210eの格納された配列要素の配列番号220dが格納されている。ノード210dと対になるノード211dのノード種別261dは1であり、インデックスキー251dには“011010”が格納されている。   The node type 260d of the node 210d is 0, the discrimination bit position 230d is 5, and the array number 220d of the array element in which the representative node 210e of the node pair 201e is stored is stored in the representative node number. The node type 261d of the node 211d paired with the node 210d is 1, and “011010” is stored in the index key 251d.

ノード対201eのノード210e、211eのノード種別260e、261eはともに1であり双方ともリーフノードであることを示し、それぞれのインデックスキー250e、251eにはインデックスキーとして“010010”と“010011”が格納されている。   The node types 260e and 261e of the nodes 210e and 211e of the node pair 201e are both 1, indicating that both are leaf nodes. “010010” and “010011” are stored as index keys in the index keys 250e and 251e, respectively. Has been.

ノード対201bのもう一方のノードであるノード211bの弁別ビット位置231bには2が格納され、リンク先の代表ノード番号にはノード対201fの代表ノード210fの格納された配列要素の配列番号221bが格納されている。   2 is stored in the discrimination bit position 231b of the node 211b which is the other node of the node pair 201b, and the array element number 221b of the array element in which the representative node 210f of the node pair 201f is stored is stored in the representative node number of the link destination. Stored.

ノード対201fのノード210f、211fのノード種別260f、261fはともに0であり双方ともブランチノードである。それぞれの弁別ビット位置230f、231fには5、3が格納されている。ノード210fの代表ノード番号にはノード対201gの代表ノード210gの格納された配列要素の配列番号220fが格納され、ノード211fの代表ノード番号にはノード対201hの代表ノードであるノード[0]210hの格納された配列要素の配列番号221fが格納されている。   The node types 260f and 261f of the nodes 210f and 211f of the node pair 201f are both 0, and both are branch nodes. 5 and 3 are stored in the discrimination bit positions 230f and 231f, respectively. The representative node number of the node 210f stores the array element number 220f of the array element in which the representative node 210g of the node pair 201g is stored, and the representative node number of the node 211f contains the node [0] 210h that is the representative node of the node pair 201h. The array element number 221f of the stored array element is stored.

ノード対201gのノード210g、211gのノード種別260g、261gはともに1であり双方ともリーフノードであることを示し、それぞれのインデックスキー250g、251gには“100010”と“100011”が格納されている。   The node types 260g and 261g of the nodes 210g and 211g of the node pair 201g are both 1, indicating that both are leaf nodes, and “100010” and “1000011” are stored in the respective index keys 250g and 251g. .

また同じくノード対201hの代表ノードであるノード[0]210hとそれと対をなすノード[1]211hのノード種別260h、261hはともに1であり双方ともリーフノードであることを示し、それぞれのインデックスキー250h、251hには“101011”と“101100”が格納されている。   Similarly, the node type 260h and 261h of the node [0] 210h, which is the representative node of the node pair 201h, and the node [1] 211h that is paired with the node [0] 210h are both 1, indicating that both are leaf nodes. In “250h” and “251h”, “101011” and “101100” are stored.

以下、上述のツリーからインデックスキー“100010”を検索する処理の流れを簡単に説明する。弁別ビット位置は、左から0、1、2、・・・とする。
まず、ビット列“100010”を検索キーとしてルートノード210aから処理をス
タートする。ルートノード210aの弁別ビット位置230aは0であるので、検索キー“100010”の弁別ビット位置が0のビット値をみると1である。そこで代表ノード番号の格納された配列番号220aに1を加えた配列番号の配列要素に格納されたノード211bにリンクする。ノード211bの弁別ビット位置231bには2が格納されているので、検索キー“100010”の弁別ビット位置が2のビット値をみると0であるから、代表ノード番号の格納された配列番号221bの配列要素に格納されたノード210fにリンクする。
The flow of processing for searching for the index key “100010” from the above tree will be briefly described below. The discrimination bit positions are 0, 1, 2,... From the left.
First, processing is started from the root node 210a using the bit string “100010” as a search key. Since the discrimination bit position 230a of the root node 210a is 0, it is 1 when the bit value of the discrimination bit position of the search key “100010” is 0 is seen. Therefore, the node 211b stored in the array element having the array element number obtained by adding 1 to the array element number 220a storing the representative node number is linked. Since 2 is stored in the discrimination bit position 231b of the node 211b, the discrimination bit position of the search key “100010” is 0 when the bit value of 2 is viewed, and therefore the array number 221b in which the representative node number is stored is Link to the node 210f stored in the array element.

ノード210fの弁別ビット位置230fには5が格納されているので、検索キー“100010”の弁別ビット位置が5のビット値をみると0であるから、代表ノード番号の格納された配列番号220fの配列要素に格納されたノード210gにリンクする。   Since 5 is stored in the discrimination bit position 230f of the node 210f, the discrimination bit position of the search key “100010” is 0 when the bit value of 5 is seen, and therefore the array number 220f in which the representative node number is stored is Link to the node 210g stored in the array element.

ノード210gのノード種別260gは1でありリーフノードであることを示しているので、インデックスキー250gを読み出して検索キーと比較すると両方とも“100010”であって一致している。このようにしてカップルドノードツリーを用いた検索が行われる。   Since the node type 260g of the node 210g is 1, indicating that it is a leaf node, when the index key 250g is read and compared with the search key, both are “100010” and match. In this way, a search using a coupled node tree is performed.

次に、図2を参照してカップルドノードツリーの構成の意味について説明する。
カップルドノードツリーの構成はインデックスキーの集合により規定される。図2の例で、ルートノード210aの弁別ビット位置が0であるのは、図2に例示されたインデックスキーに0ビット目が0のものと1のものがあるからである。0ビット目が0のインデックスキーのグループはノード210bの下に分類され、0ビット目が1のインデックスキーのグループはノード211bの下に分類されている。
Next, the meaning of the configuration of the coupled node tree will be described with reference to FIG.
The configuration of a coupled node tree is defined by a set of index keys. In the example of FIG. 2, the discrimination bit position of the root node 210a is 0 because the index key exemplified in FIG. The index key group whose 0th bit is 0 is classified under the node 210b, and the index key group whose 0th bit is 1 is classified under the node 211b.

ノード211bの弁別ビット位置が2であるのは、ノード211h、210h、211g、210gに格納された0ビット目が1のインデックスキーの1ビット目がすべて0で等しく、2ビット目で初めて異なるものがあるという、インデックスキーの集合の性質を反映している。   The discrimination bit position of the node 211b is 2 because the 0th bit stored in the nodes 211h, 210h, 211g and 210g is all equal to 0 in the 1st bit of the index key, and is different for the first time in the 2nd bit. This reflects the nature of the set of index keys.

以下0ビット目の場合と同様に、2ビット目が1であるものはノード211f側に分類され、2ビット目が0であるものはノード210f側に分類される。
そして2ビット目が1であるインデックスキーは3ビット目の異なるものがあるのでノード211fの弁別ビット位置には3が格納され、2ビット目が0であるインデックスキーでは3ビット目も4ビット目も等しく5ビット目で異なるのでノード210fの弁別ビット位置には5が格納される。
Hereinafter, as in the case of the 0th bit, a case where the second bit is 1 is classified on the node 211f side, and a case where the second bit is 0 is classified on the node 210f side.
Since there are different index keys whose second bit is 1, the third bit is different, so 3 is stored in the discrimination bit position of the node 211f, and in the index key whose second bit is 0, the third bit is also the fourth bit. Since the fifth bit is equally different, 5 is stored in the discrimination bit position of the node 210f.

ノード211fのリンク先においては、3ビット目が1のものと0のものがそれぞれ1つしかないことから、ノード210h、211hはリーフノードとなり、それぞれインデックスキー250hと251hに“101011”と“101100”が格納されている。   In the link destination of the node 211f, since there is only one each of which the first bit is 1 and 0, the nodes 210h and 211h are leaf nodes, and “101011” and “101100” are assigned to the index keys 250h and 251h, respectively. "Is stored.

仮にインデックスキーの集合に“101100”の代わりに“101101”か“101110”が含まれていたとしても、3ビット目までは“101100”と等しいので、ノード211hに格納されるインデックスキーが変わるだけで、ツリー構造自体は変わることはない。しかし、“101100”に加えて“101101”が含まれていると、ノード211hはブランチノードとなり、その弁別ビット位置は5になる。追加されるインデックスキーが“101110”であれば、弁別ビット位置は4となる。   Even if “101101” or “101110” is included in the set of index keys instead of “101100”, since the third bit is equal to “101100”, only the index key stored in the node 211h changes. Thus, the tree structure itself does not change. However, if “101101” is included in addition to “101100”, the node 211h becomes a branch node, and its discrimination bit position is 5. If the index key to be added is “101110”, the discrimination bit position is 4.

以上説明したように、カップルドノードツリーの構造は、インデックスキーの集合に含まれる各インデックスキーの各ビット位置のビット値により決定される。
そしてさらにいえば、異なるビット値となるビット位置ごとにビット値が“1”のノードとビット値が“0”のノードとに分岐していることから、ノード[1]側とツリーの深さ方向を優先させてリーフノードをたどると、それらに格納されたインデックスキーは、ノード211hのインデックスキー251hの“101100”、ノード210hのインデックスキー250hの“101011”、・・・、ノード210cのインデックスキー250cの“000111”となり降順にソートされている。
As described above, the coupled node tree structure is determined by the bit value of each bit position of each index key included in the set of index keys.
Furthermore, since the node branches to a node having a bit value “1” and a node having a bit value “0” for each bit position having a different bit value, the node [1] side and the depth of the tree When the leaf nodes are traced with priority given to the direction, the index keys stored in them are “101100” of the index key 251h of the node 211h, “101011” of the index key 250h of the node 210h,. The key 250c is “000111” and is sorted in descending order.

すなわち、カップルドノードツリーにおいては、インデックスキーはソートされてツリー上に配置されている。
検索キーで検索するときはインデックスキーがカップルドノードツリー上に配置されたルートをたどることになり、例えば検索キーが“101100”であればノード211hに到達することができる。また、上記説明からも想像がつくように、“101101”か“101110”を検索キーとした場合でもノード211hにたどり着き、インデックスキー251hと比較することにより検索が失敗したことが分かる。
That is, in the coupled node tree, the index keys are sorted and arranged on the tree.
When searching with the search key, the index key follows the route arranged on the coupled node tree. For example, if the search key is “101100”, the node 211h can be reached. Further, as can be imagined from the above description, even when “101101” or “101110” is used as a search key, it is found that the search has failed by reaching the node 211h and comparing with the index key 251h.

また、例えば“100100”で検索した場合でも、ノード210a、211b、210fのリンク経路では検索キーの3ビット目と4ビット目は使われることがなく、“100100”の5ビット目が0なので、“100010”で検索した場合と同様にノード210gに到達することになる。このように、カップルドノードツリーに格納されたインデックスキーのビット構成に応じた弁別ビット位置を用いて分岐が行われる。   For example, even when a search is performed with “100100”, the third and fourth bits of the search key are not used in the link paths of the nodes 210a, 211b, and 210f, and the fifth bit of “100100” is 0. The node 210g is reached in the same manner as when searching for “100010”. In this way, branching is performed using the discrimination bit position corresponding to the bit configuration of the index key stored in the coupled node tree.

図3は、本発明を実施するためのハードウェア構成例を説明する図である。
本発明の検索装置による検索処理及びデータメンテナンスは中央処理装置302及びキャッシュメモリ303を少なくとも備えたデータ処理装置301によりデータ格納装置308を用いて実施される。カップルドノードツリーが配置される配列309と検索中にたどるノードが格納された配列要素の配列番号を記憶する探索経路スタック310を有するデータ格納装置308は、主記憶装置305または外部記憶装置306で実現することができ、あるいは通信装置307を介して接続された遠方に配置された装置を用いることも可能である。図1の配列100は、配列309の一例である。
FIG. 3 is a diagram for explaining a hardware configuration example for carrying out the present invention.
Search processing and data maintenance by the search device of the present invention are performed by the data processing device 301 including at least the central processing unit 302 and the cache memory 303 using the data storage device 308. A data storage device 308 having a search path stack 310 for storing an array 309 in which a coupled node tree is arranged and an array element number in which a node to be traced is stored is a main storage device 305 or an external storage device 306. It is also possible to use a device that can be implemented or that is located remotely connected via the communication device 307. The array 100 in FIG. 1 is an example of the array 309.

図3の例示では、主記憶装置305、外部記憶装置306及び通信装置307が一本のバス304によりデータ処理装置301に接続されているが、接続方法はこれに限るものではない。また、主記憶装置305をデータ処理装置301内のものとすることもできるし、探索経路スタック310を中央処理装置302内のハードウェアとして実現することも可能である。あるいは、配列309は外部記憶装置306に、探索経路スタック310を主記憶装置305に持つなど、使用可能なハードウェア環境、インデックスキー集合の大きさ等に応じて適宜ハードウェア構成を選択できることは明らかである。   In the example of FIG. 3, the main storage device 305, the external storage device 306, and the communication device 307 are connected to the data processing device 301 by a single bus 304, but the connection method is not limited to this. Further, the main storage device 305 can be in the data processing device 301, and the search path stack 310 can be realized as hardware in the central processing unit 302. Alternatively, the array 309 has an external storage device 306, a search path stack 310 in the main storage device 305, etc. It is clear that the hardware configuration can be appropriately selected according to the usable hardware environment, the size of the index key set, etc. It is.

また、特に図示されてはいないが、処理の途中で得られた各種の値を後の処理で用いるためにそれぞれの処理に応じた一時記憶装置が用いられることは当然である。
次に、上述の出願において、本出願人により提案されたカップルドノードツリーを用いた基本的な検索処理、カップルドノードツリーにおける挿入削除処理、及びカップルドノードツリーに含まれるインデックスキーの最大値/最小値を求める処理等の応用処理の一部について、図4〜図5を参照することにより、本発明を理解するために必要な範囲で紹介する。
Further, although not particularly illustrated, it is natural that a temporary storage device corresponding to each process is used in order to use various values obtained during the process in a later process.
Next, in the above-mentioned application, the basic search process using the coupled node tree proposed by the applicant, the insertion / deletion process in the coupled node tree, and the maximum value of the index key included in the coupled node tree / A part of application processing such as processing for obtaining the minimum value will be introduced to the extent necessary for understanding the present invention by referring to FIGS.

図4は、本出願人による出願である上記特願2006−293619で提案されたビット列検索の基本動作を示したフローチャートである。
まず、ステップS401で、検索開始ノードの配列番号を取得する。取得された配列番号に対応する配列要素は、カップルドノードツリーを構成する任意のノードを格納したも
のである。検索開始ノードの指定は、後に説明する各種応用検索において行われる。
FIG. 4 is a flowchart showing the basic operation of the bit string search proposed in the above Japanese Patent Application No. 2006-293619 filed by the present applicant.
First, in step S401, the array element number of the search start node is acquired. The array element corresponding to the acquired array number stores arbitrary nodes constituting the coupled node tree. The designation of the search start node is performed in various application searches described later.

次に、ステップS402で、探索経路スタック310に取得された配列番号を格納し、ステップS403で、その配列番号に対応する配列要素を参照すべきノードとして読み出す。そして、ステップS404で、読み出したノードから、ノード種別を取り出し、ステップS405で、ノード種別がブランチノードであるか否かを判定する。   Next, in step S402, the obtained array element number is stored in the search path stack 310, and in step S403, the array element corresponding to the array element number is read as a node to be referred to. In step S404, the node type is extracted from the read node, and in step S405, it is determined whether or not the node type is a branch node.

ステップS405の判定において、読み出したノードがブランチノードである場合は、ステップS406に進み、ノードから弁別ビット位置についての情報を取り出し、更に、ステップS407で、取り出した弁別ビット位置に対応するビット値を検索キーから取り出す。そして、ステップS408で、ノードから代表ノード番号を取り出して、ステップS409で、検索キーから取り出したビット値と代表ノード番号とを加算し、新たな配列番号として、ステップS402に戻る。   If it is determined in step S405 that the read node is a branch node, the process proceeds to step S406, where information on the discrimination bit position is extracted from the node, and in step S407, a bit value corresponding to the extracted discrimination bit position is obtained. Retrieve from search key. In step S408, the representative node number is extracted from the node. In step S409, the bit value extracted from the search key and the representative node number are added, and the process returns to step S402 as a new array number.

以降、ステップS405の判定においてリーフノードと判定されてステップS410に進むまで、ステップS402からステップS409までの処理を繰り返す。ステップS410で、リーフノードからインデックスキーを取り出して、処理を終了する。   Thereafter, the processing from step S402 to step S409 is repeated until it is determined that the node is a leaf node in step S405 and the process proceeds to step S410. In step S410, the index key is extracted from the leaf node, and the process ends.

以上、本発明の基礎となるカップルドノードツリーについてとビット列検索の基本動作について詳細に説明した。カップルドノードツリーの生成処理については、特に図示はしていないが、本出願人による上記先の出願である特願2006−187827において説明したように、ビット列の集合があるとき、そこから任意のビット列を順次取り出してインデックスキーとして挿入する処理を繰り返すことにより可能である。   As above, the coupled node tree that is the basis of the present invention and the basic operation of the bit string search have been described in detail. The coupled node tree generation process is not particularly shown, but as described in Japanese Patent Application No. 2006-187827, which is the previous application by the present applicant, when there is a set of bit strings, an arbitrary one is generated therefrom. This is possible by repeating the process of sequentially taking out bit strings and inserting them as index keys.

先に述べたように、カップルドノードツリーに格納されたインデックスキーの値は、ノード[1]側とツリーの深さ方向をたどることにより降順にソートされてツリー上に配置されていることから、インデックスキーの挿入処理は、挿入するインデックスキーを検索キーとしてカップルドノードツリーから該当するリーフノードを検索するとともに、該リーフノードに至るまでたどったリンク経路のブランチノード及び該リーフノードが格納された配列要素の配列番号をスタックに順次格納し、検索キーと該当するリーフノードに含まれるインデックスキーの間で大小比較とビット列比較を行い、ビット列比較で異なるビット値となる先頭のビット位置と上記スタックに格納されているブランチノードの弁別ビット位置との相対的位置関係により挿入されるインデックスキーを含むリーフノードともう一方のノードからなるノード対の挿入位置を決定し、上記大小関係により挿入するインデックスキーを含むリーフノードを上記挿入されるノード対のどちらのノードとするかを決定することにより実施することができる。   As described above, the index key values stored in the coupled node tree are sorted on the tree in descending order by following the depth direction of the tree with the node [1] side. In the index key insertion process, the corresponding leaf node is searched from the coupled node tree using the index key to be inserted as a search key, and the branch node and the leaf node of the link path that has reached the leaf node are stored. The array element array numbers are sequentially stored in the stack, the size key and bit string comparison are performed between the search key and the index key included in the corresponding leaf node, and the first bit position and the above bit positions that are different in the bit string comparison The relative positional relationship with the discrimination bit position of the branch node stored in the stack The insertion position of the node pair consisting of the leaf node including the index key to be inserted and the other node is determined, and the leaf node including the index key to be inserted according to the size relationship is determined as either of the nodes of the inserted node pair. This can be done by deciding whether or not to do so.

図5は、本出願人による出願である上記特願2006−293619で提案されたカップルドノードツリー(部分木を含む)に格納されたインデックスキーの最小値を求める処理を示したフローチャートである。先に述べたようなインデックスキーのツリー上の配置から、インデックスキーの最小値を求める処理は検索開始ノードからノード[0]をリーフノードに至るまでツリー上でたどることに相当する。   FIG. 5 is a flowchart showing a process for obtaining the minimum value of the index key stored in the coupled node tree (including the partial tree) proposed in the above-mentioned Japanese Patent Application No. 2006-293619 filed by the present applicant. The processing for obtaining the minimum value of the index key from the arrangement of the index key on the tree as described above corresponds to tracing the node [0] from the search start node to the leaf node on the tree.

まず、ステップS501の検索開始ノードの配列番号の取得からステップS505のノード種別の判定までは、それぞれ上述の図4のステップS401からステップS405の処理と同様である。   First, the processing from the acquisition of the array element number of the search start node in step S501 to the determination of the node type in step S505 is the same as the processing in steps S401 to S405 in FIG.

ステップS505のノード種別の判定においてノード種別がブランチノードと判定されると、ステップS506に進み、ノードから配列の代表ノード番号を取り出し、ステップS507で、取り出した代表ノード番号に値「0」を加算してその結果を新たな配列番号
とし、ステップS502に戻る。以降、ステップS505においてそのノードがリーフノードと判定されるまでステップS502からステップS507までの処理を繰り返し、ステップS508で、リーフノードからインデックスキーを取り出し、処理を終了する。
If the node type is determined to be a branch node in the determination of the node type in step S505, the process proceeds to step S506, the representative node number of the array is extracted from the node, and the value “0” is added to the extracted representative node number in step S507. Then, the result is set as a new array number, and the process returns to step S502. Thereafter, the processing from step S502 to step S507 is repeated until it is determined in step S505 that the node is a leaf node. In step S508, the index key is extracted from the leaf node, and the processing is terminated.

上記の図5に示す処理においては、ノード[0]をたどるため、代表ノード番号に一律「0」を加算している。すなわち、図5の処理によれば、リンク先のノードは、ノード対のうち必ずノード[0]とし、より小さい値のインデックスキーが格納されているノードのほうに分岐している。これにより、ツリー構造が先に述べたように順列構成であるカップルドノードツリーの最小のインデックスキーを取り出すことができる。   In the process shown in FIG. 5 above, in order to follow the node [0], “0” is uniformly added to the representative node number. That is, according to the processing of FIG. 5, the link destination node is always node [0] of the node pair, and branches to a node storing a smaller index key. As a result, the minimum index key of the coupled node tree whose tree structure is a permutation structure as described above can be extracted.

なお、図5と類似の方法で、カップルドノードツリー(部分木を含む)に格納されたインデックスキーの最大値を求めることができるのは当然である。具体的には、図5の処理を、ステップS507において「0」ではなく「1」を加算するように変更すれば、インデックスキーの最大値を求めることができる。この変更により、代表ノード番号が表すノード対のうち、ノード[1]に常にリンクすることとなり、リーフノードに至るまでツリー構造の階層を順次たどっていくことができるからである。   Naturally, the maximum value of the index key stored in the coupled node tree (including the partial tree) can be obtained by a method similar to FIG. Specifically, if the process of FIG. 5 is changed to add “1” instead of “0” in step S507, the maximum value of the index key can be obtained. This is because, by this change, the node pair represented by the representative node number is always linked to the node [1], and the hierarchy of the tree structure can be sequentially followed up to the leaf node.

図4と図5に示すように、検索キーと一致するインデックスキーを検索する基本動作やインデックスキーの最小値/最大値の検索処理を実行する際には、探索経路スタック310に参照した配列の配列番号が順次格納されていく。   As shown in FIGS. 4 and 5, when executing a basic operation for searching for an index key that matches the search key or a search process for the minimum / maximum value of the index key, The array number is stored sequentially.

なお、上述の図5を参照したインデックスキーの最小値/最大値の検索処理では、カップルドノードツリーは配列に記憶されたものとして説明したが、カップルドノードツリーが配列に記憶されることは必須ではなく、ノード対を構成する2つのノードのうちの代表ノードのみあるいは代表ノードと隣接した記憶領域に配置されたノードのみをリンクしてリーフノードに至ることによりインデックスキーの最小値/最大値の検索が可能であることは明らかである。   In the above-described index key minimum / maximum value search processing with reference to FIG. 5, the coupled node tree has been described as being stored in the array. However, the coupled node tree is stored in the array. It is not essential, and only the representative node of the two nodes constituting the node pair or only the nodes arranged in the storage area adjacent to the representative node are linked to reach the leaf node to reach the minimum / maximum index key. It is clear that the search can be performed.

以上、カップルドノードツリーの最長一致/最短一致検索の前提となる技術を説明したが、必要とあれば、上述の特許出願の明細書及び図面の記載を参照されたい。
以下では、本発明によるカップルドノードツリーの最長一致/最短一致検索について説明する。まず、下記の実施形態で用いる用語と、下記の実施形態における前提条件を説明する。
The technology that is the premise of the longest match / shortest match search of the coupled node tree has been described above. If necessary, refer to the description of the above patent application and the drawings.
Hereinafter, a longest match / shortest match search of a coupled node tree according to the present invention will be described. First, terms used in the following embodiment and preconditions in the following embodiment will be described.

(a)最長一致検索は、指定された検索キーである最長一致検索キーと部分一致するインデックスキーのうち、差分ビット位置が最も下位となるインデックスキーを検索する処理である。そのようなインデックスキーを「最長一致条件を満たすインデックスキー」と定義する。最長一致条件を満たすインデックスキーは存在しないこともあるし、1つまたは複数存在することもある。なお、差分ビット位置とは、2つのビット列を比較したときにビット値が一致しない不一致ビットのうち、最も上位の位置を表す。 (A) The longest match search is a process of searching for an index key with the lowest difference bit position among index keys that partially match a longest match search key that is a designated search key. Such an index key is defined as an “index key that satisfies the longest matching condition”. There may be no index key that satisfies the longest matching condition, or there may be one or more index keys. Note that the difference bit position represents the highest position among non-matching bits whose bit values do not match when two bit strings are compared.

(b)最短一致検索は、指定された検索キーである最短一致検索キーと部分一致するインデックスキーのうち、差分ビット位置が上位のものを優先的に検索する処理である。最短一致の定義の細部については実施形態によって違いがあってもよい。以下の実施形態では、最短一致を次のように定義して最短一致検索方法について詳しく説明する。 (B) The shortest match search is a process of preferentially searching for an index key having a higher difference bit position among index keys that partially match a shortest match search key that is a designated search key. The details of the definition of the shortest match may vary depending on the embodiment. In the following embodiment, the shortest match search method will be described in detail by defining the shortest match as follows.

ルートノードの弁別ビット位置までのビット値が最短一致検索キーと完全に一致するが、ルートノードの弁別ビット位置以降のビット値には最短一致検索キーと不一致のビットが存在するインデックスキーを「最短一致条件を満たすインデックスキー」と定義する。最短一致条件を満たすインデックスキーは存在しないこともあるし、1つまたは複数存在
することもある。
The bit value up to the discrimination bit position of the root node is exactly the same as the shortest match search key, but the bit value after the discrimination bit position of the root node is the index key that has a bit that does not match the shortest match search key. It is defined as an index key that satisfies the matching condition. There may be no index key that satisfies the shortest matching condition, or there may be one or more index keys.

次に、カップルドノードツリーの最長一致検索の具体的な方法について図6、8、10、11を参照して説明する。
図6は、本発明の一実施形態における最長一致検索処理のフローチャートである。図6の処理の概要は、ステップS601〜S606で最長一致ノードを取得し、ステップS607〜S608で最長一致ノードをルートノードとする部分木の中から一つのインデックスキーを取得する、というものである。なお、ある部分木に含まれるすべてのリーフノードのインデックスキーが最長一致条件を満たすとき、その部分木のルートノードを最長一致ノードと定義する。よって、ステップS607〜S608により取得されたインデックスキーは最長一致条件を満たす。より詳細には、図6の処理は下記のとおりである。
Next, a specific method of the longest match search of the coupled node tree will be described with reference to FIGS.
FIG. 6 is a flowchart of the longest match search process according to an embodiment of the present invention. The outline of the processing in FIG. 6 is that the longest matching node is acquired in steps S601 to S606, and one index key is acquired from the subtree having the longest matching node as the root node in steps S607 to S608. . When the index keys of all leaf nodes included in a subtree satisfy the longest match condition, the root node of the subtree is defined as the longest match node. Therefore, the index key acquired in steps S607 to S608 satisfies the longest match condition. More specifically, the process of FIG. 6 is as follows.

ステップS601で指定された最長一致検索キーを検索キーに設定し、ステップS602でカップルドノードツリーのルートノードを検索開始ノードに設定する。
次に、ステップS603において、ステップS601で設定された検索キーを用いて配列309を検索し、インデックスキーを取得する。この検索は、図4に示したとおりである。ステップS602で検索開始ノードにルートノードが設定されているので、検索対象はカップルドノードツリー全体である。ステップS603の検索で探索経路スタック310に格納された内容は、後にステップS606で利用される。
The longest match search key specified in step S601 is set as a search key, and in step S602, the root node of the coupled node tree is set as a search start node.
Next, in step S603, the array 309 is searched using the search key set in step S601 to obtain an index key. This search is as shown in FIG. Since the root node is set as the search start node in step S602, the search target is the entire coupled node tree. The contents stored in the search path stack 310 in the search in step S603 are used later in step S606.

ステップS603でインデックスキーを取得した後、処理はステップS604に進み、ステップS601で設定された検索キー、すなわち最長一致検索キーと、ステップS603で取得されたインデックスキーとの差分ビット位置を求める。この処理の詳細は図10と合わせて後述する。   After acquiring the index key in step S603, the process proceeds to step S604, and a difference bit position between the search key set in step S601, that is, the longest match search key, and the index key acquired in step S603 is obtained. Details of this processing will be described later in conjunction with FIG.

次に、ステップS605において、ステップS604で求めた差分ビット位置が0か否かを判定する。
差分ビット位置が0のとき、判定は「はい」となり、最長一致検索処理を終了する。この場合、最長一致検索キーと、ステップS603で取得されたインデックスキーは、先頭の0ビット目が不一致である。また、カップルドノードツリーの構造から、カップルドノードツリーに含まれる他のすべてのインデックスキーも、最長一致検索キーと先頭の0ビット目が不一致である。したがって、カップルドノードツリー内に部分一致条件を満たすインデックスキーを含むリーフノードが存在しないため、「最長一致条件を満たすインデックスキーは存在しない」という検索結果が得られる。
Next, in step S605, it is determined whether or not the difference bit position obtained in step S604 is zero.
When the difference bit position is 0, the determination is “yes”, and the longest match search process ends. In this case, the longest match search key and the index key acquired in step S603 do not match the leading 0th bit. Also, due to the coupled node tree structure, all the other index keys included in the coupled node tree also do not match the longest match search key with the first 0th bit. Therefore, since there is no leaf node including an index key that satisfies the partial match condition in the coupled node tree, a search result that “there is no index key that satisfies the longest match condition” is obtained.

差分ビット位置が0ではないとき、ステップS605の判定が「いいえ」となり、処理はステップS606に進む。この場合、カップルドノードツリー内に最長一致条件を満たすインデックスキーが少なくとも1つ存在する。しかし、ステップS605の段階では、最長一致条件を満たすインデックスキーの存在が判明しただけなので、ステップS606では、具体的な最長一致ノードを取得する。   When the difference bit position is not 0, the determination in step S605 is “No”, and the process proceeds to step S606. In this case, there is at least one index key that satisfies the longest matching condition in the coupled node tree. However, since the existence of an index key that satisfies the longest matching condition is only found at the stage of step S605, a specific longest matching node is acquired in step S606.

ステップS606では、ステップS603の検索によって配列309の配列番号が格納された探索経路スタック310を参照し、ステップS604で求めた差分ビット位置に基づいて、最長一致ノードを取得する。   In step S606, the search path stack 310 in which the array element number of the array 309 is stored by the search in step S603 is referred to, and the longest matching node is acquired based on the difference bit position obtained in step S604.

最長一致ノードの取得後、次のステップS607において最長一致ノードを検索開始ノードに設定する。そして、その次のステップS608において、検索開始ノードより、図5に示した最小値検索処理を実行し、最長一致条件を満たすインデックスキーのうちの最小値を取得し、取得した最小値を最長一致検索の結果として出力して、最長一致検索処理を終了する。   After acquiring the longest matching node, the longest matching node is set as a search start node in the next step S607. Then, in the next step S608, the minimum value search process shown in FIG. 5 is executed from the search start node to acquire the minimum value of the index keys satisfying the longest match condition, and the acquired minimum value is the longest match. The longest match search process is finished as a result of the search.

なお、ステップS607とS608は、実施形態に応じて様々に変形可能である。本実施形態のように、最長一致条件を満たす1つ以上のインデックスキーの中から最小値を選択することは、処理の一例にすぎない。他の変形例については後述する。   Note that steps S607 and S608 can be variously modified according to the embodiment. As in this embodiment, selecting the minimum value from one or more index keys that satisfy the longest matching condition is merely an example of processing. Other modifications will be described later.

次に、図6のステップS604の処理について図10を参照して説明する。後述するように、図10の処理は、最短一致検索処理からも呼び出される。
ステップS101において、検索キーを比較キー1に設定し、インデックスキーを比較キー2に設定する。最長一致検索処理の場合、ここでの「検索キー」はステップS601で設定された最長一致検索キーであり、ここでの「インデックスキー」はステップS603で取得されたインデックスキーである。
Next, the process of step S604 in FIG. 6 will be described with reference to FIG. As will be described later, the process of FIG. 10 is also called from the shortest match search process.
In step S101, the search key is set to the comparison key 1 and the index key is set to the comparison key 2. In the longest match search process, the “search key” here is the longest match search key set in step S601, and the “index key” here is the index key acquired in step S603.

次に、ステップS102において、最上位の0ビット目から順に比較キー1と比較キー2のビット列を比較する。比較キー1と比較キー2で値が一致しない不一致ビットのうち最初に見つかったもののビット位置が、差分ビット位置として取得されて図10の処理が終了する。上記の説明から明らかなとおり、図6のステップS604から図10の処理が呼び出された場合、ステップS102では、最長一致検索キーとステップS603で取得されたインデックスキーとの差分ビット位置が得られる。   Next, in step S102, the bit strings of the comparison key 1 and the comparison key 2 are compared in order from the most significant 0th bit. Of the non-matching bits whose values do not match between the comparison key 1 and the comparison key 2, the bit position of the first one found is acquired as the difference bit position, and the processing of FIG. As is clear from the above description, when the process of FIG. 6 from step S604 to FIG. 10 is called, in step S102, the difference bit position between the longest match search key and the index key acquired in step S603 is obtained.

次に、図6のステップS606で行われる最長一致ノードを取得する処理について図8を参照して説明する。図8の処理を理解しやすくするために、説明は(A1)〜(A3)の3つの場合に分けて行う。   Next, the process for acquiring the longest matching node performed in step S606 of FIG. 6 will be described with reference to FIG. In order to facilitate understanding of the processing of FIG. 8, the description will be divided into three cases (A1) to (A3).

(A1)ルートノードがリーフノードの場合
この場合、図6のステップS603で取得されたインデックスキーはルートノードに格納されたインデックスキーである。よって、最長一致検索キーとインデックスキーとの差分ビット位置が0より大きければ、インデックスキーは最長一致条件を満たし、ルートノードは最長一致ノードに該当する。
(A1) When the root node is a leaf node In this case, the index key acquired in step S603 in FIG. 6 is an index key stored in the root node. Therefore, if the difference bit position between the longest match search key and the index key is greater than 0, the index key satisfies the longest match condition, and the root node corresponds to the longest match node.

また、図6のステップS605から明らかなとおり、図8の処理が行われるのは差分ビット位置が0より大きい場合のみなので、(A1)の場合、図8の処理によって必ずルートノードが最長一致ノードに設定される。具体的には次のとおりである。   Further, as apparent from step S605 of FIG. 6, the process of FIG. 8 is performed only when the difference bit position is greater than 0. In the case of (A1), the root node is always the longest matching node by the process of FIG. Set to Specifically, it is as follows.

ステップS801で、探索経路スタック310のスタックポインタを1つ戻す。
また、(A1)の場合、探索経路スタック310に格納されている配列309の配列番号はルートノードの配列番号のみである。よって、ステップS801の実行後、スタックポインタが指す内容は、ルートノードの配列番号である。この状態で処理はステップS802に移行する。
In step S801, the stack pointer of the search path stack 310 is returned by one.
In the case of (A1), the array element number of the array 309 stored in the search path stack 310 is only the array element number of the root node. Therefore, after the execution of step S801, the content pointed to by the stack pointer is the array element number of the root node. In this state, the process proceeds to step S802.

ステップS802で、探索経路スタック310のスタックポインタがルートノードの配列番号を指しているか否かを判定する。(A1)の場合は、上記のとおりであるから、判定の結果は「はい」となり、ステップS808に進む。   In step S802, it is determined whether or not the stack pointer of the search path stack 310 points to the array element number of the root node. In the case of (A1), since it is as described above, the determination result is “yes”, and the process proceeds to step S808.

ステップS808で、探索経路スタック310から、スタックポインタの指す配列番号を取り出す。つまり、(A1)の場合は、ルートノードの配列番号が取り出される。
そして、続くステップS809では、ステップS808で取得された配列番号、すなわちルートノードの配列番号を最長一致ノードの配列番号に設定し、図8の処理が終了する。
In step S808, the array element number pointed to by the stack pointer is extracted from the search path stack 310. That is, in the case of (A1), the array element number of the root node is extracted.
In subsequent step S809, the array element number acquired in step S808, that is, the array element number of the root node is set as the array element number of the longest matching node, and the process of FIG. 8 ends.

(A2)ルートノードがブランチノードであり、ルートノードの弁別ビット位置が0の場

この場合、0ビット目が0のインデックスキーと0ビット目が1のインデックスキーの双方を検索対象のカップルドノードツリーが含む。よって、少なくとも0ビット目が一致するインデックスキーが必ず存在する。これは、最長一致条件を満たすインデックスキーが必ず存在することと、図6のステップS604で取得された差分ビット位置が0より大きいことを意味する。つまり、(A2)の場合、ステップS605の判定は必ず「いいえ」となり、必ず図8の処理が実行される。
(A2) When the root node is a branch node and the discrimination bit position of the root node is 0. In this case, the 0th bit is 0 and the 0th bit is 1 index key. Contains the tree. Therefore, there is always an index key that matches at least the 0th bit. This means that there is always an index key that satisfies the longest matching condition, and that the difference bit position acquired in step S604 in FIG. That is, in the case of (A2), the determination in step S605 is always “No”, and the process of FIG. 8 is always executed.

ステップS801で、探索経路スタック310のスタックポインタを1つ戻す。その結果、スタックポインタが指す内容は、ステップS603で取得されたインデックスキーを格納しているリーフノードの配列番号となる。(A2)の場合、このリーフノードはルートノードではない。ステップS801の実行後、ステップS802〜S806のループが繰り返し実行される。このループは、探索経路スタック310を遡る操作である。   In step S801, the stack pointer of the search path stack 310 is returned by one. As a result, the content pointed to by the stack pointer is the array number of the leaf node that stores the index key acquired in step S603. In the case of (A2), this leaf node is not a root node. After execution of step S801, the loop of steps S802 to S806 is repeatedly executed. This loop is an operation that goes back through the search path stack 310.

ステップS802では、探索経路スタック310のスタックポインタがルートノードの配列番号を指しているか否かを判定する。(A2)の場合、1回目にステップS802を実行した時点での判定は「いいえ」となり、ステップS803に移行する。   In step S802, it is determined whether or not the stack pointer of the search path stack 310 points to the array element number of the root node. In the case of (A2), the determination at the time when step S802 is executed for the first time is “No”, and the process proceeds to step S803.

ステップS803では、探索経路スタック310のスタックポインタを1つ戻し、スタックポインタが指す配列番号を取り出す。続くステップS804では、配列309から、ステップS803で取得した配列番号の指す配列要素をノードとして読み出す。そして、次のステップS805では、ステップS804で読み出したノードから弁別ビット位置を取り出す。   In step S803, the stack pointer of the search path stack 310 is returned by 1, and the array element number pointed to by the stack pointer is extracted. In the subsequent step S804, the array element indicated by the array element number acquired in step S803 is read from the array 309 as a node. In the next step S805, the discrimination bit position is extracted from the node read in step S804.

なお、ステップS803〜S806は、ステップS802の判定が「いいえ」の場合のみ実行される。よって、ステップS803でスタックポインタを1つ戻したときにアンダーフローを起こさないことが保証される。また、図4とステップS802の説明から分かるとおり、ステップS803〜S806が実行されるのは、探索経路スタック310にルートノード以外のノードの配列番号が1つ以上格納されている場合である。よって、ステップS803の実行後にスタックポインタが指すのは、ルートノードであるブランチノードまたはそれ以外のブランチノードの配列番号である。   Note that steps S803 to S806 are executed only when the determination in step S802 is “No”. Therefore, it is guaranteed that no underflow will occur when the stack pointer is returned by one in step S803. 4 and step S802, steps S803 to S806 are executed when one or more array element numbers of nodes other than the root node are stored in the search path stack 310. Therefore, after execution of step S803, the stack pointer points to the array element number of the branch node that is the root node or other branch nodes.

ステップS805の次のステップS806では、取り出された弁別ビット位置が、図10のステップS102で得た差分ビット位置よりも上位か否かが判定される。弁別ビット位置が差分ビット位置よりも上位の場合、判定は「はい」となってステップS807に進み、下位の場合、判定は「いいえ」となってステップS802に戻る。   In step S806 following step S805, it is determined whether or not the extracted discrimination bit position is higher than the difference bit position obtained in step S102 of FIG. If the discrimination bit position is higher than the difference bit position, the determination is “yes” and the process proceeds to step S807. If it is lower, the determination is “no” and the process returns to step S802.

(A2)の場合は必ず、ステップS802〜S806のループを1回以上繰り返して実行した後、ステップS806の判定が「はい」となって、ステップS807、S808、S809と順に処理が進む。   In the case of (A2), after the loop of steps S802 to S806 has been repeatedly executed one or more times, the determination in step S806 is “Yes”, and the process proceeds in the order of steps S807, S808, and S809.

ステップS807では、探索経路スタック310のスタックポインタを1つ進める。ステップS807が実行されるのはステップS803が1回以上実行された後なので、ステップS807の操作によりオーバーフローが生じることはない。   In step S807, the stack pointer of the search path stack 310 is advanced by one. Since step S807 is executed after step S803 has been executed one or more times, no overflow occurs due to the operation of step S807.

続くステップS808で探索経路スタック310からスタックポインタの指す配列番号を取り出し、次のステップS809において、ステップS808で取得された配列番号を最長一致ノードの配列番号に設定し、図8の処理が終了する。   In subsequent step S808, the array element number pointed to by the stack pointer is extracted from the search path stack 310, and in the next step S809, the array element number acquired in step S808 is set as the array element number of the longest matching node, and the process of FIG. .

上記の処理により(A2)の場合に最長一致ノードとして設定されるノードは、次の2
つのいずれかである。
ステップS603で取得されたインデックスキーを格納するリーフノードにリンクするブランチノードの弁別ビット位置が、差分ビット位置よりも上位の場合、上記リーフノードが最長一致ノードとして設定される。
The node set as the longest matching node in the case of (A2) by the above processing is the following 2
One of the two.
When the discrimination bit position of the branch node linked to the leaf node storing the index key acquired in step S603 is higher than the difference bit position, the leaf node is set as the longest matching node.

弁別ビット位置がmであるブランチノードの配列番号と、そのブランチノードからリンクされ弁別ビット位置がnであるブランチノードの配列番号が探索経路スタック310に順に格納されており、弁別ビット位置mと弁別ビット位置nと差分ビット位置dとの関係が、m<d<nの場合、弁別ビット位置がnであるブランチノードが最長一致ノードとして設定される。   The array number of the branch node whose discrimination bit position is m and the array number of the branch node linked from the branch node and whose discrimination bit position is n are sequentially stored in the search path stack 310, and are distinguished from the discrimination bit position m. When the relationship between the bit position n and the difference bit position d is m <d <n, the branch node whose discrimination bit position is n is set as the longest matching node.

(A3)ルートノードがブランチノードであり、ルートノードの弁別ビット位置が0より大きい場合
この場合、図6のステップS605の判定が「はい」になることもある点が、(A2)の場合と異なる。
(A3) When the root node is a branch node and the discrimination bit position of the root node is greater than 0 In this case, the determination of step S605 in FIG. Different.

ステップS801で探索経路スタックのスタックポインタを1つ戻すことと、ステップS802〜S806のループの1回目の実行時にはステップS802の判定が必ず「いいえ」になることと、続くステップS803〜S806の動作は、(A2)の場合と同様である。   In step S801, the stack pointer of the search path stack is returned by 1, the determination in step S802 is always “NO” at the first execution of the loop in steps S802 to S806, and the operations in subsequent steps S803 to S806 are as follows. , (A2).

ステップS806で判定が「いいえ」となってステップS802に戻った場合、再度ステップS802の判定が行われる。(A3)の場合は、ステップS802の2回目以降の実行において判定が「はい」となることがある点で、(A2)の場合と異なる。   If the determination is “No” in step S806 and the process returns to step S802, the determination in step S802 is performed again. The case of (A3) differs from the case of (A2) in that the determination may be “yes” in the second and subsequent executions of step S802.

上記のとおり、ステップS802の1回目の実行時には判定が必ず「いいえ」になる。ステップS802の2回目以降の実行時には、直前にステップS806が実行され、ステップS806で「いいえ」と判定されている。つまり、ループを1回以上繰り返して実行した結果、スタックポインタがルートノードの配列番号を指すまで探索経路スタック310を遡った場合であって、ルートノードの弁別ビット位置が差分ビット位置よりも下位の場合にのみ、ステップS802で「はい」と判定される。   As described above, the determination is always “No” at the first execution of Step S802. When step S802 is executed for the second time or later, step S806 is executed immediately before, and “NO” is determined in step S806. That is, as a result of repeating the loop one or more times, the search path stack 310 is traced until the stack pointer points to the root node array number, and the discrimination bit position of the root node is lower than the difference bit position. Only in this case, “Yes” is determined in step S802.

ステップS802で「はい」と判定されると、ステップS808に進み、(A1)の場合と同様にして、ルートノードの配列番号が最長一致ノードの配列番号に設定され、図8の処理が終了する。   If “Yes” is determined in step S802, the process proceeds to step S808, and the array element number of the root node is set to the array element number of the longest matching node as in the case of (A1), and the processing in FIG. .

(A3)の場合はルートノードの弁別ビット位置が0より大きいので、ルートノードの弁別ビット位置mと差分ビット位置dとの関係は、下記のとおりである。カップルドノードツリーに含まれるすべてのインデックスキーは、0〜(m−1)ビット目が共通である。また、(A3)の場合でステップS802において「はい」と判定された場合は、0<d<mである。よって、この場合は、カップルドノードツリーに含まれるすべてのインデックスキーは、0〜(d−1)ビット目が最長一致検索キーと一致している。したがって、この場合は上記のとおり、ルートノードの配列番号を最長一致ノードの配列番号に設定する。   In the case of (A3), since the discrimination bit position of the root node is larger than 0, the relationship between the discrimination bit position m of the root node and the difference bit position d is as follows. All index keys included in the coupled node tree share the 0th to (m−1) th bits. In the case of (A3), if “Yes” is determined in step S802, 0 <d <m. Therefore, in this case, all the index keys included in the coupled node tree have the 0th to (d-1) th bits matching the longest match search key. Therefore, in this case, as described above, the array element number of the root node is set to the array element number of the longest matching node.

また、(A2)の場合と同様に、(A3)の場合でも、ステップS802〜S806のループを1回以上繰り返して実行した後、ステップS806の判定が「はい」となって、ステップS807、S808、S809と順に処理が進むことがある。その場合の処理の内容は(A2)の場合と同様である。   Similarly to the case of (A2), also in the case of (A3), after the loop of steps S802 to S806 is repeated one or more times, the determination in step S806 becomes “Yes”, and steps S807 and S808 are performed. , S809 may proceed in order. The contents of the process in that case are the same as in the case of (A2).

次に、図11を参照して、最長一致検索の具体例について説明する。図11のカップルドノードツリーは、“000111”、“010010”、“010011”、“011010”、“100010”、“100011”、“101100”、“101111”なる8つのインデックスキーを含む。図11と図2のカップルドノードツリーは同じ構造を有しているので、同じ参照符号を付した。ただし、ノード211fの弁別ビット位置231fの値と、ノード210hのインデックスキー250hの値と、ノード211hのインデックスキー251hの値は、図2とは異なる。   Next, a specific example of the longest match search will be described with reference to FIG. The coupled node tree of FIG. 11 includes eight index keys “000111”, “010010”, “010011”, “011010”, “100010”, “1000011”, “101100”, and “101111”. Since the coupled node trees of FIG. 11 and FIG. 2 have the same structure, the same reference numerals are assigned. However, the value of the discrimination bit position 231f of the node 211f, the value of the index key 250h of the node 210h, and the value of the index key 251h of the node 211h are different from those in FIG.

以下では最長一致検索キーとして“101010”が指定された場合について説明する。
図6のステップS601で“101010”が検索キーに設定され、ステップS602でルートノードが検索開始ノードに設定される。ステップS603から図4の処理が呼び出されると、探索経路スタック310には、配列番号220、(220a+1)、(221b+1)、(221f+1)が順に格納される。また、ステップS603で得られるインデックスキーは、配列番号(221f+1)の配列要素であるノード211hのインデックスキー251hに格納された“101111”である。図11では、このことをノード211hの横の「初期検索」で示した。
Hereinafter, a case where “101010” is designated as the longest match search key will be described.
In step S601 in FIG. 6, “101010” is set as the search key, and in step S602, the root node is set as the search start node. When the process of FIG. 4 is called from step S603, array numbers 220, (220a + 1), (221b + 1), and (221f + 1) are stored in the search path stack 310 in order. The index key obtained in step S603 is “101111” stored in the index key 251h of the node 211h that is the array element of the array element number (221f + 1). In FIG. 11, this is indicated by “initial search” next to the node 211h.

ステップS604で、“101111”なる値のインデックスキー251hと“101010”なる値の検索キーの差分ビット位置が求められ、その値3は0より大きいのでステップS605の判定は「いいえ」となる。そのため、ステップS606、すなわち図8の処理が実行される。ステップS802〜S806の繰り返しにより探索経路スタック310を遡り、配列番号(220a+1)が得られると、配列番号(220a+1)の配列要素に格納されたノード211bの弁別ビット位置231bが2であり、弁別ビット位置と差分ビット位置との関係は2<3なので、ステップS806で「はい」と判定される。よって、ステップS807でスタックポインタが1つ進められ、ステップS808で配列番号(221b+1)が取り出され、配列番号(221b+1)が最長一致ノードの配列番号に設定される。つまり、配列番号(221b+1)の配列要素に格納されたノード211fが最長一致ノードに設定される。   In step S604, the difference bit position between the index key 251h having a value of “101111” and the search key having a value of “101010” is obtained. Since the value 3 is greater than 0, the determination in step S605 is “no”. Therefore, step S606, that is, the process of FIG. 8 is executed. When the search path stack 310 is traced back by repeating steps S802 to S806 and the array element number (220a + 1) is obtained, the discrimination bit position 231b of the node 211b stored in the array element of the array element number (220a + 1) is 2, and the discrimination bit is Since the relationship between the position and the difference bit position is 2 <3, “Yes” is determined in step S806. Therefore, the stack pointer is advanced by 1 in step S807, the array element number (221b + 1) is extracted in step S808, and the array element number (221b + 1) is set as the array element number of the longest matching node. That is, the node 211f stored in the array element with the array element number (221b + 1) is set as the longest matching node.

ここで処理は図6に戻り、ステップS607でノード211fが検索開始ノードに設定され、ステップS608の処理、すなわち図5の最小値検索が行われる。図11のとおり、最長一致ノードに設定されたブランチノードであるノード211fの子孫のリーフノードは、ノード210hとノード211hの2つである。両ノードのインデックスキーの値は“101100”と“101111”である。いずれも、最長一致検索キー“101010”とは0〜2ビット目が一致し、3ビット目が不一致である。また、カップルドノードツリーに含まれる他の6つのインデックスキーは、いずれも、最長一致検索キー“101010”との差分ビット位置が3より小さい。ステップS608の処理により、“101100”と“101111”のうちの最小値である“101100”が選択され、図6の処理は終了する。   Here, the processing returns to FIG. 6. In step S607, the node 211f is set as the search start node, and the processing of step S608, that is, the minimum value search of FIG. 5 is performed. As shown in FIG. 11, there are two leaf nodes, the node 210h and the node 211h, which are descendants of the node 211f which is the branch node set as the longest matching node. The index key values of both nodes are “101100” and “101111”. In any case, the longest match search key “101010” matches 0th to 2nd bits and does not match 3rd bit. Further, the other six index keys included in the coupled node tree all have a difference bit position smaller than 3 with respect to the longest match search key “101010”. By the process of step S608, “101100” which is the minimum value among “101100” and “101111” is selected, and the process of FIG. 6 ends.

次に、カップルドノードツリーの最短一致検索の具体的な方法について図7、9、10、12を参照して説明する。
図7は、本発明の一実施形態における最短一致検索処理のフローチャートである。図7は、図6における「最長一致」を「最短一致」に変えた図である。
Next, a specific method of the shortest match search of the coupled node tree will be described with reference to FIGS.
FIG. 7 is a flowchart of the shortest match search process according to an embodiment of the present invention. FIG. 7 is a diagram in which “longest match” in FIG. 6 is changed to “shortest match”.

まず、ステップS701で最短一致検索キーを検索キーにし、ステップS702でルートノードを検索開始ノードに設定する。
次に、ステップS703において、ステップS701で設定された検索キーを用いて配列を検索し、インデックスキーを取得する。この検索は、図4に示したとおりである。ス
テップS702で検索開始ノードにルートノードが設定されているので、検索対象はカップルドノードツリー全体である。ステップS703の検索で探索経路スタック310に格納された内容は、後にステップS706で利用される。インデックスキーの取得後、処理はステップS704に進む。
First, in step S701, the shortest match search key is used as a search key, and in step S702, the root node is set as a search start node.
Next, in step S703, the array is searched using the search key set in step S701, and the index key is acquired. This search is as shown in FIG. Since the root node is set as the search start node in step S702, the search target is the entire coupled node tree. The contents stored in the search path stack 310 in the search in step S703 are used later in step S706. After obtaining the index key, the process proceeds to step S704.

ステップS704では、ステップS701で設定された検索キー、すなわち最短一致検索キーと、ステップS703で取得されたインデックスキーとの差分ビット位置を求める。   In step S704, the difference bit position between the search key set in step S701, that is, the shortest match search key, and the index key acquired in step S703 is obtained.

この処理の詳細は図10と合わせて既に述べたとおりである。ただし、ステップS704から図10の処理を呼び出す場合には、ステップS101で設定される比較キー1が最短一致検索キーであり、比較キー2がステップS703で取得されたインデックスキーである点が、最長一致検索の場合と異なる。   Details of this processing are as already described in conjunction with FIG. However, when the process of FIG. 10 is called from step S704, the longest point is that the comparison key 1 set in step S101 is the shortest match search key and the comparison key 2 is the index key acquired in step S703. Different from the case of matching search.

ステップS704の実行後、ステップS705において、ステップS704で求めた差分ビット位置が0か否かを判定する。
差分ビット位置が0のとき、判定は「はい」となり、最短一致検索処理を終了する。この場合、最短一致検索キーと、ステップS703で取得されたインデックスキーは、先頭の0ビット目が不一致である。また、カップルドノードツリーの構造から、カップルドノードツリーに含まれる他のすべてのインデックスキーも、最短一致検索キーと先頭の0ビット目が不一致である。したがって、「最短一致条件を満たすインデックスキーは存在しない」という検索結果が得られる。
After execution of step S704, in step S705, it is determined whether or not the difference bit position obtained in step S704 is zero.
When the difference bit position is 0, the determination is “yes” and the shortest match search process is terminated. In this case, the shortest matching search key and the index key acquired in step S703 do not match the leading 0th bit. Also, due to the coupled node tree structure, all the other index keys included in the coupled node tree also have a mismatch between the shortest match search key and the first 0th bit. Therefore, a search result “an index key that satisfies the shortest matching condition does not exist” is obtained.

差分ビット位置が0ではないとき、ステップS705の判定は「いいえ」となり、処理がステップS706に進む。この場合、カップルドノードツリー内に最短一致条件を満たすインデックスキーが少なくとも1つは存在する。しかし、ステップS705の段階では最短一致条件を満たすインデックスキーの存在が判明しただけなので、ステップS706では、具体的な最短一致ノードを取得する。なお、ある部分木に含まれるすべてのリーフノードのインデックスキーが最短一致条件を満たすとき、その部分木のルートノードを最短一致ノードと定義する。   When the difference bit position is not 0, the determination in step S705 is “No”, and the process proceeds to step S706. In this case, there is at least one index key satisfying the shortest matching condition in the coupled node tree. However, since the existence of an index key that satisfies the shortest matching condition is only found at the stage of step S705, a specific shortest matching node is acquired in step S706. When the index keys of all leaf nodes included in a certain subtree satisfy the shortest matching condition, the root node of the subtree is defined as the shortest matching node.

ステップS706では、ステップS703の検索によって配列309の配列番号が格納された探索経路スタック310を参照し、ステップS704で求めた差分ビット位置に基づいて、最短一致ノードを取得する。   In step S706, the search path stack 310 in which the array element number of the array 309 is stored by the search in step S703 is referred to, and the shortest matching node is acquired based on the difference bit position obtained in step S704.

最短一致ノードの取得後、次のステップS707において最短一致ノードを検索開始ノードに設定する。そして、その次のステップS708において、検索開始ノードより、図5に示した最小値検索処理を実行し、最短一致条件を満たすインデックスキーのうちの最小値を取得し、取得した最小値を最短一致検索の結果として出力して、最短一致検索処理を終了する。   After acquiring the shortest matching node, the shortest matching node is set as a search start node in the next step S707. Then, in the next step S708, the minimum value search process shown in FIG. 5 is executed from the search start node, the minimum value of the index keys satisfying the shortest match condition is acquired, and the acquired minimum value is the shortest match The result of the search is output and the shortest match search process is terminated.

なお、図6と同様に、ステップS707とS708は、実施形態に応じて様々に変形可能である。
次に、図7のステップS706で行われる最短一致ノードを取得する処理について図9を参照して説明する。図9の処理は、上記(b)の「最短一致条件」の定義にしたがった処理だが、図9の処理を理解しやすくするために、説明は(B1)〜(B4)の4つの場合に分けて行う。(B1)と(B2)は最短一致キーによる検索の結果、探索経路スタック上に少なくとも3つのノードの配列番号が格納されている場合であり、(B3)と(B4)はそれ以外の場合である。
As in FIG. 6, steps S707 and S708 can be variously modified depending on the embodiment.
Next, the process for acquiring the shortest matching node performed in step S706 of FIG. 7 will be described with reference to FIG. The process of FIG. 9 is a process according to the definition of the “shortest match condition” in (b) above, but in order to make the process of FIG. 9 easier to understand, the description will be made for the four cases (B1) to (B4). Do it separately. (B1) and (B2) are the cases where the array number of at least three nodes is stored on the search path stack as a result of the search using the shortest match key, and (B3) and (B4) are the other cases. is there.

(B1)ルートノードがブランチノードであり、ステップS703で取得されたインデックスキーを格納するリーフノードへのルートノードからの経路上には、ルートノード以外のブランチノードが少なくとも1つ存在し、ルートノードの弁別ビット位置をmとすると最短一致検索キーと0〜mビット目までの範囲が一致するインデックスキーが存在する場合
この場合、上記経路上には少なくとも3つのノードが存在する。探索経路スタック310には、ルートノード、ルートノードの子ノードであるブランチノード、そのブランチノードの子ノードの順で、配列番号が格納されている。上記(b)の定義より、この場合、ルートノードの子ノードであるブランチノードからリンクされ、探索経路スタック310に配列番号が格納されたノードと対をなすノードが最短一致ノードに該当する。(B1)の場合における図9の処理は、このノードを最短一致ノードに設定する処理である。
(B1) The root node is a branch node, and there is at least one branch node other than the root node on the path from the root node to the leaf node storing the index key acquired in step S703. When the discrimination bit position of m is m, the shortest matching search key and the index key having the same range from the 0th to mth bits exist. In this case, there are at least three nodes on the path. The search path stack 310 stores array element numbers in the order of a root node, a branch node that is a child node of the root node, and a child node of the branch node. From the definition of (b) above, in this case, the node that is linked from the branch node that is a child node of the root node and that is paired with the node whose array element number is stored in the search path stack 310 corresponds to the shortest matching node. The process of FIG. 9 in the case of (B1) is a process of setting this node as the shortest matching node.

まず、ステップS901で探索経路スタック310のスタックポインタを退避エリアに設定する。
続くステップS902〜S903はループを形成しており、1回以上繰り返し実行される。このループは、スタックポインタがルートノードの配列番号を指すまで探索経路スタック310を遡ることを表す。まず、ステップS902で、探索経路スタック310のスタックポインタを1つ戻す。続くステップS903で、探索経路スタック310のスタックポインタがルートノードの配列番号を指すか否かが判定される。スタックポインタがルートノードの配列番号を指している場合は判定が「はい」となってステップS904に進み、それ以外の場合は判定が「いいえ」となってステップS902に戻る。
First, in step S901, the stack pointer of the search path stack 310 is set in the save area.
Subsequent steps S902 to S903 form a loop and are repeatedly executed one or more times. This loop represents going up the search path stack 310 until the stack pointer points to the array element number of the root node. First, in step S902, the stack pointer of the search path stack 310 is returned by one. In subsequent step S903, it is determined whether or not the stack pointer of the search path stack 310 points to the array element number of the root node. If the stack pointer points to the array element number of the root node, the determination is “yes” and the process proceeds to step S904. Otherwise, the determination is “no” and the process returns to step S902.

ステップS904では、スタックポインタと退避エリアの値が比較される。ここで、ステップS904が実行されるのは、スタックポインタがルートノードの配列番号を指す場合のみである。つまり、ステップS904は、図9の処理の開始直前のスタックポインタがルートノードの配列番号を指すスタックポインタとどれほど離れているかを調べる処理であり、退避エリアの値とスタックポインタを比較し、その差に応じて処理を分岐させる処理である。   In step S904, the stack pointer is compared with the value in the save area. Here, step S904 is executed only when the stack pointer points to the array element number of the root node. That is, step S904 is a process for checking how far the stack pointer immediately before the start of the process of FIG. 9 is away from the stack pointer indicating the array element number of the root node. The process is branched according to the process.

(B1)の場合、上記のとおり探索経路スタック310には少なくとも3つのノードの配列番号が格納されているため、ステップS904の比較結果は必ず「差>2」となる。よって、処理は必ずステップS905に進む。   In the case of (B1), since the search path stack 310 stores the array numbers of at least three nodes as described above, the comparison result in step S904 is always “difference> 2.” Therefore, the process always proceeds to step S905.

ステップS905において、探索経路スタック310からスタックポインタの指す配列番号、すなわちルートノードの配列番号を取り出す。続くステップS906において、ステップS905で取り出した配列番号の指す配列要素を配列309からノードとして読み出す。次のステップS907では、ステップS906で読み出されたノード、すなわちルートノードから、弁別ビット位置を取り出す。   In step S905, the array element number indicated by the stack pointer, that is, the array element number of the root node is extracted from the search path stack 310. In subsequent step S906, the array element indicated by the array element number extracted in step S905 is read from array 309 as a node. In the next step S907, the discrimination bit position is extracted from the node read out in step S906, that is, the root node.

続くステップS908では、ステップS907で取り出された弁別ビット位置が、図10のステップS102で得た差分ビット位置よりも上位か否かが判定される。弁別ビット位置が差分ビット位置よりも上位の場合、判定は「はい」となってステップS909に進み、下位の場合、判定は「いいえ」となってステップS914に進む。   In subsequent step S908, it is determined whether or not the discrimination bit position extracted in step S907 is higher than the difference bit position obtained in step S102 of FIG. If the discrimination bit position is higher than the difference bit position, the determination is “yes” and the process proceeds to step S909. If the discrimination bit position is lower, the determination is “no” and the process proceeds to step S914.

(B1)の場合、ステップS908の判定は必ず「はい」になる。理由は次のとおりである。
図9の処理が実行されるのは差分ビット位置が0より大きいときのみなので、ステップS907で取り出されたルートノードの弁別ビット位置が0のときは必ずステップS908の判定が「はい」となる。
In the case of (B1), the determination in step S908 is always “Yes”. The reason is as follows.
Since the process of FIG. 9 is executed only when the difference bit position is greater than 0, the determination in step S908 is always “Yes” when the discrimination bit position of the root node extracted in step S907 is 0.

また、ステップS907で取り出されたルートノードの弁別ビット位置が0より大きい場合、ルートノードの弁別ビット位置をmとすると、カップルドノードツリーに含まれるすべてのインデックスキーは0〜(m−1)ビット目の範囲が同一である。また、(B1)の場合、最短一致検索キーとmビット目まで一致するインデックスキーが存在する。よって、カップルドノードツリーに含まれるすべてのインデックスキーは0〜(m−1)ビット目の範囲が最短一致検索キーと一致するので、弁別ビット位置mと差分ビット位置dとの関係は、m≦dである。よって必ずステップS908の判定が「はい」となる。   When the discrimination bit position of the root node extracted in step S907 is greater than 0, assuming that the discrimination bit position of the root node is m, all index keys included in the coupled node tree are 0 to (m−1). The bit range is the same. In the case of (B1), there is an index key that matches the shortest matching search key up to the m-th bit. Therefore, since all index keys included in the coupled node tree have a range of 0th to (m−1) th bits that matches the shortest match search key, the relationship between the discrimination bit position m and the difference bit position d is m ≦ d. Therefore, the determination in step S908 is always “Yes”.

ステップS908で「はい」と判定すると、ステップS909では探索経路スタック310のスタックポインタを2つ進める。
続くステップS910で探索経路スタック310からスタックポインタの指す配列番号を取り出す。
If “YES” is determined in step S908, the stack pointer of the search path stack 310 is advanced by two in step S909.
In subsequent step S910, the array element number pointed to by the stack pointer is extracted from the search path stack 310.

次のステップS911では、ステップS910で得た配列番号と対をなす配列番号を得る。
ステップS911の実行後、処理はステップS914に進み、ステップS911で得られた配列番号を最短一致ノードの配列番号に設定する。そして、図9の処理が終了する。
In the next step S911, the sequence number that is paired with the sequence number obtained in step S910 is obtained.
After execution of step S911, the process proceeds to step S914, and the array element number obtained in step S911 is set as the array element number of the shortest matching node. Then, the process of FIG. 9 ends.

(B2)ルートノードがブランチノードであり、ステップS703で取得されたインデックスキーを格納するリーフノードへのルートノードからの経路上には、ルートノード以外のブランチノードが少なくとも1つ存在し、ルートノードの弁別ビット位置をmとすると最短一致検索キーと0〜mビット目までの範囲が一致するインデックスキーが存在しない場合
この場合、(B1)と違うのは、最短一致検索キーと0〜mビット目までの範囲が一致するインデックスキーが存在しない点のみである。よって、ステップS907までの処理は(B1)の場合とまったく同じである。
(B2) The root node is a branch node, and there is at least one branch node other than the root node on the path from the root node to the leaf node storing the index key acquired in step S703. When the discrimination bit position of m is m, there is no index key that matches the shortest match search key and the range from the 0th to mth bits. In this case, the difference from (B1) is that the shortest match search key and 0 to m bits It is only a point that there is no index key that matches the range up to the eye. Therefore, the processing up to step S907 is exactly the same as in the case of (B1).

ステップS907の次のステップS908において、(B2)の場合は「いいえ」と判定され、ステップS914に移行する。この場合、配列番号はステップS905で取り出された配列番号、すなわちルートノードの配列番号である。よって、ステップS914ではルートノードの配列番号を最短一致ノードの配列番号に設定し、処理を終了する。   In step S908 following step S907, it is determined as “No” in the case of (B2), and the process proceeds to step S914. In this case, the array element number is the array element number extracted in step S905, that is, the array element number of the root node. Therefore, in step S914, the array element number of the root node is set to the array element number of the shortest matching node, and the process ends.

(B3)ルートノードがブランチノードであり、ステップS703で取得されたインデックスキーを格納するリーフノードがルートノードからリンクされている場合
この場合、上記経路上には2つのノードのみが存在する。つまり、探索経路スタック310は、ルートノードの配列番号とインデックスキーを格納するリーフノードの配列番号が格納された状態である。
(B3) When the root node is a branch node and the leaf node storing the index key acquired in step S703 is linked from the root node. In this case, there are only two nodes on the path. That is, the search path stack 310 is in a state in which the array number of the root node and the array number of the leaf node that stores the index key are stored.

(B3)の場合も、ステップS901〜S903は(B1)の場合と同様である。しかし、ステップS903の次のステップS904における比較結果が(B1)の場合とは異なる。(B3)の場合、ステップS901で退避エリアに設定された値とスタックポインタが比較され、「差=2」という結果が得られる。よって、処理は必ずステップS912に進む。   Also in the case of (B3), steps S901 to S903 are the same as in the case of (B1). However, the comparison result in step S904 subsequent to step S903 is different from that in the case of (B1). In the case of (B3), the value set in the save area in step S901 is compared with the stack pointer, and a result of “difference = 2” is obtained. Therefore, the process always proceeds to step S912.

ステップS912では探索経路スタック310のスタックポインタを1つ進める。次のステップS913で探索経路スタック310からスタックポインタの指す配列番号を取り出す。つまり、リーフノードの配列番号を取り出す。そして処理はステップS914に進み、ステップS913で取り出されたリーフノードの配列番号を最短一致ノードの配列番号に設定し、処理を終了する。   In step S912, the stack pointer of the search path stack 310 is advanced by one. In the next step S913, the array element number pointed to by the stack pointer is extracted from the search path stack 310. That is, the array number of the leaf node is extracted. Then, the process proceeds to step S914, the array element number of the leaf node extracted in step S913 is set as the array element number of the shortest matching node, and the process ends.

(B4)ルートノードがリーフノードの場合
この場合、図7のステップS703で取得されたインデックスキーはルートノードに格納されたインデックスキーである。よって、最短一致検索キーとインデックスキーとの差分ビット位置が0より大きければ、インデックスキーは最短一致条件を満たし、ルートノードは最短一致ノードに該当する。また、図7のステップS705から明らかなとおり、図9の処理が行われるのは差分ビット位置が0より大きい場合のみなので、(B4)の場合、図9の処理によって必ずルートノードが最短一致ノードに設定される。具体的には次のとおりである。
(B4) When the root node is a leaf node In this case, the index key acquired in step S703 in FIG. 7 is the index key stored in the root node. Therefore, if the difference bit position between the shortest match search key and the index key is greater than 0, the index key satisfies the shortest match condition, and the root node corresponds to the shortest match node. Further, as apparent from step S705 of FIG. 7, the process of FIG. 9 is performed only when the difference bit position is greater than 0. In the case of (B4), the root node is always the shortest matching node by the process of FIG. Set to Specifically, it is as follows.

ステップS901は(B1)の場合と同様である。
続くステップS902において、スタックポインタの値を1減らす。また、(B4)の場合、探索経路スタック310に格納されている配列309の配列番号はルートノードの配列番号のみである。したがって、ステップS902の実行後、スタックポインタが指す配列番号は、すなわち、ルートノードの配列番号である。この状態で処理はステップS903に移行する。
Step S901 is the same as in the case of (B1).
In subsequent step S902, the value of the stack pointer is decreased by one. In the case of (B4), the array element number of the array 309 stored in the search path stack 310 is only the array element number of the root node. Therefore, after execution of step S902, the array element number pointed to by the stack pointer is the array element number of the root node. In this state, the process proceeds to step S903.

ステップS903では、探索経路スタック310のスタックポインタがルートノードの配列番号を指しているか否かが判定される。(B4)の場合は、上記のとおりであるから、判定の結果は「はい」となり、ステップS904に移行する。   In step S903, it is determined whether or not the stack pointer of the search path stack 310 points to the array element number of the root node. In the case of (B4), since it is as described above, the determination result is “yes”, and the process proceeds to step S904.

ステップS904では、スタックポインタと退避エリアの値を比較する。(B4)の場合、「差=1」という結果が得られ、この結果にしたがって処理はステップS913に移行する。   In step S904, the stack pointer is compared with the value in the save area. In the case of (B4), the result “difference = 1” is obtained, and the process proceeds to step S913 according to this result.

ステップS913では、探索経路スタック310からスタックポインタの指す配列番号、つまりルートノードの配列番号を取り出す。そして、続くステップS914では、ルートノードの配列番号を、最短一致ノードの配列番号に設定し、図9の処理が終了する。   In step S913, the array element number indicated by the stack pointer, that is, the array element number of the root node is extracted from the search path stack 310. In subsequent step S914, the array element number of the root node is set to the array element number of the shortest matching node, and the process of FIG. 9 ends.

次に、図12を参照して、最短一致検索の具体例について説明する。図12のカップルドノードツリーは図11のものと全く同一である。
以下では最短一致検索キーとして“101010”が指定された場合について説明する。
Next, a specific example of the shortest match search will be described with reference to FIG. The coupled node tree of FIG. 12 is exactly the same as that of FIG.
Hereinafter, a case where “101010” is designated as the shortest match search key will be described.

図7のステップS701〜S705の処理は、図11の例と全く同様なので説明を省略する。ステップS705で「いいえ」と判定されてステップS706、すなわち図9の処理が実行される。まず、ステップS901でスタックポインタの値を退避エリアに設定する。次に、ステップS902〜S903の繰り返しにより探索経路スタック310を遡り、配列番号220が得られたらステップS903の判定が「はい」となってステップS904に進む。ここでスタックポインタと退避エリアの値が比較され、その結果ステップS905に進み、ステップS905〜S907によってルートノード210aの弁別ビット位置230aが取り出される。弁別ビット位置230aの値は0なので、ステップS908の判定は「はい」となり、ステップS909でスタックポインタを2つ進める。その結果、ステップS910では配列番号(221b+1)が取り出され、ステップS911ではそれと対の配列番号221bが取得される。よって、ステップS914では配列番号221bが最短一致ノードの配列番号に設定される。   The processing in steps S701 to S705 in FIG. 7 is exactly the same as the example in FIG. In step S705, “NO” is determined, and step S706, that is, the process of FIG. 9 is executed. First, in step S901, the value of the stack pointer is set in the save area. Next, the search path stack 310 is traced back by repeating steps S902 to S903, and when the array element number 220 is obtained, the determination in step S903 becomes “Yes” and the process proceeds to step S904. Here, the stack pointer and the value of the save area are compared, and as a result, the process proceeds to step S905, and the discrimination bit position 230a of the root node 210a is extracted by steps S905 to S907. Since the value of the discrimination bit position 230a is 0, the determination in step S908 is “Yes”, and the stack pointer is advanced by 2 in step S909. As a result, in step S910, the array element number (221b + 1) is extracted, and in step S911, the array element number 221b paired with it is acquired. Therefore, in step S914, the array element number 221b is set as the array element number of the shortest matching node.

ここで処理は図7に戻り、ステップS707で最短一致ノードであるノード210fが検索開始ノードに設定され、ステップS708の処理、すなわち図5の最小値検索が行われる。図12のとおり、最短一致ノードに設定されたブランチノードであるノード210fの子孫のリーフノードは、ノード210gとノード211gである。両ノードのインデ
ックスキーの値は“100011”と“100010”である。いずれも、最短一致検索キー“101010”とは0〜1ビット目が一致し、2ビット目が一致しない。
Here, the processing returns to FIG. 7. In step S707, the node 210f which is the shortest matching node is set as the search start node, and the processing of step S708, that is, the minimum value search of FIG. 5 is performed. As shown in FIG. 12, the leaf nodes that are descendants of the node 210f that is the branch node set as the shortest matching node are the node 210g and the node 211g. The index key values of both nodes are “1000011” and “100010”. In any case, the 0th to 1st bits match with the shortest match search key “101010”, and the second bit does not match.

ルートノードからの経路上のブランチノードにおける弁別ビット位置と対比すると、ルートノード210aの弁別ビット位置230aは0、次のノード211bの弁別ビット位置231bは2である。よって、0〜0ビット目の範囲ではこの2つのインデックスキーは最短一致検索キーと一致し、1〜2ビット目の範囲では不一致のビットが存在する。   Compared with the discrimination bit position in the branch node on the route from the root node, the discrimination bit position 230a of the root node 210a is 0, and the discrimination bit position 231b of the next node 211b is 2. Therefore, the two index keys match the shortest match search key in the range of the 0th to 0th bits, and there are mismatched bits in the range of the 1st to 2nd bits.

一方、カップルドノードツリーに含まれる他のインデックスキーは、部分一致条件を満足しないインデックスキー250c、251d、250e、251eと、0〜2ビット目が一致し、3ビット目が一致しないインデックスキー250hと251hである。よって、最短一致検索により、最短一致検索キーと部分一致するインデックスキーのうち、一致部分の短いものが優先的に検索されることが分かる。   On the other hand, other index keys included in the coupled node tree are index keys 250c, 251d, 250e, and 251e that do not satisfy the partial matching condition, and index keys 250h that match the 0th to 2nd bits and the 3rd bit do not match. And 251h. Therefore, it can be seen that the shortest matching search preferentially searches for the shortest matching portion of the index keys that partially match the shortest matching search key.

上記実施形態では、“100011”と“100010”のうちの最小値である“100010”がステップS708により選択される。
なお、本発明の実施形態は上述のものに限られず、様々な変形が可能である。
In the above embodiment, “100010”, which is the minimum value of “100011” and “100010”, is selected in step S708.
The embodiment of the present invention is not limited to the above-described embodiment, and various modifications can be made.

上記の実施形態では、最左という物理的なビット位置が最上位という論理的なビット位置に対応していたが、別の実施形態では、別の対応関係であってもよく、例えば、最右ビットを最上位ビットとしてもよい。図8のステップS806や図9のステップS908における判定は、論理的なビット位置にしたがった判定である。   In the above embodiment, the physical bit position of the leftmost corresponds to the logical bit position of the most significant, but in another embodiment, another correspondence relationship may be used, for example, the rightmost The bit may be the most significant bit. The determination in step S806 in FIG. 8 or step S908 in FIG. 9 is a determination according to a logical bit position.

また、上記の最長一致検索では、最長一致条件を満たすインデックスキーのうちの最小値を結果として取得している。しかし、様々な実施形態に応じた適切なものを検索結果として得るように、上記の最長一致検索処理を変形することが可能である。例えば、最長一致条件を満たすインデックスキーのうちの最大値を、最長一致検索処理の結果として取得してもよい。   In the above longest match search, the minimum value of the index keys satisfying the longest match condition is acquired as a result. However, it is possible to modify the above longest match search process so as to obtain a search result suitable for various embodiments. For example, the maximum value of the index keys that satisfy the longest matching condition may be acquired as a result of the longest matching search process.

同様に、最短一致検索も、検索結果として何を取得するかは実施形態に応じて様々である。
図9のステップS902〜S903のループでは探索経路スタック310を1つずつ遡っているが、例えば、スタックポインタにルートノードの配列番号を指すスタックポインタを代入するステップでこのループを置き換えてもよい。
Similarly, what is acquired as the search result for the shortest match search also varies depending on the embodiment.
In the loop of steps S902 to S903 in FIG. 9, the search path stack 310 is traced back one by one. However, for example, this loop may be replaced with a step of substituting the stack pointer indicating the array element number of the root node for the stack pointer.

また、最短一致検索の定義の細部は実施形態によって様々に変形可能である。図7のステップS704で得られた差分ビット位置が、ルートノードとその直下のブランチノードの弁別ビット位置の間の値である場合、図9の処理を変形して、ルートノードの直下のブランチノードを最短一致ノードに設定してもよい。   Further, details of the definition of the shortest match search can be variously modified according to the embodiment. When the difference bit position obtained in step S704 of FIG. 7 is a value between the discrimination bit position of the root node and the branch node immediately below the root node, the process of FIG. 9 is modified so that the branch node immediately below the root node. May be set as the shortest matching node.

また、ルートノードの弁別ビット位置が、0より大きく、ステップS704で得られた差分ビット位置より小さい場合、別の変形も可能である。この場合、最短一致検索キーとの差分ビット位置が最も上位なのは、ルートノードからリンクされたノード対のうち、ステップS703の検索で探索経路スタック310に配列番号が格納されなかった方のノードをルートノードとする部分木に含まれるリーフノードに格納されたインデックスキーである。よって、ステップS908の判定が「はい」の場合、ルートノードの弁別ビット位置の値が0より大きければ、ステップS909でスタックポインタを1つだけ進めるように図9の処理を変形してもよい。   Further, when the discrimination bit position of the root node is larger than 0 and smaller than the difference bit position obtained in step S704, another modification is possible. In this case, the highest difference bit position with the shortest match search key is the root of the node pair that is linked from the root node and whose array number is not stored in the search path stack 310 in the search in step S703. An index key stored in a leaf node included in a subtree as a node. Therefore, when the determination in step S908 is “Yes”, if the value of the discrimination bit position of the root node is greater than 0, the process of FIG. 9 may be modified to advance the stack pointer by one in step S909.

また、ステップS704で得られた差分ビット位置がルートノードの弁別ビット位置の
値よりも小さいとき、図9の処理を変形し、ルートノードを最短一致ノードに設定してもよい。
Further, when the difference bit position obtained in step S704 is smaller than the value of the discrimination bit position of the root node, the processing of FIG. 9 may be modified to set the root node to the shortest matching node.

また、ルートノードの弁別ビット位置の値が0より大きく、ステップS704で得た差分ビット位置の値よりも小さければ、ステップS913で取り出した配列番号と対になる配列番号を最短一致ノードの配列番号として設定してもよい。   If the value of the discrimination bit position of the root node is larger than 0 and smaller than the value of the difference bit position obtained in step S704, the array element number paired with the array element number extracted in step S913 is set to the array element number of the shortest matching node. May be set as

なお、当然ながら、上記で説明した最長一致/最短一致検索の方法は、プログラムによってコンピュータに実行させることができる。   Of course, the longest match / shortest match search method described above can be executed by a computer by a program.

配列に格納されたカップルドノードツリーの構成例を説明する図である。It is a figure explaining the structural example of the coupled node tree stored in the arrangement | sequence. カップルドノードツリーのツリー構造を概念的に示す図である。It is a figure which shows notionally the tree structure of a coupled node tree. 本発明を実施するためのハードウェア構成例を説明する図である。It is a figure explaining the hardware structural example for implementing this invention. ビット列検索の基本動作を示すフローチャートである。It is a flowchart which shows the basic operation | movement of a bit string search. カップルドノードツリーに格納されたインデックスキーの最小値を求める処理を示すフローチャートである。It is a flowchart which shows the process which calculates | requires the minimum value of the index key stored in the coupled node tree. 最長一致検索処理を示すフローチャートである。It is a flowchart which shows the longest match search process. 最短一致検索処理を示すフローチャートである。It is a flowchart which shows the shortest match search process. 最長一致ノードを取得する処理を示すフローチャートである。It is a flowchart which shows the process which acquires the longest matching node. 最短一致ノードを取得する処理を示すフローチャートである。It is a flowchart which shows the process which acquires the shortest matching node. 差分ビット位置を取得する処理を示すフローチャートである。It is a flowchart which shows the process which acquires a difference bit position. 最長一致検索の一例をカップルドノードツリーにより説明する図である。It is a figure explaining an example of the longest match search by a coupled node tree. 最短一致検索の一例をカップルドノードツリーにより説明する図である。It is a figure explaining an example of the shortest match search by a coupled node tree. 従来の検索で用いられるパトリシアツリーの一例を示す図である。It is a figure which shows an example of the Patricia tree used by the conventional search.

符号の説明Explanation of symbols

10、20、30 配列番号
100 配列
101 ノード
102、114、117、124、126、260a〜260h、261b〜261h
ノード種別
103、115、230a〜230f、231b〜231f 弁別ビット位置
104、116、220、220a〜220f、221b〜221f 代表ノード番号
111、121、201a〜201h ノード対
112、122、210a〜210h ノード[0]、代表ノード
113、123、211b〜211h ノード[1]、代表ノードと対をなすノード
118、125、126、250c〜250h、251d〜251h インデックスキー
301 データ処理装置
302 中央処理装置
303 キャッシュメモリ
304 バス
305 主記憶装置
306 外部記憶装置
307 通信装置
308 データ格納装置
309 配列
310 探索経路スタック
1730a〜1730h 検査ビット位置
1740a〜1740f 左リンク
1741a〜1741f 右リンク
1750a〜1750h インデックスキー
10, 20, 30 SEQ ID NO: 100 Array 101 Node 102, 114, 117, 124, 126, 260a-260h, 261b-261h
Node type 103, 115, 230a to 230f, 231b to 231f Discrimination bit position 104, 116, 220, 220a to 220f, 221b to 221f Representative node number 111, 121, 201a to 201h Node pair 112, 122, 210a to 210h Node [ 0], representative nodes 113, 123, 211b to 211h node [1], nodes 118, 125, 126, 250c to 250h, 251d to 251h paired with representative nodes Index key 301 data processing device 302 central processing device 303 cache memory 304 Bus 305 Main storage device 306 External storage device 307 Communication device 308 Data storage device 309 Array 310 Search path stack 1730a-1730h Check bit position 1740a-1740f Left link 1741a to 1741f Right link 1750a to 1750h Index key

Claims (9)

ルートノードと、隣接した記憶領域に配置されるブランチノードとリーフノードまたはブランチノード同士またはリーフノード同士のノード対、からなるビット列検索に用いるツリーであって、
前記ルートノードは、ツリーの始点を表すノードであって、該ツリーのノードが1つのときは前記リーフノード、ツリーのノードが2つ以上のときは前記ブランチノードであり、
前記ブランチノードは、ビット列検索を行う検索キーの弁別ビット位置とリンク先のノード対の一方のノードである代表ノードの位置を示す位置情報を含み、前記リーフノードは検索対象のビット列からなるインデックスキーを含み、
前記ツリーの任意のノードを検索開始ノードとして、前記ブランチノードにおいて該ブランチノードに含まれる弁別ビット位置の検索キーのビット値に応じてリンク先のノード対の代表ノードかあるいはそれと隣接した記憶領域に配置されたノードにリンクすることを順次前記リーフノードに至るまで繰り返すことにより、前記リーフノードに格納されたインデックスキーを、前記検索開始ノードをルートノードとする前記ツリーの任意の部分木の前記検索キーによる検索の結果である検索結果キーとするように構成されたカップルドノードツリーを用いた最長一致検索方法であって、
前記カップルドノードツリーの前記ルートノードを前記検索開始ノードとし、指定された最長一致検索キーを前記検索キーとして、前記ルートノードからの経路を記憶しながら前記検索を行って前記検索結果キーを取得する検索ステップと、
前記最長一致検索キーと前記検索結果キーのビット列を比較して、ビット値が一致しない不一致ビットの位置のうち最も上位の位置である差分ビット位置を取得する差分ビット位置取得ステップと、
前記差分ビット位置がビット列の最上位以外の位置のとき、記憶された前記経路を参照して最長一致ノードを設定する最長一致ノード設定ステップであって、
前記ルートノードが前記リーフノードの場合または前記ルートノードが前記ブランチノードであり該ルートノードの前記弁別ビット位置が前記差分ビット位置よりも下位の位置の場合は、前記ルートノードを前記最長一致ノードとして設定し、
その他の場合は、前記経路上のノードであって前記弁別ビット位置が前記差分ビット位置よりも上位にある前記ブランチノードのうち前記弁別ビット位置が最下位の前記ブランチノードの次に前記検索ステップにおいて記憶された前記ブランチノードまたは前記リーフノードを前記最長一致ノードとして取得する最長一致ノード取得ステップと、
を備えることを特徴とする最長一致検索方法。
A tree used for a bit string search consisting of a root node and a branch node and a leaf node or a node pair between branch nodes or leaf nodes arranged in an adjacent storage area,
The root node is a node representing a starting point of a tree, and when the tree has one node, the leaf node is used. When the tree has two or more nodes, the root node is the branch node.
The branch node includes position information indicating a discrimination bit position of a search key for performing a bit string search and a representative node that is one node of a link destination node pair, and the leaf node is an index key including a bit string to be searched Including
An arbitrary node of the tree is set as a search start node, and in the branch node, in the storage node adjacent to the representative node of the link destination node pair or in accordance with the bit value of the search key at the discrimination bit position included in the branch node The search for an arbitrary subtree of the tree with the index key stored in the leaf node as the root node, using the index key stored in the leaf node by sequentially linking to the arranged nodes until reaching the leaf node A longest match search method using a coupled node tree configured to be a search result key that is a search result by key,
The search result key is obtained by performing the search while storing a route from the root node using the root node of the coupled node tree as the search start node and the designated longest match search key as the search key. A search step to
A difference bit position acquisition step of comparing the bit string of the longest match search key and the search result key and acquiring a difference bit position that is the highest position among the positions of mismatch bits where the bit values do not match,
A longest match node setting step of setting a longest match node with reference to the stored path when the difference bit position is a position other than the highest bit of a bit string,
When the root node is the leaf node or when the root node is the branch node and the discrimination bit position of the root node is a position lower than the difference bit position, the root node is set as the longest matching node. Set,
In other cases, in the search step next to the branch node having the lowest discrimination bit position among the branch nodes that are nodes on the path and the discrimination bit position is higher than the difference bit position. A longest match node obtaining step of obtaining the stored branch node or the leaf node as the longest match node;
A longest match search method comprising:
前記最長一致ノードをルートノードとする前記カップルドノードツリーの部分木に含まれる前記リーフノードを選択し、選択した該リーフノードに含まれるインデックスキーを取得するインデックスキー取得ステップをさらに備えることを特徴とする請求項1に記載の最長一致検索方法。   The method further comprises an index key acquisition step of selecting the leaf node included in a subtree of the coupled node tree having the longest matching node as a root node, and acquiring an index key included in the selected leaf node. The longest match search method according to claim 1. 前記カップルドノードツリーは、配列に記憶され、前記位置情報は、該位置情報に対応する前記代表ノードが格納された前記配列の配列要素の配列番号であることを特徴とする請求項1に記載の最長一致検索方法。   The coupled node tree is stored in an array, and the position information is an array element number of an array element of the array in which the representative node corresponding to the position information is stored. The longest match search method. 前記検索ステップにおいて、前記経路上のノードの格納された前記配列要素の前記配列番号が順次スタックに保持されていくことにより、前記経路が記憶されることを特徴とする請求項3に記載の最長一致検索方法。   4. The longest path according to claim 3, wherein in the search step, the path is stored by sequentially holding the array element numbers of the array elements in which nodes on the path are stored in a stack. Match search method. ルートノードと、隣接した記憶領域に配置されるブランチノードとリーフノードまたはブランチノード同士またはリーフノード同士のノード対、からなるビット列検索に用いる
ツリーであって、
前記ルートノードは、ツリーの始点を表すノードであって、該ツリーのノードが1つのときは前記リーフノード、ツリーのノードが2つ以上のときは前記ブランチノードであり、
前記ブランチノードは、ビット列検索を行う検索キーの弁別ビット位置とリンク先のノード対の一方のノードである代表ノードの位置を示す位置情報を含み、前記リーフノードは検索対象のビット列からなるインデックスキーを含み、
前記ツリーの任意のノードを検索開始ノードとして、前記ブランチノードにおいて該ブランチノードに含まれる弁別ビット位置の検索キーのビット値に応じてリンク先のノード対の代表ノードかあるいはそれと隣接した記憶領域に配置されたノードにリンクすることを順次前記リーフノードに至るまで繰り返すことにより、前記リーフノードに格納されたインデックスキーを、前記検索開始ノードをルートノードとする前記ツリーの任意の部分木の前記検索キーによる検索の結果である検索結果キーとするように構成されたカップルドノードツリーを用いた最短一致検索方法であって、
前記カップルドノードツリーの前記ルートノードを前記検索開始ノードとし、指定された最短一致検索キーを前記検索キーとして、前記ルートノードからの経路を記憶しながら前記検索を行って前記検索結果キーを取得する検索ステップと、
前記最短一致検索キーと前記検索結果キーのビット列を比較して、ビット値が一致しない不一致ビットの位置のうち最も上位の位置である差分ビット位置を取得する差分ビット位置取得ステップと、
前記差分ビット位置がビット列の最上位以外の位置のとき、記憶された前記経路を参照して最短一致ノードを設定する最短一致ノード設定ステップであって、
前記経路が、前記ルートノードと、該ルートノードのリンク先の前記ノード対の一方の前記ブランチノードである第一のノードとを含み、前記ルートノードの前記弁別ビット位置が前記差分ビット位置よりも上位の位置の場合は、前記第一のノードのリンク先の前記ノード対のうち、前記経路に記憶されていない方のノードである第二のノードを前記最短一致ノードとして取得する最短一致ノード取得ステップと、
を備えることを特徴とする最短一致検索方法。
A tree used for a bit string search consisting of a root node and a branch node and a leaf node or a node pair between branch nodes or leaf nodes arranged in an adjacent storage area,
The root node is a node representing a starting point of a tree, and when the tree has one node, the leaf node is used. When the tree has two or more nodes, the root node is the branch node.
The branch node includes position information indicating a discrimination bit position of a search key for performing a bit string search and a representative node that is one node of a link destination node pair, and the leaf node is an index key including a bit string to be searched Including
An arbitrary node of the tree is set as a search start node, and in the branch node, in the storage node adjacent to the representative node of the link destination node pair or in accordance with the bit value of the search key at the discrimination bit position included in the branch node The search for an arbitrary subtree of the tree with the index key stored in the leaf node as the root node, using the index key stored in the leaf node by sequentially linking to the arranged nodes until reaching the leaf node A shortest match search method using a coupled node tree configured to be a search result key that is a result of a search by key,
Using the root node of the coupled node tree as the search start node and the designated shortest match search key as the search key, performing the search while storing a route from the root node to obtain the search result key A search step to
A difference bit position acquisition step of comparing the bit string of the shortest match search key and the search result key to acquire a difference bit position that is the highest position among the positions of mismatch bits where the bit values do not match,
A shortest match node setting step of setting a shortest match node with reference to the stored path when the difference bit position is a position other than the highest bit of a bit string,
The path includes the root node and a first node that is one of the branch nodes of the node pair to which the root node is linked, and the discrimination bit position of the root node is greater than the difference bit position. In the case of an upper position, the shortest matching node acquisition that acquires, as the shortest matching node, the second node that is the node that is not stored in the route among the node pairs linked to the first node Steps,
A shortest match search method comprising:
前記最短一致ノードをルートノードとする前記カップルドノードツリーの部分木に含まれる前記リーフノードを選択し、選択した該リーフノードに含まれるインデックスキーを取得するインデックスキー取得ステップをさらに備えることを特徴とする請求項5に記載の最短一致検索方法。   The method further comprises an index key acquisition step of selecting the leaf node included in a subtree of the coupled node tree having the shortest matching node as a root node, and acquiring an index key included in the selected leaf node. The shortest match search method according to claim 5. 前記カップルドノードツリーは、配列に記憶され、前記位置情報は、該位置情報に対応する前記代表ノードが格納された前記配列の配列要素の配列番号であることを特徴とする請求項5に記載の最短一致検索方法。   6. The coupled node tree is stored in an array, and the position information is an array element number of an array element of the array in which the representative node corresponding to the position information is stored. The shortest match search method. 前記検索ステップにおいて、前記経路上のノードの格納された前記配列要素の前記配列番号が順次スタックに保持されていくことにより、前記経路が記憶されることを特徴とする請求項7に記載の最短一致検索方法。   8. The shortest path according to claim 7, wherein in the search step, the path is stored by sequentially holding the array element numbers of the array elements in which nodes on the path are stored in a stack. Match search method. 請求項1〜4のいずれか1項に記載の最長一致検索方法または請求項5〜8のいずれか1項に記載の最短一致検索方法をコンピュータに実行させるためのプログラム。   The program for making a computer perform the longest match search method of any one of Claims 1-4, or the shortest match search method of any one of Claims 5-8.
JP2007132289A 2007-04-19 2007-05-18 Coupled node tree longest match / shortest match search device, search method and program Expired - Fee Related JP4514771B2 (en)

Priority Applications (6)

Application Number Priority Date Filing Date Title
JP2007132289A JP4514771B2 (en) 2007-05-18 2007-05-18 Coupled node tree longest match / shortest match search device, search method and program
EP08738589.4A EP2149845B1 (en) 2007-04-19 2008-04-14 Coupled node tree backup/restore apparatus, backup/restore method, and program
PCT/JP2008/000983 WO2008132806A1 (en) 2007-04-19 2008-04-14 Coupled node tree save/restore method, longest consistence/shortest consistence retrieval method, bit retrieval method and memory medium
CN2008800122779A CN101657818B (en) 2007-04-19 2008-04-14 Coupled node tree save/restore method, longest consistence/shortest consistence retrieval method, bit retrieval method and memory medium
TW097114278A TW200846955A (en) 2007-04-19 2008-04-18 Coupled node tree save/restore method, longest consistence/shortest consistence retrieval method, bit retrieval method and memory medium
US12/588,523 US8214405B2 (en) 2007-05-18 2009-10-19 Longest-match/shortest-match search apparatus, search method, and program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2007132289A JP4514771B2 (en) 2007-05-18 2007-05-18 Coupled node tree longest match / shortest match search device, search method and program

Publications (3)

Publication Number Publication Date
JP2008287533A true JP2008287533A (en) 2008-11-27
JP2008287533A5 JP2008287533A5 (en) 2010-03-11
JP4514771B2 JP4514771B2 (en) 2010-07-28

Family

ID=40147188

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2007132289A Expired - Fee Related JP4514771B2 (en) 2007-04-19 2007-05-18 Coupled node tree longest match / shortest match search device, search method and program

Country Status (2)

Country Link
US (1) US8214405B2 (en)
JP (1) JP4514771B2 (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2012090763A1 (en) * 2010-12-28 2012-07-05 株式会社エスグランツ Code string search device, search method, and program
CN103544191A (en) * 2012-07-17 2014-01-29 人人游戏网络科技发展(上海)有限公司 Method and device for reading cache data
CN108616403A (en) * 2018-05-09 2018-10-02 马鞍山优途网络科技有限公司 a kind of resource management system based on cloud computing
CN109783206A (en) * 2019-01-04 2019-05-21 智恒科技股份有限公司 One kind is for describing the integrally-built method of big data task flow

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8429526B2 (en) * 2006-04-10 2013-04-23 Oracle International Corporation Efficient evaluation for diff of XML documents
US8527546B2 (en) 2010-11-25 2013-09-03 International Business Machines Corporation Generating a checkpoint image for use with an in-memory database
US9155320B2 (en) 2011-07-06 2015-10-13 International Business Machines Corporation Prefix-based leaf node storage for database system
KR101341507B1 (en) * 2012-04-13 2013-12-13 연세대학교 산학협력단 Modified searching method and apparatus for b+ tree
EP2945071B1 (en) * 2013-01-11 2020-08-26 NEC Corporation Index generating device and method, and search device and search method
US9817852B2 (en) * 2014-08-28 2017-11-14 Samsung Electronics Co., Ltd. Electronic system with version control mechanism and method of operation thereof
CN105817029B (en) * 2016-03-14 2019-09-03 安徽大学 Mixed search algorithm based on road draw in chess type in six sub- chess game playing systems
KR102195836B1 (en) * 2019-02-07 2020-12-28 주식회사 티맥스티베로 Method for managing index
US20230195705A1 (en) * 2021-12-20 2023-06-22 Sap Se Branching for tree structure in database system

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2001357070A (en) * 2000-06-13 2001-12-26 Nec Corp Method and device for retrieving information

Family Cites Families (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP3887867B2 (en) * 1997-02-26 2007-02-28 株式会社日立製作所 How to register structured documents
US6029170A (en) * 1997-11-25 2000-02-22 International Business Machines Corporation Hybrid tree array data structure and method
JP3368237B2 (en) * 1999-04-14 2003-01-20 キヤノン株式会社 Code processing method, terminal device, and storage medium
US6662184B1 (en) * 1999-09-23 2003-12-09 International Business Machines Corporation Lock-free wild card search data structure and method
US6675163B1 (en) * 2000-04-06 2004-01-06 International Business Machines Corporation Full match (FM) search algorithm implementation for a network processor
US6594655B2 (en) * 2001-01-04 2003-07-15 Ezchip Technologies Ltd. Wildcards in radix- search tree structures
US6785699B1 (en) * 2001-05-04 2004-08-31 Lsi Logic Corporation Prefix comparator
JP3691018B2 (en) 2002-01-31 2005-08-31 日本電信電話株式会社 Longest match search circuit and method, program, and recording medium
US6934252B2 (en) * 2002-09-16 2005-08-23 North Carolina State University Methods and systems for fast binary network address lookups using parent node information stored in routing table entries
US6915300B1 (en) * 2003-12-19 2005-07-05 Xerox Corporation Method and system for searching indexed string containing a search string
JP2006293619A (en) 2005-04-08 2006-10-26 Toshiba Tec Corp Computer device and log output program
JP4271214B2 (en) 2006-07-07 2009-06-03 株式会社エスグランツ Bit string search device, search method and program
JP4271227B2 (en) 2006-10-30 2009-06-03 株式会社エスグランツ Bit string search device, search method and program

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2001357070A (en) * 2000-06-13 2001-12-26 Nec Corp Method and device for retrieving information

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2012090763A1 (en) * 2010-12-28 2012-07-05 株式会社エスグランツ Code string search device, search method, and program
JP2012141760A (en) * 2010-12-28 2012-07-26 S Grants Co Ltd Code string retrieval device, retrieval method and program
CN103544191A (en) * 2012-07-17 2014-01-29 人人游戏网络科技发展(上海)有限公司 Method and device for reading cache data
CN108616403A (en) * 2018-05-09 2018-10-02 马鞍山优途网络科技有限公司 a kind of resource management system based on cloud computing
CN109783206A (en) * 2019-01-04 2019-05-21 智恒科技股份有限公司 One kind is for describing the integrally-built method of big data task flow
CN109783206B (en) * 2019-01-04 2022-12-13 智恒科技股份有限公司 Method for describing overall structure of big data task flow

Also Published As

Publication number Publication date
US8214405B2 (en) 2012-07-03
US20100042597A1 (en) 2010-02-18
JP4514771B2 (en) 2010-07-28

Similar Documents

Publication Publication Date Title
JP4514771B2 (en) Coupled node tree longest match / shortest match search device, search method and program
JP4271214B2 (en) Bit string search device, search method and program
JP4271227B2 (en) Bit string search device, search method and program
JP4527753B2 (en) Bit string search device, search method and program
JP4498409B2 (en) Database index key update method and program
JP4379894B2 (en) Method and program for splitting / joining coupled node tree
JP4402120B2 (en) Bit string search device, search method and program
JP4439013B2 (en) Bit string search method and search program
JP4514768B2 (en) Coupled node tree save / restore apparatus, save / restore method, and program
JP2009140161A (en) Bit string merge sort method, and program
CN104268176A (en) Recommendation method and system based on search keyword
US8250089B2 (en) Bit string search apparatus, search method, and program
WO2009122651A1 (en) Bit sequence search device, search method, and program
JP4567754B2 (en) Bit string search device, search method and program
JP2011018296A (en) Index key insertion/deletion method for coupled node tree
JP4417431B2 (en) Method and program for splitting / joining coupled node tree
JP4813575B2 (en) Bit string search device
WO2009093290A1 (en) Bit string retrieval device, retrieval method and program

Legal Events

Date Code Title Description
A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20100120

A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20100120

A871 Explanation of circumstances concerning accelerated examination

Free format text: JAPANESE INTERMEDIATE CODE: A871

Effective date: 20100120

A975 Report on accelerated examination

Free format text: JAPANESE INTERMEDIATE CODE: A971005

Effective date: 20100210

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20100223

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20100416

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: 20100511

A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20100511

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: 20130521

Year of fee payment: 3

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

Free format text: PAYMENT UNTIL: 20130521

Year of fee payment: 3

S111 Request for change of ownership or part of ownership

Free format text: JAPANESE INTERMEDIATE CODE: R313111

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

Free format text: PAYMENT UNTIL: 20130521

Year of fee payment: 3

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

LAPS Cancellation because of no payment of annual fees