JP5387092B2 - Storage medium and trie tree generation method - Google Patents
Storage medium and trie tree generation method Download PDFInfo
- Publication number
- JP5387092B2 JP5387092B2 JP2009080245A JP2009080245A JP5387092B2 JP 5387092 B2 JP5387092 B2 JP 5387092B2 JP 2009080245 A JP2009080245 A JP 2009080245A JP 2009080245 A JP2009080245 A JP 2009080245A JP 5387092 B2 JP5387092 B2 JP 5387092B2
- Authority
- JP
- Japan
- Prior art keywords
- node
- key
- trie tree
- aaa
- character
- 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.)
- Active
Links
- 238000000034 method Methods 0.000 title claims description 236
- 230000007704 transition Effects 0.000 claims description 53
- 238000012545 processing Methods 0.000 description 117
- 238000010586 diagram Methods 0.000 description 98
- 230000015654 memory Effects 0.000 description 37
- 238000013523 data management Methods 0.000 description 23
- 241000712062 Patricia Species 0.000 description 20
- 238000012217 deletion Methods 0.000 description 18
- 230000037430 deletion Effects 0.000 description 18
- 230000006870 function Effects 0.000 description 13
- 239000000284 extract Substances 0.000 description 8
- 244000154870 Viola adunca Species 0.000 description 7
- 235000005811 Viola adunca Nutrition 0.000 description 7
- 235000013487 Viola odorata Nutrition 0.000 description 7
- 235000002254 Viola papilionacea Nutrition 0.000 description 7
- 238000003491 array Methods 0.000 description 7
- 238000000605 extraction Methods 0.000 description 6
- 244000172533 Viola sororia Species 0.000 description 3
- 238000004891 communication Methods 0.000 description 3
- 239000002699 waste material Substances 0.000 description 2
- 229910002114 biscuit porcelain Inorganic materials 0.000 description 1
- 238000010276 construction Methods 0.000 description 1
- 238000001514 detection method Methods 0.000 description 1
- 230000010354 integration Effects 0.000 description 1
- 238000007562 laser obscuration time method Methods 0.000 description 1
Images
Landscapes
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Description
本発明は、トライ木を用いて各種の処理を行うトライ木生成装置等に関する。 The present invention relates to a trie tree generation device that performs various processes using a trie tree.
文書検索システムにおいて、キーから所望の文書、値等を高速に検索するべく、トライ木が用いられている(例えば、特許文献1、2参照)。図90は、従来のトライ木の一例を示す図である。このトライ木は、ルートノードを除くノードに対して、1文字あたり1ノードを割当てることにより、木構造を構築している。また、図90に示すトライ木は、キー「black、green、blue、grey、black、grey、greenyellow」にそれぞれ値「1、3、4、5、3、2、1」が割当てられたトライ木を示している。
In a document search system, a trie tree is used to search a desired document, value, and the like from a key at high speed (see, for example,
従来の検索装置が、トライ木の検索処理を実行する場合には、入力キーを1文字ずつ取り出し、トライ木上の同じキーのノードを辿る。例えば、検索装置は、入力キー「blue」が指定された場合には、トライ木のノードをノードb、l、u、eの順に辿ることで、「blue」に割当てられた「4」を検出する。 When a conventional search device executes a trie tree search process, the input key is extracted character by character, and the node of the same key on the trie tree is traced. For example, when the input key “blue” is specified, the search device detects “4” assigned to “blue” by tracing the nodes of the trie tree in the order of nodes b, l, u, and e. To do.
ところで、図90に示したトライ木では、トライ木を構築するキーが長い場合に、ノード数が増えてしまい、使用メモリ量が増大してしまうという問題があった。また、キーが長い場合に、検索処理時に比較するノード数が増えてしまい、検索処理等が完了するまでの時間が長くなってしまうという問題が発生する。 Incidentally, the trie tree shown in FIG. 90 has a problem that the number of nodes increases and the amount of used memory increases when the key for constructing the trie tree is long. Further, when the key is long, the number of nodes to be compared at the time of the search process increases, and there is a problem that the time until the search process is completed becomes long.
そこで、かかるトライ木の問題点を解消するべく、パトリシア木(Patricia Tree)と呼ばれるトライ木が考案されている(例えば、非特許文献1参照)。図91は、パトリシア木の一例を示す図である。このパトリシア木は、ノードから他のノードへ遷移するエッジ部を、文字ではなく文字列で表現することで、使用メモリ量を削減している。なお、図91に示すパトリシア木は、キー「black、green、blue、grey、black、grey、greenyellow」にそれぞれ値「1、3、4、5、3、2、1」が割当てられたパトリシア木を示している。 Therefore, a trie tree called a Patricia tree has been devised to solve the problem of the trie tree (see, for example, Non-Patent Document 1). FIG. 91 is a diagram illustrating an example of a Patricia tree. In this Patricia tree, the amount of memory used is reduced by expressing an edge portion that transitions from one node to another by a character string instead of a character. The Patricia tree shown in FIG. 91 is a Patricia tree in which the values “1, 3, 4, 5, 3, 2, 1” are assigned to the keys “black, green, blue, grey, black, grey, greenyellow”, respectively. Is shown.
従来の検索装置が、トライ木の検索処理を実行する場合には、入力キーとエッジ部の文字列とを順次比較し、パトリシア木を辿る。例えば、検索装置は、入力キー「blue」が指定された場合には、パトリシア木のエッジ部をbl、ueの順に辿ることで、「blue」に割当てられた「4」を検出する。 When a conventional search apparatus executes a trie tree search process, the input key and the character string at the edge portion are sequentially compared, and the Patricia tree is traced. For example, when the input key “blue” is designated, the search device detects “4” assigned to “blue” by tracing the edge of the Patricia tree in the order of bl and ue.
しかしながら、上述したパトリシア木は、通常のトライ木と比較してメモリ使用量の問題等を解消することができるものの、所定の文字列毎にノードを作成する必要があるため、キーの文字数が多い場合には、メモリ使用量が増大してしまうという問題があった。 However, although the Patricia tree described above can solve the memory usage problem and the like as compared with a normal trie tree, it requires a node to be created for each predetermined character string, so the number of characters in the key is large. In this case, there is a problem that the amount of memory used increases.
そこで、この発明は、上述した従来技術の課題を解決するためになされたものであり、メモリ使用量を削減することができる記憶媒体およびトライ木生成方法を提供することを目的とする。 Accordingly, the present invention has been made to solve the above-described problems of the prior art, and an object thereof is to provide a storage medium and a trie tree generation method capable of reducing the memory usage.
上述した課題を解決し、目的を達成するため、この記憶媒体は、コンピュータに、所定の文字に対応するノードが木構造にて接続されるトライ木を記憶装置に記憶し、当該トライ木に新規の文字列を登録する場合に、当該新規の文字列の文字を先頭から順に読み出して前記トライ木に含まれるノードを当該ノードに対応する文字に応じて辿り、単一のノードに対して単一の文字列が登録されるように、辿ったノードの何れかに新規の文字列を登録する場合に、登録対象のノードの子ノードに登録された文字列と新規の文字列とを比較して一致する文字を判定し、新規の文字列から一致する文字を除いた残りの文字列と一致文字数を、登録対象のノードに登録する文字列登録機能を実現させるためのプログラムを格納することを要件とする。 In order to solve the above-described problems and achieve the object, this storage medium stores a trie tree in which a node corresponding to a predetermined character is connected in a tree structure in a computer and stores the trie tree in a new state. When registering a character string, the characters of the new character string are read in order from the top and the nodes included in the trie tree are traced according to the characters corresponding to the node, When registering a new character string in one of the traced nodes, the character string registered in the child node of the registration target node is compared with the new character string. It is necessary to store a program that realizes the character string registration function that determines the matching character and registers the remaining character string obtained by removing the matching character from the new character string and the number of matching characters in the registration target node. And
この記憶媒体が記憶するプログラムを実行することで、コンピュータは、1ノードにタグキーを1つ対応付け、タグキーを有さないノードを無くすので、メモリ使用効率を向上させることが出来る。 By executing the program stored in the storage medium, the computer associates one tag key with one node and eliminates the node having no tag key, so that the memory use efficiency can be improved.
以下に、本願の開示する記憶媒体およびトライ木生成方法の実施例を図面に基づいて詳細に説明する。なお、この実施例によりこの発明が限定されるものではない。 Hereinafter, embodiments of a storage medium and a trie tree generation method disclosed in the present application will be described in detail with reference to the drawings. Note that the present invention is not limited to the embodiments.
まず、本実施例にかかる検索装置の説明を行う前に、木構造に含まれるノードの用語について説明する。図1は、木構造に含まれるノードの用語を説明するための図である。図1に示すように、トライ木を構成する各ノードのうち、最上層に位置するノードをルートノードと定義する。また、基準ノードのひとつ上の層に存在し、基準ノードに接続されたノードを、基準ノードに対する親ノード(以下、単に親ノード)と定義する。また、基準ノードのひとつ下の層に存在し、基準ノードに接続されたノードを基準ノードに対する子供ノード(以下、単に子供ノード)と定義する。 First, before describing the search apparatus according to the present embodiment, terms of nodes included in the tree structure will be described. FIG. 1 is a diagram for explaining the terms of nodes included in a tree structure. As shown in FIG. 1, among the nodes constituting the trie tree, the node located at the uppermost layer is defined as the root node. In addition, a node that exists in the layer one level above the reference node and is connected to the reference node is defined as a parent node for the reference node (hereinafter simply referred to as a parent node). Further, a node that exists in a layer below the reference node and is connected to the reference node is defined as a child node (hereinafter simply referred to as a child node) with respect to the reference node.
また、基準ノードと同じ層に存在し、基準ノードと同じ親ノードに接続され、基準ノードの上側に存在するノードを、基準ノードに対する兄ノード(以下、単に兄ノード)と定義する。また、基準ノードと同じ層に存在し、基準ノードと同じ親ノードに接続され、基準ノードの下側に存在するノードを、基準ノードに対する弟ノード(以下、単に弟ノード)と定義する。また、根ノードから親ノードに至る各ノードをまとめて先祖ノードと定義する。また、基準ノードの配下に接続された各ノードをまとめて子孫ノードと定義する。 Further, a node that exists in the same layer as the reference node, is connected to the same parent node as the reference node, and exists above the reference node is defined as an older brother node (hereinafter simply referred to as an older brother node) with respect to the reference node. Further, a node that exists in the same layer as the reference node, is connected to the same parent node as the reference node, and exists below the reference node is defined as a brother node (hereinafter simply referred to as a brother node) with respect to the reference node. Each node from the root node to the parent node is collectively defined as an ancestor node. Also, each node connected under the reference node is collectively defined as a descendant node.
次に、本実施例にかかる検索装置の概要について説明する。図2、図3は、本実施例にかかる検索装置の概要を説明するための図である。まず、図2に示すように、本実施例にかかる検索装置は、指定されたキーに基づいてトライ木を生成する場合に、1つのノードに1つのキーを割当てる。以下の説明において、ノードに割当てられたキーをタグキーと表記する。図2において、ノードb、l、g、r、eには、それぞれタグキー「black、blue、green、grey、greenyellow」が1つずつ割当てられている。また、ノードb、l、g、r、eには、値「1、3」、「4」、「3」、「5、2」、「1」がそれぞれ割当てられている。 Next, an outline of the search device according to the present embodiment will be described. 2 and 3 are diagrams for explaining the outline of the search device according to the present embodiment. First, as illustrated in FIG. 2, the search device according to the present embodiment assigns one key to one node when generating a trie tree based on a designated key. In the following description, a key assigned to a node is referred to as a tag key. In FIG. 2, one tag key “black, blue, green, grey, greenyellow” is assigned to each of the nodes b, l, g, r, and e. Further, the values “1, 3”, “4”, “3”, “5, 2”, and “1” are assigned to the nodes b, l, g, r, and e, respectively.
図2に示したトライ木は、図90に示したトライ木あるいは図91に示したパトリシア木と同じように、タグキー「black、green、blue、grey、black、grey、greenyellow」にそれぞれ値「1、3、4、5、3、2、1」を割当てている。しかし、本実施例にかかるトライ木は、図90、91に示したトライ木、パトリシア木と異なり、1ノードにタグキーを一つ対応付けているため、データを持っていないノードが存在せず、メモリ利用効率を高めることができる。また、本実施例にかかるトライ木は、ノードに含まれる文字数が多い場合であっても、トライ木のノード数を増加させる必要がないため、メモリ使用量を抑えることが出来る。 The trie tree shown in FIG. 2 has a value “1” for each of the tag keys “black, green, blue, grey, black, grey, greenyellow” in the same manner as the trie tree shown in FIG. 90 or the Patricia tree shown in FIG. 3, 4, 5, 3, 2, 1 ". However, unlike the trie and patricia trees shown in FIGS. 90 and 91, the trie tree according to the present embodiment associates one tag key with one node, so there is no node that does not have data, Memory utilization efficiency can be increased. In addition, the trie tree according to the present embodiment does not require an increase in the number of nodes in the trie tree even when the number of characters included in the node is large, so that the memory usage can be suppressed.
ただし、本実施例にかかるトライ木は、1つのノードに1つのタグキーを割当てた代償として、実際にノードに登録されたタグキーを参照しなければ、入力キーがタグキーにヒットしたか否かを判定できない。例えば、図2に示したトライ木では、入力キー「blue」の1文字目「b」により、ノードを遷移すると、まず、ルートノードからノードbに移行する。ノードbに移行した時点では、入力キーにヒットしたか否かを判定できない。実際に、ノードbのタグキー「black」と比較して初めて、ヒットしていないと判定できる。 However, the trie tree according to the present embodiment determines whether or not the input key hits the tag key unless the tag key actually registered in the node is referred to as a price for assigning one tag key to one node. Can not. For example, in the trie tree shown in FIG. 2, when a node is transitioned by the first character “b” of the input key “blue”, the root node is first transitioned to the node b. When moving to node b, it cannot be determined whether or not the input key is hit. Actually, it can be determined that there is no hit until the tag key “black” of node b is compared.
そして、2文字目「l」によりノードlに遷移し、ノードlのタグキー「blue」と入力キー「blue」とを比較すると、入力キーとタグキーが一致したと判定できるので、ノードlに付加された値「4」が検出結果として検出される。したがって、ただ闇雲に、各ノードにタグキーを割当ててしまうと、各入力キーにより遷移する各ノードのタグキーと順次比較処理を行うこととなり、処理効率の向上が図れない。 Then, transition to node l by the second character “l”, and comparing the tag key “blue” of node l with the input key “blue”, it can be determined that the input key and tag key match, so it is added to node l The value “4” is detected as a detection result. Therefore, if a tag key is assigned to each node in the dark cloud, the comparison is performed sequentially with the tag key of each node transitioned by each input key, and the processing efficiency cannot be improved.
かかる課題を解消するため、図3に示すように、本実施例にかかる検索装置は、深さ優先探索順でタグキーが並ぶようにトライ木を構築する。このように、深さ優先探索順でタグキーを並べると、データの検索時に入力キーと比較対象となるタグキーを有するノードを絞り込むことができ、処理の効率化を図ることができる。検索装置は、深さ優先探索順でキーが並ぶようにトライ木を構築する際に、各キーの優先度を判定し、優先度が小さいキーほどルートノードに近いノードに割当てる。 In order to solve this problem, as shown in FIG. 3, the search device according to the present embodiment constructs a trie tree so that tag keys are arranged in the depth-first search order. In this way, when tag keys are arranged in the depth-first search order, nodes having tag keys to be compared with the input keys can be narrowed down when searching for data, and processing efficiency can be improved. When constructing a trie tree so that keys are arranged in the depth-first search order, the search device determines the priority of each key, and assigns a key with a lower priority to a node closer to the root node.
検索装置は、優先度を判定する場合に、異なる文字が検出されるまで各キーの文字を先頭から順に抽出する。そして、抽出した文字において、アルファベット順で、aに近い文字ほど優先度を小さくし、zに近い文字ほど優先度を大きくする。すなわち、優先度は、「a<b<c<d<e<f<g<h<i<j<k<l<m<n<o<p<q<r<s<t<u<v<w<x<y<z」となる。なお、優先度が同じ文字列は、等しい文字列であるといえる。 When determining the priority, the search device extracts the characters of each key in order from the top until a different character is detected. In the extracted characters, in the alphabetical order, the closer to a, the lower the priority, and the closer to z, the higher the priority. That is, the priority is “a <b <c <d <e <f <g <h <i <j <k <l <m <n <o <p <q <r <s <t <u <v <W <x <y <z ”. Note that character strings having the same priority can be said to be equal character strings.
例えば、タグキー「black」と「blue」を比較すると、3文字目で異なる文字が抽出される。具体的には、「black」から「a」が抽出され、「blue」から「u」が抽出される。そして、「a」と「u」とを比較すると、「u」の方が「a」よりも優先度が大きくなる。したがって、優先度の小さい「black」を「blue」よりもルートノード側のノードに割り当てる。 For example, when the tag keys “black” and “blue” are compared, different characters are extracted at the third character. Specifically, “a” is extracted from “black”, and “u” is extracted from “blue”. When “a” is compared with “u”, “u” has a higher priority than “a”. Therefore, “black” having a lower priority is assigned to a node closer to the root node than “blue”.
また、「green」と「greenyellow」を比較すると、6文字目で異なる文字が抽出される。具体的には、「green」には6文字目が存在しないので「空」が抽出され、「greenyellow」から「y」が抽出される。このような場合には、検索装置は、空白が抽出されなかったキー「greenyellow」の方が「green」よりも優先度が大きいと判定する。したがって、優先度の小さい「green」を「greenyellow」よりもルートノード側のノードに割り当てる。 Further, when “green” and “greenyellow” are compared, different characters are extracted at the sixth character. Specifically, since there is no sixth character in “green”, “sky” is extracted, and “y” is extracted from “greenyellow”. In such a case, the search device determines that the key “greenyellow” from which no blank has been extracted has a higher priority than “green”. Therefore, “green” having a lower priority is assigned to a node closer to the root node than “greenyellow”.
なお、本実施例では、同一の親ノードに直接接続された子(子供)ノードが複数存在する場合には、優先度の小さいキーを兄ノード側に配置し、優先度の大きいキーを弟ノード側に配置する。例えば、「black」と「green」とを比較すると、1文字目で異なる文字が抽出される。具体的には、「black」から「b」が抽出され、「green」から「g」が抽出される。そして、「b」と「g」を比較すると、「g」の方が「b」よりも優先度が大きくなる。したがって、優先度の小さい「black」を「green」よりも兄側のノードに配置する。なお、図2のように、各タグキーを割当てると、複数の子ノードを有する親ノードのタグキーと兄弟ノードのタグキーとの優先度の大小関係は、親ノードのキー<長男ノードのキー<次男ノードのキー<三男ノード<・・・となる。また、配下に接続されるノードほど優先度が大きくなる。例えば、図3において、ノードeのキーの優先度は、ノードr、gの優先度よりも大きい。 In this embodiment, when there are a plurality of child (child) nodes directly connected to the same parent node, a key having a low priority is arranged on the brother node side, and a key having a high priority is assigned to the brother node. Place on the side. For example, when “black” and “green” are compared, different characters are extracted at the first character. Specifically, “b” is extracted from “black”, and “g” is extracted from “green”. When “b” and “g” are compared, “g” has a higher priority than “b”. Therefore, “black” having a lower priority is placed on the brother node than “green”. As shown in FIG. 2, when each tag key is assigned, the priority relationship between the tag key of the parent node having a plurality of child nodes and the tag key of the sibling node is expressed as follows: the key of the parent node <the key of the eldest son node <the second son node The key is <the third son node <... Further, the priority is higher as the node is connected to the subordinate. For example, in FIG. 3, the priority of the key of the node e is higher than the priority of the nodes r and g.
図3に示すように、各ノードにタグキーが配置されると、入力キーの優先度と、タグキーの優先度の関係から、検索対象となる入力キーの位置を絞り込むことが出来る。これは、入力キーと優先度が等しいタグキーを捜せばよいので、入力キーの文字により遷移する各ノードの内、入力キーよりも優先度が大きいノード以降のノード(子孫ノード)のタグキーと比較する必要は無く、入力キーよりも優先度が小さいノード以前のノード(先祖ノード)のタグキーと比較する必要が無くなるためである。 As shown in FIG. 3, when a tag key is arranged at each node, the position of the input key to be searched can be narrowed down from the relationship between the priority of the input key and the priority of the tag key. Since it is only necessary to search for a tag key having the same priority as the input key, it is compared with the tag key of the node (descendant node) after the node having a higher priority than the input key among the nodes that are transitioned by the character of the input key. This is not necessary, and it is not necessary to compare with the tag key of the node (ancestor node) before the node having a lower priority than the input key.
ここで、入力キーの文字を先頭から1文字ずつ読み出して、トライ木の各ノードを遷移し、最後に到達するノードを到達ノードと定義する。また、ルートノードから到達ノードに至る各ノードに含まれ、かつ、兄ノードを有するノードの内、優先度が最も大きいキーを有するノードを特定ノードと定義する。なお、兄ノードを有するノードが存在しない場合には、ルートノードの子ノードを特定ノードと定義する。 Here, the characters of the input key are read one by one from the top, each node of the trie tree is transitioned, and the node that reaches the end is defined as the reaching node. Further, a node having a key with the highest priority among nodes having an older brother node included in each node from the root node to the reaching node is defined as a specific node. If there is no node having an older brother node, a child node of the root node is defined as a specific node.
本実施例にかかる検索装置は、入力キーに一致するタグキーを検索する場合に、到達ノードから特定ノードに至る各ノードの内、いずれかを検索対象とすればよい。検索対象となるノードの中に、入力キーと一致するタグキーが存在しない場合には、その他のタグキーを参照しなくても、入力キーと一致するタグキーは存在しないと判定可能である。 When searching for a tag key that matches the input key, the search device according to the present embodiment may search for any one of the nodes from the reaching node to the specific node. If there is no tag key that matches the input key in the search target node, it can be determined that there is no tag key that matches the input key without referring to other tag keys.
なぜなら、特定ノードの親ノードのキーの優先度は、兄ノードのキーの優先度よりも小さく、兄ノードのキーの優先度は、弟ノード(特定ノード)のキー文字列に属する登録対象の入力キーの優先度よりも小さいからであり、入力キーが弟ノードを辿っている時点で、兄ノード側のタグキーの優先度よりも、入力キーの優先度の方が大きいことが確定するからである。 Because the priority of the key of the parent node of the specific node is lower than the priority of the key of the brother node, the priority of the key of the brother node is the input of the registration target belonging to the key character string of the brother node (specific node) This is because the priority of the input key is larger than the priority of the tag key on the brother node when the input key follows the younger brother node. .
以下の説明において、到達ノードから特定ノードに至る各ノードを、比較対象ノードと表記する。検索装置は、入力キーと一致するキーを検索する場合には、かかる比較対象ノードのタグキーを対象として比較処理を実行すればよい。 In the following description, each node from the reaching node to the specific node is referred to as a comparison target node. When searching for a key that matches the input key, the search device may perform a comparison process for the tag key of the comparison target node.
図4は、比較対象ノードを説明するための図である。入力キーを先頭から1文字ずつ読みだし、最後にノード6に到達した場合には、比較対象ノードAに含まれるノード5,6のタグキーと入力キーとを比較すればよい。
FIG. 4 is a diagram for explaining the comparison target node. When the input key is read character by character from the beginning and finally reaches the
続いて、本実施例にかかる検索装置が、新規のキーをトライ木に登録する場合について説明する。図5は、新規のキーをトライ木に登録する処理を説明するための図である。新規のキーをトライ木に構築する場合にも、比較対象ノードのタグキーと比較処理を行い、優先度に応じて、新規のキーをトライ木に登録すればよい。 Next, a case where the search device according to the present embodiment registers a new key in the trie tree will be described. FIG. 5 is a diagram for explaining processing for registering a new key in the trie tree. Even when a new key is constructed in the trie tree, a comparison process is performed with the tag key of the comparison target node, and the new key may be registered in the trie tree according to the priority.
図5を用いて具体的に説明する。図5の左側に示すトライ木は、ノードb、i、l、uに、それぞれキー「beige、bisque、black、blueviolet」が1つずつ割当てられている。また、ノードb、i、l、uには、値「2」、「4」、「1、3」、「3」がそれぞれ割当てられている。 This will be specifically described with reference to FIG. In the trie tree shown on the left side of FIG. 5, one key “beige, bisque, black, blueviolet” is assigned to each of the nodes b, i, l, u. Also, the values “2”, “4”, “1, 3”, and “3” are assigned to the nodes b, i, l, and u, respectively.
検索装置は、図5の左側に示すトライ木に、キー「blue」、値「4」を追加する場合、到達ノードは「ノードu」、特定ノードは「ノードl」となる。したがって、比較対象ノードは、ノードl、ノードu、(ノードuの配下に接続されるノード)となる。 When the search device adds the key “blue” and the value “4” to the trie tree shown on the left side of FIG. 5, the reaching node is “node u” and the specific node is “node l”. Accordingly, the comparison target nodes are node l, node u (nodes connected under node u).
登録対象ノードに接続されたキー「blueviolet」、「black」をそれぞれ「blue」と比較すると、キー「blue」の優先度は、「blueviolet」よりも小さく、「black」よりも大きいので、「blueviolet」を有するノードと、「black」を有するノードの間に「blue」を登録すればよい。この場合には、図5の右側に示すように、ノードuにキー「blue」、値「4」を割り当て、ノードuの配下にノードeを作成して、かかるノードuに「blueviolet」、値「3」を割当てる。 When comparing the keys "blueviolet" and "black" connected to the registration target node with "blue", the priority of the key "blue" is lower than "blueviolet" and higher than "black". "Blue" may be registered between a node having "" and a node having "black". In this case, as shown on the right side of FIG. 5, the key “blue” and the value “4” are assigned to the node u, the node e is created under the node u, and “blueviolet” and the value are assigned to the node u. Assign “3”.
ところで、本実施例にかかる検索装置は、トライ木のメモリ使用量を更に削減するべく、ノードにタグとして付加するタグキーを、トライ部分のキーを削除した形で保持するものとする。図6は、トライ部分のキーを削除した形でタグキーを保持するトライ木の一例を示す図である。 By the way, in order to further reduce the memory usage of the trie tree, the search device according to the present embodiment holds the tag key added as a tag to the node in a form in which the key of the trie part is deleted. FIG. 6 is a diagram illustrating an example of a trie tree that holds tag keys in a form in which the key of the trie portion is deleted.
例えば、ノードlにタグキー「ack」が登録されているが、これは、ノードlにタグキー「black」を登録していることと同じ意味である。ルートノードからノードlに至るトライ部分のキーが「b、l」であるため、トライ部とタグキーとをあわせると「black」となる。 For example, the tag key “ack” is registered in the node l, which has the same meaning as that in which the tag key “black” is registered in the node l. Since the key of the trie part from the root node to the node l is “b, l”, the black part is “black” when the trie part and the tag key are combined.
図6のようなデータ構造を取ることで、タグキーの文字列が減るので、入力キーと比較するタグキーの数を減らすことが出来る。また、図6のように、トライ木上にはタグキーのデータを持たずに、各ノードはタグキーへのポインタのみを保持しても良い。また、タグキーのデータを全て保持しておき、比較を開始する文字位置を変えても良い。 By adopting the data structure as shown in FIG. 6, the number of tag keys is reduced, and the number of tag keys to be compared with the input keys can be reduced. Further, as shown in FIG. 6, each node may hold only a pointer to the tag key without having tag key data on the trie tree. Alternatively, all the tag key data may be held and the character position at which the comparison is started may be changed.
図7は、従来のパトリシア木のデータ構造による使用メモリ量と、本願発明にかかるトライ木の使用メモリ量とを示す図である。パトリシア木およびトライ木は、共に、キー「aaaaa、aacab、ababc、abacb、abcab」にそれぞれ「1、2、3、4、5」が割当てられている。 FIG. 7 is a diagram showing the used memory amount according to the data structure of the conventional Patricia tree and the used memory amount of the trie tree according to the present invention. In both the Patricia tree and the trie tree, “1, 2, 3, 4, 5” are assigned to the keys “aaaaa, aacab, ababc, aabac, abcab”, respectively.
ここで、ノードメモリを1KB、タグキーメモリを1Byte、値メモリを4Byteとすると、パトリシア木は、ノードを10個、タグキーを17文字、値を5個有しているので、合計で約10KBとなる。一方、本発明にかかるトライ木は、ノードを6ノード、タグキーを16文字、値を4個有しているので、合計で約6KBとなる。したがって、本発明にかかるトライ木は、従来のパトリシア木と比較して、使用メモリ量を削減できる。 Here, assuming that the node memory is 1 KB, the tag key memory is 1 byte, and the value memory is 4 bytes, the Patricia tree has 10 nodes, 17 tag keys, and 5 values, so the total is about 10 KB. . On the other hand, the trie tree according to the present invention has 6 nodes, 16 characters of tag keys, and 4 values, so the total is about 6 KB. Therefore, the trie tree according to the present invention can reduce the amount of memory used compared to the conventional Patricia tree.
また、本実施例にかかる検索装置は、トライ木の末端ノードに対応するリーフノードからポインタ配列を削除しても構わない。ここで、ポインタ配列は、接続先のノードを示すポインタの配列である。図8は、リーフノードからポインタ配列を削除した場合のトライ木を示す図である。このように、リーフノードからポインタ配列を削除することにより、リーフノードの使用メモリ量を削減することができる。 In addition, the search device according to the present embodiment may delete the pointer array from the leaf node corresponding to the end node of the trie tree. Here, the pointer array is an array of pointers indicating connection destination nodes. FIG. 8 is a diagram illustrating a trie tree when a pointer array is deleted from a leaf node. In this way, by deleting the pointer array from the leaf node, the amount of memory used by the leaf node can be reduced.
図9は、図8および図6に示した手法を用いてメモリ量を削減した場合の、従来のパトリシア木のデータ構造による使用メモリ量と、本実施例にかかるトライ木の使用メモリ量とを示す図である。 FIG. 9 shows the amount of memory used by the data structure of the conventional Patricia tree and the amount of memory used by the trie tree according to this embodiment when the amount of memory is reduced using the method shown in FIGS. FIG.
ここで、内部ノードメモリを1KB、リーフノードメモリを12Byte、キー1文字当たりのメモリを1Byte、値メモリを4Byteとすると、パトリシア木は、内部ノードを5個、リーフノードを5個、キーを17文字、値を5個有しているので、合計で約5KBとなる。一方、本実施例のトライ木は、内部メモリを3個、リーフノードを3個、キーを19文字、値を5個有しているので、合計で約3KBとなる。このように、図8および図9の手法を用いて使用メモリ使用量を削減した場合であっても、本実施例にかかるトライ木の方がパトリシア木と比較して、メモリ使用量をより多く削減することが出来る。 Here, if the internal node memory is 1 KB, the leaf node memory is 12 bytes, the memory per key character is 1 byte, and the value memory is 4 bytes, the Patricia tree has 5 internal nodes, 5 leaf nodes, and 17 keys. Since it has 5 characters and values, the total is about 5 KB. On the other hand, the trie tree of this embodiment has three internal memories, three leaf nodes, 19 keys, and five values, so the total is about 3 KB. Thus, even when the used memory usage is reduced by using the methods of FIGS. 8 and 9, the memory usage of the trie tree according to the present embodiment is larger than that of the Patricia tree. It can be reduced.
次に、本実施例にかかる検索装置の構成について説明する。図10は、本実施例1にかかる検索装置の構成を示す図である。図10に示すように、この検索装置100は、入力部110と、出力部120と、入出力制御部130と、記憶部140と、制御部150を有する。
Next, the configuration of the search device according to the present embodiment will be described. FIG. 10 is a diagram illustrating the configuration of the search device according to the first embodiment. As illustrated in FIG. 10, the search device 100 includes an input unit 110, an output unit 120, an input /
このうち、入力部110は、入力キー等の情報を入力する入力部であり、キーボードやマウス等に該当する。出力部120は、トライ木を用いた検索結果などの情報を出力する出力部であり、モニタ、若しくはディスプレイ、タッチパネル等に該当する。入出力制御部130は、入力部110、出力部120、記憶部140、制御部150によるデータの入出力を制御する処理部である。
Among these, the input unit 110 is an input unit for inputting information such as input keys, and corresponds to a keyboard, a mouse, or the like. The output unit 120 is an output unit that outputs information such as search results using a trie tree, and corresponds to a monitor, a display, a touch panel, or the like. The input /
記憶部140は、制御部150による各種処理に必要なデータおよびプログラムを記憶する記憶部である。この記憶部140は、登録データ管理テーブル140aとトライ木140bを有する。
The storage unit 140 is a storage unit that stores data and programs necessary for various processes performed by the
ここで、登録データ管理テーブル140aは、トライ木に登録するキーと値とを対応付けて記憶するテーブルである。図11は、本実施例1にかかる登録データ管理テーブル140aのデータ構造の一例を示す図である。図11に示すように、この登録データ管理テーブル140aは、キーと値を対応付けて記憶している。 Here, the registration data management table 140a is a table that stores keys and values registered in the trie tree in association with each other. FIG. 11 is a diagram illustrating an example of the data structure of the registered data management table 140a according to the first embodiment. As shown in FIG. 11, the registered data management table 140a stores keys and values in association with each other.
トライ木140bは、登録データ管理テーブル140aを基にして生成されるトライ木である。図12は、本実施例1にかかるトライ木のデータ構造の一例を示す図である。図12では一例として、図11に示した登録データ管理テーブル140aに対応したトライ木を示す。図12に示すように、ルートノードにノードb、ノードgが接続されており、ノードbにノードlが接続されている。
The
また、ノードbは、タグキー「eige」と値「2」が接続されている。ノードlは、タグキー「ack」と値「1、3」が接続されている。ノードgは、タグキー「reen」と値「4」が接続されている。 The node b is connected to the tag key “eige” and the value “2”. The node l is connected with the tag key “ack” and the values “1, 3”. The node g is connected with the tag key “reen” and the value “4”.
図12に示したトライ木を実データで表すと図13−1に示すデータ構造となる。図13−1は、図12に示したトライ木を実データで表した場合のデータ構造の一例を示す図である。図13−1に示すように、このトライ木140bは、ポインタ配列10〜13、テキスト表14を有している。
When the trie tree shown in FIG. 12 is represented by real data, the data structure shown in FIG. FIG. 13A is a diagram illustrating an example of a data structure when the trie tree illustrated in FIG. 12 is represented by real data. As illustrated in FIG. 13A, the
ここで、ルートノードポインタに接続されたポインタ配列10は、図12のルートノードに対応し、ポインタ配列11は、図12のノードbに対応し、ポインタ配列12は、図12のノードlに対応する。また、ポインタ配列13は、図12のノードgに対応する。
Here, the
ポインタ配列10〜13は、「TAG」領域と「Data」領域を有しており、「TAG」は、テキスト表14の文字と対応付けることで、ノードに接続されたタグキーを表現する。例えば、ポインタ配列11は、テキスト表14の「e」に接続されているので、「e」から次の空白前までの文字列「eige」をタグキーとして指定している。また、「Data」は、値と対応付けることで、ノードに接続された値を表現する。例えば、ポインタ配列11は、値「2」に接続されている。
The
また、各ポインタ配列10〜13は、配下に接続されたポインタ配列を判定するためのキー番号(ポインタ)「0×00〜0×FF」を有している。例えば、ポインタ配列10のキー番号「0×62」が、ポインタ配列11に接続され、ポインタ配列10のキー番号「0×67」が、ポインタ配列13に接続されている。
Each of the
なお、図13−1等に示したトライ木140bの実データのデータ構造は、1ノードあたりASCIIコードの1文字にあたる8ビットの場合を示しているが、これに限定されるものではない。例えば、ASCIIコード1文字を4ビット単位の2つに分割して、1ノードあたり4ビットとしてもよい。その場合、ポインタ配列のもつキー番号は8ビットの場合に「0x00〜0xFF」の256個であったのに対し、4ビットの場合には「0x0〜0xF」の16個に減らすことができ、メモリ使用量を削減することが可能である。図13−2は、トライ木140bのその他のデータ構造の一例を示す図である。
Note that the data structure of the real data of the
例えば、「beige」の場合、1ノードあたり8ビットの場合には先頭キー番号「0x62」で、ポインタ配列11に接続されているが、1ノードあたり4ビットの場合には先頭キー番号として「0x62」の前半部分の「0x6」で、図13−2のポインタ配列XXに接続される。また、「beige」に加え「black」を続けて追加する場合、1ノードあたり8ビットの場合には2番目のキー番号「0x6c」でポインタ配列12に接続されているが、1ノードあたり4ビットの場合には2番目のキー番号として「0x62」の後半部分の「0x2」で、図13−2のポインタ配列YYに接続される。なお、ポインタ配列YYはポインタ配列XXへの接続のキー番号「0x6」とポインタ配列YYへの接続のキー番号「0x2」とをあわせた「0x62」、すなわち「b」を表すノードである。またさらに「blue」を続けて追加する場合、1ノードあたり8ビットの場合には3番目の文字「u]のキー番号「0x75」で次のポインタ配列に接続するが、1ノードあたり4ビットの場合には3番目のキー番号として2文字目「l」のキー番号「0x6c」の前半部分の「0x6」で次のポインタ配列に接続する。
For example, in the case of “beige”, in the case of 8 bits per node, the head key number “0x62” is connected to the
また、日本語コードのようにマルチバイト文字に関しても、複数バイトを1文字として扱い、1ノードあたり16ビットとするのではなく、1文字を複数に分割して、1ノードあたり8ビットとしたり、4ビットとしてもよい。 Also, with regard to multibyte characters such as Japanese codes, multiple bytes are treated as one character, instead of 16 bits per node, each character is divided into multiples to 8 bits per node, It may be 4 bits.
なお、現在のコンピュータにおいては直接ビット位置を指定してビット列を取り出すことはできないが、ビット位置から所望のビット列を含むバイト位置を特定し、1バイトを取り出した後、ビット処理演算を用いて所望のビット列を取り出すことで処理できる。タグキーを表す文字列を取り出すときも同様に行うことができる。 Although it is not possible to directly extract a bit string by designating a bit position in the current computer, a byte position including a desired bit string is specified from the bit position, and after extracting one byte, a desired bit processing operation is used. Can be processed by extracting the bit string. The same can be done when extracting a character string representing a tag key.
また別に、リーフノードに該当するポインタ配列はすべてのキー番号領域がNULLであるので、ポインタ配列の一部(キー番号領域)を省くなどして簡略化しても良い。なお、この場合には、各ポインタ配列に、自身のポインタ配列がリーフノードであるか否かを示すフラグを設定する。 In addition, since all the key number areas of the pointer array corresponding to the leaf node are NULL, the pointer array may be simplified by omitting a part (key number area) of the pointer array. In this case, a flag indicating whether or not its own pointer array is a leaf node is set in each pointer array.
図10の説明に戻ると、制御部150は、各種の処理手順を規定したプログラムや制御データを格納するための内部メモリを有し、これらによって種々の処理を実行する制御部である。図10に示すように、この制御部150は、トライ木生成部150aと、トライ木探索部150bを有する。
Returning to the description of FIG. 10, the
トライ木生成部150aは、登録データ管理テーブル140aに登録されたキーに基づいて、トライ木140bを生成する処理である。なお、トライ木生成部150aは、図2、図3等で説明したように、1つのノードに1つのキーを割当てることでトライ木140を構築する。また、トライ木生成部150aは、ノードにタグキーを登録する場合に、深さ優先探索順でタグキーが並ぶようにトライ木を生成する。
The trie
図14は、トライ木生成部150aが、トライ木140bを生成する処理の概要を説明するための図である。なお、ここでは説明の便宜上、図14の左側に示すトライ木に入力キー「blue」、値「4」を登録する場合について説明する。また、図14の左側に示すトライ木は、図6において説明したトライ木と同様にして、トライ部分のキーを削除した状態で、各ノードにタグキーを割当てている。
FIG. 14 is a diagram for explaining an outline of processing in which the trie
まず、トライ木生成部150aは、入力キーから文字を1文字ずつ取り出し、トライ木上のノードを辿る。辿る途中において、トライ木生成部150aは、入力キーとタグキーとの比較を実行しない。入力キーが「blue」の場合には、「blue」の先頭から1文字ずつ文字を取り出し、トライ木上のノードを辿ると、ルートノード、ノードb、l、uの順に遷移する。
First, the trie
次に、トライ木生成部150aは、辿る先にノードが存在しない場合や、入力キーを全て辿った後に、兄ノードを持つノード、あるいは、ルートノードの子ノードまでノードを戻りながら、入力キーよりも小さいキーを検索する。つまり、比較対象ノード内で、入力キーよりも優先度の小さいタグキーを検索する。なお、入力キーとタグキーの優先度を比較する場合には、入力キーからトライ部のキーを除いた残りのキーとタグキーとを比較する。
Next, the trie
入力キーが「blue」の場合には、比較対象ノードがノードu、ノードlとなるので、ノードu、ノードlの順に比較を行う。入力キー「blue」は、ノードlのタグキー「violet」よりも優先度が小さく、「ack」よりも優先度が大きい。なお、入力キー「blue」とタグキー「violet」との優先度を比較する場合には、ルートノードからノードuに至るトライ部のキー「blue」を入力キー「blue」から取り除いた後に比較する。また、入力キー「blue」とタグキー「ack」との優先度を比較する場合には、ルートノードからノードlに至るトライ部のキー「bl」を入力キー「blue」から取り除いた後に比較する。 When the input key is “blue”, since the comparison target nodes are the node u and the node l, the comparison is performed in the order of the node u and the node l. The input key “blue” has a lower priority than the tag key “violet” of the node l and a higher priority than the “ack”. When comparing the priority between the input key “blue” and the tag key “violet”, the key “blue” of the trie section from the root node to the node u is removed from the input key “blue” and then compared. When comparing the priority of the input key “blue” with the tag key “ack”, the key “bl” of the trie section from the root node to the node l is removed from the input key “blue” and then compared.
トライ木生成部150aは、入力キーよりも優先度の大きいタグキーの中で、優先度が最小となるタグキーを有するノードに、入力キーおよび入力キーに対応する値を登録し、既に登録されてあったタグキーをシフトさせる。
The trie
入力キーが「blue」の場合には、トライ木生成部150aは、ノードuに入力キー「blue」、値「4」を登録する。ルートノードからノードuに至るトライ部分のキーが「blu」であるため、実際には、タグキー「e」をノードuに登録する。また、トライ木生成部150aは、ノードuに登録してあったタグキー「blueviolet」をシフトさせるべく、新規のノードeをノードuの配下に作成し、タグキー「blueviolet」を登録する。ノードeに至るトライ部分のキーが「blue」であるため、実際には、タグキー「violet」をノードeに登録する。上記のような登録処理を実行することで、図14の右側に示すトライ木が生成される。なお、トライ木生成部150aは、兄ノードを有するノードを識別するために、識別情報を登録しておいても良い。例えば、図14の右側では、ノードlが兄ノードiを有しているので、ノードlに識別情報を登録する。
When the input key is “blue”, the trie
以下において、トライ木生成部150aがトライ木を生成する処理について具体的に説明する。図15〜図24は、トライ木を生成する処理を説明するための図である。ここでは説明の便宜上、キー「http://aaa.aaa/e/」、値「1」と、キー「http://aaa.aaa/e/c/」、値「2」と、キー「http://aaa.aaa/e/c/」、値「3」と、キー「http://aaa.aaa/e/」、値「4」の順で、トライ木を生成する場合について説明する。
Hereinafter, a process in which the trie
図15に示すように、まず、ノードが存在しない状態で、キー「http://aaa.aaa/e/」、値「1」を追加する場合について説明する。トライ木生成部150aは、ルートノードを生成する(ステップS10a)。実データ上において、トライ木生成部150aは、ルートノードに対応するポインタ配列20を生成し、ルートノードポインタとポインタ配列20を接続する。また、ポインタ配列20はルートノードに対応するので、「TAG」を空に接続する(ステップS10b)。
As shown in FIG. 15, first, a case where a key “http://aaa.aaa/e/” and a value “1” are added in a state where no node exists will be described. The trie
トライ木生成部150aは、入力キー「http://aaa.aaa/e/」を用意する(ステップS11a)。実データ上において、トライ木生成部150aは、テキスト表14に入力キー「http://aaa.aaa/e/」を格納し、入力キーのポインタを、テキスト表14の1列目の「h」に接続する(ステップS11b)。
The trie
トライ木生成部150aは、入力キー「http://aaa.aaa/e/」の先頭文字「h」をキーとする子ノードが存在しないので、ルートノードを参照する。ここで、ルートノードにタグキーは存在しないので、ルートノードのタグキーの優先度よりも、入力キー「http://aaa.aaa/e/」の優先度が大きくなる。
The trie
トライ木生成部150aは、ルートノードの配下に「h」をキーとするノードを作成し、入力キー「http://aaa.aaa/e/」から文字「h」を除いた残りのキーをタグキーとして、ノードhに接続する。また、入力キー「http://aaa.aaa/e/」の値「1」もノードhに接続する(ステップS12a)。
The trie
実データ上において、トライ木生成部150aは、ノードhに対応するポインタ配列21を生成し、ポインタ配列20のキー番号「0×68」で、ポインタ配列20とポインタ配列21を接続する。また、トライ木生成部150aは、ポインタ配列21の「TAG」をテキスト表14の2列目の「t」に接続し、ポインタ配列21の「Data」と値「1」を接続する(ステップS12b)。
On the actual data, the trie
続いて、図16に移行し、ステップS12a、12bにおいて作成したトライ木に、キー「http://aaa.aaa/e/c/」、値「2」を追加する場合について説明する。トライ木生成部150aは、入力キー「http://aaa.aaa/e/c/」の先頭文字hでルートノードからノードhに遷移する。そして、トライ木生成部150aは、入力キー「http://aaa.aaa/e/c/」のポインタを1つ進め、2文字目の「t」に設定する(ステップS13a)。
Subsequently, the case where the key “http://aaa.aaa/e/c/” and the value “2” are added to the trie tree created in steps S12a and 12b will be described with reference to FIG. The trie
実データ上において、トライ木生成部150aは、テキスト表14に最後に登録されたキー「http://aaa.aaa/e/」との間を1つ空けて、キー「http://aaa.aaa/e/c」を登録する。そして、トライ木生成部150aは、テキスト表14の2行目2列目の文字「t」に入力キーのポインタを接続する(ステップS13b)。
On the actual data, the trie
トライ木生成部150aは、ノードhにおいて、「t」をキーとする子ノードが存在しないので、ノードhのタグキー「ttp://aaa.aaa/e/」の優先度と、トライ部分の「h」を取り除いた入力キー「ttp://aaa.aaa/e/c/」の優先度を比較する。すると、入力キーの17文字目がcであり、タグキーの17文字目が空であるため、入力キーの優先度が、タグキーの優先度よりも大きい(ステップS14)。したがって、入力キー「ttp://aaa.aaa/e/c/」は、ノードh以降のノードに登録する。
Since there is no child node having “t” as a key in the node h, the trie
続いて、図17に移行し、トライ木生成部150aは、入力キー「http://aaa.aaa/e/c/」の2文字目の「t」をキーとして新しいノードtを生成し、入力キーのポインタを3文字目の「t」に進める(ステップS15a)。
Subsequently, the process proceeds to FIG. 17, the trie
実データ上において、トライ木生成部150aは、ノードtに対応するポインタ配列22を生成し、ポインタ配列21のキー番号「0×74」で、ポインタ配列21とポインタ配列22を接続する。また、入力キーのポインタを1つ進め、テキスト表14の2行目3列目の「t」に入力キーのポインタを接続する(ステップS15b)。
On the actual data, the trie
トライ木生成部150aは、ステップS15aで作成したノードtに入力キー「http://aaa.aaa/e/c/」からトライ部分の「ht」を除いた残りのキー「tp://aaa.aaa/e/c/」をタグキーとして登録する(ステップS16a)。
The trie
実データ上において、トライ木生成部150aは、ポインタ配列22の「TAG」をテキスト表14の2行目3列目の「t」に接続し、ポインタ配列22の「Data」と値「2」を接続する(ステップS16b)。
On the actual data, the trie
続いて、図18に移行し、ステップS16a、16bにおいて作成したトライ木に、入力キー「http://aaa.aaa/d/」、値「3」を追加する場合について説明する。トライ木生成部150aは、入力キー「http://aaa.aaa/d/」の先頭文字から1文字ずつ取り出して、トライ木上をノードh、tの順に遷移する。そして、トライ木生成部150aは、遷移したノードの数に応じて、入力キー「http://aaa.aaa/d/」のポインタを2つ進め、3文字目の「t」に設定する。
Subsequently, the case where the input key “http://aaa.aaa/d/” and the value “3” are added to the trie tree created in steps S16a and 16b will be described with reference to FIG. The trie
そして、トライ木生成部150aは、ノードtにおいて、「t」をキーとする子ノードが存在しないので、ノードtのタグキー「tp://aaa.aaa/e/c/」の優先度と、トライ部分の「ht」を取り除いた入力キー「tp://aaa.aaa/d/」の優先度を比較する。すると、タグキーの14文字目が「e」であり、入力キーの14文字目が「d」であるため、タグキーの優先度の方が、入力キーの優先度よりも大きくなる(ステップS17a)。
The trie
実データ上において、トライ木生成部150aは、テキスト表14に最後に登録されたキー「http://aaa.aaa/e/c/」との間を1つ空けて、キー「http://aaa.aaa/d/」を登録する。そして、トライ木生成部150aは、テキスト表14の3行目5文字目の文字「t」に入力キーのポインタを接続する。また、ポインタ配列22の「TAG」に接続された文字を先頭とする文字列と、入力キーのポインタに接続された文字を先頭とする文字列とを順次比較すると、タグキーの14文字目が「e」であり、入力キーの14文字目が「d」であるため、タグキーの優先度の方が、入力キーの優先度よりも大きくなる(ステップS17b)。
On the actual data, the trie
トライ木生成部150aは、入力キー「http://aaa.aaa/d/」のポインタを一つ戻して、2文字目の「t」に設定し、ノードtの親ノードとなるノードhに遷移する。そして、トライ木生成部150aは、ノードhのタグキー「ttp://aaa.aaa/e/c」の優先度と、トライ部分の「h」を取り除いた入力キー「ttp://aaa.aaa/d/」の優先度を比較する。すると、タグキーの15文字目が「e」であり、入力キーの14文字目が「d」であるため、タグキーの優先度の方が、入力キーの優先度よりも大きくなる(ステップS18a)。
The trie
実データ上において、トライ木生成部150aは、現在のノードのポインタをポインタ配列21に接続し、テキスト表14の3行目4文字目の文字「t」に入力キーのポインタを接続する。また、ポインタ配列22の「TAG」に接続された文字を先頭とする文字列と、入力キーのポインタに接続された文字を先頭とする文字列とを順次比較すると、タグキーの15文字目が「e」であり、入力キーの15文字目が「d」であるため、タグキーの優先度の方が、入力キーの優先度よりも大きくなる(ステップS18b)。
On the actual data, the trie
続いて、図19に移行する。トライ木生成部150aは、ノードhの親ノードがルートノードであるため、ノードhのデータ(タグキー、値)と、入力データ(入力キー、値)を交換する。すなわち、トライ木生成部150aは、入力キー「http://aaa.aaa/d/」からトライ部分「h」を取り除いた残りのキー「ttp://aaa.aaa/d/」をノードhのタグキーに登録する。また、入力キー「http://aaa.aaa/d/」に対応する値「3」もノードhに登録する。また、トライ木生成部150aは、ノードhに登録されていたタグキー「ttp://aaa.aaa/e/」の先頭にトライ部分「h」を追加して、入力キーとして取り出す。また、タグキー「ttp://aaa.aaa/e/」に対応付けられていた値「1」も取り出す(ステップS19a)。
Subsequently, the process proceeds to FIG. Since the parent node of the node h is the root node, the trie
実データ上において、トライ木生成部150aは、ノードhのデータ(タグキー、値)と、入力データ(入力キー、値)を交換する。すなわち、トライ木生成部150aは、ノードhに対応するポインタ配列21の「TAG」をテキスト表14の3行目4列目の文字「t」に接続する。また、ポインタ配列21の「Data」と値「3」を接続する。そして、トライ木生成部150aは、入力キーのポインタを、テキスト表14の1行目2列目の「t」に接続する。また、ポインタ配列21の「Data」に接続されていた値「1」を入力値に保持する(ステップS19b)。
On the actual data, the trie
トライ木生成部150aは、ノードhから、入力キー「http://aaa.aaa/e/」の2文字目のtでノードtに遷移し、ノードtのデータ(タグキー、値)と入力データ(入力キー、値)を交換する。すなわち、トライ木生成部150aは、入力キー「http://aaa.aaa/e/」からトライ部分「ht」を取り除いた残りのキー「tp://aaa.aaa/e/」をノードtのタグキーに登録する。また、入力キー「http://aaa.aaa/e/」に対応する値「1」もノードtに登録する。また、トライ木生成部150aは、ノードtに登録されていたタグキー「tp://aaa.aaa/e/c/」の先頭にトライ部分「h」を追加して、入力キーとして取り出す。また、タグキー「ttp://aaa.aaa/e/c/」に対応付けられていた値「2」も取り出す(ステップS20a)。
The trie
実データ上において、トライ木生成部150aは、ノードtのデータ(タグキー、値)と、入力データ(入力キー、値)を交換する。すなわち、トライ木生成部150aは、ノードtに対応するポインタ配列22の「TAG」をテキスト表14の1列目3列目の文字「t」に接続する。また、ポインタ配列22の「Data」と値「1」を接続する。そして、トライ木生成部150aは、入力キーのポインタを、テキスト表14の2行目3列目の「t」に接続する。また、ポインタ配列21の「Data」に接続されていた値「2」を入力値に保持する(ステップS20b)。
On the actual data, the trie
続いて、図20に移行する。トライ木生成部150aは、入力キー「http://aaa.aaa/e/c/」の3文字目に対応するノードtが、ノードtの配下に存在しないので、ノードtの配下に新たなノードtを生成する。ここで、各ノードtを区別するために以下の説明では、親側のノードtをノードt(親)と表記し、子側のノードtをノードt(子)と表記する。また、トライ木生成部150aは、入力キーのポインタを3文字目の「p」に設定する(ステップS21a)。
Subsequently, the process proceeds to FIG. Since the node t corresponding to the third character of the input key “http://aaa.aaa/e/c/” does not exist under the node t, the trie
実データ上において、トライ木生成部150aは、ノードt(子)に対応するポインタ配列23を生成し、ポインタ配列22のキー番号「0×74」で、ポインタ配列22とポインタ配列23を接続する。また、トライ木生成部150aは、入力キーのポインタを、テキスト表14の2行目4列目の「p」に接続する(ステップS21b)。
On the actual data, the trie
続いて、図21に移行する。トライ木生成部150aは、入力キー「http://aaa.aaa/e/c/」からトライ部分「htt」を取り除いた残りのキー「p://aaa.aaa/e/c/」をノードt(子)に接続する。また、トライ木生成部150aは、入力キー「http://aaa.aaa/e/c/」に対応する値「2」をノードt(子)に接続する(ステップS22a)。
Then, it transfers to FIG. The trie
実データ上において、トライ木生成部150aは、ポインタ配列23の「TAG」をテキスト表14の2行目4列目の「p」に接続し、入力キーのポインタを開放する。また、トライ木生成部150aは、ポインタ配列23の「Data」に値「2」を接続する(ステップS22b)。
On the actual data, the trie
続いて、図22に移行し、ステップS22a、22bにおいて作成したトライ木に、キー「http://aaa.aaa/e/」、値「4」を追加する場合について説明する。トライ木生成部150aは、入力キー「http://aaa.aaa/e/」の先頭から文字を順次読み出し、ノードh、t(親)、t(子)に遷移する。そして、トライ木生成部150aは、入力キー「http://aaa.aaa/e/」のポインタを4文字目の「p」に設定する(ステップS23a)。
Subsequently, the case where the key “http://aaa.aaa/e/” and the value “4” are added to the trie tree created in steps S22a and 22b will be described with reference to FIG. The trie
実データ上において、トライ木生成部150aは、テキスト表14に最後に登録されたキー「http://aaa.aaa/e/d/」との間を1つ空けて、キー「http://aaa.aaa/e/」を登録する。そして、トライ木生成部150aは、テキスト表14の4行目6列目の文字「p」に入力キーのポインタを接続する(ステップS23b)。
On the actual data, the trie
続いて、図23に移行する。トライ木生成部150aは、ノードt(子)において、「p」をキーとする子ノードが存在しないので、ノードt(子)のタグキー「p://aaa.aaa/e/c/」の優先度と、トライ部分の「htt」を取り除いた入力キー「p://aaa.aaa/e/」の優先度を比較する。すると、入力キーの15文字目が「空」であり、タグキーの15文字目が「c」であるため、タグキーの優先度が入力キーよりも大きい。
Subsequently, the process proceeds to FIG. The trie
したがって、トライ木生成部150aは、ノードt(子)のデータと、入力データとの交換を行わずに、ノードt(子)からノードt(親)に戻り、入力キー「http://aaa.aaa/e/」のポインタを3文字目の「t」に設定する(ステップS24a)。
Therefore, the trie
実データ上において、トライ木生成部150aは、テキスト表14の4行目6列目の文字「p」に入力キーのポインタを接続する。また、トライ木生成部150aは、ポインタ配列23の「TAG」に接続された文字を先頭とする文字列と、入力キーのポインタに接続された文字を先頭とする文字列とを順次比較すると、入力キーの15文字目が「空」であり、タグキーの15文字目が「c」であるため、タグキーの優先度が入力キーよりも大きいと判定する。そして、トライ木生成部150aは、入力キーのポインタを、4行目5列目の「t」に設定する(ステップS24b)。
On the actual data, the trie
続いて、図24に移行する。トライ木生成部150aは、ノードt(親)のタグキー「tp://aaa.aaa/e/」の優先度と、トライ部分の「ht」を取り除いた入力キー「tp://aaa.aaa/e/」の優先度とを比較する。すると、入力キーとタグキーの優先度が等しい(入力キーとタグキーが同じ)である。この場合、トライ木生成部150aは、入力キー「http://aaa.aaa/e/」に対応する値「4」を、ノードtに追加する(ステップS25a)。
Subsequently, the process proceeds to FIG. The trie
実データ上において、トライ木生成部150aは、テキスト表14の4行目5列目の文字「t」に入力キーのポインタを接続する。また、トライ木生成部150aは、ポインタ配列22の「TAG」に接続された文字を先頭とする文字列と、入力キーのポインタに接続された文字を先頭とする文字列とを順次比較すると、空に至るまでの各文字列が等しいため、タグキーの優先度と入力キーの優先度は等しい(タグキーと入力キーは同じ)と判定する。そして、トライ木生成部150aは、ポインタ配列22に「Data」に値「4」を追加する(ステップS25b)。
On the actual data, the trie
図15〜図24に示したように、トライ木生成部150aは、トライ木140bを生成する場合に、1つのノードに1つのキーを割当てるので、トライ木140bのメモリ使用量を削減することが出来る。また、トライ木生成部150aは、新規の入力キーをトライ木140bに割当てる場合に、全てのタグキーと入力キーを比較することはせず、比較対象ノードのタグキーのみと比較して、タグキーを新規に登録するので、処理負荷を軽減させつつ、深さ優先探索順でタグキーが並ぶようにトライ木140bを生成することが出来る。
As shown in FIGS. 15 to 24, when the trie
なお、図15〜図24に示した実データに対応する各種データ(ポインタ配列、テキスト表等)は、記憶部140に記憶されているものとする。 It is assumed that various data (pointer array, text table, etc.) corresponding to the actual data shown in FIGS. 15 to 24 are stored in the storage unit 140.
図10の説明に戻ると、トライ木探索部150bは、トライ木140bに登録された値の集計値を抽出する処理、所定のキーに対応する値をトライ木140bから検索する処理を実行する処理部である。
Returning to the description of FIG. 10, the trie
まず、トライ木探索部150bが、トライ木140bに登録された値の集計値を抽出する処理について説明する。トライ木探索部150bは、指定された入力キーの文字を先頭から1文字ずつ読み出して、各ノードを辿り、ノードに登録されたタグキーおよび値を対応付けて順次出力することで、集計値を抽出する。ノードに複数の値が登録されている場合には、トライ木探索部150bは、各値を合計しても良いし、別々に出力しても良い。本実施例にかかるトライ木探索部150bは、一例として、各値を合計して出力する。
First, a process in which the trie
図25〜図27は、集計値を抽出する処理を説明するための図である。図25に示すように、トライ木140bは、ルートノードの配下に、ノードh、ノードt(親)、ノードt(子)が順に接続されている。ノードhは、タグキー「ttp://aaa.aaa/d/」、値「3」を登録し、ノードt(親)は、タグキー「tp://aaa.aaa/e/」、値「1、4」を登録し、ノードt(子)は、タグキー「p://aaa.aaa/e/c/」、値「2」を登録しているものとする。
FIGS. 25 to 27 are diagrams for explaining the process of extracting the total value. As shown in FIG. 25, in the
また、図25〜図27における説明では、入力キー「http://aaa.aaa/e/」が指定された場合の集計値の抽出処理について説明する。図25において、トライ木探索部150bは、入力キー「http://aaa.aaa/e/」の1文字目をポインタに設定し、ポインタの文字にしたがって、ノードhに移行する。
In addition, in the description in FIGS. 25 to 27, the total value extraction process when the input key “http://aaa.aaa/e/” is designated will be described. In FIG. 25, the trie
ノードhは、タグキー「ttp://aaa.aaa/d/」、値「3」が登録されているので、トライ木探索部150bは、トライ部分「h」をタグキー「ttp://aaa.aaa/d/」の先頭に追加したキー「http://aaa.aaa/d/」と、値(合計値)「3」を出力する(ステップS30a)。
Since the node h is registered with the tag key “ttp: //aaa.aaa/d/” and the value “3”, the trie
実データ上において、トライ木探索部150bは、テキスト表14の4行目3列目に入力キー「http://aaa.aaa/d/」を登録し、入力キーのポインタを4行目3列目に接続する。また、トライ木探索部150bは、現在のノードのポインタをポインタ配列21に接続する。また、トライ木探索部150bは、ノードhに対応するポインタ配列21の「TAG」に接続された文字の前後空までの文字列「http://aaa.aaa/d/」と、「Data」に接続された値「3」を出力する(ステップS30b)。
On the actual data, the trie
図26の説明に移行する。トライ木探索部150bは、入力キー「http://aaa.aaa/e/」の2文字目をポインタに設定し、ポインタの文字にしたがって、ノードhからノードt(親)に移行する。ノードt(親)は、タグキー「tp://aaa.aaa/e/」、値「1、4」が登録されているので、トライ木探索部150bは、トライ部分「ht」をタグキー「tp://aaa.aaa/e/」の先頭に追加したキーと、値「1、4」を合計した値「5」を出力する(ステップS31a)。
The description shifts to the description of FIG. The trie
実データ上において、トライ木探索部150bは、入力キーのポインタ接続先を1文字ずらし、テキスト表14の4行目4列目の文字「t」に接続する。また、トライ木探索部150bは、現在のノードのポインタをポインタ配列22に接続する。また、トライ木探索部150bは、ノードt(親)に対応するポインタ配列22の「TAG」に接続された文字の前後空までの文字列「http://aaa.aaa/e/」と、「Data」に接続された値「1、4」の合計値「5」を出力する(ステップS31b)。
On the actual data, the trie
図27の説明に移行する。トライ木探索部150bは、入力キー「http://aaa.aaa/e/」の3文字目をポインタに設定し、ポインタの文字にしたがって、ノードt(親)からノードt(子)に移行する。ノードt(子)は、タグキー「p://aaa.aaa/e/c/」、値「2」が登録されているので、トライ木探索部150bは、トライ部分「htt」をタグキー「p://aaa.aaa/e/c/」の先頭に追加したキーと、値(合計値)「2」を出力する(ステップS32a)。
The description shifts to the description of FIG. The trie
実データ上において、トライ木探索部150bは、入力キーのポインタ接続先を1文字ずらし、テキスト表14の4行目5列目の文字「t」に接続する。また、トライ木探索部150bは、現在のノードのポインタをポインタ配列23に接続する。また、トライ木探索部150bは、ノードt(子)に対応するポインタ配列23の「TAG」に接続された文字の前後空までの文字列「http://aaa.aaa/e/c/」と、「Data」に接続された値(合計値)「2」を出力する(ステップS32b)。
On the actual data, the trie
図25〜図27に示したように、入力キーを順次読み出し、トライ木140bを辿ることで、入力キーに対応する集計値を出力することが出来る。
As shown in FIGS. 25 to 27, by sequentially reading the input keys and tracing the
次に、トライ木探索部150bが、指定された入力キーに対応する値をトライ木140bから検索する処理について説明する。トライ木探索部150bは、トライ木140bが、深さ優先探索順でタグキーが並ぶように生成されているので、比較対象ノードに登録されたタグキーと入力キーを比較すればよい。また、比較対象ノードに含まれる各ノードと入力キーを比較する場合に、二分探索法を用いることで、更に処理負荷を軽減させることが出来る。
Next, a process in which the trie
以下において、二分探索法を用いた場合の検索処理について説明する。図28〜図31は、二分探索法を用いた場合の検索処理を説明するための図である。図28に示すように、トライ木140bは、ルートノードの配下に、ノードh、ノードt(親)、ノードt(子)が順に接続されている。ノードhは、タグキー「ttp://aaa.aaa/d/」、値「3」を登録し、ノードt(親)は、タグキー「tp://aaa.aaa/e」、値「1、4」を登録し、ノードt(子)は、タグキー「p://aaa.aaa/e/c」、値「2」を登録しているものとする。
In the following, a search process when the binary search method is used will be described. 28 to 31 are diagrams for explaining search processing when the binary search method is used. As shown in FIG. 28, in the
また、図28〜図31における説明では、入力キー「http://aaa.aaa/d」が指定された場合の検索処理について説明する。図28において、トライ木探索部150bは、入力キー「http://aaa.aaa/d」の先頭文字から順に文字を読み出し、ルートノードからノードh、ノードt(親)、ノードt(子)の順に遷移する。そして、トライ木探索部150bは、入力キー「http://aaa.aaa/d」のポインタを初期位置の「h」から3文字ずらした「p」に設定する。また、遷移した各ノードにスタックを追加する(ステップS40a)。
In the description of FIGS. 28 to 31, search processing when the input key “http://aaa.aaa/d” is designated will be described. In FIG. 28, the trie
実データ上では、トライ木探索部150bは、ノードh、ノードt(親)、ノードt(子)に対応するポインタ配列21、22、23にそれぞれスタックを追加する。また、トライ木探索部150bは、現在のノードのポインタをポインタ配列23に接続する(ステップS40b)。なお、ここでは、説明の便宜上、入力キー「http://aaa.aaa/d」の記載を省略するが、テキスト表14に入力キー「http://aaa.aaa/d」の情報が格納されているものとする。
On the actual data, the trie
続いて、図29の説明に移行する。トライ木探索部150bは、スタックの真ん中のノードt(親)に遷移し、入力キーのポインタを戻った分だけ戻す。ここでは、ノードt(子)からノードt(親)に戻っているので、入力キー「http://aaa.aaa/d」のポインタを「p」から1つ戻した「t(3文字目のt)」に設定する。
Subsequently, the description proceeds to FIG. The trie
そして、トライ木探索部150bは、ノードtのタグキー「tp://aaa.aaa/e」の優先度と、トライ部分「ht」を取り除いた入力キー「tp://aaa.aaa/d」の優先度とを比較する。すると、入力キーの14文字目が「d」であり、タグキーの14文字目が「e」であるため、トライ木探索部150bは、タグキーの優先度が入力キーの優先度よりも大きいと判定する(ステップS41a)。ノードt(親)タグキーの優先度が入力キーの優先度よりも大きい場合には、ノードt(親)以降のノードには、検索対象となるタグキーが存在しない。
Then, the trie
実データ上において、トライ木探索部150bは、スタックの真ん中に接続されたポインタ配列22に現在のノードのポインタを移動させる。そして、トライ木探索部150bは、ポインタ配列22の「TAG」に接続された文字以降の文字列「tp://aaa.aaa/e」と、トライ部分「ht」を除いた残りの入力キー「tp://aaa.aaa/d」とを比較する。すると、入力キーの14文字目が「d」であり、タグキーの14文字目が「e」であるため、トライ木探索部150bは、タグキーの優先度が入力キーの優先度よりも大きいと判定する(ステップS41b)。
On the actual data, the trie
続いて、図30の説明に移行する。図29で説明したように、ノードt(親)タグキーの優先度が入力キーの優先度よりも大きい場合には、ノードt(親)以降のノードには、検索対象となるタグキーが存在しない。したがって、トライ木探索部150bは、スタックの後半となる、ノードt(親)、ノードt(子)に追加されたスタックを削除する。
Subsequently, the description proceeds to FIG. 30. As described with reference to FIG. 29, when the priority of the node t (parent) tag key is higher than the priority of the input key, the node after the node t (parent) has no tag key to be searched. Therefore, the trie
また、トライ木探索部150bは、スタックの真ん中のノードhに遷移し、入力キーのポインタを戻った分だけ戻す。ここでは、ノードt(親)からノードhに戻っているので、入力キー「http://aaa.aaa/d/」のポインタを「t(3文字目)」から1つ戻した「t(2文字目)」に設定する(ステップS42a)。
The trie
実データ上において、トライ木生成部150aは、スタックの真ん中に接続されたポインタ配列21に現在のノードのポインタを移動させる(ステップS41b)。
On the actual data, the trie
図31の説明に移行する。トライ木探索部150bは、ノードhのタグキー「ttp://aaa.aaa/d/」の優先度と、トライ部分「h」を取り除いた入力キー「ttp://aaa.aaa/d/」の優先度を比較する。すると、タグキーと入力キーの優先度が等しい(タグキーと入力キーが同じ)ため、トライ木探索部150bは、ノードhに接続されたタグキー「ttp://aaa.aaa/d/」の先頭にトライ部分「h」を追加したキー「http://aaa.aaa/d/」と、値「3」を検索結果として出力する(ステップS43a)。
The description shifts to the description of FIG. The trie
実データ上において、トライ木探索部150bは、ポインタ配列21の「TAG」に接続された文字以降の文字列「ttp://aaa.aaa/d/」の優先度と、トライ部分「h」を取り除いた残りの入力キー「tp://aaa.aaa/d/」の優先度を比較する。すると、タグキーと入力キーの優先度が等しい(タグキーと入力キーが同じ)ため、トライ木探索部150bは、ポインタ配列21の「TAG」に接続された文字の前後空までの文字列「http://aaa.aaa/d/」と、「Data」に接続された値「3」を出力する(ステップS43b)。
On the actual data, the trie
次に、図32〜図35において、その他の例を用いて、二分探索法を用いた場合の検索処理について説明する。図32に示すように、トライ木140bは、ルートノードの配下に、ノードa、ノードb、ノードcを接続している。ノードaは、タグキー「aa」、値「3」を登録し、ノードbは、タグキー「c」、値「1」を登録し、ノードcは、タグキー「b」、値「2」を登録しているものとする。なお、ノードbとノードcの関係は、ノードbが兄ノードであり、ノードcが弟ノードである。
Next, in FIG. 32 to FIG. 35, the search processing when the binary search method is used will be described using other examples. As illustrated in FIG. 32, the
また、図32〜図35における説明では、入力キー「ac」が指定された場合の検索処理について説明する。図32において、トライ木探索部150bは、入力キー「ac」から「a」を読み出し、入力キーのポインタを「a」から「c」にずらす。また、トライ木探索部150bは、ノードaにスタックを追加する(ステップS50a)。
In the description of FIGS. 32 to 35, search processing when the input key “ac” is designated will be described. In FIG. 32, the trie
実データ上では、トライ木探索部150bは、ノードaに対応するポインタ配列21にスタックを追加する。また、トライ木探索部150bは、現在のノードのポインタをポインタ配列21に接続する。トライ木探索部150bは、入力キーのポインタを、テキスト表14の1行目14列目の文字「c」に設定する(ステップS50b)。
On the actual data, the trie
続いて、図33の説明に移行する。トライ木探索部150bは、入力キー「ac」からポインタが指定する「c」を読み出し、ノードcに遷移する。ノードcに遷移した時点で、ノードaの先祖ノードに登録されたタグキーの優先度は、入力キー「ac」の優先度よりもすべて小さいものとなるため、検索対象から外す必要がある。したがって、トライ木探索部150bは、一旦スタックを空にし、スタックに新しくノードcを追加する。また、入力キーのポインタを「c」から1文字ずらし、ポインタを「空」に設定する(ステップS51a)。
Subsequently, the description proceeds to FIG. The trie
実データ上では、トライ木探索部150bは、現在のノードをポインタ配列23に指定する。トライ木探索部150bは、ポインタ配列21に接続されたスタックを削除し、ポインタ配列23にスタックを追加する。また、トライ木探索部150bは、入力キーのポインタをテキスト表14の1行目15文字目の「空」に設定する(ステップS51b)。
On the actual data, the trie
続いて、図34の説明に移行する。トライ木探索部150bは、ポインタが指定する文字が「空」なので、スタックの真ん中のノードcを現在のノードに設定し、ノードcのタグキー「b」の優先度と、トライ部分「ac」を除いた「空」の優先度を比較する。トライ木探索部150bは、比較した結果、タグキーの優先度の方が入力キーの優先度よりも大きいと判定する(ステップS52a)。
Subsequently, the description proceeds to FIG. Since the character designated by the pointer is “empty”, the trie
実データ上では、トライ木探索部150bは、スタックの真ん中に対応するポインタ配列23に現在のノードを設定し、ポインタ配列23の「TAG」に接続された文字を先頭とする文字列と、入力キーのポインタに接続された「空」とを比較する。トライ木探索部150bは、比較した結果、タグキーの優先度の方が入力キーの優先度よりも大きいと判定する(ステップS52b)。
On the actual data, the trie
続いて、図35の説明に移行する。トライ木探索部150bは、タグキーの優先度の方が入力キーの優先度よりも大きいので、タグキーを登録するノードcのスタックを削除する。全てのスタックが無くなり、入力キー「ac」と一致するタグキーが存在しないので、トライ木探索部150bは、一致データが存在しない旨を出力する(ステップS53a)。
Subsequently, the description proceeds to FIG. Since the priority of the tag key is higher than the priority of the input key, the trie
実データ上では、トライ木探索部150bは、タグキーの優先度の方が入力キーの優先度よりも大きいので、ノードcに対応するポインタ配列28に接続されたスタックを削除する。全てのスタックが無くなり、入力キー「ac」と一致するタグキーが存在しないので、トライ木探索部150bは、一致データが存在しない旨を出力する(ステップS53b)。
On the actual data, the trie
上述した図28〜図35では、トライ木探索部150bが、二分探索法を用いて検索処理を実行する場合について説明したが、トライ木探索部150bは、必ずしも二分探索法を用いなくてもよい。図36〜図40は、二分探索法を用いない場合の探索処理を説明するための図である。図36に示すように、トライ木140bは、ルートノードの配下にノードb、ノードa、ノードb、ノードcが接続されている。ここで、各ノードbを区別するために、ルートノードの子ノードに対応するノードbをノードb(1)と表記し、もう一方のノードbをノードb(2)と表記する。
In FIG. 28 to FIG. 35 described above, the trie
ノードb(1)は、タグキー「a」、値「1」を登録し、ノードaは、タグキー「aa」、値「3」を登録し、ノードb(2)は、タグキー「c」、値「1」を登録し、ノードcは、タグキー「b」、値「2」を登録しているものとする。 Node b (1) registers tag key “a” and value “1”, node a registers tag key “aa” and value “3”, and node b (2) registers tag key “c” and value It is assumed that “1” is registered and the node c has registered the tag key “b” and the value “2”.
また、図36〜図40における説明では、入力キー「baca」が指定された場合の検索処理について説明する。図36において、トライ木探索部150bは、入力キーのポインタを先頭文字「b」に設定し、ポインタの指定する「b」により、ルートノードからノードb(1)に遷移する。そして、トライ木探索部150bは、入力キーのポインタを「b」から1文字ずらした「a」に設定する(ステップS60a)。
36 to 40, search processing when the input key “baca” is designated will be described. In FIG. 36, the trie
実データ上では、トライ木探索部150bは、テキスト表14に入力キー「baca」を登録し、入力キーのポインタをテキスト表14の2行目1列目の「b」に接続する。トライ木探索部150bは、入力キーのポインタに接続された「b」により、ポインタ配列20からポインタ配列21に現在のノードのポインタを遷移させ、入力キーのポインタを1文字ずらした「a」に設定する(ステップS60b)。
On the actual data, the trie
続いて、図37の説明に移行する。トライ木探索部150bは、ポインタの指定する「a」により、ノードb(1)からノードaに遷移し、入力キーのポインタを「a」から1文字ずらした「c」に設定する(ステップS61a)。
Subsequently, the description proceeds to FIG. The trie
実データ上では、トライ木探索部150bは、入力キーのポインタに接続された「a」により、ポインタ配列21からポインタ配列22に現在のノードのポインタを遷移させ、入力キーのポインタを1文字ずらした「c」に設定する(ステップS61b)。
On the actual data, the trie
続いて、図38の説明に移行する。トライ木探索部150bは、ポインタの指定する「c」により、ノードaからノードcに遷移し、入力キーのポインタを「c」から1文字ずらした「a」に設定する(ステップS62a)。
Subsequently, the description proceeds to FIG. The trie
実データ上では、トライ木探索部150bは、入力キーのポインタに接続された「c」により、ポインタ配列22からポインタ配列24に現在のノードのポインタを遷移させ、入力キーのポインタを1文字ずらした「a」に設定する(ステップS62b)。
On the actual data, the trie
図39の説明に移行する。トライ木探索部150bは、ポインタの指定する「a」に対応した子ノードが、ノードcに存在しないので、ノードcに登録されたタグキー「b」の優先度と、トライ部分「bac」を取り除いた入力キー「a」の優先度とを比較する。トライ木探索部150bは、比較した結果、入力キーの優先度よりもタグキーの優先度の方が大きいと判定する(ステップS63a)。
The description shifts to the description of FIG. The trie
実データ上では、トライ木探索部150bは、ポインタ配列24の「TAG」に接続された文字「b」の優先度と、入力キーのポインタに接続された文字「a」の優先度を比較する。トライ木探索部150bは、比較した結果、入力キーの優先度よりもタグキーの優先度の方が大きいと判定する(ステップS63b)。
On the actual data, the trie
図40の説明に移行する。トライ木探索部150bは、ノードcが兄ノード(ノードb(2))を有するので、ノードcより前のノード(ノードa、ノードb(1))に、入力キーと一致するタグキーを有するノードは存在しないと判定する。トライ木探索部150bは、該当データが無い旨を出力する(ステップS64)。
The description shifts to the description of FIG. Since the node c has an older brother node (node b (2)), the trie
ところで、トライ木探索部150bは、トライ木140bに対して削除するキーを指定された場合に、指定された入力キーをトライ木140bから削除する。図41は、削除処理を説明するための図である。ここでは、図41の左側に示すトライ木からタグキー「black」、値「1」を削除する場合について説明する。
By the way, when the key to be deleted is designated for the
まず、トライ木探索部150bは、上述した探索処理と同様にして、入力キー「black」と同じタグキーを有するノードlを探索し、ノードlに登録されたタグキー「ack」と値「1」を削除する。
First, the trie
そして、トライ木探索部150bは、ノードlの長男ノードとなるノードuのタグキー「e(blue)」、値「4」をノードlに登録する。また、トライ木探索部150bは、ノードuの長男ノードとなるノードeのタグキー「blueviolet」、値「3」をノードuに登録し、ノードeをトライ木から削除する。トライ木探索部150bが、図41の左側に示すトライ木からキー「black」、値「1」を削除することで、図41の右側に示すトライ木が生成される。
Then, the trie
次に、本実施例1にかかる検索装置100の各種の処理手順について説明する。まず、本実施例1にかかる検索装置100がトライ木140bを生成する処理について説明する。図42は、本実施例2にかかるトライ木生成処理の処理手順を示すフローチャートである。
Next, various processing procedures of the search device 100 according to the first embodiment will be described. First, the process in which the search device 100 according to the first embodiment generates the
図42に示すように、トライ木生成部150aは、ルートノードを生成し(ステップS101)、次の入力データ(キー、値)が登録データ管理テーブル140aに存在するか否かを判定する(ステップS102)。
As shown in FIG. 42, the trie
トライ木生成部150aは、次の入力データが登録データ管理テーブル140aに存在しないと判定した場合には(ステップS103、No)、処理を終了する。一方、トライ木生成部150aは、次の入力データが登録データ管理テーブル140aに登録されている場合には(ステップS103,Yes)、未読の入力データを読み出し(ステップS104)、データ追加処理を実行し(ステップS105)、ステップS102に移行する。
If the trie
次に、図42のステップS105に示したデータ追加処理の処理手順について説明する。ここでは、二分探索法を用いないでデータ追加処理を実行する場合と、二分探索法を用いてデータ追加処理を実行する場合に分けて説明する。 Next, the procedure of the data addition process shown in step S105 of FIG. 42 will be described. Here, a case where the data addition process is executed without using the binary search method and a case where the data addition process is executed using the binary search method will be described separately.
図43および図44は、二分探索法を用いないデータ追加処理の処理手順を示すフローチャートである。図43に示すように、トライ木生成部150aは、現在のノードをルートノードに設定し(ステップS150)、入力キーが空であるか否かを判定する(ステップS151)。
FIG. 43 and FIG. 44 are flowcharts showing a processing procedure of data addition processing that does not use the binary search method. As shown in FIG. 43, the trie
トライ木生成部150aは、入力キーが空ではない場合には(ステップS152,No)、入力キーの先頭文字のキーで子ノードを参照し、子ノードが存在するか否かを判定する(ステップS153)。トライ木生成部150aは、子ノードが存在する場合には(ステップS154,Yes)、入力キーの先頭の1文字を読取り、入力キーのポインタを1文字進め、読み出した文字をキーとして子ノードに遷移し(ステップS155)、ステップS151に移行する。
When the input key is not empty (No in step S152), the trie
一方、トライ木生成部150aは、子ノードが存在しない場合には(ステップS154,No)、ステップS156に移行する。
On the other hand, if there is no child node (No at Step S154), the trie
ところで、ステップS152において、入力キーが空の場合には(ステップS152,Yes)、ノードの情報を参照し(ステップS156)、タグキーの優先度が入力キーの優先度と等しい(タグキーが入力キーと等しい)か否かを判定する(ステップS157)。タグキーの優先度と入力キーの優先度が等しい場合には(ステップS158,Yes)、トライ木生成部150aは、現在のノードに入力値(入力キーに対応する値)を追加し(ステップS159)、データ追加処理を終了する。
In step S152, if the input key is empty (step S152, Yes), the node information is referred to (step S156), and the priority of the tag key is equal to the priority of the input key (the tag key is the input key). It is determined whether or not (step S157). When the priority of the tag key and the priority of the input key are equal (step S158, Yes), the trie
一方、タグキーの優先度と入力キーの優先度が異なる場合には(ステップS158,No)、トライ木生成部150aは、タグキーの優先度が入力キーの優先度よりも大きいか否かを判定する(ステップS160)。タグキーの優先度が入力キーの優先度よりも小さい場合には(ステップS161,No)、ステップS164に移行する。
On the other hand, when the priority of the tag key is different from the priority of the input key (No in step S158), the trie
タグキーの優先度が入力キーの優先度よりも大きい場合には(ステップS161,Yes)、兄ノードが存在する、または、親ノードがルートノードであるか否かを判定する(ステップS162)。兄ノードが存在せず、かつ、親ノードがルートノードではない場合には(条件を満たさない場合には)(ステップS163,No)、入力キーのポインタを1文字戻し、親ノードへ遷移し(ステップS164)、ステップS160に遷移する。 If the priority of the tag key is higher than the priority of the input key (step S161, Yes), it is determined whether there is an older brother node or whether the parent node is a root node (step S162). When there is no brother node and the parent node is not the root node (when the condition is not satisfied) (step S163, No), the input key pointer is returned by one character, and the transition is made to the parent node ( Step S164) and the process proceeds to Step S160.
一方、兄ノードが存在する、または、親ノードがルートノードの場合(条件を満たす場合)には(ステップS163,Yes)、現在のノードのタグキー、値と入力キー、入力値をそれぞれ交換し(ステップS168)、ステップS165に移行する。 On the other hand, if the older brother node exists or the parent node is the root node (when the condition is satisfied) (step S163, Yes), the tag key, the value and the input key, and the input value of the current node are respectively exchanged ( Step S168) and the process proceeds to Step S165.
ところで、トライ木生成部150aは、ステップS161において、タグキーの優先度が入力キーの優先度よりも小さい場合には(ステップS161,No)、入力キーの先頭文字のキーで子ノードを参照し、子ノードが存在するか否かを判定する(ステップS165)。
By the way, if the priority of the tag key is lower than the priority of the input key in step S161 (step S161, No), the trie
子ノードが存在する場合には(ステップS166,Yes)、トライ木生成部150aは、入力キーの先頭1文字を読み取り、入力キーのポインタを1文字進め、読み出した文字をキーとして子ノードへ遷移し(ステップS167)、ステップS168に移行する。
When there is a child node (step S166, Yes), the trie
一方、子ノードが存在しない場合には(ステップS166,No)、トライ木生成部150aは、新しいノードを生成し(ステップS169)、入力キーの先頭1文字を読み取り、入力キーのポインタを1文字進め、読み出した文字をキーとして、現在のノードから新しいノードへ接続する(ステップS170)。
On the other hand, if no child node exists (step S166, No), the trie
トライ木生成部150aは、入力キーをタグキーとして新しいノードに付加し(ステップS171)、入力値を新しいノードに付加し(ステップS172)、データ追加処理を終了する。
The trie
図45〜図47は、二分探索法を用いるデータ追加処理の処理手順を示すフローチャートである。トライ木生成部150aは、現在のノードをルートノードに設定し(ステップS180)、入力キーが空であるか否かを判定する(ステップS181)。
45 to 47 are flowcharts showing a processing procedure of data addition processing using the binary search method. The trie
入力キーが空の場合には(ステップS182,Yes)、トライ木生成部150aは、ステップS190に移行する。一方、入力キーが空ではない場合には(ステップS182,No)、トライ木生成部150aは、入力キーの先頭文字のキーで子ノードを参照し、子ノードが存在するか否かを判定する(ステップS183)。
If the input key is empty (step S182, Yes), the trie
子ノードが存在する場合には(ステップS184,Yes)、トライ木生成部150aは、子ノードが長男であるか否かを判定し(ステップS185)、子ノードが長男の場合には(ステップS186,Yes)、ステップS188に移行する。
When a child node exists (step S184, Yes), the trie
一方、子ノードが長男ではない場合には(ステップS186,No)、トライ木生成部150aは、スタックを空に設定し(ステップS187)、入力キーの先頭1文字を読み取り、入力キーのポインタを1文字進め、読み出した文字をキーとして子ノードへ遷移する(ステップS188)。トライ木生成部150aは、遷移したノードをスタックに追加し(ステップS189)、ステップS181に移行する。
On the other hand, when the child node is not the eldest son (step S186, No), the trie
ところで、トライ木生成部150aは、ステップS184において、子ノードが存在しない場合には(ステップS184,No)、スタックが空であるか否かを判定し(ステップS191)、スタックが空ではない場合には(ステップS191,No)、スタックの真ん中のデータを現在のノードとし、入力キーのポインタを移動した分だけ、ずらす(ステップS192)。
By the way, when there is no child node in Step S184 (No in Step S184), the trie
図46に移行する。トライ木生成部150aは、タグキーの優先度と入力キーの優先度が等しいか否かを判定し(ステップS193)、タグキーの優先度と入力キーの優先度が等しい場合には(ステップS194,Yes)、現在のノードに入力値を追加する(ステップS195)。
Shifting to FIG. The trie
一方、トライ木生成部150aは、タグキーの優先度と入力キーの優先度が異なる場合には(ステップS194,No)、タグキーの優先度が入力キーの優先度よりも大きいか否かを判定する(ステップS196)。
On the other hand, when the priority of the tag key and the priority of the input key are different (No in step S194), the trie
トライ木生成部150aは、タグキーの優先度が入力キーの優先度よりも大きい場合には(ステップS197,Yes)、真ん中のスタックを含む、スタックの後半を削除し(ステップS199)、図45のステップS190に移行する。
If the priority of the tag key is higher than the priority of the input key (step S197, Yes), the trie
一方、トライ木生成部150aは、タグキーの優先度が入力キーの優先度よりも小さい場合には(ステップS197,No)、真ん中のスタックを含む、スタックの前半を削除し(ステップS198)、図45のステップS190に移行する。
On the other hand, when the priority of the tag key is lower than the priority of the input key (No at Step S197), the trie
ところで、図45のステップS191において、スタックが空の場合には(ステップS191,Yes)、図47に移行し、トライ木生成部150aは、入力キーの先頭文字のキーで子ノードを参照し、子ノードが存在するか否かを判定する(ステップS200)。
By the way, when the stack is empty in step S191 of FIG. 45 (step S191, Yes), the process proceeds to FIG. 47, and the trie
トライ木生成部150aは、子ノードが存在する場合には(ステップS201,Yes)、入力キーの先頭1文字を読み取り、残り入力キーのポインタを1文字進め、読み出した文字をキーとして、子ノードに遷移する(ステップS202)。そして、トライ木生成部150aは、現在のノードのタグキー、値と入力キー、入力値をそれぞれ交換し(ステップS203)、ステップS200に移行する。
If there is a child node (Yes in step S201), the trie
一方、トライ木生成部150aは、子ノードが存在しない場合には(ステップS201,No)、新しいノードを生成し(ステップS204)、入力キーの先頭1文字を読み取り、残り入力キーのポインタを1文字進め、読み出した文字をキーとして、現在のノードから新しいノードへ接続する(ステップS205)。トライ木生成部150aは、入力キーをタグキーとして新しいノードに付加し(ステップS206)、入力値を新しいノードに付加する(ステップS207)。
On the other hand, if there is no child node (No in step S201), the trie
次に、本実施例にかかる検索装置100がトライ木140bを用いて検索を行う処理について説明する。ここでは、二分探索法を用いないで検索処理を実行する場合と、二分探索法を用いて検索処理を実行する場合について説明する。
Next, a process in which the search device 100 according to the present embodiment performs a search using the
まず、二分探索法を用いない検索処理の処理手順について説明する。図48は、二分探索法を用いない検索処理の処理手順を示すフローチャートである。図48に示すように、トライ木探索部150bは、現在のノードをルートノードに設定し(ステップS300)、入力キーが空であるか否かを判定する(ステップS301)。
First, a processing procedure of search processing that does not use the binary search method will be described. FIG. 48 is a flowchart showing a processing procedure of search processing that does not use the binary search method. As shown in FIG. 48, the trie
トライ木探索部150bは、入力キーが空ではない場合には(ステップS302,No)、入力キーの先頭文字のキーで子ノードを参照し、子ノードが存在するか否かを判定する(ステップS303)。トライ木探索部150bは、子ノードが存在しない場合には(ステップS304,No)、ステップS306に移行する。
If the input key is not empty (No in step S302), the trie
一方、トライ木探索部150bは、子ノードが存在する場合には(ステップS304,Yes)、入力キーの先頭1文字を読み取り、入力キーのポインタを1文字進め、読み出した文字をキーとして子ノードに遷移し(ステップS305)、ステップS301に移行する。
On the other hand, if there is a child node (Yes in step S304), the trie
ところで、ステップS302において、入力キーが空の場合には(ステップS302,Yes)、トライ木探索部150bは、ノードの情報を参照し、タグキーの優先度と入力キーの優先度が等しいか否かを判定する(ステップS306)。トライ木探索部150bは、タグキーの優先度と入力キーの優先度が等しい場合には(ステップS307,Yes)、現在のノードのデータ(値)を出力する(ステップS308)。
By the way, when the input key is empty in step S302 (step S302, Yes), the trie
一方、タグキーの優先度と入力キーの優先度が異なる場合には(ステップS307,No)、トライ木探索部150bは、タグキーの優先度が入力キーの優先度よりも大きいか否かを判定する(ステップS310)。トライ木探索部150bは、タグキーの優先度が入力キーの優先度よりも小さい場合には(ステップS310,No)、ステップS314に移行する。
On the other hand, if the priority of the tag key is different from the priority of the input key (No in step S307), the trie
一方、タグキーの優先度が入力キーの優先度よりも大きい場合には(ステップS310,Yes)、トライ木探索部150bは、兄ノードが存在するか、または、親ノードがルートノードであるか否かを判定する(ステップS311)。
On the other hand, if the priority of the tag key is higher than the priority of the input key (step S310, Yes), the trie
トライ木探索部150bは、兄ノードが存在しないで、かつ、親ノードがルートノードではない場合(条件を満たさない場合)に(ステップS312,No)、入力キーのポインタを1文字戻し、親ノードへ遷移する(ステップS313)。
When there is no brother node and the parent node is not the root node (when the condition is not satisfied) (No in step S312), the trie
一方、トライ木探索部150bは、兄ノードが存在するか、または、親ノードがルートノードの場合(条件を満たす場合)に(ステップS312,Yes)、一致するデータが存在しない旨を出力する(ステップS314)。
On the other hand, the trie
続いて、二分探索法を用いる検索処理の処理手順について説明する。図49および図50は、二分探索法を用いる検索処理の処理手順を示すフローチャートである。図49に示すように、トライ木探索部150bは、現在のノードをルートノードに設定し(ステップS350)、入力キーが空であるか否かを判定する(ステップS351)。
Subsequently, a processing procedure of search processing using the binary search method will be described. FIG. 49 and FIG. 50 are flowcharts showing the processing procedure of search processing using the binary search method. As shown in FIG. 49, the trie
トライ木探索部150bは、入力キーが空の場合には(ステップS352,Yes)、図50のステップS360に移行する。一方、トライ木探索部150bは、入力キーが空ではない場合に(ステップS352,No)、入力キーの先頭文字のキーで、子ノードが存在するか否かを判定する(ステップS353)。
If the input key is empty (Yes in step S352), the trie
トライ木探索部150bは、子ノードが存在しない場合には(ステップS354,No)、図50のステップS360に移行する。一方、トライ木探索部150bは、子ノードが存在する場合に(ステップS354,Yes)、子ノードが長男であるか否かを判定する(ステップS355)。
If there is no child node (No in step S354), the trie
トライ木探索部150bは、子ノードが長男である場合には(ステップS356,Yes)、ステップS358に移行する。一方、トライ木探索部150bは、子ノードが長男ではない場合に(ステップS356,No)、スタックを空に設定する(ステップS357)。
When the child node is the eldest son (step S356, Yes), the trie
トライ木探索部150bは、入力キーの先頭1文字を読み取り、入力キーのポインタを1文字進め、読み出した文字をキーとして子ノードに遷移する(ステップS358)。そして、トライ木探索部150bは、遷移したノードをスタックに追加し(ステップS359)、ステップS351に移行する。
The trie
ところで、トライ木探索部150bは、ステップS352において、入力キーが空の場合(ステップS352,Yes)、または、ステップS354において、子ノードが存在しない場合(ステップS354,No)には、図50のステップS360に移行する。
By the way, if the input key is empty in step S352 (step S352, Yes), or if no child node exists in step S354 (step S354, No), the trie
図50において、トライ木探索部150bは、スタックが空であるか否かを判定し(ステップS360)、スタックが空の場合には(ステップS361,Yes)、一致データが無い旨の情報を出力する(ステップS362)。
In FIG. 50, the trie
一方、トライ木探索部150bは、スタックが空ではない場合に(ステップS361,No)、スタックの真ん中のノードを現在のノードとし、入力キーのポインタを移動した分だけ、ずらす(ステップS363)。
On the other hand, when the stack is not empty (step S361, No), the trie
トライ木探索部150bは、タグキーの優先度と入力キーの優先度が等しいか否かを判定し(ステップS364)、タグキーの優先度と入力キーの優先度が等しい場合には(ステップS365,Yes)、現在のノードのデータ(値)を出力する(ステップS366)。
The trie
一方、トライ木探索部150bは、タグキーの優先度と入力キーの優先度が異なる場合には(ステップS365,No)、タグキーの優先度が入力キーの優先度よりも大きいか否かを判定する(ステップS367)。
On the other hand, if the priority of the tag key and the priority of the input key are different (No in step S365), the trie
トライ木探索部150bは、タグキーの優先度が入力キーの優先度よりも小さい場合には(ステップS368,No)、真ん中のスタックを含むスタックの前半を削除し(ステップS369)、ステップS360に移行する。
When the priority of the tag key is lower than the priority of the input key (No at Step S368), the trie
一方、トライ木探索部150bは、タグキーの優先度が入力キーの優先度よりも大きい場合には(ステップS368,Yes)、真ん中のスタックを含むスタックの後半を削除し(ステップS370)、ステップS360に移行する。
On the other hand, when the priority of the tag key is higher than the priority of the input key (Yes in step S368), the trie
次に、検索装置100が、集計値を抽出する処理について説明する。図51は、集計値の抽出処理の処理手順を示すフローチャートである。図51に示すように、このトライ木探索部150bは、現在のノードをルートノードに設定し(ステップS400)、子ノードが存在するか否かを判定する(ステップS401)。
Next, a process in which the search device 100 extracts a total value will be described. FIG. 51 is a flowchart illustrating the processing procedure of the total value extraction processing. As shown in FIG. 51, the trie
トライ木探索部150bは、子ノードが存在する場合には(ステップS402,Yes)、各子ノードのうち、長男ノードへ遷移し(ステップS403)、現在のノードの各種データを加工し出力し(ステップS404)、ステップS401に移行する。ステップS404において、トライ木探索部150bは、例えば、長男ノードに複数の値が登録されている場合には、各値を加算する処理をおこない、加算した値を出力する。
When there is a child node (Yes in step S402), the trie
一方、子ノードが存在しない場合には(ステップS402,No)、トライ木探索部150bは、弟ノードが存在するか否かを判定し(ステップS405)、弟ノードが存在する場合には(ステップS406,Yes)、次の弟ノードへ遷移し(ステップS407)、ステップS404に移行する。
On the other hand, when there is no child node (step S402, No), the trie
一方、トライ木探索部150bは、弟ノードが存在しない場合には(ステップS406,No)、親ノードへ遷移し(ステップS408)、現在のノードがルートノードであるか否かを判定する(ステップS409)。
On the other hand, if there is no younger brother node (step S406, No), the trie
トライ木探索部150bは、現在のノードがルートノードでない場合には(ステップS410,No)、ステップS405に移行する。一方、トライ木探索部150bは、現在のノードがルートノードの場合に(ステップS410,Yes)、処理を終了する。
When the current node is not the root node (No at Step S410), the trie
次に、検索装置100が、トライ木140bのデータを削除する削除処理について説明する。図52および図53は、削除処理の処理手順を示すフローチャートである。図52に示すように、トライ木探索部150bは、現在のノードをルートノードに設定し(ステップS450)、入力キーが空か否かを判定する(ステップS451)。
Next, a deletion process in which the search device 100 deletes the data of the
トライ木探索部150bは、入力キーが空ではない場合に(ステップS452,No)、入力キーの先頭文字のキーで子ノードを参照し、子ノードが存在するか否かを判定する(ステップS453)。トライ木探索部150bは、子ノードが存在しない場合には(ステップS454,No)、ステップS456に移行する。
When the input key is not empty (step S452, No), the trie
一方、トライ木探索部150bは、子ノードが存在する場合に(ステップS454,Yes)、入力キーの先頭1文字を読み取り、入力キーのポインタを1文字進め、読み出した文字をキーとして子ノードに遷移し(ステップS455)、ステップS451に移行する。
On the other hand, if there is a child node (Yes in step S454), the trie
ところで、ステップS452において、トライ木探索部150bは、入力キーが空の場合に(ステップS452,Yes)、ノードの情報を参照し、タグキーの優先度が入力キーの優先度と等しいか否かを判定する(ステップS456)。
By the way, in step S452, when the input key is empty (Yes in step S452), the trie
トライ木探索部150bは、タグキーの優先度と入力キーの優先度が等しくない場合に(ステップS457,No)、タグキーの優先度が入力キーの優先度よりも大きいか否かを判定する(ステップS458)。トライ木探索部150bは、タグキーの優先度が入力キーの優先度よりも小さい場合に(ステップS459,No)、ステップS463に移行する。
When the priority of the tag key is not equal to the priority of the input key (No in step S457), the trie
トライ木探索部150bは、タグキーの優先度が入力キーの優先度よりも大きい場合には(ステップS459,Yes)、兄ノードが存在、あるいは、親ノードがルートノードであるか否かを判定する(ステップS460)。
When the priority of the tag key is higher than the priority of the input key (step S459, Yes), the trie
トライ木探索部150bは、兄ノードが存在せず、かつ、親ノードがルートノードではない場合(条件を満たさない場合)に(ステップS461,No)、入力キーのポインタを1文字戻し、親ノードへ遷移し(ステップS462)、ステップS456に移行する。
When there is no brother node and the parent node is not the root node (when the condition is not satisfied) (step S461, No), the trie
一方、トライ木探索部150bは、兄ノードが存在する、または、親ノードがルートノードの場合に(ステップS461,Yes)、削除データが存在しない旨を出力する(ステップS463)。
On the other hand, the trie
ところで、ステップS457において、トライ木探索部150bは、タグキーの優先度が入力キーの優先度と等しい場合に(ステップS457,Yes)、図53のステップS464に移行する。
Incidentally, in step S457, when the priority of the tag key is equal to the priority of the input key (step S457, Yes), the trie
トライ木探索部150bは、削除対象のデータ(値)が存在するか否かを判定し(ステップS464)、削除対象のデータが存在しない場合には(ステップS465,No)、削除データが存在しない旨を出力する(ステップS466)。
The trie
一方、トライ木探索部150bは、削除対象のデータが存在する場合に(ステップS465,Yes)、他のデータ(値)が存在するか否かを判定する(ステップS467)。トライ木探索部150bは、他のデータが存在する場合に(ステップS468,Yes)、処理を終了する。
On the other hand, when there is data to be deleted (Yes in step S465), the trie
一方、トライ木探索部150bは、他のデータが存在しない場合に(ステップS468,No)、子ノードが存在するか否かを判定する(ステップS469)。トライ木探索部150bは、子ノードが存在しない場合に(ステップS470,No)、親ノードの現在のノードへのエッジを削除(接続を解除)し、現在のノードを削除する(ステップS471)。
On the other hand, when there is no other data (No at Step S468), the trie
一方、トライ木探索部150bは、子ノードが存在する場合に(ステップS470,Yes)、現在のノードのデータを長男ノードのデータとし(ステップS472)、長男ノードへ遷移し(ステップS473)、ステップS469に移行する。
On the other hand, when there is a child node (step S470, Yes), the trie
上述してきたように、本実施例にかかる検索装置100は、トライ木生成部150aがトライ木140bを作成する場合に、1ノードにタグキーを1つ対応付け、タグキーを有さないノードを無くすので、メモリ使用効率を向上させることが出来る。
As described above, when the trie
また、本実施例にかかる検索装置100は、トライ木生成部150aがトライ木140bの各ノードにタグキーを登録する場合に、優先度の低いタグキーをルートノード側のタグキーに登録するので、トライ木探索部150bが検索処理などを実行する場合に、比較対象となるノードの領域を絞り込むことができ、検索処理にかかる処理効率を向上させることが出来る。
In addition, when the trie
まず、上述した実施例1にかかる検索装置100の課題を説明する。図54は、実施例1にかかる検索装置100の課題を説明するための図である。図54に示すトライ木は、ルートノードにノードh、ノードt(親)、ノードt(子)が順に接続されており、ノードhはタグキー「ttp://aaa.aaa/e/」を有し、ノードt(親)はタグキー「tp://aaa.aaa/e/c/」を有し、ノードt(子)はタグキー「p://aaa.aaa/g/」を有している。ここでは説明の便宜上、値の記載は省略するが、各ノードは値を有しているものとする。 First, the problem of the search device 100 according to the first embodiment will be described. FIG. 54 is a diagram for explaining the problem of the search device 100 according to the first embodiment. In the trie tree shown in FIG. 54, a node h, a node t (parent), and a node t (child) are connected in order to the root node, and the node h has a tag key “ttp: //aaa.aaa/e/”. Node t (parent) has a tag key “tp: //aaa.aaa/e/c/” and node t (child) has a tag key “p: //aaa.aaa/g/” Yes. Here, for convenience of explanation, description of values is omitted, but each node has a value.
例えば、検索装置100が新規にキーを登録する場合には、登録対象となる入力キーの先頭文字から順に文字を読み出し、読み出した文字をキーにしてトライ木の各ノードを遷移する。そして、検索装置100は、遷移先のノードから順に、ノードに登録されたタグキーの各文字と、入力キーの各文字を順に比較して、優先度の大小を判定することで、入力キーを登録していた。 For example, when the search device 100 newly registers a key, characters are read in order from the first character of the input key to be registered, and each node of the trie tree is transitioned using the read character as a key. Then, the search apparatus 100 registers the input key by sequentially comparing each character of the tag key registered in the node with each character of the input key in order from the transition destination node, and determining the priority level. Was.
具体的に、登録対象となる入力キーを「http://aaa.aaa/b/」として説明を行う。検索装置100は、入力キーの文字を先頭文字から順に読み出し、読み出した文字をキーにしてトライ木の各ノードを遷移する。ここでは、文字「h、t、t」が順に読み出されるので、ルートノードから、ノードh、ノードt(親)、ノードt(子)に遷移し、現在のノードをノードt(子)に設定する。 Specifically, the input key to be registered is described as “http://aaa.aaa/b/”. The search device 100 reads the characters of the input key in order from the first character, and transitions between the nodes of the trie tree using the read characters as keys. Here, since the characters “h, t, t” are read in order, the transition from the root node to node h, node t (parent), node t (child) is made, and the current node is set to node t (child) To do.
そして、検索装置100は、入力キーからトライ部分「htt」を除いたキー「p://aaa.aaa/d/」と、ノードt(子)のタグキー「p://aaa.aaa/g/」を先頭から1文字ずつ比較すると、タグキーの優先度が入力キーの優先度よりも大きいので、検索装置100は、現在のノードをノードt(親)に遷移する。 Then, the search device 100 uses the key “p: //aaa.aaa/d/” obtained by removing the trie part “htt” from the input key and the tag key “p: //aaa.aaa/g” of the node t (child). When “/” is compared character by character from the beginning, the priority of the tag key is higher than the priority of the input key, so the search device 100 transitions the current node to the node t (parent).
検索装置100は、入力キーからトライ部分「ht」を除いた「tp://aaa.aaa/b/」と、ノードt(親)のタグキー「tp://aaa.aaa/e/c/」を先頭から1文字ずつ比較すると、タグキーの優先度が入力キーの優先度よりも大きいので、検索装置100は、現在のノードをノードhに移行する。 The search apparatus 100 uses “tp: //aaa.aaa/b/” obtained by removing the trial part “ht” from the input key and the tag key “tp: //aaa.aaa/e/c/” of the node t (parent). ”Is compared character by character from the beginning, the priority of the tag key is higher than the priority of the input key, so the search device 100 moves the current node to the node h.
検索装置100は、入力キーからトライ部分「h」を除いた「ttp://aaa.aaa/b/」と、ノードhのタグキー「ttp://aaa.aaa/e/」を先頭から1文字ずつ比較すると、タグキーの優先度が入力キーの優先度よりも大きい。ここで、ノードhの親ノードはルートノードなので、検索装置100は、入力キーからトライ部分「h」を除いた「ttp://aaa.aaa/b/」をノードhに登録すると判定する。 The search device 100 adds “ttp: //aaa.aaa/b/” obtained by removing the trie part “h” from the input key and the tag key “ttp: //aaa.aaa/e/” of the node h from the top. When comparing character by character, the priority of the tag key is higher than the priority of the input key. Here, since the parent node of the node h is the root node, the search device 100 determines to register “ttp: //aaa.aaa/b/” in which the try part “h” is removed from the input key in the node h.
このように、実施例1にかかる検索装置100は、各ノードのタグキーの各文字と入力キーの各文字を順次比較することで、入力キーを登録するノードを判定していた。しかしながら、図54に示すトライ木の各タグキーを参照すると、トライ部分を含むタグキーの「http://aaa.aaa/」が共通している。このように、各タグキーの一部が共通している場合であっても、実施例1の検索装置100は、先頭文字から順に比較を行っているので、処理効率が悪かった。 As described above, the search device 100 according to the first embodiment determines a node to register an input key by sequentially comparing each character of the tag key of each node and each character of the input key. However, referring to each tag key of the trie tree shown in FIG. 54, the tag key “http://aaa.aaa/” including the trie portion is common. As described above, even when a part of each tag key is common, the search device 100 according to the first embodiment performs the comparison in order from the first character, and thus the processing efficiency is poor.
例えば、ノードt(子)のタグキーの「p://aaa.aaa/g/」と、入力キーを比較した後に、ノードt(親)のタグキー「tp://aaa.aaa/e/c/」と入力キーとを比較する場合には、タグキーの「tp://aaa.aaa/」は既に比較済みであるため、入力キーとタグキー「tp://aaa.aaa/e/c/」を初めから1文字ずつ比較することは無駄である。 For example, after comparing the input key with the tag key “p: //aaa.aaa/g/” of the node t (child), the tag key “tp: //aaa.aaa/e/c” of the node t (parent) / "And the input key, the tag key" tp: //aaa.aaa/ "has already been compared, so the input key and tag key" tp: //aaa.aaa/e/c/ It is useless to compare each character from the beginning.
本実施例2にかかる検索装置は、上述した実施例1にかかる検索装置の無駄を省くことで、処理の高速化を図る。図55は、本実施例2にかかる検索装置の概要を説明するための図である。同図に示すように、本実施例2にかかる検索装置がトライ木を生成する場合には、子ノードのタグキーと親ノードのタグキーとを比較する。そして、検索装置は、親ノードにタグキーを登録する場合に、全てのタグキーを登録するのではなく、子ノードと一致しない部分の文字列のみを親ノードに登録する。また、検索装置は、子ノードのタグキーと親ノードのタグキーと一致する部分の文字数もあわせて親ノードに登録する。 The search device according to the second embodiment increases the processing speed by eliminating the waste of the search device according to the first embodiment. FIG. 55 is a diagram for explaining the outline of the search device according to the second embodiment. As shown in the figure, when the search device according to the second embodiment generates a trie tree, the tag key of the child node is compared with the tag key of the parent node. Then, when registering the tag key in the parent node, the search device does not register all the tag keys but registers only the character string of the portion that does not match the child node in the parent node. In addition, the search device also registers the number of characters that match the tag key of the child node and the tag key of the parent node in the parent node.
例えば、図55に示すように、親ノードのタグキーが「tp://aaa.aaa/e/c/」、子ノードのタグキーが「p://aaa.aaa/g/」の場合には、一致する文字が「(t)p://aaa.aaa/」となるため、親ノードに一致する文字数「13」と、残りの文字列「e/c/」を登録する。以下の説明において、一致する文字数を一致数と表記する。 For example, as shown in FIG. 55, when the tag key of the parent node is “tp: //aaa.aaa/e/c/” and the tag key of the child node is “p: //aaa.aaa/g/” Since the matching character is “(t) p: //aaa.aaa/”, the number of characters “13” that matches the parent node and the remaining character string “e / c /” are registered. In the following description, the number of matching characters is expressed as the number of matches.
また、親ノードのタグキーが「ttp://aaa.aaa/e/」、子ノードのタグキーが「tp://aaa.aaa/e/c/」の場合には、一致する文字が「(t)tp://aaa.aaa/e/」となるため、親ノードに一致数「16」を親ノードに登録する。なお、この場合は、一致する文字列がそのまま、親ノードのタグキーとなるので、親ノードには、文字列が登録されない。 If the tag key of the parent node is “ttp: //aaa.aaa/e/” and the tag key of the child node is “tp: //aaa.aaa/e/c/”, the matching character is “( t) tp: //aaa.aaa/e/ ”, so that the number of matches“ 16 ”is registered in the parent node. In this case, since the matching character string is directly used as the tag key of the parent node, the character string is not registered in the parent node.
図55のように、トライ木を生成することで、実施例1の検索装置100のように、1度比較した文字列を重複して比較するという無駄を省くことが出来る。具体的に、登録対象となる入力キーを「http://aaa.aaa/b/」として説明を行う。 As shown in FIG. 55, by generating a trie tree, it is possible to eliminate the waste of redundantly comparing character strings that have been compared once, as in the search device 100 of the first embodiment. Specifically, the input key to be registered is described as “http://aaa.aaa/b/”.
本実施例2にかかる検索装置は、入力キーの文字を先頭から順に読み出し、読み出した文字をキーにしてトライ木の各ノードを遷移する。ここでは、文字「h、t、t」が順に読み出されるので、ルートノードから、ノードh、ノードt(親)、ノードt(子)に遷移し、現在のノードをノードt(子)に設定する。 The search device according to the second embodiment reads the characters of the input key in order from the top, and transitions each node of the trie tree using the read characters as keys. Here, since the characters “h, t, t” are read in order, the transition from the root node to node h, node t (parent), node t (child) is made, and the current node is set to node t (child) To do.
本実施例2にかかる検索装置は、入力キーからトライ部分「htt」を除いたキー「p://aaa.aaa/b/」と、ノードt(子)のタグキー「p://aaa.aaa/g/」を先頭から1文字ずつ比較すると、タグキーの優先度が入力キーの優先度よりも大きいので、検索装置は、現在のノードをノードt(親)に遷移する。 The search apparatus according to the second embodiment has a key “p: //aaa.aaa/b/” obtained by removing the try part “htt” from the input key and a tag key “p: // aaa. When comparing “aaa / g /” one character at a time from the beginning, the priority of the tag key is higher than the priority of the input key, so the search device transitions the current node to the node t (parent).
本実施例2にかかる検索装置は、入力キーからトライ部分「ht」を除いた「tp://aaa.aaa/b/」と、ノードt(親)のタグキーとを比較する。ここで、親ノードt(親)に一致数「13」が登録されているので、検索装置は、キー「tp://aaa.aaa/b/」のうち、先頭から13文字目までの比較処理をスキップし、14文字目から、ノードt(親)のタグキー「e/c/」と比較を行う。すると、タグキーの優先度が入力キーの優先度よりも大きいので、検索装置は、現在のノードをノードhに移行する。 The search device according to the second embodiment compares “tp: //aaa.aaa/b/” obtained by removing the try part “ht” from the input key and the tag key of the node t (parent). Here, since the number of matches “13” is registered in the parent node t (parent), the search device compares the 13th character from the beginning of the key “tp: //aaa.aaa/b/”. Processing is skipped, and comparison is made with the tag key “e / c /” of node t (parent) from the 14th character. Then, since the priority of the tag key is higher than the priority of the input key, the search device shifts the current node to the node h.
本実施例2にかかる検索装置は、入力キーからトライ部分「h」を除いた「ttp://aaa.aaa/b/」と、ノードhのタグキーを比較する。ここで、ノードhに一致数「16」が登録されているので、検索装置は、キー「ttp://aaa.aaa/b/」のうち、先頭から16文字目までの比較処理をスキップする。すると、比較対象となるキーが空になる。この場合には、タグキーが入力キーよりも大きいと判定する。ここで、ノードhの親ノードはルートノードなので、検索装置は、入力キーからトライ部「h」を除いた「ttp://aaa.aaa/b/」をノードhに登録すると判定する。 The search device according to the second embodiment compares the tag key of the node h with “ttp: //aaa.aaa/b/” obtained by removing the try portion “h” from the input key. Here, since the number of matches “16” is registered in the node h, the search device skips the comparison process from the head to the 16th character in the key “ttp: //aaa.aaa/b/”. . Then, the key to be compared becomes empty. In this case, it is determined that the tag key is larger than the input key. Here, since the parent node of the node h is the root node, the search device determines to register “ttp: //aaa.aaa/b/”, which is obtained by removing the try part “h” from the input key, in the node h.
このように、本実施例2にかかる検索装置は、各ノードのタグキーと入力キーとを比較する場合に、先頭文字から順に各キーの文字を比較するのではなく、一致数だけ比較する文字をスキップするので、入力キーをトライ木に登録する処理を高速化することが出来る。 As described above, when comparing the tag key of each node with the input key, the search device according to the second embodiment does not compare the characters of each key in order from the first character, but compares the characters to be compared by the number of matches. Skipping can speed up the process of registering the input key in the trie tree.
ところで、図55に示す例では、新規に入力キーを登録する場合の処理について説明したが、トライ木から入力キーと一致するタグキーを検索する場合にも、一致数を用いて同様に、検索処理の処理効率を向上させることが出来る。 By the way, in the example shown in FIG. 55, the process in the case of newly registering an input key has been described. However, when searching for a tag key that matches the input key from the trie tree, the search process is similarly performed using the number of matches. The processing efficiency can be improved.
次に、本実施例2にかかる検索装置200の構成について説明する。図56は、本実施例2にかかる検索装置200の構成を示す図である。図56に示すように、この検索装置200は、入力部210、出力部220、入出力制御部230、記憶部240、制御部250を有する。
Next, the configuration of the
このうち、入力部210は、入力キー等の情報を入力する入力部であり、キーボードやマウス等に該当する。出力部220は、トライ木を用いた検索結果などの情報を出力する出力部であり、モニタ、若しくはディスプレイ、タッチパネル等に該当する。入出力制御部230は、入力部210、出力部220、記憶部240、制御部250によるデータの入出力を制御する処理部である。
Among these, the input unit 210 is an input unit for inputting information such as input keys, and corresponds to a keyboard, a mouse, or the like. The
記憶部240は、制御部250による各種処理に必要なデータおよびプログラムを記憶する記憶部である。図56に示すように、この記憶部240は、登録データ管理テーブル240aとトライ木240bを有する。
The storage unit 240 is a storage unit that stores data and programs necessary for various processes performed by the
ここで、登録データ管理テーブル240aは、トライ木に登録するキーと値とを対応付けて記憶するテーブルである。図57は、本実施例2にかかる登録データ管理テーブル240aのデータ構造の一例を示す図である。図57に示すように、この登録データ管理テーブル240aは、キーと値を対応付けて記憶している。 Here, the registration data management table 240a is a table that stores the keys and values registered in the trie tree in association with each other. FIG. 57 is a diagram illustrating an example of the data structure of the registration data management table 240a according to the second embodiment. As shown in FIG. 57, the registered data management table 240a stores keys and values in association with each other.
トライ木240bは、登録データ管理テーブル240aを基にして生成されるトライ木である。図58は、本実施例2にかかるトライ木のデータ構造の一例を示す図である。図58では一例として、図57に示した登録データ管理テーブル240aに対応したトライ木を示す。図58に示すように、ルートノードにノードb、ノードgが接続されており、ノードbにノードlが接続されている。
The
ノードbは、一致数「1」、タグキー「ack」、値「2」を有し、ノードlは、一致数「0」、タグキー「ue」、値「1、3」を有し、ノードgは、一致数「0」、タグキー「reen」、値「4」を有している。 The node b has a match number “1”, a tag key “ack”, and a value “2”, and the node l has a match number “0”, a tag key “ue”, and a value “1, 3”, and the node g Has a match number “0”, a tag key “reen”, and a value “4”.
図58に示したトライ木240bを実データで表すと、図59に示すデータ構造となる。図59は、図58に示したトライ木を実データで表した場合のデータ構造の一例を示す図である。図59に示すように、このトライ木240bは、ポインタ配列30〜33、テキスト表34を有している。
If the
ここで、ルートノードポインタに接続されたポインタ配列30は、図58のルートノードに対応し、ポインタ配列31は、図58のノードbに対応する。また、ポインタ配列32は、図58のノードlに対応し、ポインタ配列33は、図58のノードgに対応する。 Here, the pointer array 30 connected to the root node pointer corresponds to the root node in FIG. 58, and the pointer array 31 corresponds to the node b in FIG. The pointer array 32 corresponds to the node l in FIG. 58, and the pointer array 33 corresponds to the node g in FIG.
ポインタ配列30〜33は、「一致」領域、「TAG」領域、「Data」領域を有している。「一致」は、数値と対応付けることで、ノードの一致数を表現する。「TAG」は、テキスト表34の文字と対応付けることで、ノードに接続されたタグキーを表現する。例えば、ポインタ配列31は、テキスト表34の「a」に接続されているので、「a」から次の空白前までの文字列「ack」をタグキーとして指定している。また、「Data」は、値と対応付けることで、ノードに接続された値を表現する。例えば、ポインタ配列31は、値「2」に接続されている。 The pointer arrays 30 to 33 have a “match” area, a “TAG” area, and a “Data” area. “Match” expresses the number of node matches by associating with a numerical value. “TAG” represents a tag key connected to a node by associating with a character in the text table 34. For example, since the pointer array 31 is connected to “a” in the text table 34, the character string “ack” from “a” to the next space is designated as a tag key. “Data” expresses a value connected to a node by associating it with a value. For example, the pointer array 31 is connected to the value “2”.
また、各ポインタ配列30〜33は、配下に接続されたポインタ配列を判定するためのキー番号(ポインタ)「0×00〜0×FF」を有している。例えば、ポインタ配列30のキー番号「0×62」が、ポインタ配列31に接続され、キー番号「0×67」が、ポインタ配列33に接続されている。 Further, each of the pointer arrays 30 to 33 has a key number (pointer) “0 × 00 to 0 × FF” for determining a pointer array connected to the subordinate array. For example, the key number “0 × 62” of the pointer array 30 is connected to the pointer array 31, and the key number “0 × 67” is connected to the pointer array 33.
図56の説明に戻ると、制御部250は、各種の処理手順を規定したプログラムや制御データを格納するための内部メモリを有し、これらによって種々の処理を実行する制御部である。図56に示すように、この制御部250は、トライ木生成部250aと、トライ木探索部250bを有する。
Returning to the description of FIG. 56, the
トライ木生成部250aは、登録データ管理テーブル240aに登録されたキーに基づいて、トライ木240bを生成する処理である。なお、トライ木生成部250aは、実施例1と同様にして、深さ優先探索順でタグキーが並ぶようにトライ木を生成する。更に、トライ木生成部250aは、図55で説明したように、親ノードのタグキーと子ノードのタグキーを比較して、一致する文字数を一致数としてノードに登録する。また、トライ木生成部250aは、親ノードのタグキーと子ノードのタグキーの一致する文字列を削除し、残りの文字列のみをタグキーとしてノードに登録する。
The trie
以下において、トライ木生成部250aがトライ木を生成する処理について具体的に説明する。図60〜図69は、本実施例2にかかるトライ木を生成する処理を説明するための図である。ここでは説明の便宜上、キー「http://aaa.aaa/e/」、値「1」と、キー「http://aaa.aaa/e/c/」、値「2」と、キー「http://aaa.aaa/d/」、値「3」と、キー「http://aaa.aaa/e/」、値「4」の順でトライ木を生成する場合について説明する。
Hereinafter, a process in which the trie
図60に示すように、まず、ノードが存在しない状態で、キー「http://aaa.aaa/e/」、値「1」を追加する場合について説明する。トライ木生成部250aは、ルートノードを生成する(ステップS70a)。実データ上において、トライ木生成部250aは、ルートノードに対応するポインタ配列30を生成し、ルートノードポインタとポインタ配列30を接続する。また、ポインタ配列30をルートノードに対応するので、「TAG」を空に接続する(ステップS70b)。
As shown in FIG. 60, first, a case where a key “http://aaa.aaa/e/” and a value “1” are added in a state where no node exists will be described. The trie
トライ木生成部250aは、入力キー「http://aaa.aaa/e/」を用意する(ステップS71a)。実データ上において、トライ木生成部250aは、テキスト表34に入力キー「http://aaa.aaa/e/」を格納し、入力キーのポインタを、テキスト表34の1行目1列目の「h」に接続する(ステップS71b)。
The trie
トライ木生成部250aは、入力キー「http://aaa.aaa/e/」の先頭文字「h」をキーとする子ノードが存在しないので、ルートノードを参照する。ここで、ルートノードにタグキーは存在しないので、ルートノードのタグキーの優先度よりも、入力キー「http://aaa.aaa/e/」の優先度が大きくなる。
The trie
したがって、トライ木生成部250aは、ルートノードの配下に「h」をキーとするノードを作成し、入力キー「http://aaa.aaa/e/」からトライ部分「h」を取り除いた残りのキー「ttp://aaa.aaa/e/」をタグキーとして、ノードhに接続する。また、トライ木生成部250aは、一致数「0」、値「1」をノードhに接続する(ステップS72a)。
Therefore, the trie
実データ上において、トライ木生成部250aは、ノードhに対応するポインタ配列31を生成し、ポインタ配列30のキー番号「0×68」で、ポインタ配列30とポインタ配列31を接続する。また、トライ木生成部250aは、ポインタ配列31の「TAG」をテキスト表34の1行目2列目の「t」に接続し、ポインタ配列31の「Data」に1を接続する。また、トライ木生成部250aは、ポインタ配列31の一致(一致数)を「0」に設定する(ステップS72b)。
On the actual data, the trie
続いて、図61に移行し、ステップS72a、72bにおいて作成したトライ木に、キー「http://aaa.aaa/e/c/」、値「2」を追加する場合について説明する。トライ木生成部250aは、入力キー「http://aaa.aaa/e/c/」の先頭文字hでルートノードからノードhに遷移する。そして、トライ木生成部250aは、入力キー「http://aaa.aaa/e/c/」のポインタを1つ進め、2文字目の「t」に設定する(ステップS73a)。
Next, the case where the key “http://aaa.aaa/e/c/” and the value “2” are added to the trie tree created in steps S72a and 72b will be described with reference to FIG. The trie
実データ上において、トライ木生成部250aは、テキスト表34に最後に登録されたキー「http://aaa.aaa/e/」との間を1つ空けて、キー「http://aaa.aaa/e/c」を登録する。そして、トライ木生成部250aは、テキスト表34の2行目2列目の文字「t」に入力キーのポインタを接続する(ステップS73b)。
On the actual data, the trie
トライ木生成部250aは、ノードhにおいて、「t」をキーとする子ノードが存在しないので、ノードhのタグキー「ttp://aaa.aaa/e/」の優先度と、トライ部分の「h」を取り除いた入力キー「ttp://aaa.aaa/e/c/」の優先度を比較する。トライ木生成部250aは、ノードhの一致数が「0」であるため、入力キーの先頭から順に比較を行う。
Since there is no child node having “t” as a key in the node h, the trie
すると、入力キーの17文字目がcであり、タグキーの17文字目が空であるため、トライ木生成部250aは、入力キーの優先度が、タグキーの優先度よりも大きいと判定する。また、トライ木生成部250aは、入力キーとタグキーを比較し、16文字「ttp://aaa.aaa/e/」が一致していると判定する(ステップS74)。
Then, since the 17th character of the input key is c and the 17th character of the tag key is empty, the trie
続いて、図62に移行する。トライ木生成部250aは、ノードhに一致数「16」を登録し、ノードhのタグキー「ttp://aaa.aaa/e/」のポインタを16文字進める。その結果、ノードhに接続されるタグキーは空となる。
Subsequently, the flow proceeds to FIG. The trie
また、トライ木生成部250aは、入力キー「ttp://aaa.aaa/e/c/」の2文字目の「t」をキーとして新しいノードtを生成し、入力キーのポインタを3文字目の「t」に進める(ステップS75a)。
The trie
実データ上において、トライ木生成部250aは、ノードtに対応するポインタ配列32を生成し、ポインタ配列31のキー番号「0×74」で、ポインタ配列31とポインタ配列32を接続する。トライ木生成部250aは、ノードhの「一致」に一致数「16」を登録し、「TAG」に接続される文字を16文字進め、テキスト表34の1行目18列目の空に設定する。トライ木生成部250aは、入力キーのポインタを1つ進め、テキスト表34の2行目3列目の「t」に入力キーのポインタを接続する(ステップS75b)。
On the actual data, the trie
トライ木生成部250aは、入力キー「http://aaa.aaa/e/c/」からトライ部分の「ht」を取り除いた残りのキー「tp://aaa.aaa/e/c/」を、ノードtのタグキーとして登録する。トライ木生成部250aは、入力キー「http://aaa.aaa/e/c/」に対応する値「2」をノードtに登録する。また、トライ木生成部250aは、一致数「0」をノードtに登録する(ステップS76a)。
The trie
実データ上において、トライ木生成部250aは、ポインタ配列32の「TAG」をテキスト表34の2行目3列目の「t」に接続し、ポインタ配列32の「Data」と値「2」を接続する。また、トライ木生成部250aは、ポインタ配列32の「一致」に、一致数「0」を登録する(ステップS76b)。
On the actual data, the trie
続いて、図63に移行し、ステップS76a、76bにおいて作成したトライ木に、入力キー「http://aaa.aaa/d/」、値「3」を追加する場合について説明する。トライ木生成部250aは、入力キー「http://aaa.aaa/d/」の先頭文字から1文字ずつ取り出して、トライ木上をノードh、tの順に遷移する。そして、トライ木生成部250aは、遷移したノード数に応じて、入力キー「http://aaa.aaa/d/」のポインタを2つ進め、3文字目の「t」に設定する。
Next, the case where the input key “http://aaa.aaa/d/” and the value “3” are added to the trie tree created in steps S76a and 76b will be described with reference to FIG. The trie
トライ木生成部250aは、ノードtにおいて、「t」をキーとする子ノードが存在しないので、ノードtのタグキー「tp://aaa.aaa/e/c」の優先度と、トライ部分の「ht」を取り除いた入力キー「tp://aaa.aaa/d/」の優先度を比較する。すると、タグキーの14文字目が「e」であり、入力キーの14文字目が「d」であるため、タグキーの優先度の方が、入力キーの優先度よりも大きくなる(ステップS77a)。
Since there is no child node having “t” as a key in the node t, the trie
実データ上において、トライ木生成部250aは、テキスト表34に最後に登録されたキー「http://aaa.aaa/e/c」との間を1つ空けて、キー「http://aaa.aaa/d/」を登録する。そして、トライ木生成部250aは、テキスト表34の3行目5列目の文字「t」に入力キーのポインタを接続する。また、ポインタ配列32の「TAG」に接続された文字を先頭とする文字列と、入力キーのポインタに接続された文字を先頭とする文字列とを順次比較すると、タグキーの14文字目が「e」であり、入力キーの14文字目が「d」であるため、タグキーの優先度の方が、入力キーの優先度よりも大きくなる(ステップS77b)。
On the actual data, the trie
トライ木生成部250aは、入力キーとタグキーを比較して、世代数を判定する。この世代数は、入力キーが何文字目までタグキーと同じであるか否かを示す数値である。トライ木生成部250aは、ノードtに登録されたタグキー「tp://aaa.aaa/e/c」と入力キーからトライ部分「ht」を取り除いたキー「tp://aaa.aaa/d/」とを比較した場合に、先頭から13文字「tp://aaa.aaa/」が一致しているので、世代数が13となる。
The trie
トライ木生成部250aは、入力キー「http://aaa.aaa/d/」のポインタを現在の3文字目の「t」から13文字進めて、「d」に設定する。そして、トライ木生成部250aは、現在のノードをノードhに移行し、世代数に1を加算して、世代数を14とする(ステップS78a)。これは、親ノードとなるノードhに遷移することで、比較対象となる入力キーの文字が1文字増えるが、かかる増加分の文字は、親ノードのタグキーと一致しているためである。
The trie
実データ上において、トライ木生成部250aは、テキスト表34の3行目18列目の文字「d」に、入力キーのポインタを接続する。また、トライ木生成部250aは、世代数を判定し、世代数に「14」を登録する。また、現在のノードのポインタをポインタ配列31に接続する(ステップS78b)。
On the actual data, the trie
続いて、図64に移行する。トライ木生成部250aは、ノードhのタグキーの優先度と、入力キー「http://aaa.aaa/d/」の優先度を比較する前に、ノードhに登録された一致数と、入力キーの世代数とを比較する。ノードhのタグキーの一致数は「16」であり、入力キーの世代数は「14」であるため、一致数の方が世代数よりも大きい。
Subsequently, the flow proceeds to FIG. The trie
一致数が世代数よりも大き場合には、トライ木生成部250aは、ノードhのタグキーの優先度と、入力キー「http://aaa.aaa/d/」の優先度を直接比較しなくても、ノードhのタグキーの優先度の方が大きいと判定できる。
When the number of matches is larger than the number of generations, the trie
例えば、世代数14の入力キーは、先頭文字から13文字目までは、ノードhの子ノードとなるノードtのタグキーと同じであることを示し、14文字目において、入力キーの優先度がノードtの優先度よりも小さい。そして、ノードhの一致数が入力キーの世代数より大きいということは、ノードtのタグキーの優先度が入力キーの優先度よりも大きいという決め手になった文字まで、ノードhのタグキーは少なくとも同じである。したがって、トライ木生成部250aは、ノードhのタグキーの優先度と、入力キー「http://aaa.aaa/d/」の優先度を直接比較しなくても、ノードhのタグキーの優先度の方が大きいと判定できる。
For example, the 14th generation input key indicates that the 13th character from the first character is the same as the tag key of the node t that is a child node of the node h, and the priority of the input key is the node at the 14th character. Less than t priority. And if the number of matches of node h is greater than the number of generations of input keys, the tag key of node h is at least the same until the character that made the priority of the tag key of node t greater than the priority of the input key. It is. Therefore, the trie
ノードhの親ノードがルートノードであるため、トライ木生成部250aは、ノードhのデータ(一致数、タグキー、値)と、入力データ(世代数、入力キー、値)を交換する。具体的に、トライ木生成部250aは、入力キーの世代数「14」を一致数としてノードhに登録し、入力キーの値「3」もノードhに登録する。また、入力キー「http://aaa.aaa/d/」のポインタ以降の文字列「d/」をノードhのタグキーに登録する。
Since the parent node of the node h is the root node, the trie
そして、トライ木生成部250aは、現在の入力キーを「http://aaa.aaa/e/」、値「1」、世代数「16」に設定する。また、トライ木生成部250aは、入力キーのポインタを先頭文字から16文字ずらした「/」に設定する。トライ木生成部250aは、ノードhの子ノードとなるノードtに移行し、入力キーのポインタを1文字ずらした「空」に設定する(ステップS79a)。
Then, the trie
実データ上において、トライ木生成部250aは、ポインタ配列31の「TAG」と、テキスト表34の3行目8列目の「t」に接続し、ポインタ配列31の「一致」に「14」を登録する。また、入力キーのポインタを、テキスト表34の1行目18列目の「空」に接続する。また、トライ木生成部250aは、現在の世代数を「16」に設定する(ステップS79b)。
On the actual data, the trie
トライ木生成部250aは、ノードtに移行した場合に、世代数16から1を減算することで、世代数を「15」に設定する。そして、トライ木生成部250aは、ノードtのデータ(一致数、タグキー、値)と、入力データ(世代数、入力キー、値)を交換する。具体的に、トライ木生成部250aは、入力キーの世代数「15」を一致数としてノードtに登録し、入力キーの値「1」もノードtに登録する。また、入力キー「http://aaa.aaa/e/」のポインタ以降の文字「空」をノードtのタグキーに登録する。
The trie
そして、トライ木生成部250aは、現在の入力キーを「http://aaa.aaa/e/c/」、値「2」、世代数「0」に設定する。また、トライ木生成部250aは、入力キーのポインタを、トライ部分に対応して、3文字目の「t」に設定する(ステップS80a)。
Then, the trie
実データ上において、トライ木生成部250aは、現在のノードのポインタをポインタ配列32に接続する。トライ木生成部250aは、ポインタ配列32の「TAG」を、テキスト表34の1行目18列目の「空」に接続し、「一致」を15に設定する。また、トライ木生成部250aは、入力キーのポインタを、テキスト表34の2行目3列目に接続し、世代数を「0」に設定する(ステップS80b)。
On the actual data, the trie
続いて、図65の説明に移行する。トライ木生成部250aは、入力キー「http://aaa.aaa/e/c/」の3文字目に対応するノードtが、ノードtの配下に存在しないので、ノードtの配下に新たなノードtを生成する。ここで、各ノードtを区別するために以下の説明では、親側のノードtをノードt(親)と表記し、子側のノードtをノードt(子)と表記する。また、トライ木生成部250aは、入力キーのポインタを3文字目の「p」に設定する(ステップS81a)。
Subsequently, the description shifts to the description of FIG. Since the node t corresponding to the third character of the input key “http://aaa.aaa/e/c/” does not exist under the node t, the trie
実データ上において、トライ木生成部250aは、ノードt(子)に対応するポインタ配列33を生成し、ポインタ配列32のキー番号「0×74」で、ポインタ配列32とポインタ配列33を接続する。また、トライ木生成部250aは、入力キーのポインタを、テキスト表34の2行目4列目の「p」に接続する(ステップS81b)。
On the actual data, the trie
続いて、図66の説明に移行する。トライ木生成部250aは、入力キー「http://aaa.aaa/e/c/」からトライ部分を取り除いた残りのキー「p://aaa.aaa/e/c/」をノードt(子)に接続する。また、トライ木生成部250aは、入力キー「http://aaa.aaa/e/c/」に対応する値「2」をノードt(子)に接続する(ステップS82a)。
Subsequently, the description proceeds to FIG. The trie
実データ上において、トライ木生成部250aは、ポインタ配列33の「TAG」をテキスト表34の2行目4列目の「p」に接続し、入力キーのポインタを開放する。また、トライ木生成部250aは、ポインタ配列33の「Data」に値「2」を接続する(ステップS82b)。
On the actual data, the trie
続いて、図67に移行し、ステップS82a、82bにおいて作成したトライ木に、キー「http://aaa.aaa/e/」、値「4」を追加する場合について説明する。トライ木生成部250aは、入力キー「http://aaa.aaa/e/」の先頭から文字を順次読み出し、ノードh、ノードt(親)、ノードt(子)に遷移する。そして、トライ木生成部250aは、入力キー「http://aaa.aaa/e/」のポインタを4文字目の「p」に設定する(ステップS83a)。
Subsequently, the case where the key “http://aaa.aaa/e/” and the value “4” are added to the trie tree created in steps S82a and 82b will be described with reference to FIG. The trie
実データ上において、トライ木生成部250aは、テキスト表34において最後に登録されたキー「http://aaa.aaa/e/d/」との間を1つ空けて、キー「http://aaa.aaa/e/」を登録する。そして、トライ木生成部250aは、テキスト表34の4行目6列目の文字「p」に入力キーのポインタを接続する(ステップS83b)。
On the actual data, the trie
続いて、図68に移行する。トライ木生成部250aは、ノードt(子)において、「p」をキーとする子ノードが存在しないので、ノードtのタグキー「p://aaa.aaa/e/c/」の優先度と、トライ部分の「htt」を取り除いた入力キー「p://aaa.aaa/e/」の優先度を比較する。トライ木生成部250aは、ノードt(子)の一致数が「0」であるため、入力キーの先頭から順に比較を行う。
Subsequently, the flow proceeds to FIG. Since there is no child node having “p” as a key in the node t (child), the trie
すると、入力キーのトライ木部分を除いた15文字目が「空」であり、タグキーの15文字目が「c」であるため、トライ木生成部250aは、入力キーの優先度がタグキーの優先度よりも小さいと判定する。また、トライ木生成部250aは、入力キーとタグキーを比較し、14文字「p://aaa.aaa/e/」が一致していると判定する。
Then, since the 15th character excluding the trie portion of the input key is “empty” and the 15th character of the tag key is “c”, the
トライ木生成部250aは、入力キーのポインタを4文字目「p」から14文字進める。また、トライ木生成部250aは、親ノードとなるノードt(親)に遷移し、世代数「14」に1を加算して「15」とする(ステップS84a)。
The trie
実データ上において、トライ木生成部250aは、入力キーのポインタをテキスト表34の5行目2列目の空に接続する。また、トライ木生成部250aは、現在のノードをポインタ配列32に接続し、世代数を「15」に設定する(ステップS84b)。
On the actual data, the trie
続いて、図69の説明に移行する。トライ木生成部250aは、ノードt(親)の一致数と、世代数を比較すると双方とも「15」で一致し、かつ、入力キーの優先度とタグキーの優先度が等しくなるので、ノードt(親)に値「4」を登録する(ステップS85a)。
Subsequently, the description proceeds to FIG. 69. The trie
実データ上において、トライ木生成部250aは、ポインタ配列31の一致と世代数とを比較しと双方とも「15」で位置し、かつ、入力キーのポインタに接続された文字と、ポインタ配列32に接続された文字が「空」で一致するので、ポインタ配列32の「Data」に値「4」を接続する(ステップS85b)。
On the actual data, the trie
図56の説明に戻ると、トライ木探索部250bは、トライ木240bに登録された値の集計値を抽出する処理、所定のキーに対応する値をトライ木240bから検索する処理を実行する処理部である。
Returning to the description of FIG. 56, the trie
まず、トライ木探索部250bが、トライ木240bに登録された値の集計値を抽出する処理について説明する。図70〜図72は、本実施例2における集計値を抽出する処理を説明するための図である。図70に示すように、トライ木240bは、ルートノードの配下に、ノードh、ノードt(親)、ノードt(子)が順に接続されている。ノードhは、一致数「14」、タグキー「d/(http://aaa.aaa/d/)」、値「3」を登録し、ノードt(親)は、一致数「15」、タグキー「空(http://aaa.aaa/e/)」、値「1、4」を登録する。また、ノードt(子)は、一致数「0」、タグキー「p://aaa.aaa/e/c/(http://aaa.aaa/e/c/)」、値「2」を登録する。
First, a process in which the trie
また、図70〜72における説明では、ルートノード、ノードh、ノードt(親)、ノードt(子)の順に、集計値を抽出する場合について説明する。図70において、トライ木探索部250bは、ルートノードからノードhに移行する。ノードhは、タグキー「d/(http://aaa.aaa/d/」、値「3」が登録されているので、トライ木探索部250bは、キー「http://aaa.aaa/d/」と、値(合計値)「3」を出力する(ステップS86a)。
Further, in the description of FIGS. 70 to 72, a case where the total value is extracted in the order of the root node, the node h, the node t (parent), and the node t (child) will be described. In FIG. 70, the trie
実データ上において、トライ木探索部250bは、現在のノードをノードhに対応するポインタ配列31に接続する。トライ木探索部250bは、ノードhの階層数「1」と一致「14」を加算した値「15」を算出し、「TAG」に接続された文字「d」を起点として15文字戻す。そして、トライ木探索部250bは、戻した文字「h」から「空」までのキー「http://aaa.aaa/d/」を出力する。また、トライ木探索部250bは、ポインタ配列31の「Data」に接続された値「3」を出力する(ステップS86b)。
On the actual data, the trie
図71の説明に移行する。トライ木探索部250bは、ノードhからノードt(親)に移行する。ノードt(親)は、タグキー「空(http://aaa.aaa/e/)」、値「1、4」が登録されているので、トライ木探索部250bは、キー「http://aaa.aaa/e/」と、値「1、4」を合計した値「5」を出力する(ステップS87a)。
The description shifts to the description of FIG. The trie
実データ上において、トライ木探索部250bは、現在のノードをノードt(親)に対応するポインタ配列32に接続する。トライ木探索部250bは、ノードt(親)の階層数「2」と一致「15」を加算した値「17」を算出し、「TAG」に接続された「空」を起点として17文字戻す。そして、トライ木探索部250bは、戻した文字「h」から「空」までのキー「http://aaa.aaa/e/」を出力する。また、トライ木探索部250bは、「Data」に接続された値「1、4」の合計値「5」を出力する(ステップS87b)。
On the actual data, the trie
図72の説明に移行する。トライ木探索部250bは、ノードt(親)からノードt(子)に移行する。ノードt(子)は、タグキー「p://aaa.aaa/e/c/(http://aaa.aaa/e/c/)」、値「2」が登録されているので、トライ木探索部250bは、キー「http://aaa.aaa/e/c/」と、値「2」を出力する(ステップS88a)。
Shifting to the description of FIG. The trie
実データ上において、トライ木探索部250bは、現在のノードをノードt(子)に対応するポインタ配列33に接続する。トライ木探索部250bは、ノードt(子)の階層数「3」と一致「0」を加算した値「3」を算出し、「TAG」に接続された「p」を起点として3文字戻す。そして、トライ木探索部250bは、戻した文字「h」から「空」までのキー「http://aaa.aaa/e/c/」を出力する。また、トライ木探索部250bは、「Data」に接続された値「2」を出力する(ステップS88b)。
On the actual data, the trie
図70〜図72では、ルートノードから順にノードを辿って、各ノードに登録されたキー、値を出力する場合について説明した。しかし、実施例1に示したように、所定のキーを指定し、指定したキーに基づいて集計値を抽出しても良い。 In FIG. 70 to FIG. 72, the case has been described in which the nodes are sequentially traced from the root node and the keys and values registered in each node are output. However, as shown in the first embodiment, a predetermined key may be designated, and the total value may be extracted based on the designated key.
次に、トライ木探索部250bが、指定された入力キーに対応する値をトライ木240bから検索する処理について説明する。トライ木探索部250bは、トライ木240bが、深さ優先探索順でタグキーが並ぶように生成されているので、比較対象ノードに登録されたタグキーと入力キーを比較すればよい。また、図60〜69に示したトライ木を生成する処理と同様にして、一致数、世代数を利用することで、比較する文字数を削減することも可能である。
Next, a process in which the trie
図73〜図77は、本実施例2にかかる探索処理を説明するための図である。図73に示すように、トライ木240bは、ルートノードの配下にノードb、ノードa、ノードb、ノードcが接続されている。ここで、各ノードbを区別するために、ルートノードの子ノードに対応するノードbをノードb(1)と表記し、もう一方のノードbをノードb(2)と表記する。
FIGS. 73 to 77 are diagrams for explaining the search processing according to the second embodiment. As shown in FIG. 73, in the
ノードb(1)は、一致数「1」、タグキー「空」、値「1」を登録し、ノードaは、一致数「0」、タグキー「aa」、値「3」を登録する。ノードb(2)は、一致数「0」、タグキー「c」、値「1」を登録し、ノードcは、一致数「0」、タグキー「b」、値「2」を登録する。 Node b (1) registers the number of matches “1”, tag key “empty”, and value “1”, and node a registers the number of matches “0”, tag key “aa”, and value “3”. Node b (2) registers the number of matches “0”, tag key “c”, and value “1”, and node c registers the number of matches “0”, tag key “b”, and value “2”.
また、図73〜図77における説明では、入力キー「baca」が指定された場合の検索処理について説明する。図73において、トライ木探索部250bは、入力キーのポインタを先頭文字「b」に設定し、ポインタの指定する「b」により、ルートノードからノードb(1)に遷移する。そして、トライ木探索部250bは、入力キーのポインタを「b」から1文字ずらした「a」に設定する(ステップS89a)。
73 to 77, search processing when the input key “baca” is designated will be described. In FIG. 73, the trie
実データ上では、トライ木探索部250bは、テキスト表34に入力キー「baca」を登録し、入力キーのポインタをテキスト表34の2行目1列目の「b」に接続する。トライ木探索部250bは、入力キーのポインタに接続された「b」により、ポインタ配列40からポインタ配列41に現在のノードのポインタを移動させ、入力キーのポインタを1文字ずらした「a」に設定する(ステップS89b)。
On the actual data, the trie
続いて、図74の説明に移行する。トライ木探索部250bは、ポインタの指定する「a」により、ノードb(1)からノードaに遷移し、入力キーのポインタを「a」から1文字ずらした「c」に設定する(ステップS90a)。
Subsequently, the description proceeds to FIG. The trie
実データ上では、トライ木探索部250bは、入力キーのポインタに接続された「a」により、ポインタ配列41からポインタ配列42に現在のノードのポインタを遷移させ、入力キーのポインタを1文字ずらした「c」に設定する(ステップS90b)。
On the actual data, the trie
続いて、図75の説明に移行する。トライ木探索部250bは、ポインタの指定する「c」により、ノードaからノードcに遷移し、入力キーのポインタを「c」から1文字ずらした「a」に設定する(ステップS91a)。
Subsequently, the description proceeds to FIG. 75. The trie
実データ上では、トライ木探索部250bは、入力キーのポインタに接続された「c」により、ポインタ配列42からポインタ配列43に現在のノードのポインタを遷移させ、入力キーのポインタを1文字ずらした「a」に設定する(ステップS91b)。
On the actual data, the trie
続いて、図76の説明に移行する。トライ木探索部250bは、ポインタの指定する「a」に対応する子ノードが、ノードaに存在しないので、ノードcの一致数と世代数を比較する。一致数と世代数が等しいので、トライ木探索部250bは、ノードcのタグキー「b」と、トライ部分「bac」を取り除いた入力キー「a」の優先度とを比較する。トライ木探索部250bは、ノードcの一致数が「0」であるため、キーの先頭から順に比較を行う。トライ木探索部250bは、比較した結果、入力キーの優先度よりもタグキーの優先度の方が大きいと判定する(ステップS92a)。
Subsequently, the description proceeds to FIG. 76. Since the child node corresponding to “a” designated by the pointer does not exist in the node a, the trie
実データ上において、トライ木探索部250bは、ポインタ配列44の「一致」と世代数を比較する。一致数と世代数が等しいので、トライ木探索部250bは、ポインタ配列44の「TAG」に接続された文字「b」の優先度と、入力キーのポインタに接続された文字「a」の優先度を比較する。トライ木探索部250bは、比較した結果、入力キーの優先度よりもタグキーの優先度の方が大きいと判定する(ステップS92b)。
On the actual data, the trie
図77の説明に移行する。トライ木探索部250bは、ノードcが兄ノード「ノードb(2)」を有するので、ノードcより前のノード(ノードa、ノードb(1))に、入力キーと一致するタグキーを有するノードは存在しないと判定する。トライ木探索部250bは、該当データが存在しない旨を出力する(ステップS93)。
The description shifts to the description of FIG. Since the node c has the older brother node “node b (2)”, the trie
次に、本実施例2にかかる検索装置200の各種の処理手順について説明する。まず、本実施例2にかかる検索装置200がトライ木240bを生成する処理について説明する。図78は、本実施例2にかかるトライ木生成処理の処理手順を示すフローチャートである。
Next, various processing procedures of the
図78に示すように、トライ木生成部250aは、ルートノードを生成し(ステップS500)、次の入力データ(キー、値)が登録データ管理テーブル240aに存在するか否かを判定する(ステップS501)。
As shown in FIG. 78, the trie
トライ木生成部250aは、次の入力データが登録データ管理テーブル240aに存在しないと判定した場合には(ステップS502,No)、処理を終了する。一方、トライ木生成部250aは、次の入力データが登録データ管理テーブル240aに登録されている場合には(ステップS502,Yes)、未読の入力データを読み出し(ステップS503)、データ追加処理を実行する(ステップS504)。
If the trie
次に、図78のステップS504に示したデータ追加処理の処理手順について説明する。ここでは、二分探索法を用いないでデータ追加処理を実行する場合について説明するが、実施例1と同様にして、二分探索法を用いても良い。 Next, the processing procedure of the data addition processing shown in step S504 in FIG. 78 will be described. Here, the case where the data addition process is executed without using the binary search method will be described, but the binary search method may be used in the same manner as in the first embodiment.
図79〜図81は、本実施例2にかかるデータ追加処理の処理手順を示すフローチャートである。図79に示すように、トライ木生成部250aは、現在のノードをルートノードに設定し(ステップS510)、入力キーが空であるか否かを判定する(ステップS511)。
FIGS. 79 to 81 are flowcharts illustrating the processing procedure of the data addition processing according to the second embodiment. As shown in FIG. 79, the trie
トライ木生成部250aは、入力キーが空の場合に(ステップS512,Yes)、世代数を0に設定し(ステップS513)、図80のステップS519に移行する。一方、トライ木生成部250aは、入力キーが空ではない場合に(ステップS512,No)、入力キーの先頭文字のキーで子ノードを参照し、子ノードが存在するか否かを判定する(ステップS514)。
When the input key is empty (step S512, Yes), the trie
トライ木生成部250aは、子ノードが存在する場合に(ステップS515,Yes)、入力キーの先頭の1文字を読み取り、入力キーのポインタを1文字進め、読み出した文字をキーとして子ノードに遷移し(ステップS516)、ステップS511に移行する。
If there is a child node (step S515, Yes), the trie
一方、トライ木生成部250aは、子ノードが存在しない場合に(ステップS515,No)、長男キーの優先度が入力キーの先頭文字のキーの優先度よりも小さいか否かを判定する(ステップS517)。トライ木生成部250aは、長男キーの優先度が入力キーの先頭文字のキーの優先度よりも小さくない場合に(ステップS518,No)、ステップS513に移行する。
On the other hand, when there is no child node (step S515, No), the trie
一方、トライ木生成部250aは、長男キーの優先度が入力キーの先頭文字のキーの優先度よりも小さい場合に(ステップS518,Yes)、図81のステップ536に移行する。
On the other hand, when the priority of the eldest son key is lower than the priority of the key of the first character of the input key (step S518, Yes), the trie
続いて、図80の説明に移行し、トライ木生成部250aは、ノードの情報を参照し(ステップS519)、一致数と世代数が等しいか否かを判定する(ステップS520)。トライ木生成部250aは、一致数と世代数が異なる場合に(ステップS521,No)、一致数が世代数よりも大きいか否かを判定する(ステップS522)。
Subsequently, the description proceeds to the description of FIG. 80. The trie
トライ木生成部250aは、一致数が世代数よりも大きくない場合には(ステップS523,No)、図81のステップS538に移行する。一方、トライ木生成部250aは、一致数が世代数よりも大きい場合に(ステップS523,Yes)、ステップS530に移行する。
If the number of matches is not greater than the number of generations (step S523, No), the trie
ところで、トライ木生成部250aは、ステップS525において、タブキーの優先度と入力キーの優先度が等しい場合に(ステップS525,Yes)、現在のノードのデータに入力値を追加し(ステップS526)、データ追加処理を終了する(ステップS527)。
By the way, if the priority of the tab key is equal to the priority of the input key in step S525 (step S525, Yes), the trie
一方、トライ木生成部250aは、タグキーの優先度と入力キーの優先度が異なる場合に(ステップS525,No)、タグキーの優先度が入力キーの優先度よりも大きいか否かを判定する(ステップS527)。トライ木生成部250aは、タグキーの優先度が入力キーの優先度よりも大きくない場合には(ステップS528,No)、図81のステップS533に移行する。
On the other hand, when the priority of the tag key is different from the priority of the input key (No in step S525), the trie
一方、トライ木生成部250aは、タグキーの優先度が入力キーの優先度よりも大きい場合に(ステップS528,Yes)、前方一致した文字数を世代数に追加し、入力キーのポインタを前方一致した文字数分だけ進める(ステップS529)。
On the other hand, when the priority of the tag key is higher than the priority of the input key (Yes in step S528), the trie
トライ木生成部250aは、兄ノードが存在する、または、親ノードがルートノードであるか否かを判定する(ステップS530)。トライ木生成部250aは、兄ノードが存在せず、かつ、親ノードがルートノードでない場合(条件を満たさない場合)に(ステップS531,No)、世代数に1を加算し、親ノードへ遷移し(ステップS532)、ステップS529に移行する。
The trie
一方、トライ木生成部250aは、兄ノードが存在する、または、親ノードがルートノードである場合(条件を満たす場合)に(ステップS531,Yes)、図81のステップS539に移行する。
On the other hand, the trie
続いて、図81の説明に移行し、トライ木生成部250aは、現在のタグ情報において、一致数に前方一致した文字数を加算し、タグキーのポインタを前方一致した文字数分だけ進め(ステップS533)、世代数が0であるか否かを判定する(ステップS534)。
Subsequently, the description proceeds to the description of FIG. 81. The trie
トライ木生成部250aは、世代数が0の場合に(ステップS535,Yes)、新しいノードを生成し、現在のノードから入力キーの先頭文字をキーとして新しいノードに接続し、入力キーのポインタを進める(ステップS536)。
When the generation number is 0 (Yes in step S535), the trie
トライ木生成部250aは、世代数、入力キーをタグ情報として新しいノードに付加し(ステップS537)、入力値を新しいノードに付加し(ステップS538)、データ追加処理を終了する。
The trie
一方、トライ木生成部250aは、世代数が0ではない場合に(ステップS535,No)、世代数から1を減算し、長男ノードへ遷移する(ステップS538)。トライ木生成部250aは、現在のノードの一致数、タグキー、値と世代数、入力キー、入力値をぞれぞれ交換し(ステップS539)、世代数が0であるか否かを判定する(ステップS540)。
On the other hand, when the number of generations is not 0 (step S535, No), the trie
トライ木生成部250aは、世代数が0の場合に(ステップS541,Yes)、入力キーの先頭文字のキーで子ノードを参照し(ステップS542)、ステップS536に移行する。一方、トライ木生成部250aは、世代数が0ではない場合に(ステップS541,No)、ステップS538に移行する。
When the number of generations is 0 (step S541, Yes), the trie
次に、本実施例2にかかる検索装置200がトライ木240bを用いて検索を行う処理について説明する。ここでは、二分探索法を用いないで検索処理を実行する場合について説明するが、実施例1と同様にして、二分探索法を用いても良い。
Next, processing in which the
図82および図83は、本実施例2にかかる検索処理の処理手順を示すフローチャートである。図82に示すように、トライ木探索部250bは、現在のノードをルートノードに設定し(ステップS550)、入力キーが存在するか否かを判定する(ステップS551)。
FIG. 82 and FIG. 83 are flowcharts illustrating the processing procedure of the search processing according to the second embodiment. As shown in FIG. 82, the trie
トライ木探索部250bは、入力キーが存在する場合に(ステップS552,Yes)、入力キーの先頭文字のキーで子ノードを参照し、キーの子ノードが存在するか否かを判定する(ステップS553)。
When there is an input key (step S552, Yes), the trie
トライ木探索部250bは、子ノードが存在する場合に(ステップS554,Yes)、先頭キーで子ノードへ遷移し、入力キーのポインタを進め(ステップS555)、ステップS551に移行する。
When there is a child node (Yes in step S554), the trie
一方、トライ木探索部250bは、子ノードが存在しない場合に(ステップS554,No)、長男キーの優先度が入力キーの先頭のキーの優先度よりも小さいか否かを判定する(ステップS556)。
On the other hand, when there is no child node (No in step S554), the trie
トライ木探索部250bは、長男キーの優先度が入力キーの先頭のキーの優先度よりも小さい場合に(ステップS557,Yes)、一致データが無い旨を出力する(ステップS558)。一方、トライ木探索部250bは、長男キーの優先度が入力キーの先頭のキーの優先度よりも小さくない場合には(ステップS557,No)、ステップS559に移行する。
When the priority of the eldest son key is lower than the priority of the first key of the input key (step S557, Yes), the trie
ところで、トライ木探索部250bは、ステップS552において、入力キーが存在しない場合に(ステップS552,No)、世代数を0に設定し(ステップS559)、図83のステップS560に移行する。
By the way, if there is no input key in step S552 (step S552, No), the trie
続いて、図83の説明に移行し、トライ木探索部250bは、ノードの情報を参照し、一致数が世代数と等しいか否かを判定する(ステップS560)。トライ木探索部250bは、一致数と世代数が等しくない場合に(ステップS561,No)、一致数が世代数よりも大きいか否かを判定する(ステップS562)。
Subsequently, the description proceeds to FIG. 83, and the trie
トライ木探索部250bは、一致数が世代数よりも大きくない場合に(ステップS563,No)、一致データが無い旨を出力する(ステップS564)。トライ木探索部250bは、一致数が世代数よりも大きい場合に(ステップS563,Yes)、ステップS571に移行する。
When the number of matches is not greater than the number of generations (step S563, No), the trie
ところで、トライ木探索部250bは、ステップS561において、一致数と世代数が等しい場合に(ステップS561,Yes)、タグキーの優先度と入力キーの優先度が等しいか否かを判定する(ステップS565)。
By the way, the trie
トライ木探索部250bは、タグキーの優先度と入力キーの優先度が等しい場合に(ステップS566,Yes)、現在のノードのデータを出力する(ステップS567)。一方、トライ木探索部250bは、タグキーの優先度と入力キーの優先度が異なる場合に(ステップS566,No)、タグキーの優先度が入力キーの優先度よりも大きいか否かを判定する(ステップS568)。
When the priority of the tag key is equal to the priority of the input key (Yes in step S566), the trie
トライ木探索部250bは、タグキーの優先度が入力キーの優先度よりも大きくない場合には(ステップS569,No)、ステップS564に移行する。一方、トライ木探索部250bは、タグキーの優先度が入力キーの優先度よりも大きい場合に(ステップS569,Yes)、前方一致した文字数を世代数に追加し、入力キーのポインタを前方一致した文字数分だけ進める(ステップS570)。
When the priority of the tag key is not greater than the priority of the input key (No at Step S569), the trie
トライ木探索部250bは、兄ノードが存在する、または、親ノードがルートノードであるか否かを判定する(ステップS571)。トライ木探索部250bは、兄ノードが存在しない、かつ、親ノードがルートノードでない場合(条件を満たさない場合)に(ステップS572,No)、世代数に1を加算し、親ノードへ遷移し(ステップS573)、ステップS560に移行する。
The trie
一方、トライ木探索部250bは、兄ノードが存在する、または、親ノードがルートノードである場合(条件を満たす場合)に(ステップS572,Yes)、ステップS564に移行する。
On the other hand, the trie
次に、本実施例2にかかる検索装置200が実行する集計値の抽出処理について説明する。図84は、本実施例2にかかる集計値の抽出処理の処理手順を示すフローチャートである。図84に示すように、トライ木探索部250bは、現在のノードをルートノードに設定し(ステップS600)、子ノードが存在するか否かを判定する(ステップS601)。
Next, a summary value extraction process executed by the
トライ木探索部250bは、子ノードが存在しない場合には(ステップS602,No)、弟ノードが存在するか否かを判定する(ステップS603)。トライ木探索部250bは、弟ノードが存在しない場合に(ステップS604,No)、親ノードへ遷移し(ステップS605)、ステップS603に移行する。
If there is no child node (No in step S602), the trie
一方、トライ木探索部250bは、弟ノードが存在する場合に(ステップS604,Yes)、次弟ノードへ遷移し(ステップS606)、ステップS609に移行する。
On the other hand, when the younger brother node exists (step S604, Yes), the trie
ところで、トライ木探索部250bは、ステップS602において、子ノードが存在する場合に(ステップS602,Yes)、タグキーのポインタから一致数+階層数分だけ戻した位置から、キーを取得する(ステップS608)。そして、トライ木探索部250bは、現在のノードの各種値を加工し出力し(ステップS609)、ステップS601に移行する。
By the way, if there is a child node in step S602 (step S602, Yes), the trie
次に、本実施例2にかかる検索装置200が実行する削除処理の処理手順について説明する。図85〜図88は、本実施例2にかかる削除処理の処理手順を示すフローチャートである。図85に示すように、トライ木探索部250bは、入力キーが存在するか否かを判定し(ステップS610)、入力キーが存在する場合(ポインタの示す文字が空でない場合)には(ステップS611,Yes)、入力キーの先頭文字のキーで子ノードを参照し、子ノードが存在するか否かを判定する(ステップS612)。
Next, a processing procedure of deletion processing executed by the
トライ木探索部250bは、子ノードが存在する場合には(ステップS613,Yes)、先頭キーで子ノードへ遷移し、入力キーのポインタを進め(ステップS614)、ステップS610に移行する。
If there is a child node (step S613, Yes), the trie
一方、トライ木探索部250bは、子ノードが存在しない場合には(ステップS613,No)、ノードの一致数が0であるか否かを判定する(ステップS615)。トライ木探索部250bは、一致数が0でない場合に(ステップS616,No)、長男キーの優先度が入力キーの先頭文字のキーの優先度よりも小さいか否かを判定する(ステップS617)。トライ木探索部250bは、長男キーの優先度が入力キーの先頭文字のキーの優先度よりも小さい場合には(ステップS618,Yes)、削除データが存在しない旨を出力する(ステップS619)。
On the other hand, when there is no child node (No in step S613), the trie
ところで、トライ木探索部250bは、ステップS611において、入力キーが存在しない場合(ポインタの文字が空の場合)には(ステップS611,No)、世代数を0に設定し(ステップS620)、図86のステップS621に移行する。
By the way, the trie
続いて、トライ木探索部250bは、図86において、ノードの情報を参照し(ステップS621)、一致数が世代数と等しいか否かを判定する(ステップS622)。トライ木探索部250bは、一致数と世代数が等しくない場合に(ステップS623,No)、一致数が世代数よりも大きいか否かを判定する(ステップS624)。
Subsequently, the trie
トライ木探索部250bは、一致数が世代数よりも大きい場合に(ステップS625,Yes)、ステップS631に移行する。一方、トライ木探索部250bは、一致数が世代数よりも大きくない場合に(ステップS625,No)、ステップS634に移行する。
When the number of matches is greater than the number of generations (Yes in step S625), the trie
ところで、トライ木探索部250bは、ステップS623において、一致数と世代数が等しい場合に(ステップS623,Yes)、タグキーの優先度が入力キーの優先度と等しいか否かを判定する(ステップS626)。
By the way, when the number of matches is equal to the number of generations in step S623 (step S623, Yes), the trie
トライ木探索部250bは、タグキーの優先度が入力キーの優先度と等しい場合に(ステップS627,Yes)、図87のステップS635に移行する。一方、トライ木探索部250bは、タグキーの優先度が入力キーの優先度と等しくない場合に(ステップS627,No)、タグキーの優先度が入力キーの優先度よりも大きいか否かを判定する(ステップS628)。
If the priority of the tag key is equal to the priority of the input key (step S627, Yes), the trie
トライ木探索部250bは、タグキーの優先度が入力キーの優先度よりも大きくない場合には(ステップS629,No)、ステップS634に移行する。一方、トライ木探索部250bは、タグキーの優先度が入力キーの優先度よりも大きい場合に(ステップS629,Yes)、前方一致した文字を世代数に追加し、入力キーのポインタを前方一致した文字数分だけ進める(ステップS630)。
When the priority of the tag key is not higher than the priority of the input key (No at Step S629), the trie
トライ木探索部250bは、兄ノードが存在する、または、親ノードがルートノードであるか否かを判定する(ステップS631)。トライ木探索部250bは、兄ノードが存在せず、かつ、親ノードがルートノードでない場合(条件を満たさない場合)に(ステップS632,No)、世代数に1を加算し、親ノードへ遷移し(ステップS633)、ステップS621に移行する。
The trie
一方、トライ木探索部250bは、兄ノードが存在する、または、親ノードがルートノードの場合に(ステップS632,Yes)、削除データが存在しない旨を出力する(ステップS634)。
On the other hand, the trie
続いて、図87に移行し、トライ木探索部250bは、削除対象データが存在するか否かを判定する(ステップS635)。トライ木探索部250bは、削除対象データが存在しない場合に(ステップS636,No)削除データが存在しない旨を出力する(ステップS637)。
Subsequently, the process proceeds to FIG. 87, and the trie
一方、トライ木探索部250bは、削除対象データが存在する場合に(ステップS638)、他のデータが存在するか(ノードに他の値が登録されているか否か)否かを判定する(ステップS639)。トライ木探索部250bは、他のノードが存在する場合に(ステップS640,Yes)、処理を終了する。一方、トライ木探索部250bは、他のデータが存在しない場合に(ステップS640,No)、図88のステップS641に移行する。
On the other hand, when there is data to be deleted (step S638), the trie
続いて、図88に移行し、トライ木探索部250bは、現在のノードが長男であるか否かを判定し(ステップS641)、長男ではない場合に(ステップS642,No)、ステップS647に移行する。
Subsequently, the process proceeds to FIG. 88, and the trie
一方、トライ木探索部250bは、現在のノードが長男の場合に(ステップS642,Yes)、親ノードの一致数が現在のノードの一致数よりも大きいか否かを判定する(ステップS643)。トライ木探索部250bは、親ノードの一致数が現在のノードの一致数よりも大きくない場合に(ステップS644,No)、ステップS647に移行する。
On the other hand, when the current node is the eldest son (step S642, Yes), the trie
一方、トライ木探索部250bは、親ノードの一致数が現在のノードの一致数よりも大きい場合に(ステップS644,Yes)、親ノードの一致数から現在のノードの一致数を減算したものから更に1を減算したものを差分一致数として算出する(ステップS645)。
On the other hand, when the number of matches of the parent node is larger than the number of matches of the current node (step S644, Yes), the trie
トライ木探索部250bは、現在のノードの一致数に1を加算したものを親ノードの一致数に設定し、親ノードのタグ文字列のポインタを差分一致数分戻し(ステップS646)、子ノードが存在するか否かを判定する(ステップS647)。
The trie
トライ木探索部250bは、子ノードが存在する場合に(ステップS648,Yes)、現在のノードのデータを長男ノードのデータとし、一致数に1加算する(ステップS649)。トライ木探索部250bは、長男ノードへ遷移し(ステップS650)、ステップS647に移行する。
When there is a child node (step S648, Yes), the trie
一方、トライ木探索部250bは、子ノードが存在しない場合に(ステップS648,No)、現在のノードが長男であるか否かを判定する(ステップS612)。トライ木探索部250bは、現在のノードが長男ではない場合に(ステップS652,No)、ステップS654に移行する。
On the other hand, when there is no child node (No in step S648), the trie
一方、トライ木探索部250bは、現在のノードが長男ノードの場合に(ステップS652,Yes)、親ノードのタグ文字列のポインタを親ノードの一致数分だけ戻し、親ノードの一致数を0にする(ステップS653)。そして、トライ木探索部250bは、親ノードの現在のノードへのエッジを削除し、現在のノードを削除する(ステップS654)。
On the other hand, when the current node is the eldest node (step S652, Yes), the trie
上述してきたように、本実施例2にかかる検索装置200は、各ノードのタグキーと入力キーとを比較する場合に、先頭文字から順に各キー(タグキーと入力キー)の文字を比較するのではなく、子ノードに登録されたタグキーとの一致数だけ比較する文字をスキップするので、入力キーをトライ木に登録する処理を高速化することが出来る。
As described above, the
なお、本実施例2では一例として、子ノードの文字列と一部一致する文字列を親ノードに登録する場合に、文字列をそのまま親ノードに登録する代わりに、一致する文字列の長さと、残りの文字列を親ノードに登録していた。しかし、本願発明は、これに限定されるものではない。例えば、親ノードの文字列と一部一致する文字列を子ノードに登録する場合に、文字列をそのまま子ノードに登録する代わりに、一致する文字列の長さと、残りの文字列を子ノードに登録してもよい。 In the second embodiment, as an example, when a character string that partially matches the character string of the child node is registered in the parent node, the length of the matching character string is used instead of registering the character string in the parent node as it is. The remaining character string was registered in the parent node. However, the present invention is not limited to this. For example, when registering a character string that partially matches the character string of the parent node to the child node, instead of registering the character string directly to the child node, the length of the matching character string and the remaining character string are set to the child node. You may register with.
ところで、本実施例において説明した各処理のうち、自動的におこなわれるものとして説明した処理の全部または一部を手動的におこなうこともでき、あるいは、手動的におこなわれるものとして説明した処理の全部または一部を公知の方法で自動的におこなうこともできる。この他、上記文書中や図面中で示した処理手順、制御手順、具体的名称、各種のデータやパラメータを含む情報については、特記する場合を除いて任意に変更することができる。 By the way, among the processes described in the present embodiment, all or part of the processes described as being automatically performed can be manually performed, or the processes described as being manually performed can be performed. All or a part can be automatically performed by a known method. In addition, the processing procedure, control procedure, specific name, and information including various data and parameters shown in the above-described document and drawings can be arbitrarily changed unless otherwise specified.
また、図示した各装置の各構成要素は機能概念的なものであり、必ずしも物理的に図示の如く構成されていることを要しない。すなわち、各装置の分散・統合の具体的形態は図示のものに限られず、その全部または一部を、各種の負荷や使用状況などに応じて、任意の単位で機能的または物理的に分散・統合して構成することができる。さらに、各装置にて行なわれる各処理機能は、その全部または任意の一部が、CPUおよび当該CPUにて解析実行されるプログラムにて実現され、あるいは、ワイヤードロジックによるハードウェアとして実現され得る。 Further, each component of each illustrated apparatus is functionally conceptual, and does not necessarily need to be physically configured as illustrated. In other words, the specific form of distribution / integration of each device is not limited to that shown in the figure, and all or a part thereof may be functionally or physically distributed or arbitrarily distributed in arbitrary units according to various loads or usage conditions. Can be integrated and configured. Further, all or any part of each processing function performed in each device may be realized by a CPU and a program analyzed and executed by the CPU, or may be realized as hardware by wired logic.
図89は、実施例2に示した検索装置200(あるいは、実施例1にかかる検索装置100)に対応するコンピュータのハードウェア構成を示す図である。図89に示すように、このコンピュータ(検索装置)10は、入力装置11、モニタ12、RAM(Random Access Memory)13、ROM(Read Only Memory)14、ネットワークを介して他の装置とデータ通信を実行する通信制御装置15、媒体読取装置16、CPU(Central Processing Unit)17、HDD(Hard Disk Drive)18をバス19で接続している。
FIG. 89 is a diagram illustrating a hardware configuration of a computer corresponding to the
そして、HDD18には、上述した検索装置200の機能と同様の機能を発揮するトライ木生成プログラム18b、トライ木探索プログラム18cが記憶されている。CPU17が、トライ木生成プログラム18b、トライ木探索プログラム18cを読み出して実行することにより、トライ木生成プロセス17a、トライ木探索プロセス17bが起動される。
The
ここで、トライ木生成プロセス17aは、図56に示したトライ木生成部250aに対応する。また、トライ木探索プロセス17bは、図56に示したトライ木探索部250bに対応する。
Here, the trie tree generation process 17a corresponds to the trie
なお、HDD18は、図56で示した記憶部240に記憶されたデータに対応する各種データ18aを記憶している。CPU17は、HDD18に記憶された各種データ18aをRAM13に読み出し、各種データ13aを利用して、トライ木の構築等を実行する。
The
以上の各実施例を含む実施形態に関し、さらに以下の付記を開示する。 The following supplementary notes are further disclosed with respect to the embodiments including the above examples.
(付記1)コンピュータに、
所定の文字に対応するノードが木構造にて接続されるトライ木を記憶装置に記憶し、当該トライ木に新規の文字列を登録する場合に、当該新規の文字列の文字を先頭から順に読み出して前記トライ木に含まれるノードを当該ノードに対応する文字に応じて辿り、単一のノードに対して単一の文字列が登録されるように、辿ったノードの何れかに新規の文字列を登録する場合に、登録対象のノードの子ノードに登録された文字列と新規の文字列とを比較して一致する文字を判定し、新規の文字列から一致する文字を除いた残りの文字列と一致文字数を、登録対象のノードに登録する文字列登録機能
を実現させるためのプログラムを格納した記憶媒体。
(Supplementary note 1)
When a trie tree in which nodes corresponding to a predetermined character are connected in a tree structure is stored in the storage device and a new character string is registered in the trie tree, the characters of the new character string are read in order from the top. The node included in the trie tree is traced according to the character corresponding to the node, and a new character string is added to any of the traced nodes so that a single character string is registered for the single node. When registering, the character string registered in the child node of the registration target node is compared with the new character string to determine the matching character, and the remaining characters excluding the matching character from the new character string A storage medium that stores a program that implements a character string registration function that registers the number of characters that match a character string in a node to be registered.
(付記2)前記文字列登録機能は、各ノードに登録される各文字列に対して所定も文字順序に基づく優先度を設定し、当該優先度に基づいて各ノードに各文字列を登録することを特徴とする付記1に記載の記憶媒体。
(Supplementary Note 2) The character string registration function sets a priority based on a predetermined character order for each character string registered in each node, and registers each character string in each node based on the priority. The storage medium according to
(付記3)前記文字列登録機能は、ノードに登録された文字列の優先度と、新規の文字列の優先度とを比較して、登録されたノードの文字列の優先度よりも新規の文字列の優先度の方が小さい場合に、登録された文字列と新規の文字列で一致する文字数を判定する判定機能と、前記ノードの親ノードに遷移し、前記判定機能で判定した一致する文字数と、前記親ノードに登録された一致文字数とを基にして、新規のノードを前記親ノードに登録するか否かを判定する登録機能を更に実現させるためのプログラムを格納した付記1または2に記載の記憶媒体。
(Supplementary note 3) The character string registration function compares the priority of the character string registered in the node with the priority of the new character string, and is newer than the priority of the character string of the registered node. When the priority of the character string is lower, the determination function that determines the number of characters that match between the registered character string and the new character string, and the matching that is determined by the determination function by transitioning to the parent node of the
(付記4)検索文字列を検索する場合に、ノードに登録された文字列と、該検索文字列とを比較して、各文字列が一致しない場合に、登録された文字列と該検索文字列で一致する文字数を判定する検索判定機能と、前記ノードの親ノードに遷移し、前記検索判定機能で判定した一致する文字数に応じて、該検索文字列と前記親ノードの文字列の一部を除いた後に、各文字列が一致するか否かを判定する一致判定機能を更に実現させるためのプログラムを格納した記憶媒体。 (Supplementary Note 4) When searching for a search character string, the character string registered in the node is compared with the search character string, and if the character strings do not match, the registered character string and the search character string A search determination function that determines the number of characters that match in the column, and a transition to the parent node of the node, and according to the number of matching characters determined by the search determination function, the search character string and a part of the character string of the parent node A storage medium storing a program for further realizing a coincidence determination function for determining whether or not each character string matches after removing.
(付記5)検索装置が、
所定の文字に対応するノードが木構造にて接続されるトライ木を記憶装置に記憶するステップと、
前記記憶装置に記憶されたトライ木に新規の文字列を登録する場合に、当該新規の文字列の文字を先頭から順に読み出して前記トライ木に含まれるノードを当該ノードに対応する文字に応じて辿り、単一のノードに対して単一の文字列が登録されるように、辿ったノードの何れかに新規の文字列を登録する場合に、登録対象のノードの子ノードに登録された文字列と新規の文字列とを比較して一致する文字を判定し、新規の文字列から一致する文字を除いた残りの文字列と一致文字数を、登録対象のノードに登録するステップと
を含んだことを特徴とするトライ木生成方法。
(Supplementary Note 5) The search device is
Storing a trie tree in which nodes corresponding to predetermined characters are connected in a tree structure in a storage device;
When registering a new character string in the trie tree stored in the storage device, the characters of the new character string are read in order from the top, and the node included in the trie tree is determined according to the character corresponding to the node. If a new character string is registered in any of the traced nodes so that a single character string is registered for a single node, the characters registered in the child nodes of the registered node And comparing the new character string with the new character string to determine the matching character, and registering the remaining character string excluding the matching character from the new character string and the number of matching characters in the node to be registered. A trie tree generation method characterized by that.
(付記6)所定の文字に対応するノードが木構造にて接続されるトライ木を記憶装置に記憶し、当該トライ木に新規の文字列を登録する場合に、当該新規の文字列の文字を先頭から順に読み出して前記トライ木に含まれるノードを当該ノードに対応する文字に応じて辿り、単一のノードに対して単一の文字列が登録されるように、辿ったノードの何れかに新規の文字列を登録する場合に、登録対象のノードの子ノードに登録された文字列と新規の文字列とを比較して一致する文字を判定し、新規の文字列から一致する文字を除いた残りの文字列と一致文字数を、登録対象のノードに登録する文字列登録手段
を有することを特徴とするトライ木生成装置。
(Supplementary note 6) When a trie tree in which nodes corresponding to a predetermined character are connected in a tree structure is stored in a storage device and a new character string is registered in the trie tree, the character of the new character string is Read from the top in order and follow the node included in the trie tree according to the character corresponding to the node, so that a single character string is registered for a single node. When registering a new character string, the character string registered in the child node of the node to be registered is compared with the new character string to determine a matching character, and the matching character is excluded from the new character string. A trie tree generating device, comprising: a character string registration unit that registers the number of matching characters with the remaining character string in a node to be registered.
10 コンピュータ
11 入力装置
12 モニタ
13 RAM
13a,18a 各種データ
14 ROM
15 通信制御装置
16 媒体読取装置
17 CPU
17a トライ木生成プロセス
17b トライ木探索プロセス
18b トライ木生成プログラム
18c トライ木探索プログラム
19 バス
100,200 検索装置
110,210 入力部
120,220 出力部
130,230 入出力制御部
140,240 記憶部
140a,240a 登録データ管理テーブル
140b,240b トライ木
150,250 制御部
150a,250a トライ木生成部
150b,250b トライ木探索部
10
13a, 18a
15
17a Trie tree generation process 17b Trie
Claims (5)
ノードに対応付けられる文字列のうち、子ノードに登録された文字列と一致する一致文字数と、ノードに対応付けられた文字列から子ノードに対応付けられた文字列を取り除いた残りの文字列とを登録したノードが木構造にて接続されるトライ木を記憶装置に記憶し、当該トライ木に新規の文字列を登録する場合に、当該新規の文字列の文字を先頭から順に読み出して前記トライ木に含まれるノードを当該ノードに対応する文字に応じて辿り、単一のノードに対して単一の文字列が登録されるように、辿ったノードの何れかに新規の文字列を登録する場合に、先頭文字から登録対象のノードに登録された一致文字数だけ比較する文字をスキップした新規の文字列と、登録対象のノードの子ノードに登録された文字列とを比較して一致する文字を判定し、新規の文字列から一致する文字を除いた残りの文字列と一致文字数を、登録対象のノードに登録する文字列登録機能
を実現させるためのプログラムを格納した記憶媒体。 On the computer,
Of the character strings associated with the node, the number of matching characters that match the character string registered with the child node, and the remaining character string obtained by removing the character string associated with the child node from the character string associated with the node storing trie tree node that registered the door is connected by a tree structure in the storage device, to register a new string in the prefix tree, the said new string characters from the beginning are read sequentially Follow a node included in the trie tree according to the character corresponding to the node, and register a new character string in one of the traced nodes so that a single character string is registered for a single node. If a new character string skipped from the first character compared to the number of matching characters registered in the registration target node is compared with the character string registered in the child node of the registration target node character Determined, a new remaining string as matched characters excluding the character that matches the character string, storage medium storing a program for realizing the character string registration function of registering a node to be registered.
ノードに対応付けられる文字列のうち、子ノードに登録された文字列と一致する一致文字数と、ノードに対応付けられた文字列から子ノードに対応付けられた文字列を取り除いた残りの文字列とを登録したノードが木構造にて接続されるトライ木を記憶装置に記憶するステップと、
前記記憶装置に記憶されたトライ木に新規の文字列を登録する場合に、当該新規の文字列の文字を先頭から順に読み出して前記トライ木に含まれるノードを当該ノードに対応する文字に応じて辿り、単一のノードに対して単一の文字列が登録されるように、辿ったノードの何れかに新規の文字列を登録する場合に、先頭文字から登録対象のノードに登録された一致文字数だけ比較する文字をスキップした新規の文字列と、登録対象のノードの子ノードに登録された文字列とを比較して一致する文字を判定し、新規の文字列から一致する文字を除いた残りの文字列と一致文字数を、登録対象のノードに登録するステップと
を含んだことを特徴とするトライ木生成方法。 The search device
Of the character strings associated with the node, the number of matching characters that match the character string registered with the child node, and the remaining character string obtained by removing the character string associated with the child node from the character string associated with the node Storing in a storage device a trie tree in which nodes that are registered in a tree structure are connected;
When registering a new character string in the trie tree stored in the storage device, the characters of the new character string are read in order from the top, and the node included in the trie tree is determined according to the character corresponding to the node. If a new character string is registered in any of the traced nodes so that a single character string is registered for a single node, the match registered in the registration target node from the first character A new character string that is skipped by the number of characters to be compared is compared with a character string that is registered in the child node of the registration target node to determine a matching character, and the matching character is excluded from the new character string. A trie tree generation method comprising: registering a remaining character string and the number of matching characters in a registration target node.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2009080245A JP5387092B2 (en) | 2009-03-27 | 2009-03-27 | Storage medium and trie tree generation method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2009080245A JP5387092B2 (en) | 2009-03-27 | 2009-03-27 | Storage medium and trie tree generation method |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2010231643A JP2010231643A (en) | 2010-10-14 |
JP5387092B2 true JP5387092B2 (en) | 2014-01-15 |
Family
ID=43047372
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2009080245A Active JP5387092B2 (en) | 2009-03-27 | 2009-03-27 | Storage medium and trie tree generation method |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP5387092B2 (en) |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5202986A (en) * | 1989-09-28 | 1993-04-13 | Bull Hn Information Systems Inc. | Prefix search tree partial key branching |
JP3570323B2 (en) * | 1999-05-11 | 2004-09-29 | 日本電気株式会社 | How to store prefixes for addresses |
JP2000339332A (en) * | 1999-05-28 | 2000-12-08 | Nippon Telegr & Teleph Corp <Ntt> | Medium recording retrieval index, method and device for updating retrieval index and medium recording its program |
JP4726310B2 (en) * | 2001-03-01 | 2011-07-20 | ソフトバンクテレコム株式会社 | Information retrieval apparatus, information retrieval multiprocessor and router |
US20070094313A1 (en) * | 2005-10-24 | 2007-04-26 | Igor Bolotin | Architecture and method for efficient bulk loading of a PATRICIA trie |
-
2009
- 2009-03-27 JP JP2009080245A patent/JP5387092B2/en active Active
Also Published As
Publication number | Publication date |
---|---|
JP2010231643A (en) | 2010-10-14 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP5278534B2 (en) | Storage medium | |
US8208408B2 (en) | Tree-based node insertion method and memory device | |
CN102841852B (en) | Wear leveling method, storing device and information system | |
CN103455432B (en) | It is used for managing the method for a memory and its relevant memory | |
KR20210057835A (en) | Compressed Key-Value Store Tree Data Block Leak | |
JP6262874B2 (en) | Database implementation method | |
CN113196260A (en) | Key value storage tree capable of selectively using key portions | |
WO2015096698A1 (en) | Data writing and reading methods for flash | |
CN107291858B (en) | Data indexing method based on character string suffix | |
TWI329804B (en) | ||
JP2008181260A5 (en) | ||
JP2009015530A5 (en) | ||
CN101908102B (en) | Precasting method and device for stalk-based RNA (Ribonucleic Acid) secondary structure | |
CN101158955A (en) | A Construction Method of Chinese Thesaurus | |
CN110955713A (en) | Mnemonic word generating method and device and storage medium | |
CA2936485C (en) | Optimized data condenser and method | |
JP5387092B2 (en) | Storage medium and trie tree generation method | |
CN105138528B (en) | Method and device for storing and reading multi-value data and access system thereof | |
JP2014093612A (en) | Coding device and method of controlling the same | |
CN101452459B (en) | System and method for finding similar translation results using index | |
JP5493431B2 (en) | Storage medium, trie tree generation method, and trie tree generation apparatus | |
CN115630100A (en) | Mixed processing method and device for unit and multivariate time sequence data and computer equipment | |
JP6524668B2 (en) | Document retrieval apparatus, document retrieval method, program, | |
CN102968467A (en) | Optimization method and query method for multiple layers of Bloom Filters | |
CN114254591A (en) | Construction method and device of simplified and traditional conversion tool |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20111205 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20130702 |
|
A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20130822 |
|
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: 20130910 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20130923 |
|
R150 | Certificate of patent or registration of utility model |
Ref document number: 5387092 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R150 Free format text: JAPANESE INTERMEDIATE CODE: R150 |