WO2009090697A1 - ビット列検索装置、検索方法及びプログラム - Google Patents

ビット列検索装置、検索方法及びプログラム Download PDF

Info

Publication number
WO2009090697A1
WO2009090697A1 PCT/JP2008/003264 JP2008003264W WO2009090697A1 WO 2009090697 A1 WO2009090697 A1 WO 2009090697A1 JP 2008003264 W JP2008003264 W JP 2008003264W WO 2009090697 A1 WO2009090697 A1 WO 2009090697A1
Authority
WO
WIPO (PCT)
Prior art keywords
node
key
search
tree
string
Prior art date
Application number
PCT/JP2008/003264
Other languages
English (en)
French (fr)
Inventor
Toshio Shinjo
Mitsuhiro Kokubun
Original Assignee
S.Grants Co., Ltd.
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by S.Grants Co., Ltd. filed Critical S.Grants Co., Ltd.
Priority to EP08871045.4A priority Critical patent/EP2249257B1/en
Priority to CN200880124936.8A priority patent/CN101911068B/zh
Publication of WO2009090697A1 publication Critical patent/WO2009090697A1/ja
Priority to US12/805,183 priority patent/US8195667B2/en

Links

Images

Classifications

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

Definitions

  • the present invention relates to a search device, a search method, and a program for searching for a desired bit string from a set of bit strings, and particularly to a technical field for improving search speed and the like by devising a data structure for storing bit strings. is there.
  • FIG. 1 shows an example of a Patricia tree used in the above-described conventional search process.
  • the Patricia tree node includes an index key, a check bit position of the search key, and left and right link pointers. Although not explicitly shown, it goes without saying that the node includes information for accessing the record corresponding to the index key.
  • the node 1750a holding the index key “100010” is the root node, and the check bit position is 0.
  • a node 1750b is connected to the left link 1740a of the node 1750a, and a node 1750f is connected to the right link 1741a.
  • the index key held by the node 1750b is “010011”, and the check bit position 2030b is 1.
  • a node 1750c is connected to the left link 1740b of the node 1750b, and a node 1750d is connected to the right link 1741b.
  • the index key held by the node 1750c is “000111”, and the check bit position is 3.
  • the index key held by the node 1750d is “011010”, and the check bit position is 2.
  • the portion connected by a solid line from the node 1750c indicates the left and right link pointers of the node 1750c, and the left pointer 1740c not connected by the dotted line indicates that the column is blank.
  • the connection destination of the dotted line of the right pointer 1741c connected to the dotted line represents the address indicated by the pointer, and in this case indicates that the right pointer designates the node 1750c.
  • the right pointer 1741d of the node 1750d points to the node 1750d itself, and the node 1750e is connected to the left link 1740d.
  • the index key held by the node 1750e is “010010”, and the check bit position is 5.
  • the left pointer 1740e of the node 1750e points to the node 1750b, and the right pointer 1741e points to the node 1750e.
  • the index key held by the node 1750f is “101011”, and the check bit position 1730f is 2.
  • a node 1750g is connected to the left link 1740f of the node 1750f, and a node 1750h is connected to the right link 1741f.
  • the index key held by the node 1750g is “1000011”, and the check bit position 1730g is 5.
  • the left pointer 1740g of the node 1750g points to the node 1750a, and the right pointer 1741g points to the node 1750g.
  • the index key held by the node 1750h is “101100”, and the check bit position 1730h is 3.
  • the left pointer 1740h of the node 1750h points to the node 1750f, and the right pointer 1741h points to the node 1750h.
  • the check bit position of each node is configured to increase as the tree descends from the root node 1750a.
  • the check bit position of the search key held in each node is sequentially checked from the root node, and it is determined whether the bit value of the check bit position is 1 or 0, If it is 1, follow the right link, if it is 0, follow the left link. If the check bit position of the link destination node is not larger than the check bit position of the link source node, that is, if the link destination returns upward rather than downward (the reverse link indicated by the dotted line in FIG.
  • the index key of the link destination node and the search key are compared. As a result of the comparison, it is guaranteed that the search is successful if they are equal and the search is unsuccessful if they are not equal.
  • search processing using the Patricia tree has advantages such as being able to search only by checking the necessary bits and comparing the entire key only once, but there are always two links from each node. Increase in storage capacity due to the presence of the data, complicating judgment processing due to the presence of a back link, difficulty in data maintenance such as search processing delay and addition / deletion by comparing with an index key for the first time by returning by a back link, etc. There are disadvantages.
  • Patent Document 1 there is a technique disclosed in Patent Document 1 below as an attempt to eliminate the disadvantages of these Patricia trees.
  • the lower left and right nodes are stored in a continuous area, thereby reducing the storage capacity of the pointer, and a bit indicating whether or not the next link is a back link Is provided at each node to reduce the back link determination process.
  • the search can be performed using not only the value of an item corresponding to the record of the database as an index key but also the value of any item constituting the record as a search key. Usually done. Since the value of this item is not necessarily unique depending on the record, a search using duplicate keys in a plurality of records is performed. An example of handling such a duplicate key is described in Patent Document 2 below. JP 2001-357070 A JP-A-11-96058
  • the problem to be solved by the present invention is to search for a bit string having a data structure that can be searched with duplicate keys, requires a small storage capacity, has a high search speed, and is easy to maintain.
  • An apparatus and a search method are provided.
  • the present applicant has disclosed in Japanese Patent Application No. 2006-187827 that the root node, the branch node arranged in the adjacent storage area, the leaf node, the branch nodes, or the leaf.
  • a tree used for bit string search consisting of node pairs between nodes, where the root node is a node representing the starting point of the tree, and when there is one node in the tree, it is a leaf node, and when there are two or more nodes in the tree Is a branch node
  • the branch node includes a discrimination bit position of a search key for performing a bit string search and position information indicating a position of a representative node which is one node of a link destination node pair, and the leaf node is a search Using a coupled node tree that includes an index key consisting of the target bit string Proposed Tsu door string search.
  • a basic method using a coupled node tree such as a method for generating a coupled node tree from a given set of index keys and a method for retrieving a single index key from the coupled node tree.
  • a search technique is shown.
  • the present applicant arranges the index key in an area different from the coupled node tree, and the leaf node indicates the position of the storage area where the index key is arranged instead of the index key.
  • a coupled node tree storing information and various search processes using it were proposed.
  • An object of the present invention is to enable handling of duplicate keys in a high-speed search technique using this coupled node tree.
  • an index key composed of a plurality of key strings is obtained as a unique key.
  • the second position information indicating the position of the storage area where the unique key is arranged is stored in the leaf node of the above-mentioned coupled node tree.
  • the search key is a combination of a plurality of keys as a key string, and the last key of the key string is a unique search key string.
  • the branch node has a first discrimination position indicating the position information of the key to be compared in the search key string for performing the bit string search and a second discrimination position indicating the discrimination bit position of the key.
  • the branch node includes first position information indicating the position of a representative node that is one node of the link destination node pair.
  • the key of the first discrimination position of the branch node is extracted from the search key string, and the bit value of the second discrimination position (discrimination bit position) of the key
  • linking to any node of the linked note pairs is performed up to the leaf node, and the information indicating the position of the storage area stored in the leaf node is arranged in the storage area.
  • a search using the search key string is performed.
  • bit string data it is possible to handle duplicate keys and to search bit string data at higher speed.
  • addition and deletion of bit string data can be easily performed.
  • the position of the representative node of the link destination held by the branch node can be the address information of the storage device, but an array that can store the larger storage capacity of the area occupied by the branch node or leaf node
  • the position of the node can be represented by an array number, and the amount of information of position information indicating the position of the representative node can be reduced.
  • FIG. 2A is a diagram illustrating a configuration example of a coupled node tree stored in an array according to an embodiment of the present invention.
  • the node 101 is arranged in the array element of array number 10 in the array 100.
  • the node 101 includes a node type 102, a first discrimination position 103a, a second discrimination position 103, and a representative node number 104.
  • the node type 102 is 0, indicating that the node 101 is a branch node.
  • 0 is stored in the first discrimination position 103a, which indicates that bit string comparison is performed for the key at the 0th position in the search key string.
  • 1 is stored in the second discrimination position 103.
  • the representative node number 104 stores the array element number 20 of the representative node of the link destination node pair.
  • the array element number stored in the representative node number may be referred to as a representative node number.
  • the array element number stored in the representative node number may be represented by a code attached to the node or a code attached to the node pair.
  • the value stored in the first discrimination position or the second discrimination position may be simply referred to as the first discrimination position or the second discrimination position.
  • the node [0] 112 that is the representative node of the node pair 111 is stored in the array element of the array element number 20. Then, node [1] 113 paired with the representative node is stored in the next adjacent array element (array number 20 + 1).
  • the node [0] 112 is a branch node like the node 101. 0 is stored in the node type 114 of the node [0] 112, 1 is stored in the first discrimination position 115a, 3 is stored in the second discrimination position 115, and 30 is stored in the representative node number 116.
  • the node [1] 113 includes a node type 117 and a reference pointer 118a.
  • the node type 117 stores 1 and indicates that the node [1] 113 is a leaf node.
  • the reference pointer 118a stores a pointer for referring to the index key storage area.
  • the data stored in the reference pointer 118a is a specific example of the second position information. In the following, for simplicity of description, data stored in the reference pointer is also referred to as a reference pointer.
  • access destination information for accessing the record corresponding to the index key is naturally necessary.
  • the association between the index key and the access destination information may be performed, for example, by storing the access destination information corresponding to the index key in a storage area adjacent to the storage area storing the index key.
  • the access destination information is omitted.
  • a representative node may be represented by a node [0] and a node paired therewith may be represented by a node [1].
  • a node stored in an array element having a certain array number may be referred to as a node having the array number
  • an array number of the array element in which the node is stored may be referred to as a node array number.
  • the contents of the node pair 121 composed of the node 122 and the node 123 stored in the array elements of the array element numbers 30 and 31 are omitted.
  • the 0 or 1 added to the array elements stored in the node [0] 112, the node [1] 113, the node 122, and the node 123, respectively, is assigned to which node of the node pair when searching with the search key string. Indicates whether to link.
  • the value 0 or 1 is linked to the node of the array element number added to the representative node number.
  • the array element storing the link destination node is added.
  • the sequence number can be determined.
  • the representative node number is the smaller one of the array numbers in which the node pairs are arranged, but it is obvious that the larger one can be adopted.
  • FIG. 2B is a diagram conceptually showing a tree structure of a coupled node tree and a storage area of a search key string (hereinafter sometimes referred to as an index key) according to the present embodiment.
  • FIG. 2B (1) shows a tree structure of a coupled node tree.
  • a reference numeral 210a indicates a root node.
  • the root node 210a is a representative node of the node pair 201a arranged at the array element number 220.
  • a node pair 201b is arranged below the root node 210a, a node pair 201c and a node pair 201f are arranged below it, and a node pair 201h and a node pair 201g are arranged below the node pair 201f.
  • a node pair 201d is disposed below the node pair 201c, and a node pair 201e is disposed below the node pair 201d.
  • the code 0 or 1 added before each node is the same as the code assigned before the array element described in FIG. 2A.
  • the tree is traced according to the bit value of the discrimination bit position of the search key, and the leaf node corresponding to the index key to be searched is found.
  • the node type 260a of the root node 210a is 0, indicating that it is a branch node, the first discrimination position 240a is 0, and the discrimination bit position 230a is 0.
  • the representative node number is 220a, which is the array element number of the array element stored in the representative node 210b of the node pair 201b.
  • the node pair 201b is composed of nodes 210b and 211b, and their node types 260b and 261b are both 0, indicating that they are branch nodes. 0 is stored in the first discrimination position 240b of the node 210b, 1 is stored in the discrimination bit position 230b, and the array element number 220b of the array element stored in the representative node 210c of the node pair 201c is stored in the link destination representative node number. Is stored.
  • this node is a leaf node and therefore includes a reference pointer 250c.
  • the reference pointer 250c stores a pointer that refers to a storage area in which an index key including a first key 290c and a second key 290c 'is stored.
  • Data stored in the reference pointer 250c is also referred to as a reference pointer and is represented by reference numeral 280c.
  • the reference pointer and the data stored in the reference pointer are represented by the same reference pointer.
  • FIG. 2B (2) shows an example in which a plurality of index key storage areas are continuously provided, and the entire continuous storage area is shown as an index key storage area 311.
  • the index key is a continuous area. Need not be stored in Also, the relationship between the leaf nodes in the tree structure and the order of index key arrangement in the index key storage area 311 may be irrelevant.
  • the node type 261c of the other node 211c paired with the representative node 210c is 0, the first discrimination position 241c is 1, and the discrimination bit position 231c is 0.
  • the node type 260d of the node 210d is 0, the first discrimination position 240d is 1, the discrimination bit position 230d is 2, and the representative node number is the array element number 220d of the array element stored in the representative node 210e of the node pair 201e.
  • the node type 261d of the node 211d that is paired with the node 210d is 1, and the reference pointer 251d stores the reference pointer 281d indicating the storage area storing the key strings 291d and 291d ′ of “011010” and “1000”. ing.
  • the node types 260e and 261e of the nodes 210e and 211e of the node pair 201e are both 1, indicating that both are leaf nodes.
  • the reference pointers 250e and 251e of the nodes 210e and 211e are respectively stored in storage areas storing key sequences 290e and 290e '"011010" and "0101" and key sequences 291e and 291e' "011010" and "0110".
  • Reference pointers 280e and 281e are stored.
  • 0 is stored in the first discrimination position 241b of the node 211b which is the other node of the node pair 201b, 2 is stored in the discrimination bit position 231b, and the representative node number of the link destination is the representative node 210f of the node pair 201f.
  • the array element number 221b of the stored array element is stored.
  • the node types 260f and 261f of the nodes 210f and 211f of the node pair 201f are both 0, and both are branch nodes. 0 and 1 are stored in the first discrimination positions 240f and 241f, and 5 and 2 are stored in the discrimination bit positions 230f and 231f.
  • the representative node number of the node 210f stores the array element number 220f of the array element in which the representative node 210g of the node pair 201g is stored, and the representative node number of the node 211f contains the node [0] 210h that is the representative node of the node pair 201h.
  • the array element number 221f of the stored array element is stored.
  • the node types 260g and 261g of the nodes 210g and 211g of the node pair 201g are both 1, indicating that both are leaf nodes.
  • the key sequences 290g and 290g 'of "100010" and "0100” and the key sequences 291g and 291g' of "100011” and "0011" are stored.
  • Reference pointers 280g and 281g are stored.
  • the node types 260h and 261h of the node [0] 210h which is the representative node of the node pair 201h, and the node [1] 211h paired therewith are both 1, indicating that both are leaf nodes.
  • the reference pointers 250h and 251h of the nodes 210h and 211h include “101100” and “0001”, respectively.
  • Reference pointers 280h and 281h to the storage area storing the key strings 291h and 291h ′ are stored.
  • the index key is the first key “101100” And the second key “0010”.
  • the first discrimination position and the second discrimination position are 0, 1, 2,... From the left.
  • processing is started from the root node 210a using the bit string “1011000010” as a search key string. Since the first discrimination position 240a of the root node 210a is 0 and the discrimination bit position 230a is 0, the bit value where the discrimination bit position of the first key “101100” in the search key string is 0 is 1 is there. Therefore, the node 211b stored in the array element having the array element number obtained by adding 1 to the array element number 220a storing the representative node number is linked. Since 0 is stored in the first discrimination position 241b of the node 211b and 2 is stored in the discrimination bit position 231b, it is 1 when the bit value of the discrimination bit position of the first key “101100” is 2. The node 211f stored in the array element of the array element number 221b in which the representative node number is stored is linked.
  • the storage area indicated by the reference pointer 281h is referred to, and the key strings 291h and 291h ′ which are index keys stored therein are read out. . In this way, a search using a coupled node tree is performed. When the read key string is compared with the search key, it can be seen that the above example matches.
  • the first discrimination position for identifying the position of the key in the search key string is the key position corresponding to the order of the key arrangement such as 0, 1, 2,.
  • the number is not limited to this, for example, an offset value from the first bit of the entire search key string, or by indicating that the key position has been switched by using 0 and 1 alternately, Identification can be possible.
  • the configuration of a coupled node tree is defined by a set of index keys.
  • the first discrimination position 240a of the root node is 0 because the first key of the index key is different, that is, all the first keys are duplicated. This is not the case.
  • the reason why the discrimination bit position 230a of the root node 210a is 0 is that the first key, which is the first key of the index key, includes one having a 0th bit of 0 and one.
  • the group of index keys whose 0th bit of the first key is 0 is classified under the node 210b, and the group of index keys whose 0th bit is 1 is classified under the node 211b.
  • the reason why the discrimination bit position 231b of the node 211b is 2 is that the first bit of the first key of the index key corresponding to the lower leaf nodes 211h, 210h, 211g, and 210g is all equal to 0. Reflects the nature of the set of index keys, something different for the first time.
  • the first discrimination position of the node 211f of the node pair 201f immediately below the node 211b is 1 because the first keys 290h and 291h of the index key corresponding to the leaf nodes 211h and 210h below the node 211f overlap. This indicates that the position of the node on the couple node tree is determined by the bit strings of the second keys 290h ′ and 291h ′.
  • the reason why the discrimination bit position 231f of the node 211f is 2 is that the second keys 290h ′ and 291h ′ have different values in the second bit from the top, and reflect the bit values.
  • Leaf nodes 211h and 210h are arranged at positions corresponding to the index keys.
  • the third bit and the fourth bit are equal and the fifth bit is different, so 5 is stored in the discrimination bit position 230f of the node 210f. Since there is only one index key in which the fifth bit of the first key is 1 and 0, each of the nodes 210g and 211g linked to the node 210f becomes a leaf node, and the reference pointers 250g and 251g Stores reference pointers 280g and 281g indicating the storage areas storing the key strings 290g and 290g 'and the key strings 291g and 291g', respectively.
  • the coupled node tree structure is determined by the bit value of each bit position of each index key included in the set of index keys. Furthermore, since the node branches to a node having a bit value “1” and a node having a bit value “0” for each bit position having a different bit value, the node [1] side and the depth of the tree If the leaf nodes are traced with priority given to the direction, the index keys stored in them correspond to the index key “1011000010” corresponding to the node 211h, the index key “1011000001” corresponding to the node 210h,. The index key becomes “0001110111” and is sorted in descending order. That is, in the coupled node tree, the index keys are sorted and arranged on the tree.
  • the index key When searching with the search key string, the index key follows the route arranged on the coupled node tree. For example, if the search key string is “1011000001”, the node 210h can be reached. Further, as can be imagined from the above description, even when “1011000000” is used as a search key string, the node 210h is reached, and the index key stored in the storage area indicated by the reference pointer 280h is obtained as the search result key string. .
  • the third and fourth bits of the first key in the search key column are not used in the link paths of the nodes 210a, 211b, and 210f. Since the fifth bit of “100100” is 0, the node 210g is reached in the same manner as when searching for “1000100100”. In this way, branching is performed using the first discrimination position and the second discrimination position (discrimination bit position) corresponding to the bit configuration of the index key stored in the coupled node tree.
  • FIG. 3 is a diagram for explaining a hardware configuration example for carrying out the present invention.
  • Search processing and data maintenance by the search device of the present invention are performed by the data processing device 301 including at least the central processing unit 302 and the cache memory 303 using the data storage device 308.
  • the array 100 in FIG. 2A is an example of the array 309. As in FIG.
  • the index key storage area 311 is illustrated as a continuous area, but may be a discontinuous area.
  • the search path stack 310 stores the array element number of the array element in which the node to be traced during the search is stored. The information indicating the position of the node such as the address of the storage area in which is stored is stored.
  • the main storage device 305, the external storage device 306, and the communication device 307 are connected to the data processing device 301 by a single bus 304, but the connection method is not limited to this.
  • the main storage device 305 can be in the data processing device 301
  • the search path stack 310 can be realized as hardware in the central processing unit 302.
  • the array 309 has an external storage device 306, a search path stack 310 in the main storage device 305, etc. It is clear that the hardware configuration can be appropriately selected according to the usable hardware environment, the size of the index key set, etc. It is.
  • a temporary storage area corresponding to each process is used in order to use various values obtained during the process in a later process.
  • the value stored or set in the temporary storage area may be referred to by the name of the temporary storage area, as in the case of the first discrimination position described above.
  • the array 309 including array elements storing the nodes of the coupled node tree and the index key storage area 311 are different areas. Therefore, compared with the case where the index key is included in the array element storing the leaf node, the configuration of FIG. 3 generally requires less storage area for one array element. That is, by separating the index key storage area 311 from the array 309 storing the coupled node tree, the number of nodes stored per cache block can be increased in reading the coupled node tree into the cache memory 303. It becomes possible. As a result, the frequency of cache misses is reduced in search processing, which will be described later, and processing is performed at higher speed.
  • FIG. 4 is a flowchart showing bit string search processing according to an embodiment. It is.
  • step S401a the array element number of the search start node is acquired.
  • the array corresponding to the acquired array element number stores arbitrary nodes constituting a coupled node tree.
  • the designation of the search start node is performed in various application searches described later.
  • the obtained array number of the search start node is set in a search start node setting area (not shown).
  • This search start node setting area is used to set various values obtained in the middle of processing as described later. This is one of the “temporary storage areas corresponding to each process for use in the process”.
  • “set in a search start node setting area (not shown)” “get the search start node array number”, “set as search start node” or simply “start search” It may also be described as “set to node”.
  • step S401b an initial value is set to the retraction discrimination position which is a temporary storage area where the value of the first discrimination position is retreated later. Since the first discrimination position of the first key row of the index key is set to 0, a negative value is set as the initial value.
  • step S402 the obtained array element number is stored in the search path stack, and in step S403, the array element corresponding to the array element number is read out as a node to be referred to.
  • step S404 the node type is extracted from the read node, and in step S405, it is determined whether or not the node type is a branch node.
  • step S405 If it is determined in step S405 that the read node is a branch node, the process proceeds to step S406a.
  • step S406a the first discrimination position is extracted from the node, and in the next step S406b, it is determined whether or not the first discrimination position extracted in step S406a matches the retraction discrimination position.
  • step S406 If the first discrimination position matches the retraction discrimination position, the process proceeds to step S406. If not, the process proceeds to step S406c, and the key indicated by the first discrimination position extracted in step S406a is extracted from the search key string. Set to search key.
  • step S406d the first discrimination position extracted in step S406a is set as the retraction discrimination position, and the process proceeds to step S406.
  • the second discrimination position discrimination bit position
  • step S407 the bit value corresponding to the extracted discrimination bit position is extracted from the search key.
  • step S408 the representative node number is extracted from the node read in step S403.
  • step S409 the bit value extracted from the search key and the representative node number are added, and the process returns to step S402 as a new array number.
  • step S410a the reference pointer is extracted from the leaf node, and the search ends.
  • FIGS. 5 to 8A illustrate normal insertion processing
  • FIG. 8A illustrates root node insertion processing. Since the coupled node tree is generated by the root node insertion process and the normal insertion process, the description of the node insertion process is also the description of the coupled node tree generation process.
  • FIG. 5 is a diagram showing the processing flow of the search process, which is the first stage of the insert process, and corresponds to the search process shown in FIG. 4 with the insert key string as the search key string and the search start node as the root node. .
  • step S501a the root node array number is set in the search start node
  • step S501b the insertion key string is set in the search key string.
  • the insertion key string is stored in the storage area as a precondition for the insertion process by obtaining a pointer of the index key storage area in advance.
  • the last key of the insertion key string has a unique value for the entire index key.
  • step S510a the search process shown in FIG. 4 is performed from the search start node by using the search key string to obtain the reference pointer, and in step S510b, the key string pointed to by the reference pointer is extracted and set as the comparison key string.
  • step S510c the key of the insertion key string and the key of the comparison key string are sequentially compared. As a result of the comparison, information on whether or not the comparison key string completely matches the insertion key string is output. If they do not match completely, the position of the first mismatched key is set as the first discrimination position, and the key at the first discrimination position in the insertion key string is set as the insertion key, and the comparison key string The key at the first discrimination position is set as a comparison key. Details of step S510c will be described later with reference to FIG. 8B.
  • step S511a it is determined as a result of the comparison in step S510c whether the keys of the insertion key string and the comparison key string are all equal. If they are equal, the insertion key string is already stored in the storage area pointed to by the reference pointer of the coupled node tree. Therefore, the insertion fails and the process ends. If not equal, the process proceeds to the next process, that is, the process from step S512 onward in FIG.
  • FIG. 6 is a process flow diagram illustrating a process for preparing an array element for a node pair to be inserted.
  • step S512 an empty node pair is obtained from the array, and the array element number of the array element to be the representative node is acquired from the node pair.
  • step S513a the insertion key obtained at step S510c is compared with the comparison key, and a value 1 is obtained when the insertion key is large, and a Boolean value 0 is obtained when the insertion key is small. Proceeding to step S514, an array element number is obtained by adding the Boolean value obtained at step S513 to the array element number of the representative node obtained at step S512.
  • an array element number is obtained by adding the logical negation value of the Boolean value obtained at step S513 to the array element number of the representative node obtained at step S512.
  • the array element number obtained in step S514 is the array element array element number in which the leaf node having the reference pointer to the storage area storing the insertion key string as the index key is stored.
  • the array element number obtained in step S515 is This is an array element in which a node forming a node pair with a leaf node is stored.
  • the leaf node that holds the reference pointer to the insertion key string is located in either node of the inserted node pair. It is determined whether it is stored.
  • the index key of the search result is the key string “0110101000” corresponding to the node 211d.
  • the first key does not match, and a Boolean value is obtained by comparing the magnitudes of the first keys.
  • the first key of the insertion key string is obtained. Therefore, a Boolean value 1 is obtained, and a leaf node holding a reference pointer to the insertion key string is stored in an array element obtained by adding 1 to the representative node number of the node pair to be inserted.
  • the reference pointer 281d to the index key “0110101000” is stored in the array element of the array number obtained by adding the logical inversion of the Boolean value obtained by the magnitude comparison to the representative node number.
  • the node 211d sets the discrimination bit position to 5, It becomes a branch node having the representative node number as the array number of the representative node of the inserted node pair.
  • the search result becomes an index key having a value of “0110101000” corresponding to the node 211d.
  • the first key of the inserted key string and the key string of the search result do not match, and in this case, the first key of the inserted key string is smaller, so a Boolean value 0 is obtained and inserted.
  • a leaf node holding a reference pointer to the insertion key string is stored in an array element obtained by adding 0 to the representative node number of the node pair.
  • the node 211d sets the discrimination bit position to 4, and sets the representative node number to The branch node is the array element number of the representative node of the inserted node pair.
  • step S516 the bit string comparison of the insertion key and the comparison key obtained in step S510c is performed by, for example, exclusive OR, to obtain a difference bit string.
  • step S517 the bit position of the first non-matching bit viewed from the higher-order 0th bit (hereinafter also referred to as the difference bit position) is obtained from the difference bit string obtained in step S516.
  • a CPU having a priority encoder can input a difference bit string to obtain a mismatched bit position. It is also possible to obtain the bit position of the first non-matching bit by performing processing equivalent to that of the priority encoder in software.
  • FIG. 7 is a diagram showing a processing flow for storing a node in the array element prepared in FIG. 6, obtaining its insertion position, changing the contents of the existing node, and completing the insertion process.
  • step S518 to step S523 is processing for obtaining the position of the node pair to be inserted on the coupled node tree, and the processing after step S524 is processing for setting the data in each node and completing the insertion processing. .
  • step S5128 it is determined whether the stack pointer of the search path stack points to the array number of the root node. If so, the process proceeds to step S524, and if not, the process proceeds to step S519.
  • step S519 the stack pointer of the search path stack is returned by 1, and the array element number stacked there is taken out. Proceeding to step S520, the array element having the array element number extracted at step S519 is read from the array as a node.
  • step S520a the first discrimination position is extracted from the node read out in step S520, and in step S520b, the first discrimination position “A” extracted in step S520a and the first discrimination position “obtained in step S510c” are extracted. Compare the size of B ′′.
  • step S521 the second discrimination position (discrimination bit position) is extracted from the node read in step S520, and the process proceeds to step S522.
  • the discrimination bit position extracted in step S521 is higher than the difference bit position obtained in step S517. Judge whether it is positional relationship.
  • the upper positional relationship is a position on the left side of the bit string, that is, a position where the value of the bit position is small.
  • step S522 If the determination result in step S522 is negative, the process returns to step S518 and is repeated until the determination in step S518 is affirmed, A ⁇ B is determined in step S520b, or the determination in step S522 is affirmative. . If the determination in step S522 is affirmative, the process proceeds to step S523.
  • step S523 the stack pointer of the search path stack is incremented by 1, and the process proceeds to step S524 and subsequent steps.
  • the processing described in steps S518 to S523 above is obtained in step S510c and the first discrimination position (A) of the branch node stored in the search path stack to determine the insertion position of the node pair to be inserted.
  • the link destination of the root node becomes the insertion position.
  • the index key of the search result is “1011000001” corresponding to the node 210h.
  • the difference bit position between the insertion key “111000” and the comparison key “101100” is 1 and the discrimination bit position 231b is 2, the process further goes back to the root node 210a.
  • the insertion position is the link destination of the node 211b.
  • the discrimination bit position of the branch node 211b becomes the difference bit position value 1 as described later.
  • a ⁇ B is a case where, for example, an insertion key string including a duplicated first key is inserted into an index key in which the first key is not duplicated.
  • the first discrimination position (A) is the first discrimination position 240f and the value is 0, and the value of the first discrimination position (B) is 1.
  • a ⁇ B is established, and the node 210g becomes the insertion position, and becomes the branch node immediately above the node pair to be inserted.
  • step S524 the array element number pointed to by the stack pointer is extracted from the search path stack.
  • step S525d the leaf of the node type of the array element indicated by the array element number obtained at step S514 is written, and the pointer of the insertion key string is written to the reference pointer. Proceeding to step S526, the array element having the array element number obtained at step S524 is read from the array.
  • step S527 the contents read in step S526 are written in the array element having the array element number obtained in step S515.
  • step S528a the branch is set as the node type of the array element indicated by the array element number obtained in step S524, the first discrimination position obtained in step S510c is set as the first discrimination position, and the step S517 is set as the second discrimination position.
  • the array position obtained in step S512 is written in the representative node number for the bit position obtained in step S5, and the process ends.
  • step S525d the contents of the node 211b are written in the node [0].
  • step S528a 0 is stored in the node type of the node 211b, 0 is stored in the first discrimination position, and the differential bit position 1 obtained by the bit string comparison is stored in the discrimination bit position.
  • the array element number of the array element storing the representative node is stored.
  • FIG. 8A is a diagram for explaining the processing flow of the entire leaf node insertion process including the root node insertion process in one embodiment of the present invention.
  • step S551 it is determined whether the array element number of the root node of the coupled node tree requested to be acquired has been registered. If registered, the normal insertion process described with reference to FIGS. 5 to 7 is performed.
  • step S551 If the determination in step S551 has not been registered, registration and generation of a completely new coupled node tree will start. Also in this case, it is assumed that the insertion key string is acquired in advance as a precondition for the insertion process, by acquiring a pointer to the index key storage area.
  • step S552 an empty node pair is obtained from the array, and the array element number of the array element to be the representative node of the node pair is acquired.
  • step S553 an array element number obtained by adding 0 to the array element number obtained in step S552 is obtained. (In practice, it is equal to the array element number acquired in step S552.)
  • step S554d the array element of the array element number acquired in step S553, that is, the array element corresponding to the root node to be inserted, leaves for the node type, Write the insertion key string pointer to the reference pointer.
  • step S556 the array element number of the root node acquired in step S553 is registered, and the process ends.
  • the index keys are sequentially extracted from the set, and the processing of FIGS. 8A and 5 to 7 is repeated, so that the couple of the present invention corresponding to the set of index keys is performed.
  • a node tree can be constructed.
  • step S101 a value “0” is set as an initial value in the discrimination position.
  • step S102 it is determined whether or not all keys in the column have been processed. If processed, complete matching information is output and the process ends. If not, the process proceeds to step S103.
  • step S103 the key indicated by the discrimination position is extracted from the insertion key row and set as the insertion key.
  • step S104 the key pointed to by the discrimination position is extracted from the comparison key string set at step S510b shown in FIG. 5, and set as a comparison key.
  • step S105 it is determined whether the insertion key matches the comparison key. If they match, the value set in the discrimination position in step S106 is updated and the process returns to step S102. If they do not match, the process proceeds to step S107 to set the discrimination position as the first discrimination position and output incomplete match To finish the process.
  • FIG. 9 is a diagram showing the processing flow of the search process that is the first stage of the delete process, and corresponds to the search process shown in FIG. 4 with the delete key string as the search key string and the search start node as the root node. To do.
  • step S901a the root node array element number is set as the search start node, and in step S901b, the deletion key string is set as the search key string.
  • step S910a the search process shown in FIG. 4 is performed from the search start node by using the search key string to obtain the reference pointer, and in step S910b, the key string pointed to by the reference pointer is extracted and set as the comparison key string.
  • step S910c the last key of the deletion key string is set as the deletion key
  • step S910d the last key of the comparison key string is set as the index key
  • step S911 the deletion key set in step S910c is compared with the index key set in step S910d. If they are not equal, the deletion does not exist in the coupled node tree, so the deletion fails and the process ends. . If they are equal, the process proceeds to the next process, the process of step S912 and subsequent steps in FIG.
  • the reason for comparing the last key in the key sequence is that the last key is a unique key without duplication.
  • FIG. 10 is a diagram for explaining the processing flow at the latter stage of the deletion processing.
  • step S912 it is determined whether two or more array element numbers are stored in the search path stack. The fact that two or more array numbers are not stored is, in other words, only one, and the array number is that of the array element in which the root node is stored. In that case, the process proceeds to step S918, the node pair related to the array element number of the root node obtained in step S901a is deleted, and the process ends.
  • step S912 If it is determined in step S912 that two or more array element numbers are stored in the search path stack, the process proceeds to step S913a, and the representative node number obtained in step S408 of the search process shown in FIG. 4 executed in step S910a is set. Similarly, the array element number obtained by adding the values obtained by inverting the bit values obtained in step S407 of the search process shown in FIG. 4 executed in step S910a is obtained. In this process, the array element number in which the node paired with the leaf node to be deleted is arranged is obtained.
  • step S914 the contents of the array element having the array element number obtained in step S913 are read, and in step S915, the stack pointer of the search path stack is returned by 1 to extract the array element number.
  • step S916 the contents of the array element read in step S914 are overwritten on the array element of the array element number obtained in step S915.
  • a branch node that is a link source to the leaf node to be deleted is replaced with a node that is paired with the leaf node.
  • step S917 the node pair related to the representative node number obtained in step S408 of the search process shown in FIG. 4 executed in step S910a is deleted, and the process ends.
  • 11A and 11B are diagrams illustrating an example in which deletion processing is performed using “0110101000” as a deletion key string in the coupled node tree illustrated in FIG. 2B.
  • the deletion key string “0110101000” is a key string composed of the first key “011010” and the second key “1000”, and is stored in the deletion key 270 which is a temporary storage area.
  • the search path stack 310 stores an array number, and the stack pointer points to the array number 221c + 1.
  • nodes surrounded by a thick frame are nodes traced by the search process, and their array numbers are stacked on the search path stack 310 from the root node 210a to the leaf node 211d.
  • the array element number 220 of the root node 210 a is acquired and stored in the search path stack 310. Since the first discrimination position 240a of the root node 210a is 0, the first key “011010” of the deletion key string is extracted and set as the search key, the discrimination bit position 230a is 0, and the bit of the search key Since the bit value at position 0 is 0, the array element number 220a obtained by adding the bit value 0 to the representative node number 220a is stored in the search path stack 310.
  • the node 210b pointed to by the array element number 220a is read out and determined to be a branch node. Since the first discrimination position 240b is 0 and is not different from the first discrimination position 240a, the bit value 1 of the bit position corresponding to the value 1 of the discrimination bit position 230b is obtained from the previously set search key, In addition to the representative node number 220b, an array element number 220b + 1 is obtained and stored in the search path stack 310.
  • the second key “1000” in the deletion key string is set as the search key. Since the discrimination bit position 231c is 0 and the bit value of the search key bit position 0 is 1, the array element number 221c + 1 obtained by adding 1 to the representative node number 221c is stored in the search path stack 310 as shown in the figure. .
  • the node type 261d of the node 211d stored in the array element with the array element number 221c + 1 is 1, indicating that it is a leaf node.
  • the index keys (key strings 291d and 291d ') corresponding to the leaf nodes are stored in the storage area indicated by the reference pointer 281d.
  • the storage area is a part of the index key storage area 311. Therefore, when the second key 291d ', which is the last key of the index key referred to by the reference pointer 281d, is taken out, the value is "1000", which matches the second key stored in the delete key 270.
  • the contents of the node 210d paired with the node 211d to be deleted are read out, and the contents are stored in the array number stored when the stack pointer of the search path stack 310 is returned by one. It is written in the array element (node 211c) of 220b + 1. Thereafter, the node pair 201d is deleted. The array element from which the node pair is deleted becomes empty and can be reused.
  • the coupled node tree shown in FIG. 11B is after the deletion process is completed.
  • the values stored in the node 210d are stored as they are as shown in parentheses.
  • the stack pointer of the search path stack 310 points to the array element number 220b + 1.
  • FIG. 12A shows a coupled node tree having reference pointers 1281b, 1281c, and 1280c that refer to bit strings “01000001”, “00010010”, and “00000011” as index keys.
  • a key string composed of the first key 1291b “0100” and the second key 1291b ′ “0001” is stored.
  • the storage area pointed to by the reference pointer 1281c stores a key string composed of the first key 1291c “0001” and the second key 1291c ′ “0010”.
  • the storage area pointed to by the reference pointer 1280c Stored is a key string consisting of a first key 1290c “0000” and a second key 1290c ′ “0011”.
  • the insertion key string to be inserted is “00000100” in the illustrated example.
  • the insertion key string is obtained by acquiring the pointer 1281d of the index key storage area and stored in the area pointed to by the pointer 1281d, and the second key which is the last key of the insertion key string.
  • the key “0100” is premised on taking a unique value for the entire index key.
  • the illustrated tree is composed of node pairs 1201a, 1201b, and 1201c.
  • the representative node of the node pair 1201a is the root node 1210a, and 0 is held in the first discrimination position and 1 is held in the discrimination bit position.
  • the representative node 1210b of the node pair 1201b lower than the node pair 1201a is a branch node, and 0 is held in the first discrimination position, 3 is held in the discrimination bit position, and the node 1211b paired with the representative node 1210b is a leaf node.
  • the reference pointer 1281b to the key strings 1291b and 1291b ′ is held.
  • the node 1210b which is a branch node is linked to the node pair 1201c.
  • the nodes 1210c and 1211c constituting the node pair 1201c are both leaf nodes, and store reference pointers 1280c and 1281c to the key strings 1290c and 1290c 'and the key strings 1291c and 1291c', respectively.
  • the first key 1291d in the insertion key string overlaps with the first key in the key string stored in the storage area pointed to by the reference pointer 1280c. Therefore, in the example shown in the figure, when the search is performed with the insertion key string, the leaf node 1210c storing the reference pointer 1280c is reached, the second key 1290c ′ is set as the comparison key, and the second key of the insertion key string is set. Using 1290d ′ as an insertion key, the magnitude relationship determination and bit string comparison are performed. Then, the insertion key is larger than the comparison key, and the position of the first mismatch bit is 1.
  • FIG. 12B is a diagram showing a coupled node tree in which the insertion key string “00000100” is inserted.
  • a new node pair 1201d is inserted below the node pair 1201c.
  • the node [1] 1211d of the node pair 1201d is generated as a leaf node including the insertion key string pointer as the reference pointer 1281d, and the contents of the node 1210 shown in FIG. 12A are written in the node [0] 1210d.
  • 1 indicating that the first discrimination position of the branch node 1210c shown in FIG. 12B is the second key is the position of the first mismatch bit of the insertion key and the comparison key in the second discrimination position. 1 is stored, and the representative node number stores the array element number of the array element in which the representative node 1210d of the node pair 1201 is arranged.
  • the leaf node can include the index key itself instead of the information indicating the position of the storage area storing the index key.
  • the first discrimination position for identifying the position of the key in the search key string is the key position number corresponding to the order of the key arrangement such as 0, 1, 2,.
  • the key position can be identified by using an offset value from the first bit of the entire search key string or by indicating that the key position has been switched by alternately using 0 and 1 for example. This is obvious to those skilled in the art.
  • the apparatus for executing the bit string search method of the present invention can be constructed on a computer by a storage means for storing a coupled node tree and a program for causing the computer to execute the processing shown in FIG.
  • the insertion method of the present invention can be realized by a program that causes a computer to execute the insertion process shown in FIGS. 5 to 7, FIG. 8A, and FIG. 8B and its equivalent, and the deletion shown in FIG. 9 and FIG. It is also clear that the deletion method of the present invention can be realized by a program that causes a computer to execute processing and its equivalents.
  • a means for identifying a branch node and a leaf node, a means for linking to one of a pair of linked nodes according to the discrimination bit position of the branch node, and the like are realized on the computer.
  • the program and a computer-readable storage medium storing the program are included in the embodiment of the present invention. Furthermore, the data structure of the coupled node tree of the present invention is also included in the embodiment of the present invention.
  • the coupled node tree which is a new data structure provided by the present invention described in detail above, it is possible to handle duplicate keys and to search for bit string data at a higher speed. In addition, addition and deletion of bit string data can be easily performed.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Software Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

カップルドノードツリーを応用した検索手法において、重複キーの取り扱いを可能とするために、最後尾のキーをユニークキーとする複数のキーをキー列として組み合わせてインデックスキーとし、検索キーは複数のキーをキー列として組み合わせ、キー列の最後尾のキーがユニークな検索キー列とする。ブランチノードに、ビット列検索を行う検索キー列中の、ビット列比較をするキーの位置情報を示す第1の弁別位置とそのキーの第2の弁別位置を持たせ、またリンク先のノード対の一方のノードである代表ノードの位置を示す位置情報を含む。検索キー列からブランチノードの第1の弁別位置のキーを取り出し、該キーの第2の弁別位置のビット値に応じてリンク先のノート対の一方のノードにリンクすることをインデックスキーと対応付けられたリーフノードに至るまで行いインデックスキーを検索する。

Description

ビット列検索装置、検索方法及びプログラム
 本発明はビット列の集合から所望のビット列を検索する検索装置、検索方法及びプログラムに関するものであり、特にビット列を記憶するデータ構造に工夫をして、検索速度等の向上を図る技術分野のものである。
 近年、社会の情報化が進展し、大規模なデータベースが各所で利用されるようになってきている。このような大規模なデータベースからレコードを検索するには、各レコードの記憶されたアドレスと対応づけられたレコード内の項目をインデックスキーとして検索をし、所望のレコードを探し出すことが通例である。また、全文検索における文字列も、文書のインデックスキーと見なすことができる。
 そして、それらのインデックスキーはビット列で表現されることから、データベースの検索はビット列の検索に帰着されるということができる。
 上記ビット列の検索を高速に行うために、ビット列を記憶するデータ構造を種々に工夫することが従来から行われている。このようなものの一つとして、パトリシアツリーという木構造が知られている。
 図1は、上述の従来の検索処理に用いられているパトリシアツリーの一例を示すものである。パトリシアツリーのノードは、インデックスキー、検索キーの検査ビット位置、左右のリンクポインタを含んで構成される。明示はされていないが、ノードにはインデックスキーに対応するレコードにアクセスするための情報が含まれていることは勿論である。
 図1の例では、インデックスキー“100010”を保持するノード1750aがルートノードとなっており、その検査ビット位置は0である。ノード1750aの左リンク1740aにはノード1750bが接続され、右リンク1741aにはノード1750fが接続されている。
 ノード1750bの保持するインデックスキーは“010011”であり、検査ビット位置2030bは1である。ノード1750bの左リンク1740bにはノード1750cが、右リンク1741bにはノード1750dが接続されている。ノード1750cが保持するインデックスキーは“000111”、検査ビット位置は3である。ノード1750dが保持するインデックスキーは“011010”、検査ビット位置は2である。
 ノード1750cから実線で接続された部分はノード1750cの左右のリンクポインタを示すものであり、点線の接続されていない左ポインタ1740cは、その欄が空欄であることを示している。点線の接続された右ポインタ1741cの点線の接続先は、ポインタの示すアドレスを表しており、今の場合ノード1750cを右ポインタが指定していることを表している。
 ノード1750dの右ポインタ1741dはノード1750d自身を指しており、左リンク1740dにはノード1750eが接続されている。ノード1750eの保持するインデックスキーは“010010”、検査ビット位置は5である。ノード1750eの左ポインタ1740eはノード1750bを、右ポインタ1741eはノード1750eを指している。
 また、ノード1750fの保持するインデックスキーは“101011”であり、検査ビット位置1730fは2である。ノード1750fの左リンク1740fにはノード1750gが、右リンク1741fにはノード1750hが接続されている。
 ノード1750gの保持するインデックスキーは“100011”であり、検査ビット位置1730gは5である。ノード1750gの左ポインタ1740gはノード1750aを、右ポインタ1741gはノード1750gを指している。
 ノード1750hの保持するインデックスキーは“101100”であり、検査ビット位置1730hは3である。ノード1750hの左ポインタ1740hはノード1750fを、右ポインタ1741hはノード1750hを指している。
 図1の例では、ルートノード1750aからツリーを降りるにしたがって、各ノードの検査ビット位置が大きくなるように構成されている。
 ある検索キーで検索を行うとき、ルートノードから順次各ノードに保持される検索キーの検査ビット位置を検査していき、検査ビット位置のビット値が1であるか0であるか判定を行い、1であれば右リンクをたどり、0であれば左リンクをたどる。そして、リンク先のノードの検査ビット位置がリンク元のノードの検査ビット位置より大きくなければ、すなわち、リンク先が下方でなく上方に戻れば(図1において点線で示されたこの逆戻りのリンクをバックリンクという)、リンク先のノードのインデックスキーと検索キーの比較を行う。比較の結果、等しければ検索成功であり、等しくなければ検索失敗であることが保証されている。
 上記のように、パトリシアツリーを用いた検索処理では、必要なビットの検査だけで検索できること、キー全体の比較は1回ですむことなどのメリットがあるが、各ノードからの2つのリンクが必ずあることにより記憶容量が増大することや、バックリンクの存在による判定処理の複雑化、バックリンクにより戻ることで初めてインデックスキーと比較することによる検索処理の遅延及び追加削除等データメンテナンスの困難性などの欠点がある。
 これらのパトリシアツリーの欠点を解消しようとするものとして、例えば下記特許文献1に開示された技術がある。下記特許文献1に記載されたパトリシアツリーにおいては、下位の左右のノードは連続した領域に記憶することによりポインタの記憶容量を削減するとともに、次のリンクがバックリンクであるか否かを示すビットを各ノードに設けることにより、バックリンクの判定処理を軽減している。
 しかしながら、下記特許文献1に開示されたものにおいても、1つのノードは必ずインデックスキーの領域とポインタの領域を占めること、下位の左右のノードを連続した領域に記憶するようにしてポインタを1つとしたため、例えば図1に示したパトリシアツリーの最下段の部分である左ポインタ1740c、右ポインタ1741h等の部分にもノードと同じ容量の記憶領域を割り当てる必要があるなど、記憶容量の削減効果はあまり大きいものではない。また、バックリンクによる検索処理の遅延の問題や追加削除等の処理が困難であることも改善されていない。
 また、データベースからレコードを検索する場合、データベースのレコードと1対1で対応する項目の値をインデックスキーとするだけでなく、レコードを構成する任意の項目の値を検索キーとして検索を行うことが通常行われている。この項目の値はレコードによってユニークとは限らないことから、複数のレコードにおいて重複するキーによる検索が行われている。このような重複キーの取り扱いの一例が下記特許文献2に記載されている。
特開2001-357070号公報 特開平11-96058号公報
 そこで本発明の解決しようとする課題は、重複キーによる検索が可能であって、かつ、必要とする記憶容量が小さく、検索速度が高速であり、データメンテナンスの容易なデータ構造を備えたビット列検索装置及び検索方法を提供することである。
 上述の従来の検索手法における問題点を解決するものとして、本出願人は、特願2006-187827において、ルートノードと、隣接した記憶領域に配置されるブランチノードとリーフノードまたはブランチノード同士またはリーフノード同士のノード対からなるビット列検索に用いるツリーであって、ルートノードはツリーの始点を表すノードであって、該ツリーのノードが1つのときはリーフノード、ツリーのノードが2つ以上のときは前記ブランチノードであり、前記ブランチノードは、ビット列検索を行う検索キーの弁別ビット位置とリンク先のノード対の一方のノードである代表ノードの位置を示す位置情報を含み、前記リーフノードは検索対象のビット列からなるインデックスキーを含むカップルドノードツリーを用いたビット列検索を提案した。
 上記出願においては、与えられたインデックスキーの集合からカップルドノードツリーを生成する方法と、カップルドノードツリーから単一のインデックスキーを検索する手法等の、カップルドノードツリーを用いた基本的な検索手法が示されている。
 また、ビット列の検索には、最小値、最大値を求める、ある範囲の値のものを求める等の各種の検索要求が存在する。そこで、本出願人は、特願2006-293619において、カップルドノードツリーの任意の部分木に含まれるインデックスキーの最大値/最小値を求める手法等を提案した。
 さらに本出願人は、特願2007-114915において、インデックスキーをカップルドノードツリーとは別の領域に配置し、リーフノードにはインデックスキーに代えてインデックスキーが配置された記憶領域の位置を示す情報を格納したカップルドノードツリーとそれを用いた各種検索処理を提案した。
 しかし、上述のカップルドノードツリーの構造は、インデックスキー同士のビット値の異なる位置である差分ビット位置に基づくものであるため、そのままでは重複キーを取り扱うことができない。
 本発明は、このカップルドノードツリーを応用した高速な検索手法において、重複キーの取り扱いを可能とすることを目的とする。
 本発明の一つの態様によれば、複数のキーをキー列として組み合わせ、キー列の最後尾のキーを重複のないユニークなものとすることにより、複数キーのキー列からなるインデックスキーをユニークキーとして構成する。そして、上述のカップルドノードツリーのリーフノードにはそのユニークキーが配置された記憶領域の位置を示す第2の位置情報を格納する。検索キーは、複数のキーをキー列として組み合わせ、キー列の最後尾のキーがユニークな検索キー列とする。ブランチノードには、ビット列検索を行う検索キー列中の、ビット列比較をするキーの位置情報を示す第1の弁別位置とそのキーの弁別ビット位置を示す第2の弁別位置を持たせる。また、ブランチノードは、リンク先のノード対の一方のノードである代表ノードの位置を示す第1の位置情報を含む。
 以上のようなデータ構造を有するカップルドノードツリーを用いて、検索キー列から、ブランチノードの第1の弁別位置のキーを取り出し、該キーの第2の弁別位置(弁別ビット位置)のビット値に応じて、リンク先のノート対のうちのいずれかのノードにリンクすることをリーフノードに至るまで行い、リーフノードに格納された記憶領域の位置を示す情報により、該記憶領域に配置されたインデックスキーを取得することにより、上記検索キー列による検索を実施する。
 本発明によれば、重複キーの取り扱いが可能であり、かつ、より高速なビット列データの検索を行うことが可能となる。しかもビット列データの追加削除も容易に実行することができる。
従来の検索で用いられるパトリシアツリーの一例を示す図である。 配列に格納されたカップルドノードツリーの構成例を説明する図である。 カップルドノードツリーのツリー構造を概念的に示す図である。 本発明を実施するためのハードウェア構成例を説明する図である。 本発明の一実施形態における検索処理を説明するフローチャートである。 本発明の一実施形態における挿入処理の前段である検索処理の処理フローを説明する図である。 本発明の一実施形態における挿入処理における挿入するノード対のための配列要素を準備する処理フローを説明する図である。 ノード対を挿入する位置を求め、ノード対の各ノードの内容を書き込んで挿入処理を完成させる処理フローを説明する図である。 本発明の一実施形態におけるルートノードの挿入処理を含むリーフノードの挿入処理全体の処理フローを説明する図である。 本発明の一実施形態におけるキー列の比較処理の処理フローを説明する図である。 本発明の一実施形態における削除処理の前段である検索処理の処理フローを説明する図である。 本発明の一実施形態における削除処理の後段の処理フローを説明する図である。 削除処理前のカップルドノードツリーと削除キー列を例示して説明する図である。 削除処理後のカップルドノードツリーを説明する図である。 挿入処理前のカップルドノードツリーと挿入キー列を例示して説明する図である。 挿入処理後のカップルドノードツリーを説明する図である。
 以下、本発明を実施するための最良の形態として、カップルドノードツリーを配列に格納する例について説明する。ブランチノードが保持するリンク先の代表ノードの位置を示すデータとして、記憶装置のアドレス情報とすることもできるが、ブランチノードあるいはリーフノードのうち占有する領域の記憶容量の大きい方を格納可能な配列要素からなる配列を用いることにより、ノードの位置を配列番号で表すことができ、代表ノードの位置を示す位置情報の情報量を削減することができる。
 図2Aは、本発明の一実施形態における配列に格納されたカップルドノードツリーの構成例を説明する図である。
 図2Aを参照すると、ノード101が配列100の配列番号10の配列要素に配置されている。ノード101はノード種別102、第1の弁別位置103a、第2の弁別位置103及び代表ノード番号104で構成されている。ノード種別102は0であり、ノード101がブランチノードであることを示している。第1の弁別位置103aには0が格納されており、検索キー列の0番目の位置のキーについてビット列比較を行うことを示している。第2の弁別位置103には1が格納されている。代表ノード番号104にはリンク先のノード対の代表ノードの配列番号20が格納されている。なお、以下では表記の簡略化のため、代表ノード番号に格納された配列番号を代表ノード番号ということもある。また、代表ノード番号に格納された配列番号をそのノードに付した符号あるいはノード対に付した符号で表すこともある。さらに、第1の弁別位置あるいは第2の弁別位置に格納された値を、単に第1の弁別位置あるいは第2の弁別位置ということもある。
 配列番号20の配列要素には、ノード対111の代表ノードであるノード[0]112が格納されている。そして隣接する次の配列要素(配列番号20+1)に代表ノードと対になるノード[1]113が格納されている。ノード[0]112はノード101と同様にブランチノードである。ノード[0]112のノード種別114には0が、第1の弁別位置115aには1が、第2の弁別位置115には3が、代表ノード番号116には30が格納されている。またノード[1]113は、ノード種別117と参照ポインタ118aで構成されている。ノード種別117には1が格納されており、ノード[1]113がリーフノードであることを示している。参照ポインタ118aには、インデックスキーの記憶領域を参照するポインタが格納されている。参照ポインタ118aに格納されたデータは、上記の第2の位置情報の具体例である。以下では表記の簡略化のため、参照ポインタに格納されたデータのことも参照ポインタということがある。
 パトリシアツリーについて先に述べたと同様に、インデックスキーと対応するレコードにアクセスするためのアクセス先情報も当然必要である。インデックスキーとアクセス先情報との対応づけは、例えば、インデックスキーを記憶している記憶領域に隣接する記憶領域に、当該インデックスキーに対応するアクセス先情報を記憶することによって行ってもよい。以下ではアクセス先情報については省略して説明する。
 なお、代表ノードをノード[0]で表し、それと対になるノードをノード[1]で表すことがある。また、ある配列番号の配列要素に格納されたノードを、その配列番号のノードということがあり、ノードの格納された配列要素の配列番号を、ノードの配列番号ということもある。
 配列番号30及び31の配列要素に格納されたノード122とノード123からなるノード対121の内容は省略されている。
 ノード[0]112、ノード[1]113、ノード122、及びノード123の格納された配列要素にそれぞれ付された0あるいは1は、検索キー列で検索を行う場合にノード対のどちらのノードにリンクするかを示すものである。検索キー列のうち前段のブランチノードの第1の弁別位置にあるキー(以下、検索キーということがある。)の第2の弁別位置(以下、弁別ビット位置ということがある。)にあるビット値である0か1を代表ノード番号に加えた配列番号のノードにリンクする。
 したがって、前段のブランチノードの代表ノード番号に、前段のブランチノードの第1の弁別位置にある検索キーの弁別ビット位置にあるビット値を加えることにより、リンク先のノードが格納された配列要素の配列番号を求めることができる。
 なお、上記の例では代表ノード番号をノード対の配置された配列番号のうち小さい方を採用しているが、大きいほうを採用することも可能であることは明らかである。
 図2Bは、本実施形態に係るカップルドノードツリーのツリー構造と検索キー列(以下、インデックスキーということがある。)の格納領域を概念的に示す図である。
 図2Bの(1)に示すのはカップルドノードツリーのツリー構造である。符号210aで示すのがルートノードである。図示の例では、ルートノード210aは配列番号220に配置されたノード対201aの代表ノードとしている。
 ツリー構造としては、ルートノード210aの下にノード対201bが、その下層にノード対201cとノード対201fが配置され、ノード対201fの下層にはノード対201hとノード対201gが配置されている。ノード対201cの下にはノード対201dが、さらにその下にはノード対201eが配置されている。
 各ノードの前に付された0あるいは1の符号は、図2Aにおいて説明した配列要素の前に付された符号と同じである。検索キーの弁別ビット位置のビット値に応じてツリーをたどり、検索対象のインデックスキーに対応するリーフノードを見つけることになる。
 図示された例では、ルートノード210aのノード種別260aは0でブランチノードであることを示し、第1の弁別位置240aは0、弁別ビット位置230aは0を示している。代表ノード番号は220aであり、それはノード対201bの代表ノード210bの格納された配列要素の配列番号である。
 ノード対201bはノード210bと211bで構成され、それらのノード種別260b、261bはともに0であり、ブランチノードであることを示している。ノード210bの第1の弁別位置240bには0が、弁別ビット位置230bには1が格納され、リンク先の代表ノード番号にはノード対201cの代表ノード210cの格納された配列要素の配列番号220bが格納されている。
 ノード210cのノード種別260cには1が格納されているので、このノードはリーフノードであり、したがって、参照ポインタ250cを含んでいる。参照ポインタ250cには、図示の例では、第1のキー290cと第2のキー290c’からなるインデックスキーが格納されている記憶領域を参照するポインタを格納する。参照ポインタ250cに格納されたデータのことも参照ポインタといい、符号280cにより表す。他のリーフノードでも同様に、参照ポインタと参照ポインタに格納されたデータを同じ参照ポインタという語で表す。
 図2Bの(2)には、複数のインデックスキーの記憶領域が連続して設けられる例を示し、それら連続した記憶領域全体をインデックスキーの記憶領域311として示したが、インデックスキーは連続した領域に格納されなくてもよい。また、リーフノード同士のツリー構造上での関係と、インデックスキーの記憶領域311におけるインデックスキーの配置順は無関係であってもよい。
 ノード対201cの説明に戻ると、代表ノード210cと対になるもう一方のノード211cのノード種別261cは0、第1の弁別位置241cは1、弁別ビット位置231cは0であり、代表ノード番号にはノード対201dの代表ノード210dの格納された配列要素の配列番号221cが格納されている。
 ノード210dのノード種別260dは0、第1の弁別位置240dは1、弁別ビット位置230dは2であり、代表ノード番号にはノード対201eの代表ノード210eの格納された配列要素の配列番号220dが格納されている。ノード210dと対になるノード211dのノード種別261dは1であり、参照ポインタ251dには、“011010”、“1000”というキー列291d、291d’を格納した記憶領域を示す参照ポインタ281dが格納されている。
 ノード対201eのノード210e、211eのノード種別260e、261eはともに1であり双方ともリーフノードであることを示す。ノード210e、211eの参照ポインタ250e、251eにはそれぞれ、“011010”、“0101”というキー列290e、290e’と、“011010”、“0110”というキー列291e、291e’を格納した記憶領域への参照ポインタ280e、281eが格納されている。
 ノード対201bのもう一方のノードであるノード211bの第1の弁別位置241bには0、弁別ビット位置231bには2が格納され、リンク先の代表ノード番号にはノード対201fの代表ノード210fの格納された配列要素の配列番号221bが格納されている。
 ノード対201fのノード210f、211fのノード種別260f、261fはともに0であり双方ともブランチノードである。それぞれの第1の弁別位置240f、241fには0、1が、弁別ビット位置230f、231fには5、2が格納されている。ノード210fの代表ノード番号にはノード対201gの代表ノード210gの格納された配列要素の配列番号220fが格納され、ノード211fの代表ノード番号にはノード対201hの代表ノードであるノード[0]210hの格納された配列要素の配列番号221fが格納されている。
 ノード対201gのノード210g、211gのノード種別260g、261gはともに1であり双方ともリーフノードであることを示す。ノード210g、211gのそれぞれの参照ポインタ250g、251gには“100010”、“0100”というキー列290g、290g’と“100011”、“0011”というキー列291g、291g’を格納した記憶領域への参照ポインタ280g、281gが格納されている。
 また同じくノード対201hの代表ノードであるノード[0]210hとそれと対をなすノード[1]211hのノード種別260h、261hはともに1であり双方ともリーフノードであることを示す。ノード210h、211hのそれぞれの参照ポインタ250h、251hには、“101100”、“0001”
というキー列290h、290h’と“101100”、“0010”
というキー列291h、291h’を格納した記憶領域への参照ポインタ280h、281hが格納されている。
 以下、上述のツリーからインデックスキー“1011000010”を検索する処理の流れを簡単に説明する。上記インデックスキーは第1のキー“101100”
と第2のキー“0010”からなるキー列である。第1の弁別位置及び第2の弁別位置(弁別ビット位置)は、左から0、1、2、・・・とする。
 まず、ビット列“1011000010”を検索キー列としてルートノード210aから処理をスタートする。ルートノード210aの第1の弁別位置240aは0であり、弁別ビット位置230aは0であるので、検索キー列の第1のキー“101100”の弁別ビット位置が0のビット値をみると1である。そこで代表ノード番号の格納された配列番号220aに1を加えた配列番号の配列要素に格納されたノード211bにリンクする。ノード211bの第1の弁別位置241bには0、弁別ビット位置231bには2が格納されているので、第1のキー“101100”の弁別ビット位置が2のビット値をみると1であるから、代表ノード番号の格納された配列番号221bの配列要素に格納されたノード211fにリンクする。
 ノード211fの第1の弁別位置241fには1、弁別ビット位置231fには2が格納されているので、第2のキー“0010”の弁別ビット位置が2のビット値をみると1であるから、代表ノード番号の格納された配列番号221fの配列要素に格納されたノード211hにリンクする。
 ノード211hのノード種別261hは1でありリーフノードであることを示しているので、参照ポインタ281hにより示される記憶領域を参照し、そこに格納されたインデックスキーであるキー列291h、291h’を読み出す。このようにしてカップルドノードツリーを用いた検索が行われる。読み出されたキー列を検索キーと比較すると、上記の例の場合は一致していることが分かる。
 なお、上述の説明では、検索キー列中のキーの位置を識別する第1の弁別位置を、左から0、1、2、・・・のようにキーの並びの順番に応じたキーの位置番号としたが、これに限ることなく、例えば検索キー列全体の先頭ビットからのオフセット値としたり、0と1を交互に用いることによりキー位置が切り替わったことを示すことにより、キーの位置の識別を可能とすることができる。
 次に、図2Bを参照してカップルドノードツリーの構成の意味について説明する。
 カップルドノードツリーの構成はインデックスキーの集合により規定される。図2Bの例で、ルートノードの第1の弁別位置240aが0であるのは、インデックスキーの第1のキーには異なるものがあること、すなわち全ての第1のキーが重複しているのではない、ということを反映している。ルートノード210aの弁別ビット位置230aが0であるのは、インデックスキーの先頭のキーである第1のキーに0ビット目が0のものと1のものがあるからである。第1のキーの0ビット目が0のインデックスキーのグループはノード210bの下に分類され、0ビット目が1のインデックスキーのグループはノード211bの下に分類されている。
 ノード211bの弁別ビット位置231bが2であるのは、その下位のリーフノード211h、210h、211g、210gに対応するインデックスキーの第1のキーの1ビット目がすべて0で等しく、2ビット目で初めて異なるものがあるという、インデックスキーの集合の性質を反映している。
 ノード211bの直近下位のノード対201fのノード211fの第1の弁別位置が1であるのは、ノード211fの下位のリーフノード211h、210hに対応するインデックスキーの第1のキー290h、291hが重複していることを反映しており、次に第2のキー290h’、291h’のビット列によりカップルノノードツリー上のノードの位置が決定されることを示している。そして、ノード211fの弁別ビット位置231fが2であるのは、第2のキー290h’、291h’は先頭から2ビット目で異なる値となっているからであり、そのビット値を反映してそれぞれのインデックスキーに対応した位置にリーフノード211h、210hが配置されている。
 一方、第1のキーの2ビット目が0であるインデックスキーでは3ビット目も4ビット目も等しく5ビット目で異なるのでノード210fの弁別ビット位置230fには5が格納される。インデックスキーには第1のキーの5ビット目が1のものと0のものがそれぞれ1つしかないことから、ノード210fのリンク先のノード210g、211gはリーフノードとなり、参照ポインタ250gと251gには、キー列290g、290g’とキー列291g、291g’を格納した記憶領域を指す参照ポインタ280g、281gがそれぞれ格納されている。
 仮にインデックスキーの集合に“1011000001”の代わりに“1011010001”か“1011100001”が含まれていたとしても、第1のキーの3ビット目までと第2のキーは“1011000001”と等しいので、ノード210hの参照ポインタ280hにより示される記憶領域に格納されるインデックスキーの値が変わるだけで、ツリー構造自体は変わることはない。しかし、“1011000001”に加えて“1011000000”が含まれていると、ノード210hはブランチノードとなり、その弁別ビット位置は3になる。
 以上説明したように、カップルドノードツリーの構造は、インデックスキーの集合に含まれる各インデックスキーの各ビット位置のビット値により決定される。
 そしてさらにいえば、異なるビット値となるビット位置ごとにビット値が“1”のノードとビット値が“0”のノードとに分岐していることから、ノード[1]側とツリーの深さ方向を優先させてリーフノードをたどると、それらに格納されたインデックスキーは、ノード211hに対応するインデックスキー“1011000010”、ノード210hに対応するインデックスキー“1011000001”、・・・、ノード210cに対応するインデックスキー“0001110111”となり降順にソートされている。
 すなわち、カップルドノードツリーにおいては、インデックスキーはソートされてツリー上に配置されている。
 検索キー列で検索するときはインデックスキーがカップルドノードツリー上に配置されたルートをたどることになり、例えば検索キー列が“1011000001”であればノード210hに到達することができる。また、上記説明からも想像がつくように、“1011000000”を検索キー列とした場合でもノード210hにたどり着き、参照ポインタ280hにより示される記憶領域に格納されたインデックスキーが検索結果キー列として得られる。
 また、例えば“1001001001”で検索した場合でも、ノード210a、211b、210fのリンク経路では検索キーの列の第1のキーの3ビット目と4ビット目は使われることがなく、第1のキーの“100100”の5ビット目が0なので、“1000100100”で検索した場合と同様にノード210gに到達することになる。このように、カップルドノードツリーに格納されたインデックスキーのビット構成に応じた第1の弁別位置と第2の弁別位置(弁別ビット位置)を用いて分岐が行われる。
 図3は、本発明を実施するためのハードウェア構成例を説明する図である。
 本発明の検索装置による検索処理及びデータメンテナンスは中央処理装置302及びキャッシュメモリ303を少なくとも備えたデータ処理装置301によりデータ格納装置308を用いて実施される。カップルドノードツリーが配置される配列309と検索中にたどるノードが格納された配列要素の配列番号を記憶する探索経路スタック310とインデックスキーの記憶領域311を有するデータ格納装置308は、主記憶装置305または外部記憶装置306で実現することができ、あるいは通信装置307を介して接続された遠方に配置された装置を用いることも可能である。図2Aの配列100は配列309の一例である。また、図2Bと同様に、インデックスキーの記憶領域311は連続した領域のように図示されているが、不連続の領域でもよいことは当然である。なお、カップルドノードツリーは配列に配置されるとして説明するため、探索経路スタック310には検索中にたどるノードが格納された配列要素の配列番号を記憶すると説明したが、一般的には、ノードの格納された記憶領域のアドレス等のノードの位置を示す情報が記憶される。
 図3の例示では、主記憶装置305、外部記憶装置306及び通信装置307が一本のバス304によりデータ処理装置301に接続されているが、接続方法はこれに限るものではない。また、主記憶装置305をデータ処理装置301内のものとすることもできるし、探索経路スタック310を中央処理装置302内のハードウェアとして実現することも可能である。あるいは、配列309は外部記憶装置306に、探索経路スタック310を主記憶装置305に持つなど、使用可能なハードウェア環境、インデックスキー集合の大きさ等に応じて適宜ハードウェア構成を選択できることは明らかである。
 また、特に図示されてはいないが、処理の途中で得られた各種の値を後の処理で用いるためにそれぞれの処理に応じた一時記憶領域が用いられることは当然である。以下の説明では、先に述べた第1の弁別位置等の場合と同様に、一時記憶領域に格納されたあるいは設定された値を一時記憶領域の名前で呼ぶことがある。
 図3に示したとおり、カップルドノードツリーのノードを格納した配列要素からなる配列309と、インデックスキーの記憶領域311とは別の領域である。したがって、リーフノードを格納した配列要素にインデックスキーが含まれる場合に比べて、図3の構成では、一般に1つの配列要素に必要な記憶領域の量が少ない。つまり、カップルドノードツリーを格納する配列309からインデックスキーの記憶領域311を分離することによって、キャッシュメモリ303へのカップルドノードツリーの読み込みにおいて1キャッシュブロックあたりに格納されるノード数を増やすことが可能となる。それにより、後述する検索処理等においてキャッシュミスの頻度が減って処理がより高速に行われるようになる。
 次に、本発明の一実施態様に係るカップルドノードツリーを用いた基本的な操作である、検索、挿入、削除について順に詳しく説明する
 図4は、一実施形態におけるビット列の検索処理を示すフローチャートである。
 まず、ステップS401aで、検索開始ノードの配列番号を取得する。取得された配列番号に対応する配列は、カップルドノードツリーを構成する任意のノードを格納したものである。検索開始ノードの指定は、後に説明する各種応用検索において行われる。
 取得された検索開始ノードの配列番号は、図示しない検索開始ノード設定エリアに設定されるが、この検索開始ノード設定エリアは、先に述べた「処理の途中で得られた各種の値を後の処理で用いるためにそれぞれの処理に応じた一時記憶領域」の一つである。以下の説明では、「図示しない検索開始ノード設定エリアに設定する」のような表現に変えて、「検索開始ノードの配列番号を得る。」、「検索開始ノードとして設定する」あるいは単に「検索開始ノードに設定する」のように記述することもある。
 次にステップS401bで、後に第1の弁別位置の値を退避する一時記憶領域である退避弁別位置に初期値を設定する。インデックスキーの先頭のキー列の第1の弁別位置を0としているので、初期値にはマイナスの値を設定する。
 次に、ステップS402で、探索経路スタックに取得された配列番号を格納し、ステップS403で、その配列番号に対応する配列要素を参照すべきノードとして読み出す。そして、ステップS404で、読み出したノードから、ノード種別を取り出し、ステップS405で、ノード種別がブランチノードであるか否かを判定する。
 ステップS405の判定において、読み出したノードがブランチノードである場合は、ステップS406aに進む。ステップS406aでは、ノードから第1の弁別位置を取り出し、次のステップS406bで、ステップS406aで取り出した第1の弁別位置が退避弁別位置と一致するか判定する。
 第1の弁別位置が退避弁別位置と一致する場合はステップS406に移行し、一致しない場合はステップS406cに進んで、検索キー列から、ステップS406aで取り出した第1の弁別位置が指すキーを取り出し、検索キーに設定する。
 次にステップS406dで退避弁別位置にステップS406aで取り出した第1の弁別位置を設定し、ステップS406に進む。
 ステップS406では、ステップS403で読み出したノードから第2の弁別位置(弁別ビット位置)を取り出し、更に、ステップS407で、取り出した弁別ビット位置に対応するビット値を検索キーから取り出す。そして、ステップS408で、ステップS403で読み出したノードから代表ノード番号を取り出し、ステップS409で、検索キーから取り出したビット値と代表ノード番号とを加算し、新たな配列番号として、ステップS402に戻る。
 以降、ステップS405の判定においてリーフノードと判定されてステップS410aに進むまで、ステップS402からステップS409までの処理を繰り返す。ステップS410aでは、リーフノードから参照ポインタを取り出し、検索を終了する。
 次に、図5~図8Aによりカップルドノードツリーにおけるノード挿入処理を説明する。図5~図7が通常の挿入処理を説明するものであり、図8Aはルートノードの挿入処理を説明するものである。ルートノードの挿入処理と通常の挿入処理により、カップルドノードツリーが生成されることから、ノード挿入処理の説明はカップルドノードツリーの生成処理の説明でもある。
 図5は挿入処理の前段である検索処理の処理フローを示す図であり、図4に示した検索処理において、挿入キー列を検索キー列とし、検索開始ノードをルートノードとしたものに相当する。
 まず、ステップS501aで検索開始ノードにルートノードの配列番号を設定し、ステップS501bで検索キー列に挿入キー列を設定する。挿入キー列は、挿入処理の前提条件として、予めインデックスキーの格納領域のポインタを取得して、該格納領域に格納されているものとする。挿入キー列の末尾のキーは、インデックスキー全体でユニークな値をとるものとする。
 次にステップS510aにおいて、検索キー列により検索開始ノードより図4に示す検索処理を行い、参照ポインタを取得し、ステップS510bにおいて該参照ポインタの指すキー列を取り出して比較キー列に設定する。
 次にステップS510cにおいて、挿入キー列のキーと比較キー列のキーを順次比較する。比較の結果、比較キー列が挿入キー列に完全に一致するかしないかの情報を出力する。完全に一致しない場合には、最初に不一致となったキーの位置を第1の弁別位置として設定するとともに、挿入キー列における該第1の弁別位置のキーを挿入キーに設定し、比較キー列における該第1の弁別位置のキーを比較キーに設定する。ステップS510cの詳細は、後に図8Bを参照して説明する。
 次にステップS511aにおいて、ステップS510cでの比較の結果、挿入キー列のキーと比較キー列のキーが全て等しいか判定し、等しければ挿入キー列は既にカップルドノードツリーの参照ポインタが指す記憶領域に存在するのであるから、挿入は失敗となり、処理を終了する。等しくなければ次の処理、図6のステップS512以下の処理に進む。
 図6は、挿入するノード対のための配列要素を準備する処理を説明する処理フロー図である。
 ステップS512において、配列から空きのノード対を求め、そのノード対のうち代表ノードとなるべき配列要素の配列番号を取得する。
 ステップS513aに進み、ステップS510cで得た挿入キーと比較キーの大小を比較し、挿入キーが大きいときは値1を小さいときは値0のブール値を得る。
 ステップS514に進み、ステップS512で得た代表ノードの配列番号にステップS513で得たブール値を加算した配列番号を得る。
 ステップS515に進み、ステップS512で得た代表ノードの配列番号にステップS513で得たブール値の論理否定値を加算した配列番号を得る。
 ステップS514で得た配列番号は、挿入キー列をインデックスキーとして格納する記憶領域への参照ポインタを持つリーフノードが格納される配列要素の配列番号であり、ステップS515で得た配列番号は、そのリーフノードとノード対を成すノードが格納される配列要素のものである。
 つまり、前段の検索処理で得られたリーフノードに対応するインデックスキーと挿入キー列の大小により、挿入されるノード対のうちどちらのノードに、挿入キー列への参照ポインタを保持するリーフノードが格納されるかが決定される。
 例えば図2Bのカップルドノードツリーに挿入キー列“0110111001”を挿入する場合、検索結果のインデックスキーは、ノード211dに対応する、キー列
“0110101000”になる。挿入キー列と検索結果のキー列のキーを順次比較すると第1のキーで不一致となり、第1のキー同士の大小比較によりブール値が求められ、今の例では挿入キー列の第1のキーの方が大きいのでブール値1が得られ、挿入されるノード対の代表ノード番号に1を加えた配列要素に挿入キー列への参照ポインタを保持するリーフノードが格納される。一方、インデックスキー“0110101000”への参照ポインタ281dは、大小比較で得られたブール値を論理反転した値を代表ノード番号に加算した配列番号の配列要素に格納される。
 その際、検索結果のインデックスキーの第1のキー291d“011010”と挿入キー列の第1のキー“011011”とは5ビット目で異なることから、ノード211dは、弁別ビット位置を5とし、代表ノード番号を挿入されたノード対の代表ノードの配列番号とするブランチノードとなる。
 また図2Bのカップルドノードツリーに“0110011010”を挿入しようとする場合も、検索結果は、ノード211dに対応する、“0110101000”という値のインデックスキーになる。この場合にも挿入キー列と検索結果のキー列の第1のキーは不一致であり、この場合には挿入キー列の第1のキーの方が小さいのでブール値0が得られ、挿入されるノード対の代表ノード番号に0を加えた配列要素に挿入キー列への参照ポインタを保持するリーフノードが格納される。そして、インデックスキーの第1のキー291d“011010”と挿入キー列の第1のキー“011001”とは4ビット目で異なることから、ノード211dは、弁別ビット位置を4とし、代表ノード番号を挿入されたノード対の代表ノードの配列番号とするブランチノードとなる。
 次にステップS516で、ステップS510cで得た挿入キーと比較キーのビット列比較を例えば排他的論理和で行い、差分ビット列を得る。
 ステップS517に進み、ステップS516で得た差分ビット列から、上位0ビット目から見た最初の不一致ビットのビット位置(以下、差分ビット位置ということがある。)を得る。この処理は、例えばプライオリティエンコーダを有するCPUではそこに差分ビット列を入力し、不一致のビット位置を得ることができる。また、ソフト的にプライオリティエンコーダと同等の処理を行い最初の不一致ビットのビット位置を得ることも可能である。
 ステップS517に引き続き、図7に示すステップS518以下の処理を行う。
 図7は図6で準備された配列要素にノードを格納するとともにその挿入位置を求め、既存のノードの内容を変更して挿入処理を完成させる処理フローを示す図である。
 ステップS518~ステップS523までの処理は、挿入するノード対のカップルドノードツリー上の位置を求める処理であり、ステップS524以下の処理は各ノードにデータを設定して挿入処理を完成させる処理である。
 ステップS518において、探索経路スタックのスタックポインタがルートノードの配列番号を指しているか判定する。指していればステップS524に移行し、指していなければステップS519に進む。
 ステップS519において、探索経路スタックのスタックポインタを1つ戻してそこにスタックされている配列番号を取り出す。
 ステップS520に進み、ステップS519で取り出した配列番号の配列要素を配列からノードとして読み出す。
 ステップS520aに進み、ステップS520で読み出したノードから、第1の弁別位置を取り出し、ステップS520bにおいて、ステップS520aで取り出した第1の弁別位置“A”とステップS510cで得た第1の弁別位置“B”の大小を比較する。
 A>Bであれば、ステップS518にもどり、A=Bであれば、ステップS521に進み、A<Bであれば、ステップS523に進む。
 ステップS521では、ステップS520で読み出したノードから、第2の弁別位置(弁別ビット位置)を取り出し、ステップS522に進み、ステップS521で取り出した弁別ビット位置がステップS517で得た差分ビット位置より上位の位置関係か判定する。ここで上位の位置関係とは、ビット列のより左側の位置、すなわちビット位置の値が小さい位置であることとする。
 ステップS522の判定結果が否定であれば、ステップS518に戻り、ステップS518での判定が肯定になるか、ステップS520bにおいてA<Bと判定されるか、ステップS522での判定が肯定になるまで繰り返す。ステップS522での判定が肯定になると、ステップS523に進む。
 ステップS523では、探索経路スタックのスタックポインタを1つ進め、ステップS524以下の処理に移行する。
 上記ステップS518~ステップS523で説明した処理は、挿入するノード対の挿入位置を決定するために、探索経路スタックに格納されているブランチノードの第1の弁別位置(A)とステップS510cで取得した第1の弁別位置(B)の相対的位置関係を調べ、A<Bであればブランチノードのリンク先を挿入するノード対の挿入位置とし、A=Bであれば、挿入するインデックスキー(挿入キー)と検索により取得されたインデックスキー(比較キー)の間のビット列比較で異なるビット値となる差分ビット位置と探索経路スタックに格納されているブランチノードの弁別ビット位置との相対的位置関係を調べ、弁別ビット位置が上位となるブランチノードの次のブランチノードのリンク先を挿入するノード対の挿入位置とするものである。
 また、探索経路スタックを逆にたどりルートノードに至った場合は、ルートノードのリンク先が挿入位置となる。
 例えば図2Bのカップルドノードツリーに“1110000000”を挿入するとき、検索結果のインデックスキーは、ノード210hに対応する“1011000001”になる。この例の場合、第1の弁別位置(A)は1(第1の弁別位置241f)、第1の弁別位置(B)は0であるからA>Bとなり、リンク経路をノード211bに戻ると、第1弁別位置241bは0なのでA=Bとなる。今の例の場合、挿入キー“111000”と比較キー“101100”の差分ビット位置は1であり、弁別ビット位置231bは2なので、さらにルートノード210aまでさかのぼる。
 ルートノード210aの弁別ビット位置230aは0で差分ビット位置1より上位になるのでスタックポインタは220aを指す。したがって、挿入位置はノード211bのリンク先である。ブランチノード211bの弁別ビット位置は、ノード対が挿入されると
後に述べるように差分ビット位置の値1になる。
 なお、A<Bとなるのは、例えば第1のキーに重複が無いインデックスキーに対して、重複する第1のキーを含む挿入キー列が挿入される場合であり、図2Bの例では、挿入キー列“1000101001”が与えられると第1の弁別位置(A)は第1の弁別位置240fであって値が0であり、第1の弁別位置(B)の値は1であって、A<Bが成立し、ノード210gが挿入位置になり、挿入されるノード対の直近上位のブランチノードになる。
 次に、ステップS524以下の各ノードにデータを設定して挿入処理を完成させる処理
について説明する。
 ステップS524では探索経路スタックからスタックポインタの指す配列番号を取り出す。
 ステップS525dに進み、ステップS514で得た配列番号の指す配列要素の、ノード種別にリーフを、参照ポインタに挿入キー列のポインタを書き込む。
 ステップS526に進み、配列からステップS524で得た配列番号の配列要素を読み出す。
 次にステップS527において、ステップS515で得た配列番号の配列要素にステップS526で読み出した内容を書き込む。
 最後にステップS528aにおいて、ステップS524で得た配列番号の指す配列要素のノード種別にブランチを、第1の弁別位置にステップS510cで得た第1の弁別位置を、第2の弁別位置にステップS517で得たビット位置を、代表ノード番号にステップS512で得た配列番号を書き込み、処理を終了する。
 上述の図2Bのカップルドノードツリーに挿入キー列“1110000000”を挿入する例では、ステップS525dにおいて、取得された空ノード対のノード[1]を挿入キー列“1110000000”への参照ポインタを保持するリーフノードとし、ステップS527において、ノード[0]にノード211bの内容を書き込む。そして、ステップS528aにおいて、ノード211bのノード種別に0、第1の弁別位置に0、弁別ビット位置にビット列比較により得られた差分ビット位置1を格納し、代表ノード番号には取得されたノード対の代表ノードが格納される配列要素の配列番号が格納される。
 図8Aは、本発明の一実施形態におけるルートノードの挿入処理を含むリーフノードの挿入処理全体の処理フローを説明する図である。
 ステップS551において、取得することを求められたカップルドノードツリーのルートノードの配列番号が登録済みであるか判定される。登録済みであれば、図5~図7を用いて説明した通常の挿入処理が行われる。
 ステップS551での判定が登録済みでなければ、まったく新しいカップルドノードツリーの登録、生成が始まることになる。この場合にも、挿入キー列は、挿入処理の前提条件として、予めインデックスキーの格納領域のポインタを取得して、該格納領域に格納されているものとする。
 まず、ステップS552において、配列から空きのノード対を求め、そのノード対のうち代表ノードとなるべき配列要素の配列番号を取得する。次にステップS553において、ステップS552で得た配列番号に0を加えた配列番号を求める。(実際には、ステップS552で取得した配列番号に等しい。)次にステップS554dにおいて、ステップS553で得た配列番号の配列要素すなわち挿入するルートノードに対応する配列要素の、ノード種別にリーフを、参照ポインタに挿入キー列のポインタを書き込む。そしてステップS556では、ステップS553で取得したルートノードの配列番号を登録して処理を終了する。
 先にも述べたように、インデックスキーの集合があるとき、そこから順次インデックスキーを取り出し、図8A及び図5~図7の処理を繰り返すことにより、インデックスキーの集合に対応した本発明のカップルドノードツリーを構築することができることは明らかである。
 次に、図8Bを参照して、先に述べた図5に示すステップS510cで実行される、本発明の一実施形態におけるキー列の比較処理の処理フローを説明する。
 図に示すように、ステップS101において、弁別位置に初期値として値“0”を設定する。
 ステップS102において、列中の全てのキーは処理済みか判定し、処理済であれば完全一致の情報を出力して処理を終了し、処理済でなければステップS103に進む。
 ステップS103では、挿入キー列から、弁別位置の指すキーを取り出し、挿入キーとして設定する。
 ステップS104に進み、図5に示すステップS510bで設定した比較キー列から、弁別位置の指すキーを取り出し、比較キーとして設定する。
 次にステップS105に進み、挿入キーは比較キーと一致するか判定する。一致すればステップS106で弁別位置に設定した値を更新してステップS102に戻り、一致しなければ、ステップS107に移行して弁別位置を第1の弁別位置として設定するとともに、非完全一致を出力して処理を終了する。
 次に図9、図10を参照して、本発明の一実施形態におけるカップルドノードツリーから特定のインデックスキーに対応するリーフノードを削除する処理フローを説明する。
 図9は、削除処理の前段である検索処理の処理フローを示す図であり、図4に示した検索処理において、削除キー列を検索キー列とし、検索開始ノードをルートノードとしたものに相当する。
 まず、ステップS901aで検索開始ノードにルートノードの配列番号を設定し、ステップS901bで検索キー列に削除キー列を設定する。
 次にステップS910aにおいて、検索キー列により検索開始ノードより図4に示す検索処理を行い、参照ポインタを取得し、ステップS910bにおいて該参照ポインタの指すキー列を取り出して比較キー列に設定する。
 次にステップS910cにおいて、削除キーとして、削除キー列の末尾のキーを設定し、ステップS910dにおいて、インデックスキーとして、比較キー列の末尾のキーを設定する。
 ステップS911においてステップS910cで設定した削除キーとステップS910dで設定したインデックスキーを比較し、等しくなければ削除するインデックスキーはカップルドノードツリーに存在しないのであるから、削除は失敗となり、処理を終了する。等しければ次の処理、図10のステップS912以下の処理に進む。なお、前述のキー列中の末尾のキーを比較するのは、末尾のキーが重複のないユニークキーであることによる。
 図10は、削除処理の後段の処理フローを説明する図である。
 まず、ステップS912で探索経路スタックに2つ以上の配列番号が格納されているか判定する。2つ以上の配列番号が格納されていないということは、言い換えれば1つだけで、その配列番号はルートノードの格納された配列要素のものである。その場合はステップS918に移行し、ステップS901aで得たルートノードの配列番号に係るノード対を削除して、処理を終了する。
 ステップS912において探索経路スタックに2つ以上の配列番号が格納されていると判定されたときはステップS913aに進み、ステップS910aで実行した図4に示す検索処理のステップS408で得た代表ノード番号に、同じくステップS910aで実行した図4に示す検索処理のステップS407で得たビット値を反転した値を加算した配列番号を得る。この処理は、削除対象のリーフノードと対をなすノードの配置された配列番号を求めるものである。
 次にステップS914において、ステップS913で得た配列番号の配列要素の内容を読み出し、ステップS915において探索経路スタックのスタックポインタを1つ戻して配列番号を取り出す。
 次にステップS916に進み、ステップS914で読み出した配列要素の内容をステップS915で得た配列番号の配列要素に上書きする。この処理は、削除対象のリーフノードへのリンク元であるブランチノードを上記リーフノードと対をなすノードに置き換えるものである。
 続くステップS917において、ステップS910aで実行した図4に示す検索処理のステップS408で得た代表ノード番号に係るノード対を削除し、処理を終了する。
 図11A及び図11Bは、図2Bに例示したカップルドノードツリーにおいて“0110101000”を削除キー列として削除処理を行う例を説明する図である。
 図11Aに示したカップルドノードツリーは、ノード対201f以下のノードは記載を省略している。削除キー列“0110101000”は、第1のキー“011010”と第2のキー“1000”から構成されるキー列であり、一時記憶領域である削除キー270に格納されている。
 探索経路スタック310には配列番号が格納されており、そのスタックポインタは配列番号221c+1を指している。図中太枠で囲まれたノードが検索処理でたどられたノードであり、その配列番号がルートノード210aのものからリーフノード211dのものまで探索経路スタック310に積まれている。
 削除キー列“0110101000”による検索処理においては、まず始めにルートノード210aの配列番号220を取得し、それを探索経路スタック310に格納する。ルートノード210aの第1の弁別位置240aが0であるので、削除キー列の第1のキー“011010”が取り出されて検索キーに設定され、弁別ビット位置230aが0であり、検索キーのビット位置0のビット値が0であるので、代表ノード番号220aにビット値0を加えた配列番号220aが探索経路スタック310に格納される。
 次に配列番号220aの指すノード210bが読み出され、ブランチノードであることが判定される。第1の弁別位置240bは0で第1の弁別位置240aと変わりは無いので、先に設定した検索キーから、弁別ビット位置230bの値1に対応するそのビット位置のビット値1を取得し、代表ノード番号220bに加えて配列番号220b+1を得てそれを探索経路スタック310に格納する。
 次にノード211cが読み出され、第1の弁別位置241cが1であって、1つ更新されたので、削除キー列の第2のキー“1000”が検索キーとして設定される。弁別ビット位置231cが0であり、検索キーのビット位置0のビット値が1であるので、代表ノード番号221cに1を加えた配列番号221c+1が図に示すとおり探索経路スタック310に格納されている。
 配列番号が221c+1の配列要素に格納されたノード211dのノード種別261dは1であり、リーフノードであることを示している。このリーフノードに対応するインデックスキー(キー列291d、291d’)は、参照ポインタ281dにより示される記憶領域に格納されている。その記憶領域はインデックスキーの記憶領域311の一部である。そこで参照ポインタ281dの参照するインデックスキーの末尾のキーである第2のキー291d’を取り出すとその値は“1000”であり、削除キー270に格納された第2のキーと一致している。
 図11Aに示した状態において、削除対象のノード211dと対をなすノード210dの内容が読み出され、その内容が、探索経路スタック310のスタックポインタを1つ戻したところに格納されている配列番号220b+1の配列要素(ノード211c)に書き込まれる。その後ノード対201dを削除する。ノード対が削除された配列要素は空となり、再利用可能となる。
 図11Bに示したカップルドノードツリーは、削除処理の終了後のものである。ノード211cのノード種別261c、第1の弁別位置241c、弁別ビット位置231c、代表ノード番号221cには、括弧書きで示すように、ノード210dに格納されていた値がそのまま格納されている。また、探索経路スタック310のスタックポインタは配列番号220b+1を指している。
 次に、図12A及び図12Bを参照して挿入処理の具体例を説明する。
 図12Aに示すのは、ビット列“01000001”、“00010010”、“00000011”をインデックスキーとして参照する参照ポインタ1281b、1281c、1280cを持つカップルドノードツリーである。
 参照ポインタ1281bの指す記憶領域には、第1のキー1291b“0100”と第2のキー1291b’“0001”からなるキー列が格納されている。同様に、参照ポインタ1281cの指す記憶領域には、第1のキー1291c“0001”と第2のキー1291c’“0010”からなるキー列が格納され、参照ポインタ1280cの指す記憶領域には、第1のキー1290c“0000”と第2のキー1290c’“0011”からなるキー列が格納されている。
 これから挿入しようとする挿入キー列は図示の例では“00000100”である。挿入キー列は、先に述べたように、インデックスキーの格納領域のポインタ1281dを取得して、ポインタ1281dの指す領域に格納されているものとし、挿入キー列の末尾のキーである第2のキー“0100”はインデックスキー全体でユニークな値をとることを前提としている。
 図示のツリーはノード対1201a、1201b、1201cで構成されている。
 ノード対1201aの代表ノードはルートノード1210aであり、第1の弁別位置には0、弁別ビット位置には1が保持されている。ノード対1201aの下位のノード対1201bの代表ノード1210bはブランチノードであり、第1の弁別位置には0、弁別ビット位置には3が保持され、代表ノード1210bと対になるノード1211bはリーフノードであり、キー列1291b、1291b’への参照ポインタ1281bが保持されている。ブランチノードであるノード1210bはノード対1201cにリンクしている。
 ノード対1201cを構成するノード1210cと1211cはともにリーフノードであり、それぞれキー列1290c、1290c’とキー列1291c、1291c’への参照ポインタ1280c、1281cが格納されている。
 挿入キー列の第1のキー1291dは、参照ポインタ1280cの指す記憶領域に格納されたキー列の第1のキーと重複している。したがって図示の例の場合、挿入キー列で検索をすると、参照ポインタ1280cの格納されたリーフノード1210cに至り、比較キーとして、第2のキー1290c’が設定され、挿入キー列の第2のキー1290d’を挿入キーとして大小関係の判定とビット列比較が行われる。すると、挿入キーが比較キーより大きく、最初の不一致ビットの位置は1となる。
 図12Bは、挿入キー列“00000100”を挿入したカップルドノードツリーを示す図である。新たなノード対1201dがノード対1201cの下位に挿入されている。ノード対1201dのノード[1]1211dが挿入キー列のポインタを参照ポインタ1281dとして含むリーフノードとして生成され、ノード[0]1210dには、図12Aに示すノード1210の内容が書き込まれている。そして、図12Bに示すブランチノード1210cの第1の弁別位置には第2のキーであることを示す1が、第2の弁別位置には挿入キーと比較キーの最初の不一致ビットの位置である1が格納され、代表ノード番号には、ノード対1201の代表ノード1210dの配置された配列要素の配列番号が格納されている。
 以上本発明を実施するための最良の形態について詳細に説明したが、本発明の実施の形態はそれに限ることなく種々の変形が可能であることは当業者に明らかである。例えばリーフノードが、インデックスキーを格納した記憶領域の位置を示す情報に代えてインデックスキー自体を含むようにすることが可能であることは、当業者に自明である。また、検索キー列中のキーの位置を識別する第1の弁別位置を、左から0、1、2、・・・のようにキーの並びの順番に応じたキーの位置番号としたが、これに限ることなく、例えば検索キー列全体の先頭ビットからのオフセット値としたり、0と1を交互に用いることによりキー位置が切り替わったことを示すことにより、キーの位置の識別が可能であることは、当業者に自明である。
 また、本発明のビット列検索方法を実行する装置が、カップルドノードツリーを格納する記憶手段と図4に示した処理をコンピュータに実行させるプログラムによりコンピュータ上に構築可能なことは明らかである。
 さらに、図5~図7、図8A、図8Bに示した挿入処理とその均等物をコンピュータに実行させるプログラムにより、本発明の挿入方法が実現可能であり、図9及び図10に示した削除処理とその均等物をコンピュータに実行させるプログラムにより、本発明の削除方法が実現可能であることも明らかである。そして、それらのプログラムにより、ブランチノードとリーフノードの識別手段、ブランチノードの弁別ビット位置に応じてリンク先のノード対のどちらかにリンクする手段等がコンピュータ上に実現される。
 したがって、上記プログラム、及びプログラムを記憶したコンピュータ読み取り可能な記憶媒体は、本発明の実施の形態に含まれる。さらに、本発明のカップルドノードツリーのデータ構造も、本発明の実施の形態に含まれる。
 以上詳細に説明した、本発明が提供する新しいデータ構造であるカップルドノードツリーを用いることにより、重複キーを取り扱うことができるとともに、より高速なビット列データの検索を行うことが可能となる。しかもビット列データの追加削除も容易に実行することができる。

Claims (15)

  1.  ルートノードと、隣接した記憶領域に配置されるブランチノードとリーフノードまたはブランチノード同士またはリーフノード同士のノード対、からなるビット列検索に用いるツリーであって、
     前記ルートノードは、ツリーの始点を表すノードであって、該ツリーのノードが1つのときは前記リーフノード、ツリーのノードが2つ以上のときは前記ブランチノードであり、
     前記ブランチノードは、リンク先のノード対の一方のノードである代表ノードの位置を示す第一の位置情報を含み、前記リーフノードは、検索対象のビット列からなるインデックスキーを格納した記憶領域の位置を示す第二の位置情報を含むカップルドノードツリーを用いたビット列検索方法において、
     前記インデックスキーは1つ以上のキーの列であって該キー列の末尾のキーは重複のないユニークキーであり、前記ブランチノードは、ビット列検索を行う検索キー列中のキーの位置を識別する第1の弁別位置と、該キーの弁別ビット位置である第2の弁別位置をさらに含み、
     前記カップルドノードツリーの任意のノードを検索開始ノードとして、前記ブランチノードにおいて、前記検索キー列のうち該ブランチノードに含まれる第1の弁別位置で識別される位置のキーの前記弁別ビット位置のビット値に応じて、リンク先のノード対の代表ノードかあるいはそれと隣接した記憶領域に配置されたノードにリンクすることを順次前記リーフノードに至るまで繰り返すことにより、前記リーフノードに含まれる前記第二の位置情報が示す記憶領域に格納されたインデックスキーを、前記検索開始ノードをルートノードとする前記カップルドノードツリーの任意の部分木の前記検索キー列による検索結果である検索結果キー列とすることを特徴とするビット列検索方法。
  2.  前記カップルドノードツリーは配列に記憶され、前記第一の位置情報は、該第一の位置情報に対応する前記代表ノードが格納された前記配列の配列要素の配列番号であることを特徴とする請求項1記載のビット列検索方法。
  3.  前記検索開始ノードの格納された配列要素の配列番号及び前記検索開始ノードから前記リーフノードに至るリンク先のノードの格納された配列要素の配列番号が、順次スタックに保持されていくことを特徴とする請求項2記載のビット列検索方法。
  4.  請求項1記載のビット列検索方法で用いるカップルドノードツリーに、新たなインデックスキーが格納された記憶領域の位置を示す前記第二の位置情報を含むリーフノードを挿入するリーフノード挿入方法において、
     前記新たなインデックスキーを前記検索キー列とし、前記カップルドノードツリーのルートノードを検索開始ノードとして、ルートノードからリーフノードに至るリンク経路を記憶しながら請求項1記載のビット列検索方法により前記検索結果キー列を取得する検索結果キー列取得ステップと、
     前記検索キー列と前記検索結果キー列のキーを先頭のキーから順次比較して最初に異なる値となるキーの位置を取得する第1の弁別位置取得ステップと、
     前記検索キー列と前記検索結果キー列の前記第1の弁別位置取得ステップで取得したキーの位置にあるキーの間で大小比較とビット列比較を行う比較ステップと、
     前記リンク経路上のブランチノードの第1の弁別位置と前記第1の弁別位置取得ステップで取得した前記キーの位置との相対的位置関係、及び前記比較ステップにおけるビット列比較で異なるビット値となる先頭のビット位置と前記リンク経路上のブランチノードの第2の弁別位置との相対的位置関係により、挿入される前記リーフノードともう一方のノードからなるノード対の挿入位置を決定する挿入位置決定ステップと、
     前記比較ステップにおける前記大小比較の結果により、挿入される前記リーフノードを挿入される前記ノード対のどちらのノードとするかを決定するノード位置決定ステップと、
     前記新たなインデックスキーを格納する記憶領域の位置を示す情報を前記第二の位置情報として前記リーフノードに格納するリーフノード生成ステップと、
     を含むことを特徴とするリーフノード挿入方法。
  5.  前記カップルドノードツリーは配列に記憶され、前記第一の位置情報は、該第一の位置情報に対応する前記代表ノードが格納された前記配列の配列要素の配列番号であることを特徴とする請求項4記載のリーフノード挿入方法。
  6.  前記ルートノードの格納された配列要素の配列番号及び前記ルートノードから前記リーフノードに至るリンク先のノードの格納された配列要素の配列番号が、順次スタックに保持されていくことを特徴とする請求項5記載のリーフノード挿入方法。
  7.  請求項1記載のビット列検索方法で用いるカップルドノードツリーから、指定された前記インデックスキーが格納された記憶領域の位置を示す前記第二の位置情報を含むリーフノードを削除する、リーフノード削除方法において、
     前記指定されたインデックスキーを検索キー列とし、前記カップルドノードツリーのルートノードを検索開始ノードとして請求項1記載のビット列検索方法により前記検索結果キー列を取得し、
     前記検索結果キー列を格納する記憶領域の位置を示す情報を前記第二の位置情報として含むリーフノードと対をなすもう一方のノードを、該リーフノードのリンク元のブランチノードに格納することにより前記リーフノードを削除する、
     ことを特徴とするリーフノード削除方法。
  8.  前記カップルドノードツリーは配列に記憶され、前記第一の位置情報は、該第一の位置情報に対応する前記代表ノードが格納された前記配列の配列要素の配列番号であることを特徴とする請求項7記載のリーフノード削除方法。
  9.  前記ルートノードの格納された配列要素の配列番号及び前記ルートノードから前記リーフノードに至るリンク先のノードの格納された配列要素の配列番号が、順次スタックに保持されていくことを特徴とする請求項8記載のリーフノード削除方法。
  10.  請求項1~9いずれか1項に記載の方法をコンピュータに実行させるためのプログラム。
  11.  ビット列検索に用いるツリー状のデータ構造であって、
     ルートノードと、隣接した記憶領域に配置されるブランチノードとリーフノードまたはブランチノード同士またはリーフノード同士のノード対、からなり、
     前記ルートノードは、ツリーの始点を表すノードであって、該ツリーのノードが1つのときは前記リーフノード、ツリーのノードが2つ以上のときは前記ブランチノードであり、
     前記ブランチノードは、リンク先のノード対の一方のノードである代表ノードの位置を示す第一の位置情報を含み、
     前記インデックスキーは1つ以上のキーの列であって該キー列の末尾のキーは重複のないユニークキーであり、前記ブランチノードは、ビット列検索を行う検索キー列中のキーの位置を識別する第1の弁別位置と、該キーの弁別ビット位置である第2の弁別位置をさらに含み、
     前記カップルドノードツリーの任意のノードを検索開始ノードとして、前記ブランチノードにおいて、前記検索キー列のうち、該ブランチノードに含まれる第1の弁別位置で識別される位置のキーの前記弁別ビット位置のビット値に応じてリンク先のノード対の代表ノードかあるいはそれと隣接した記憶領域に配置されたノードにリンクすることを順次前記リーフノードに至るまで繰り返すことにより、前記検索キー列による検索の実行を可能とすることを特徴とするデータ構造。
  12.  前記データ構造は配列に記憶され、前記第一の位置情報は、該第一の位置情報に対応する前記代表ノードが格納された前記配列の配列要素の配列番号であることを特徴とする請求項11記載のデータ構造。
  13.  ルートノードと、隣接した記憶領域に配置されるブランチノードとリーフノードまたはブランチノード同士またはリーフノード同士のノード対、からなるビット列検索に用いるツリーであって、
     前記ルートノードは、ツリーの始点を表すノードであって、該ツリーのノードが1つのときは前記リーフノード、ツリーのノードが2つ以上のときは前記ブランチノードであり、
     前記ブランチノードは、リンク先のノード対の一方のノードである代表ノードの位置を示す第一の位置情報を含み、前記リーフノードは、検索対象のビット列からなるインデックスキーを格納した記憶領域の位置を示す第二の位置情報を含むカップルドノードツリーを用いたビット列検索装置において、
     前記インデックスキーは1つ以上のキーの列であって該キー列の末尾のキーはユニークキーであり、前記ブランチノードは、ビット列検索を行う検索キー列中のキーの位置を識別する第1の弁別位置と、該キーの弁別ビット位置である第2の弁別位置をさらに含み、
     前記カップルドノードツリーの任意のノードを検索開始ノードとして、前記ブランチノードにおいて、前記検索キー列のうち、該ブランチノードに含まれる第1の弁別位置で識別される位置のキーの前記弁別ビット位置のビット値に応じてリンク先のノード対の代表ノードかあるいはそれと隣接した記憶領域に配置されたノードにリンクすることを順次前記リーフノードに至るまで繰り返すことにより、前記リーフノードに含まれる前記第二の位置情報が示す記憶領域に格納されたインデックスキーを、前記検索開始ノードをルートノードとする前記カップルドノードツリーの任意の部分木の前記検索キー列による検索結果である検索結果キー列とすることを特徴とするビット列検索装置。
  14.  配列を備え、前記カップルドノードツリーは該配列に記憶され、前記第一の位置情報は、該第一の位置情報に対応する前記代表ノードが格納された前記配列の配列要素の配列番号であることを特徴とする請求項13記載のビット列検索装置。
  15.  スタックを備え、前記検索開始ノードの格納された配列要素の配列番号及び前記検索開始ノードから前記リーフノードに至るリンク先のノードの格納された配列要素の配列番号が、順次前記スタックに保持されていくことを特徴とする請求項14記載のビット列検索装置。
PCT/JP2008/003264 2008-01-17 2008-11-11 ビット列検索装置、検索方法及びプログラム WO2009090697A1 (ja)

Priority Applications (3)

Application Number Priority Date Filing Date Title
EP08871045.4A EP2249257B1 (en) 2008-01-17 2008-11-11 Bit string retrieval device, retrieval method and program
CN200880124936.8A CN101911068B (zh) 2008-01-17 2008-11-11 比特序列检索装置、检索方法
US12/805,183 US8195667B2 (en) 2008-01-17 2010-07-16 Bit string search apparatus, search method, and program

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
JP2008007690A JP4567754B2 (ja) 2008-01-17 2008-01-17 ビット列検索装置、検索方法及びプログラム
JP2008-007690 2008-01-17

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US12/805,183 Continuation US8195667B2 (en) 2008-01-17 2010-07-16 Bit string search apparatus, search method, and program

Publications (1)

Publication Number Publication Date
WO2009090697A1 true WO2009090697A1 (ja) 2009-07-23

Family

ID=40885108

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2008/003264 WO2009090697A1 (ja) 2008-01-17 2008-11-11 ビット列検索装置、検索方法及びプログラム

Country Status (5)

Country Link
US (1) US8195667B2 (ja)
EP (1) EP2249257B1 (ja)
JP (1) JP4567754B2 (ja)
CN (1) CN101911068B (ja)
WO (1) WO2009090697A1 (ja)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9400817B2 (en) * 2013-12-31 2016-07-26 Sybase, Inc. In-place index repair
JP5960863B1 (ja) * 2015-03-11 2016-08-02 エヌ・ティ・ティ・コミュニケーションズ株式会社 検索装置、検索方法、プログラム、及び記録媒体

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH05265821A (ja) * 1992-03-17 1993-10-15 Hitachi Ltd データベースのインデックス管理方式
JPH1196058A (ja) 1997-09-22 1999-04-09 Nippon Telegr & Teleph Corp <Ntt> T木インデックス構築方法及び装置及びt木インデックス構築プログラムを格納した記憶媒体
JP2001357070A (ja) 2000-06-13 2001-12-26 Nec Corp 情報検索方法及び装置
JP2006187827A (ja) 2005-01-05 2006-07-20 Toyo Tire & Rubber Co Ltd 研磨パッド
JP2006293619A (ja) 2005-04-08 2006-10-26 Toshiba Tec Corp コンピュータ装置及びログ出力プログラム
JP2007114915A (ja) 2005-10-19 2007-05-10 Kazumi Sonomoto 自己診断チェックシステムを活用したユーザー側に設置されている通報装置からの情報送出による自動メンテチェックシステム。
WO2008004335A1 (fr) * 2006-07-07 2008-01-10 S.Grants Co., Ltd. dispositif de recherche de séquence de bits, procédé de recherche et programme

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH01239632A (ja) * 1988-03-19 1989-09-25 Hitachi Ltd 情報検索方式
JP3184008B2 (ja) * 1993-06-28 2001-07-09 エヌイーシーソフト株式会社 索引ファイルの入出力方法
JP2957703B2 (ja) * 1994-06-06 1999-10-06 ノキア テレコミュニカシオンス オサケ ユキチュア データを記憶し検索する方法及びメモリ構成体
SE510000C2 (sv) * 1997-07-21 1999-03-29 Ericsson Telefon Ab L M Struktur vid databas
US6675163B1 (en) * 2000-04-06 2004-01-06 International Business Machines Corporation Full match (FM) search algorithm implementation for a network processor
US7096235B2 (en) * 2003-03-27 2006-08-22 Sand Technology Systems International, Inc. Computer implemented compact 0-complete tree dynamic storage structure and method of processing stored data
US8150856B2 (en) 2006-07-07 2012-04-03 S. Grants Co., Ltd. Bit string searching apparatus, searching method, and program
JP4271227B2 (ja) 2006-10-30 2009-06-03 株式会社エスグランツ ビット列検索装置、検索方法及びプログラム
JP4439013B2 (ja) 2007-04-25 2010-03-24 株式会社エスグランツ ビット列検索方法及び検索プログラム

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH05265821A (ja) * 1992-03-17 1993-10-15 Hitachi Ltd データベースのインデックス管理方式
JPH1196058A (ja) 1997-09-22 1999-04-09 Nippon Telegr & Teleph Corp <Ntt> T木インデックス構築方法及び装置及びt木インデックス構築プログラムを格納した記憶媒体
JP2001357070A (ja) 2000-06-13 2001-12-26 Nec Corp 情報検索方法及び装置
JP2006187827A (ja) 2005-01-05 2006-07-20 Toyo Tire & Rubber Co Ltd 研磨パッド
JP2006293619A (ja) 2005-04-08 2006-10-26 Toshiba Tec Corp コンピュータ装置及びログ出力プログラム
JP2007114915A (ja) 2005-10-19 2007-05-10 Kazumi Sonomoto 自己診断チェックシステムを活用したユーザー側に設置されている通報装置からの情報送出による自動メンテチェックシステム。
WO2008004335A1 (fr) * 2006-07-07 2008-01-10 S.Grants Co., Ltd. dispositif de recherche de séquence de bits, procédé de recherche et programme

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP2249257A4

Also Published As

Publication number Publication date
CN101911068B (zh) 2012-07-25
CN101911068A (zh) 2010-12-08
US8195667B2 (en) 2012-06-05
JP4567754B2 (ja) 2010-10-20
JP2009169715A (ja) 2009-07-30
EP2249257A4 (en) 2011-09-14
EP2249257B1 (en) 2013-04-24
EP2249257A1 (en) 2010-11-10
US20100287193A1 (en) 2010-11-11

Similar Documents

Publication Publication Date Title
JP4271214B2 (ja) ビット列検索装置、検索方法及びプログラム
JP4271227B2 (ja) ビット列検索装置、検索方法及びプログラム
JP4514771B2 (ja) カップルドノードツリーの最長一致/最短一致検索装置、検索方法及びプログラム
US8332410B2 (en) Bit string merge sort device, method, and program
US8224861B2 (en) Coupled node tree splitting/conjoining method and program
JP4439013B2 (ja) ビット列検索方法及び検索プログラム
JP4402120B2 (ja) ビット列検索装置、検索方法及びプログラム
US8250089B2 (en) Bit string search apparatus, search method, and program
JP4567754B2 (ja) ビット列検索装置、検索方法及びプログラム
US8166043B2 (en) Bit strings search apparatus, search method, and program
WO2009122651A1 (ja) ビット列検索装置、検索方法及びプログラム
JP2011018296A (ja) カップルドノードツリーのインデックスキー挿入/削除方法
JP4417431B2 (ja) カップルドノードツリーの分割/結合方法及びプログラム
JP4813575B2 (ja) ビット列検索装置
WO2009093290A1 (ja) ビット列検索装置、検索方法及びプログラム

Legal Events

Date Code Title Description
WWE Wipo information: entry into national phase

Ref document number: 200880124936.8

Country of ref document: CN

121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 08871045

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

WWE Wipo information: entry into national phase

Ref document number: 2008871045

Country of ref document: EP