JP4519028B2 - XPath processing equipment - Google Patents
XPath processing equipment Download PDFInfo
- Publication number
- JP4519028B2 JP4519028B2 JP2005218239A JP2005218239A JP4519028B2 JP 4519028 B2 JP4519028 B2 JP 4519028B2 JP 2005218239 A JP2005218239 A JP 2005218239A JP 2005218239 A JP2005218239 A JP 2005218239A JP 4519028 B2 JP4519028 B2 JP 4519028B2
- Authority
- JP
- Japan
- Prior art keywords
- path
- xpath
- branch
- predicate
- tan
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Expired - Lifetime
Links
Images
Landscapes
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Description
本発明は、XPath式処理装置に関する。
The present invention relates to the XPath expression processing equipment.
XML(Extensible Markup Language)は、ネットワーク上で交換可能な標準的なデータ記述方式を提供する技術であり、現在newsMLなどをはじめとして広く使われている。XPath(XML Path Language)式は、XMLデータの一部を特定するための記述方式を提供する技術であり、XMLデータに対するクエリや変換などにおいて重要な役割を果たしている。 XML (Extensible Markup Language) is a technology that provides a standard data description method that can be exchanged on a network, and is currently widely used including newsML. The XPath (XML Path Language) expression is a technology that provides a description method for specifying a part of XML data, and plays an important role in queries and conversions for XML data.
XMLデータとその中の一部分を表しているXPath式とを入力としたときに、XPath式により指定された部分を抽出する技術が注目を集めている。例えば、newsMLは、ニュース記事やそれに関連した画像、動画、音声などをウェッブ端末、携帯電話、テレビ(データ放送)等、さまざまな端末に送ることができる。このとき、newsMLの受け側(利用者)は、XPath式を配信サーバに登録しておくことで膨大な情報の中から、必要な情報のみを得ることができる。 A technique for extracting a part specified by an XPath expression when XML data and an XPath expression representing a part of the XML data are input has been attracting attention. For example, newsML can send news articles and related images, videos, voices, and the like to various terminals such as a web terminal, a mobile phone, and a television (data broadcast). At this time, the recipient (user) of newsML can obtain only necessary information from a vast amount of information by registering the XPath expression in the distribution server.
なお、XPathは、W3C(The World Wide Web Consortium)が勧告した標準規格で、XML文書の中の特定の要素を指し示す記述方法を定めている。XPathは、XSLT(XML Stylesheet Language Transformations)やXPointer(XML Pointer Language)で使われる位置指定の記述方式を独立させたものである。XPathは、ハイパーリンクなどに使われる人為的に付加されたアンカーによる指定とは異なり、XMLデータを表す木構造をたどって文書内のあらゆる要素や属性にアクセスする手段を提供する。なお、XPath式は、XPathの規格に従った実際の式である。 XPath is a standard recommended by the World Wide Web Consortium (W3C) and defines a description method for indicating a specific element in an XML document. XPath is an independent description method for position designation used in XML Stylesheet Language Transformations (XSLT) and XML Pointer Language (XPointer). XPath provides a means for accessing every element and attribute in a document by following a tree structure representing XML data, unlike designation by an artificially added anchor used for a hyperlink or the like. The XPath expression is an actual expression according to the XPath standard.
XMLデータのパース(Parse)処理は、DOM(Document Object Model)またはSAX(Simple API for XML)に分類される。DOMとは、XMLが木で表現できることに注目し処理を行う技術である。DOM(XMLを内部木で表現したもの)に対して走査を行うことで、分岐処理に対応することができる。ただし、DOMでは巨大なXMLに対しても内部木(以下、DOM木)を作らなければならないために、メモリ使用量が膨大となる。また、ニュース配信や株価配信のように逐次的なデータ(時系列データなど)として送られてリアルタイム処理を必要とする場合には、DOM木を用いたXPath式処理は不可能である。 Parsing processing of XML data is classified into DOM (Document Object Model) or SAX (Simple API for XML). DOM is a technology that performs processing by paying attention to the fact that XML can be expressed by a tree. A branch process can be handled by scanning DOM (XML represented by an internal tree). However, in DOM, an internal tree (hereinafter referred to as a DOM tree) must be created even for a large XML, so that the amount of memory used becomes enormous. In addition, when it is sent as sequential data (such as time series data) and requires real-time processing as in news distribution or stock price distribution, XPath processing using a DOM tree is impossible.
一方、SAXは、前記のDOMの弱点であるリアルタイム性とメモリ使用量削減を狙った技術である。DOMでは、XMLを木として表現することで、XPath式を与えられたときに走査することで検索およびフィルタリング処理を行った。一方SAXを用いた場合には、XMLをあくまでも文書を上から下へ走査することしかできないために、DOMと同じようには、XPath式処理を行うことができない。 On the other hand, SAX is a technology aimed at real-time performance and memory usage reduction, which are weak points of the DOM. In DOM, XML is expressed as a tree, and scanning and filtering processing is performed by scanning when an XPath expression is given. On the other hand, when SAX is used, since XML can only scan a document from top to bottom, XPath expression processing cannot be performed as in DOM.
そこで、SAXを用いたXPath式処理技術としては、NFA(Nondeterministic Finite Automaton)を利用した方法やDFA(Deterministic Finite Automaton)を利用した方法がある。NFAとDFAとは完全に独立したものではなく、それぞれ一長一短がある。NFAは、1つのXPath式に対して1つのオートマトンを構築する。複数のXPath式が与えられたときには、いくつものオートマトンを構築する必要がある。DFAは、NFAから構築される。それぞれの長所短所を表1に示す。
NFAやDFAが作成されると入力されたXMLの中でどの部分がXPath式に一致するかを判断することが可能となる。NFAを利用した方法は、1つのXPath式に対して1つのNFAを作成する。この方法は、XPath式が多くなると処理速度が著しく劣化する特徴がある(非特許文献2)。DFAを利用した方法は、前記NFAを変換することで実現できる。DFAは、XPath式が多くなっても処理速度が一定のまま高速に維持できるという特徴がある。ただし、変換の際にメモリ利用量が膨大になるという欠点も有する。 When an NFA or DFA is created, it is possible to determine which part of the input XML matches the XPath expression. A method using NFA creates one NFA for one XPath expression. This method is characterized in that the processing speed is remarkably deteriorated as the number of XPath expressions increases (Non-Patent Document 2). A method using DFA can be realized by converting the NFA. DFA has a feature that even if the number of XPath expressions increases, the processing speed can be maintained at a high speed while maintaining a constant processing speed. However, there is a disadvantage that the memory usage becomes enormous during conversion.
遅延型DFA(lazyDFA)と呼ばれる手法は、非決定オートマトンからDFAヘすぐに変換を行うことをせず、XMLが入力された際に利用されるオートマトンのみを変換することで高速な処理を実現している(非特許文献1)。 A method called delayed DFA (lazy DFA) realizes high-speed processing by converting only the automaton used when XML is input, without converting immediately from the non-deterministic automaton to the DFA. (Non-Patent Document 1).
前記のSAXを利用したXPath式処理装置を拡張し、1つのXPath式に対して複数の検索条件に対応した技術が分岐XPath式処理装置である(非特許文献3、特許文献1)。このシステムでは、複数の分岐XPath式を1つずつ処理している。つまり、1つのXPath式に対して、1つの検索インデックスを構築しているということである。検索インデックスは、XPath式の数と同じだけ存在するので、XPath式が増加すればするほど線形に処理時間が増加することが知られている。
前記した分岐XPath式処理装置は、複数の条件を処理するにあたりNFAを用いたために、登録されるXPath式が増加するに従って、XPath式に含まれる条件を判定する処理が増加してしまい、性能が著しく劣化するという問題がある。実運用上では複数の条件を指定する必要性が高いため、この性能劣化は分岐XPath式処理装置におけるボトルネックとなっている。 Since the branch XPath processing device described above uses NFA for processing a plurality of conditions, as the number of registered XPath expressions increases, the processing for determining the conditions included in the XPath expressions increases, and the performance is improved. There is a problem of significant deterioration. Since it is highly necessary to specify a plurality of conditions in actual operation, this performance deterioration is a bottleneck in the branch XPath processing apparatus.
そこで、本発明は、前記した問題を解決し、XMLデータをフィルタリング処理するための検索条件を示す分岐XPath式が複数存在するときに、フィルタリング処理を高速化し、かつメモリ使用量を削減することができるように、分岐XPath式を処理する手段を提供することを主な目的とする。 Therefore, the present invention solves the above-described problem, and when there are a plurality of branch XPath expressions indicating search conditions for filtering XML data, the filtering process can be accelerated and the memory usage can be reduced. The main object is to provide a means for processing a branched XPath expression so that it can.
前記課題を解決するために、本発明は、
XMLデータをフィルタリング処理するための分岐XPath式を処理するXPath式処理装置であって、
前記XPath式処理装置は、XPath式格納手段と、パス抽出手段と、共有化インデックス構築手段と、共有化バッファ管理手段と、XPath式処理手段と、を有し、
前記XPath式格納手段は、入力された複数の分岐XPath式を記憶手段に格納し、
前記パス抽出手段は、前記XPath式格納手段により前記記憶手段に格納された分岐XPath式ごとに、
分岐XPath式の述語の条件を満たしたときに返すパスをターゲットパスの絶対パスとし、
分岐XPath式の一番左にある述語のコンテキストパスをターゲットパスのスコープパスとし、
相対パスで表現されている述語と述語のコンテキストパスとを結合して述語の絶対パスとし、
述語のコンテキストパスを述語のスコープパスとして、それぞれ抽出し、
前記共有化インデックス構築手段は、
前記パス抽出手段により抽出された前記ターゲットパスの絶対パスからTAN(Target Absolute Node)を生成し、
前記パス抽出手段により抽出された前記ターゲットパスのスコープパスからTSN(Target Scope Node)を生成し、
前記パス抽出手段により抽出された前記述語の絶対パスからPAN(Predicate Absolute Node)を生成し、
前記パス抽出手段により抽出された前記述語のスコープパスからPSN(Predicate Scope Node)を生成し、
同じ分岐XPath式から抽出される前記TANおよび前記TSNの組のうちのパスが一致する組が複数存在するときには、それらの組を1つの組へと統合し、
同じ分岐XPath式から抽出される前記PANおよび前記PSNの組のうちのパスが一致する組が複数存在するときには、それらの組を1つの組へと統合し、
前記TSNおよび前記PSNをSN(Scope Node)とし、パスが一致するSNが複数存在するときには、それらを1つのSNへと統合し、
抽出元の前記分岐XPath式から生成され、ノードの組み合わせにより、前記分岐XPath式を表現することができ、同じ抽出元の分岐XPath式から抽出される前記TANと当該TANが示す絶対パスに対応するスコープパスに該当する前記SNとをリンクで接続し、前記同じ抽出元の分岐XPath式から抽出される前記PANと当該PANが示す絶対パスに対応するスコープパスに該当する前記SNとをリンクで接続し、前記同じ抽出元の分岐XPath式から抽出される前記TANと前記PANとを、その同じ抽出元の分岐XPath式で示されている論理和または論理積を表す論理記号で接続することで、複数の分岐XPath式から1つの共有化インデックスを構築し、
前記共有化バッファ管理手段は、入力されたXMLデータの構成要素ごとにその出現順序に従って順番に番号を割り当てた共有化バッファを、前記共有化インデックスの前記TANごとに構築するとともに、その各TANの共有化バッファに各TANが示すターゲットパスの範囲分のXMLデータを格納し、
前記XPath式処理手段は、
入力された前記XMLデータをSAXパーサで構文解析することにより、コールバック関数を発生させ、
前記共有化インデックスの前記SNが示すスコープパスの終了が前記コールバック関数により通知されると、
前記共有化インデックスにおける、前記通知された前記SNからリンクで接続される前記PANが示す述語の真偽判定を行い、
前記述語の真偽判定を行った前記PANからリンクで接続される前記TANについて、そのTANにリンクする前記PANの判定結果が偽であるときには、そのTANの共有化バッファから前記SNが示すスコープパスの範囲分のXMLデータを削除するとともに、前記通知された前記SNからリンクで接続される全ての前記PANに対して前記述語の真偽判定を行った後に、前記通知された前記SNからリンクで接続される全ての前記TANについて、そのTANの共有化バッファからそのTANが示すターゲットパスの範囲分のXMLデータのうちの削除されなかった範囲分のXMLデータをフィルタリング結果として出力することを特徴とする。
In order to solve the above problems, the present invention provides:
An XPath-type processing apparatus that processes a branch XPath expression for filtering XML data,
The XPath type processing device includes an XPath type storage means, a path extraction means, a shared index construction means, a shared buffer management means, and an XPath type processing means,
The XPath expression storage means stores a plurality of input branch XPath expressions in a storage means,
The path extraction means is provided for each branch XPath expression stored in the storage means by the XPath expression storage means.
The path to be returned when the predicate condition of the branch XPath expression is satisfied is the absolute path of the target path,
The scope path of the target path is the context path of the predicate at the leftmost of the branch XPath expression.
By combining the predicate expressed by the relative path and the context path of the predicate, the absolute path of the predicate is obtained.
Extract the context path of the predicate as the scope path of the predicate,
The shared index construction means includes:
Generate a TAN (Target Absolute Node) from the absolute path of the target path extracted by the path extraction means,
A TSN (Target Scope Node) is generated from the scope path of the target path extracted by the path extraction means,
Generate a PAN (Predicate Absolute Node) from the absolute path of the previous description word extracted by the path extraction means,
A PSN (Predicate Scope Node) is generated from the scope path of the previous description word extracted by the path extraction means,
When there are a plurality of pairs having the same path among the TAN and TSN pairs extracted from the same branch XPath expression, these sets are combined into one set,
When there are a plurality of pairs having the same path among the PAN and PSN pairs extracted from the same branch XPath expression, these sets are merged into one set;
The TSN and the PSN are SNs (Scope Nodes), and when there are multiple SNs with matching paths, they are integrated into one SN,
The branch XPath expression generated from the extraction source branch XPath expression can be expressed by a combination of nodes, and corresponds to the TAN extracted from the same extraction source branch XPath expression and the absolute path indicated by the TAN. The SN corresponding to the scope path is connected by a link, and the PAN extracted from the branch XPath expression of the same extraction source and the SN corresponding to the scope path corresponding to the absolute path indicated by the PAN are connected by a link. The TAN and the PAN extracted from the same extraction source branch XPath expression are connected with a logical symbol representing a logical sum or logical product indicated by the same extraction source branch XPath expression, Construct one shared index from multiple branch XPath expressions,
The shared buffer management means constructs, for each TAN of the shared index, a shared buffer in which numbers are assigned in order according to the appearance order for each component of the input XML data. XML data for the range of the target path indicated by each TAN is stored in the shared buffer,
The XPath processing means is:
By parsing the input XML data with a SAX parser, a callback function is generated,
When the end of the scope path indicated by the SN of the shared index is notified by the callback function,
In the shared index, the authenticity determination of the predicate indicated by the PAN connected by a link from the notified SN is performed,
When the determination result of the PAN linked to the TAN is false for the TAN connected by a link from the PAN that has performed the authenticity determination of the previous description word, the scope indicated by the SN from the shared buffer of the TAN After deleting the XML data for the range of the path, and after determining the authenticity of the previous descriptive word for all the PANs connected by links from the notified SN, from the notified SN For all the TANs connected by the link, output the XML data for the range not deleted from the XML data for the range of the target path indicated by the TAN from the TAN shared buffer as a filtering result. Features.
これにより、フィルタリング処理を高速化しかつメモリ使用量を削減することができる。 As a result, the filtering process can be speeded up and the amount of memory used can be reduced.
本発明によれば、複数の分岐XPath式が入力される場合に、分岐XPath式に関する条件判断やコールバック呼び出しの回数を減らすように共有化インデックスを構築することによって、フィルタリングの高速化を行うことができる。 According to the present invention, when a plurality of branch XPath expressions are input, the speed of filtering is increased by constructing a shared index so as to reduce the number of conditional judgments and callback calls regarding the branch XPath expressions. Can do.
以下に、本発明が適用されるXPath式処理システムの一実施形態について、図面を参照して詳細に説明する。 Hereinafter, an embodiment of an XPath processing system to which the present invention is applied will be described in detail with reference to the drawings.
まず、本実施形態の概要を説明する。最初にXPath式に関する説明を行い、その後にXMLに関する説明を行う。 First, an outline of the present embodiment will be described. First, the XPath expression will be described, and then the XML will be described.
/bib/book[contains(title/text(),‘XML')][.//author=‘Bob'][publication<=1999] …式1
式1などのXPath式は、XML文書の中の特定の要素を指し示す記述方法を定めている。XPath式の基本的な記述の仕方はUNIX(登録商標)のファイルシステムに似ていて、文書木構造の頂点となるルートノードを「/」で表し、以下、「/」で区切って要素をたどっていく。a要素の中のbという値を参照するには「/a/b」と記述する。ノードのデータ型やノードの種類、名前空間(XML namespace)の扱いなどについても規定があり、これらを使用して条件式や演算などを含んだ複雑な位置指定を行うこともできる。
/bib/book[contains(title/text(),'XML')][.//author='Bob'][publication<=1999]…
An XPath expression such as
XML文書の中の特定の要素を指し示すパスは、絶対パス(Absolute Path)または相対パス(Comparative Path)の形式で表現される。絶対パスとは、ルートノードから記述されているようなXPath式である。絶対パスは、あるノードを指し示す上で完全な情報を持ったXPath式であり、絶対パスを用いることで検索対象ノードの等価性を完全に判断すること、つまり絶対パスと絶対パスとが同じか否かを判定することが可能となる。一方、相対パスは、ある着目するノード(コンテキストとも呼ばれる)から見た相対的な位置を示すパスである。 A path pointing to a specific element in the XML document is expressed in the form of an absolute path or a relative path. The absolute path is an XPath expression as described from the root node. An absolute path is an XPath expression that has complete information for pointing to a certain node, and that the absolute path is used to completely determine the equivalence of search target nodes, that is, whether the absolute path and the absolute path are the same. It becomes possible to determine whether or not. On the other hand, the relative path is a path indicating a relative position as viewed from a node of interest (also referred to as a context).
1つのXPath式からは、1つのターゲットパス(Target Path)および1つ以上の述語(Predicate)が抽出される。ターゲットパスは、分岐XPath式が条件を満たした場合に、返されるべきXMLの部分を示したパスである。ターゲットパスは、XPath式の括弧[…]で囲まれた部分を除く部分を抽出することにより得られる。 From one XPath expression, one target path (Target Path) and one or more predicates (Predicate) are extracted. The target path is a path indicating the portion of XML to be returned when the branch XPath expression satisfies the condition. The target path is obtained by extracting a portion excluding a portion surrounded by parentheses [...] in the XPath expression.
一方、述語は、XPath式中に存在する条件部であり、XPath式の括弧[…]で囲まれている。1つの述語は、1つの括弧[…]に対応する。なお、分岐XPath式は、述語を複数持ったXPath式である。なお、本実施形態は、後記するように、1つ以上の分岐XPath式を1つの共有化インデックスに変換することによって、分岐XPath式を高効率で処理することを特徴とする。 On the other hand, the predicate is a condition part existing in the XPath expression, and is enclosed in parentheses [...] of the XPath expression. One predicate corresponds to one parenthesis [...]. The branch XPath expression is an XPath expression having a plurality of predicates. The present embodiment is characterized in that the branch XPath expression is processed with high efficiency by converting one or more branch XPath expressions into one shared index, as will be described later.
次に、ターゲットパスおよび述語について、絶対パスおよびスコープパス(SP:Scope Path)を定義する。スコープパスは、述語の絶対パスやターゲットパスが有効であることを示すための絶対パスである。述語の絶対パスやターゲットパスがコールバック関数によって呼び出されたとしても、その時点で対応するスコープパスに含まれていない場合には、述語の絶対パスやターゲットパスの真偽判断、出力判断を行うことができない。
ターゲットパスの絶対パス(TAP:Target Absolute Path)は、前記したように、XPath式の括弧[…]で囲まれた部分を除く部分を抽出することにより得られる。ターゲットパスのスコープパス(TSP:Target Scope Path)は、XPath式の一番ルート側にある述語の前までの絶対パス、つまり、分岐XPath式の一番左にある述語のコンテキストパスとする。 As described above, the target path absolute path (TAP: Target Absolute Path) is obtained by extracting a portion excluding a portion surrounded by parentheses [...] Of the XPath expression. The target path scope path (TSP: Target Scope Path) is the absolute path up to the predicate on the most root side of the XPath expression, that is, the context path of the predicate on the leftmost side of the branch XPath expression.
述語の絶対パス(PAP:Predicate Absolute Path)は、述語に含まれるXPath式(述語の相対パス)と、後記する述語のスコープパスとを結合することにより、得られる。述語のスコープパス(PSP:Predicate Scope Path)は、コンテキストパスとすることで構築できる。コンテキストパスとは、述語内に含まれる相対パスで表現されたXPath式がどのような状況において有効であるかを示している。実際には、分岐XPath式の先頭からその述語までの分岐XPath式を解析、取得する。得られた分岐XPath式から述語を全て抜いたものがコンテキストパスとなる。 A predicate absolute path (PAP) is obtained by combining an XPath expression (relative path of a predicate) included in a predicate and a scope path of a predicate described later. A predicate scope path (PSP) can be constructed by using a context path. The context path indicates in which situation the XPath expression expressed by the relative path included in the predicate is effective. Actually, the branch XPath expression from the head of the branch XPath expression to the predicate is analyzed and acquired. A context path is obtained by removing all predicates from the obtained branch XPath expression.
次に、XMLおよびそのXMLに対してXPath式を適用するSAXベースのフィルタリング処理に関する説明を行う。なお、XMLの詳細については、例えば、文献「中山幹敏,奥井康弘著、“改訂版標準XML完全解説(上)(下)”、技術評論社(2001).」に詳しい。 Next, description will be made regarding XML and SAX-based filtering processing that applies an XPath expression to the XML. Details of XML are detailed in, for example, the literature “Mikitoshi Nakayama, Yasuhiro Okui,“ Revised Standard XML Complete Explanation (above) (below) ”, Technical Review (2001).”.
図1は、SAXフィルタとユーザアプリケーションとの関係を示す説明図である。まず、SAXのコールバック関数について説明する。SAXは、前記のように、XMLデータを解析するときに木を構成しない。よって、XMLデータの解析処理を行う際には、コールバック関数を用いた手法がとられている。 FIG. 1 is an explanatory diagram showing the relationship between the SAX filter and the user application. First, the SAX callback function will be described. As described above, SAX does not construct a tree when analyzing XML data. Therefore, a technique using a callback function is employed when performing XML data analysis processing.
SAXフィルタにXMLデータが入力されると、上から順に読み込まれる。bibが認識されると、SAX装置はユーザアプリケーション上にあるstartElement関数を呼び出す。この際、startElement関数の引数には、bibを入れておくことで、ユーザアプリケーション側ではbibという情報を取得することができる。このように、フィルタ装置がユーザアプリケーションの関数を呼び出すことをコールバックと呼ぶ。コールバック関数には、表3のようなものがある。
図2(a)は、XMLデータの一例を示している。文献用のXMLでありbibタグの下にbookタグがある。bookタグの下には、title(タイトル)タグ、author(著者)タグ、publication(発行年)タグ、price(価格)タグがある。このような、XMLに対して、発行年が1999年以前であり、タイトルにXMLを含み、著者がBobであるような条件に一致したbook要素を抽出するXPath式は、式1のように記すことができる。
FIG. 2A shows an example of XML data. It is XML for documents, and there is a book tag under the bib tag. Below the book tag, there are a title (title) tag, an author (author) tag, a publication (issue year) tag, and a price (price) tag. For such XML, an XPath expression that extracts a book element that matches the condition that the publication year is before 1999, the title includes XML, and the author is Bob is expressed as
図2(a)のXMLに式1のXPath式を適用した場合に期待される返値は、図2(b)に示したものとなる。注意してほしいのは、bookタグに含まれる部分が返されていることである。/bib/bookという記述が述語の条件を満たしたときに返されるタグ名を示している。この/bib/bookが前記したTAPである。それぞれの述語のPSPは、述語にいたるまでのパスをつなげたものであるので、/bib/bookとなる。
A return value expected when the XPath expression of
次に、式2について考える。
/bib/book[contains(title/text(),‘XPath')][publication=2000]/authors …式2
式2は、タイトルが「XPath」という文字列を含んでおり、発行年が2000年であるような本の著者を取得するというものである。このXPath式を図2(a)のXMLに適用させた場合の返値は、図2(c)のようになる。このときのTAPは、/bib/book/authorsとなる。PSPは、/bib/bookである。
Next, consider
/ bib / book [contains (title / text (), 'XPath')] [publication = 2000] / authors…
図3に示すXPath式処理システムは、XPath式登録装置110、パス抽出装置160、共有化インデックス構築装置150、共有化バッファ管理装置180、XPath式処理装置190、共有化インデックス検索装置140、および、分岐無XPath式処理装置200を含む。XPath式処理システムの記憶手段は、XPath式格納装置120のXPath式、入力される解析対象となるXMLデータ130、および、XMLデータ130から生成される共有化バッファ170を格納する。このXPath式処理システムを構成する計算機の台数は、図3に示す台数に限定されず、1台に集約するなど様々な構成を取ることができる。 The XPath type processing system shown in FIG. 3 includes an XPath type registration device 110, a path extraction device 160, a shared index construction device 150, a shared buffer management device 180, an XPath type processing device 190, a shared index search device 140, and A branchless XPath processing apparatus 200 is included. The storage unit of the XPath type processing system stores the XPath type of the XPath type storage device 120, the input XML data 130 to be analyzed, and the shared buffer 170 generated from the XML data 130. The number of computers constituting this XPath processing system is not limited to the number shown in FIG. 3, and various configurations such as a single unit can be adopted.
XPath式処理システムの各装置は、演算処理を行う際に用いられる記憶手段としてのメモリと、前記演算処理を行う演算処理装置とを少なくとも備えるコンピュータとして構成される。なお、メモリは、RAM(Random Access Memory)などにより構成される。演算処理は、CPU(Central Processing Unit)によって構成される演算処理装置が、メモリ上のプログラムを実行することで、実現される。以下、各装置の詳細を説明する。 Each device of the XPath processing system is configured as a computer including at least a memory serving as a storage unit used when performing arithmetic processing and an arithmetic processing device that performs the arithmetic processing. The memory is constituted by a RAM (Random Access Memory) or the like. Arithmetic processing is realized by an arithmetic processing unit configured by a CPU (Central Processing Unit) executing a program on a memory. Details of each device will be described below.
図3において、破線の矢印はデータフローを示す。XPath式処理システムにXMLデータ130が入力されると、XPath式処理装置190へ転送される。XPath式処理装置190では、入力されたXMLデータ130を分岐無XPath式処理装置200へ出力する。分岐無XPath式処理装置200によって、入力されたXMLデータ130が解析されて、共有化インデックス装置150において登録された分岐無XPath式に対する結果がXPath式処理装置190へ送られてくる。このとき、分岐無XPath式処理装置200は、SAXベースでXMLデータ130を処理するために、返値に対して順番をつけることが可能となる。 In FIG. 3, the dashed arrows indicate the data flow. When XML data 130 is input to the XPath processing system, it is transferred to the XPath processing device 190. The XPath processing device 190 outputs the input XML data 130 to the branchless XPath processing device 200. The branchless XPath processing device 200 analyzes the input XML data 130 and sends the result for the branchless XPath formula registered in the shared index device 150 to the XPath processing device 190. At this time, the branchless XPath processing device 200 can process the XML data 130 on an SAX basis, and can order the return values.
図3において、実線の矢印は機能呼び出し関係を示しており、利用するほうから利用されるほうへと向きを描いている。XPath式処理装置190は、分岐無XPath式処理装置200の結果を共有化バッファ管理装置180へ送る。このとき、コールバック関数を利用してデータを送ることになる。 In FIG. 3, the solid line arrows indicate the function call relationship, and the direction is drawn from the use to the use. The XPath processing device 190 sends the result of the branchless XPath processing device 200 to the shared buffer management device 180. At this time, data is sent using a callback function.
XPath式登録装置110は、入力された分岐XPath式をXPath式格納装置120に登録する。パス抽出装置160は、XPath式格納装置120を呼び出して分岐XPath式を取得し、その分岐XPath式から各パス(TAP,TSP,PAP,PSP)を抽出する。以下、パスの抽出処理を詳細に説明する。 The XPath type registration device 110 registers the input branch XPath type in the XPath type storage device 120. The path extraction device 160 calls the XPath expression storage device 120 to obtain a branch XPath expression, and extracts each path (TAP, TSP, PAP, PSP) from the branch XPath expression. Hereinafter, the path extraction process will be described in detail.
パス抽出装置160は、分岐XPath式をターゲットパスおよび述語に分解し、それぞれの絶対パス(AP)を構築する。パス抽出装置160は、分岐XPath式から述語を除きつなぎ合わせてTAPを構築し、分岐XPath式から述語を取り出して述語に含まれる相対パスおよび述語までのパスをつなぎ合わせてPAPを構築する。なお、構築された絶対パスは、分岐無しXPath式であるためそれ自体のフィルタ処理は、分岐無XPath式処理装置200を用いて行うことができる。 The path extraction device 160 decomposes the branch XPath expression into a target path and a predicate, and constructs each absolute path (AP). The path extraction device 160 constructs a TAP by concatenating predicates from the branch XPath expression, and constructs a PAP by extracting predicates from the branch XPath expression and concatenating relative paths included in the predicate and paths to the predicates. Since the constructed absolute path is a branchless XPath expression, the filter processing of itself can be performed by using the branchless XPath processing apparatus 200.
そして、パス抽出装置160は、TSPはターゲットパス自身とし、PSPは述語のコンテキストパスとすることで、それぞれSPを構築する。なお、述語のコンテキストパスとは、述語内に含まれる相対パスで表現されたXPath式がどのような状況において有効であるかを示している。実際には、分岐XPath式の先頭からその述語までの分岐XPath式を解析、取得する。得られた分岐XPath式から述語を全て抜いたものがコンテキストパスとなる。 Then, the path extraction device 160 constructs the SP by setting the TSP as the target path itself and the PSP as the context path of the predicate. The context path of the predicate indicates in what situation the XPath expression expressed by the relative path included in the predicate is effective. Actually, the branch XPath expression from the head of the branch XPath expression to the predicate is analyzed and acquired. A context path is obtained by removing all predicates from the obtained branch XPath expression.
なお、分岐XPath式の処理では、分岐無しXPath式の処理とは異なり、出力するか否かの判断が述語の真偽判定までできないので、出力の可能性のあるデータをバッファすることが必要になる。図4は、TANが持つバッファ構造の一例を示す説明図である。まず、入力されたストリームXMLの中で、出力される可能性のあるXMLデータ130を基本バッファへ格納する。複数の分岐XPath式に対して、それぞれがどのようなバッファを持つかについては、基本バッファヘの参照情報を用いて構築する。つまり、複数の分岐XPath式に対してただひとつのバッファ実体を持たせることを可能とし、メモリ使用量を抑えることが可能となる。 In branch XPath expression processing, unlike branchless XPath expression processing, it is not possible to determine whether or not to output until the predicate is true or false, so it is necessary to buffer data that may be output. Become. FIG. 4 is an explanatory diagram showing an example of the buffer structure of the TAN. First, XML data 130 that may be output in the input stream XML is stored in the basic buffer. For each of the plurality of branch XPath expressions, what kind of buffer each has is constructed using reference information to the basic buffer. That is, it is possible to have only one buffer entity for a plurality of branch XPath expressions, and to reduce the memory usage.
共有化インデックス構築装置150は、パス抽出装置160が抽出した各パスを用いて、共有化インデックスを構築する。共有化インデックスは、述語群の論理積や論理和、述語に対応する絶対パスをノードとし、それぞれのノード間の関係をリンクとするグラフである。共有化インデックスにおける分岐XPath式の述語は、分解された述語群の論理積や論理和を用いて表現されている。 The shared index construction device 150 constructs a shared index using each path extracted by the path extraction device 160. The shared index is a graph in which a logical product or logical sum of predicate groups, an absolute path corresponding to the predicate is a node, and a relationship between each node is a link. The predicate of the branch XPath expression in the shared index is expressed using the logical product or logical sum of the decomposed predicate group.
なお、共有化インデックスでは、複数の分岐XPath式から部分的に等しいノードやリンクが共有化される。複数の分岐XPath式が入力され、それぞれが共有化インデックスを持つ場合には、ストリームが入力された場合に同様の処理を行う場合が比較的多く存在する。同様の処理を行う部分を共有化、つまり、複数の分岐XPath式の共有化インデックスの共有化を行い、共有化インデックスを構築する。共有化インデックスを用いて、一括して複数の分岐XPath式を処理することが可能となる。 In the shared index, partially equal nodes and links are shared from a plurality of branch XPath expressions. When a plurality of branch XPath expressions are input and each has a shared index, there are relatively many cases where similar processing is performed when a stream is input. A part that performs the same processing is shared, that is, a plurality of branch XPath-type shared indexes are shared to construct a shared index. It is possible to process a plurality of branch XPath expressions at once using the shared index.
具体的には、共有化インデックス構築装置150は、複数の分岐XPath式が入力された場合に、まず、最初の分岐XPath式に対して共有化インデックスを構築する。次に、別の分岐XPath式は、パス抽出装置160と共有化インデックス構築装置150とによって解析される。このとき、共有化インデックス構築装置150は、最初の分岐XPath式の共有化インデックスに対して走査を行い、共有化インデックス中に別の分岐XPath式の共有化インデックスと同様の処理を行う部分がある場合には、最初の分岐XPath式の共有化インデックスを利用する。全ての分岐XPath式に対して順次このように共有化インデックスを構築する。以下、共有化インデックスを構成するノードを説明する。なお、分岐無XPath式処理装置200は、入力された各パスから後記する各ノードが保持する返値を出力する。
TAN(Target Absolute Node)は、TAPに対応するノードである。TSN(Target Scope Node)は、TSPに対応するノードである。PAN(Predicate Absolute Node)は、PAPに対応するノードである。PSN(Predicate Scope Node)は、PSPに対応するノードである。そして、絶対パスに対応するノード(AN:Absolute path Node)は、TANおよびPANであり、スコープパスに対応するノード(SN:Scope path Node)は、TSNおよびPSNである。なお、共有化インデックスは、前記したノードの他に、論理ノード(LN:Logical Node)を含めてもよい。なお、LNは、TAN、PAN、および、LNを論理演算子(and,or)によって結合するノードである。 TAN (Target Absolute Node) is a node corresponding to TAP. TSN (Target Scope Node) is a node corresponding to TSP. PAN (Predicate Absolute Node) is a node corresponding to PAP. PSN (Predicate Scope Node) is a node corresponding to PSP. Nodes corresponding to absolute paths (AN: Absolute path Node) are TAN and PAN, and nodes corresponding to scope paths (SN: Scope path Node) are TSN and PSN. The shared index may include a logical node (LN: Logical Node) in addition to the nodes described above. Note that LN is a node that connects TAN, PAN, and LN by logical operators (and, or).
ここで、一致する複数のパスの組(TAPおよびTSP)は、1つのノードの組(TANおよびTSN)に統合することができる。同様に、一致する複数のパスの組(PAPおよびPSP)は、1つのノードの組(PANおよびPSN)に統合することができる。さらに、パスが一致する複数のSP(TSPまたはPSP)は、1つのSNに統合することができる。これにより、パスの個数よりもノードの個数のほうが少なくなることが期待され、それに伴い述語のノードに関する比較回数およびTAP,PAPに対するコールバック関数の呼び出し回数も少なくなることが期待される。 Here, multiple pairs of matching paths (TAP and TSP) can be combined into one node pair (TAN and TSN). Similarly, multiple matching sets of paths (PAP and PSP) can be combined into a single set of nodes (PAN and PSN). Furthermore, multiple SPs (TSP or PSP) with matching paths can be integrated into one SN. As a result, it is expected that the number of nodes will be smaller than the number of paths, and accordingly, the number of comparisons related to the predicate node and the number of calls of the callback function for TAP and PAP are also expected to decrease.
共有化バッファ管理装置180は、分岐XPath式のターゲットパスに対して結果を構築する際に必要となるバッファを共有化した共有化バッファ170を構築する。つまり、共有化バッファ管理装置180は、入力されたXMLデータ130が分岐XPath式に適合する可能性がある場合に、1つの基本バッファを用意して入力XMLデータ130をバッファリングする。複数の分岐XPath式を処理する場合には、それぞれの分岐XPath式に関するバッファは実際のXMLデータ130を持たずに、基本バッファの区間アドレスを保持する。こうすることで、大きなバッファをそれぞれの分岐XPath式に対して用意する必要がなくなるため、メモリの使用量を軽減させることが可能となる。 The shared buffer management device 180 constructs a shared buffer 170 in which a buffer necessary for constructing a result for a branch XPath target path is shared. That is, the shared buffer management device 180 prepares one basic buffer and buffers the input XML data 130 when there is a possibility that the input XML data 130 may conform to the branch XPath expression. When a plurality of branch XPath expressions are processed, the buffer related to each branch XPath expression does not have the actual XML data 130 but holds the section address of the basic buffer. By doing so, it is not necessary to prepare a large buffer for each branch XPath expression, and the amount of memory used can be reduced.
XPath式処理装置190は、分岐XPath式のフィルタリング処理を行う。つまり、XPath式処理装置190は、分岐無XPath処理装置200からのコールバック関数を受けて、分岐XPath式のフィルタリング処理を行い、その結果を出力する。XPath式処理装置190は、共有化インデックス検索装置140および共有化バッファ管理装置180を利用する。具体的には、XPath式処理装置190は、入力されたXMLデータ130をSAXパーサおよびオートマトンを用いて処理し、コールバック関数を用いて実施されるスコープパスの終了が通知された直後に、ターゲットパスに対する述語の真偽判定を行い、複数の分岐XPath式を一括してフィルタリング処理する。 The XPath type processing device 190 performs a branching XPath type filtering process. That is, the XPath processing device 190 receives the callback function from the branchless XPath processing device 200, performs a branching XPath filtering process, and outputs the result. The XPath processing device 190 uses a shared index search device 140 and a shared buffer management device 180. Specifically, the XPath processing device 190 processes the input XML data 130 using a SAX parser and an automaton, and immediately after the end of the scope path implemented using the callback function is notified, A predicate for the path is determined to be true or false, and a plurality of branch XPath expressions are collectively filtered.
分岐無XPath式処理装置200は、既存技術のSAXベースのXPath式処理装置となっており(非特許文献1、非特許文献2参照)、ターゲットパスや述語、スコープパスの分岐無しXPath式を登録し、ストリームのXMLデータ130を入力するとコールバック関数を通じて、分岐無しXPath式に対する結果を返す。
The branchless XPath processing device 200 is an existing SAX-based XPath processing device (see
分岐無XPath式処理装置200は、次のような複数の分岐無しXPath式を高速に処理することができることが知られている。このXPathは、述語を含んでいないが、分岐XPath式を分解して登録することが可能である。SAXのコールバック関数による返値と述語の条件とを比較することで、分岐XPath式はストリームXMLデータ130が述語に適合するかどうかを決定することが可能となる。
/bib/book
/bib/book/title
/bib/book/publication
It is known that the branchless XPath processing apparatus 200 can process a plurality of branchless XPath expressions as follows. Although this XPath does not include a predicate, it is possible to decompose and register a branch XPath expression. By comparing the return value of the SAX callback function with the predicate condition, the branch XPath expression can determine whether the stream XML data 130 matches the predicate.
/ bib / book
/ bib / book / title
/ bib / book / publication
図5は、パス抽出装置によるパス抽出処理の実行例を示す説明図であり、式3〜式5のXPath式が入力されたときの出力を示している。それぞれの分岐XPath式に対して、結果が出力される。
/bib/book[price<=21OO][publication<=2000]/authors[author='Bob'] …式3
/bib/book[price<=21OO][publication<=2000]/authors/author …式4
/bib[book/price=21OO][book/publication<=2000]/book/authors/author …式5
式3に対しては、まず、分岐XPath式から全ての述語を抜いた後記のようなXPath式をTAPとする。
/bib/book/authors
FIG. 5 is an explanatory diagram showing an execution example of the path extraction processing by the path extraction device, and shows an output when the XPath expressions of
/ bib / book [price <= 21OO] [publication <= 2000] / authors [author = 'Bob']…
/ bib / book [price <= 21OO] [publication <= 2000] / authors / author…
/ bib [book / price = 21OO] [book / publication <= 2000] / book / authors / author…
For
/ bib / book / authors
次に、一番ルート側にある述語
[price<=2100]
の前までのXPath式をTSPとする。次に、後記の全ての述語について考える。
[price<=2100]
[publication<=2000]
[author='Bob']
それぞれ、述語が出現する直前までのXPath式は、
/bib/book
/bib/book
/bib/book/authors
となり、それぞれのPSP(=コンテキストパス)とする。述語の相対パスは、後記のようになる。
price
publication
author
Next, the predicate at the root side
[price <= 2100]
Let the XPath expression up to be TSP. Next, consider all the predicates described below.
[price <= 2100]
[publication <= 2000]
[author = 'Bob']
Each XPath expression until just before the predicate appears is
/ bib / book
/ bib / book
/ bib / book / authors
And each PSP (= context path). The relative path of the predicate is as follows.
price
publication
author
前記の相対パスとスコープパスを結合したXPath式が後記のようなPAPとなる。
/bib/book/price
/bib/book/publication
/bib/book/authors/author
An XPath expression obtained by combining the relative path and the scope path is a PAP as described later.
/ bib / book / price
/ bib / book / publication
/ bib / book / authors / author
式4に関しては、式3とほぼ同様であるため、省略する。式5に対しても同様に、まず、分岐XPath式から全ての述語を抜いた次のようなXPath式をTAPとする。
/bib/book/authors/author
次に、一番ルート側にある述語
[book/price=2100]
の前までのXPath式をTSPとする。つまり、
/bib
となる。
/ bib / book / authors / author
Next, the predicate at the root side
[book / price = 2100]
Let the XPath expression up to be TSP. That means
/ bib
It becomes.
次に、次の全ての述語について考える。
[book/price=2100]
[book/publication<=2000]
それぞれ、述語が出現する直前までのXPath式は、
/bib
/bib
となり、それぞれのPSP(=コンテキストパス)とする。述語の相対パスは、次のようになる。
book/price
book/publication
Next, consider all the following predicates:
[book / price = 2100]
[book / publication <= 2000]
Each XPath expression until just before the predicate appears is
/ bib
/ bib
And each PSP (= context path). The relative path of the predicate is as follows:
book / price
book / publication
前記の相対パスとスコープパスを結合したXPath式が次のようなPAPとなる。
/bib/book/price
/bib/book/publication
/bib/book/authors/author
式3および式5のPAPは等しいが、PSPが変わっていることに注意してほしい。
The XPath expression combining the relative path and the scope path is the following PAP.
/ bib / book / price
/ bib / book / publication
/ bib / book / authors / author
Note that the PAPs in
図6は、共有化インデックスの構築処理の実行例を示す説明図である。図6には、2つのXPath式(式3、式4)から共有化インデックスを構築した場合の模式図を示している。四角の枠は、TAN(TAN1,TAN2)、PAN(PAN1,PAN2,PAN3)(述語の条件部も共有化のためにノードとして表現している)、SN(SN1,SN2)、LN(LN1,LN2)を示している。また、ノード間をつなぐ線は、2つのノードがリンクされていることを示している。LN1はノード「<=2100」およびノード「<=2000」の親ノードに相当し、LN2はLN1の親ノードに相当する。
FIG. 6 is an explanatory diagram illustrating an execution example of a shared index construction process. FIG. 6 shows a schematic diagram when a shared index is constructed from two XPath expressions (
注目してほしいことは、式3および式4において、[price<=2100][publication<=2000]の条件判断を共有化していることである。具体例においては、簡単のため2つのXPath式のみを挙げているが、実用上登録されるXPath式は、数万〜数十万単位で登録される。よって、このように処理が同じである場合には、それを1つに統合することにより共有化を図ることができる。また、共有化インデックスを利用しない場合には、同じ意味を持ったインデックスを重複して作成することになるため、不必要なメモリを使うことになる。つまり、共有化インデックスを用いると使用メモリ量の削減を図ることができる。
What should be noted is that, in
表5は、共有化バッファ170の構築処理の実行例を示す説明図である。コールバック関数によって呼び出される順番が、カウンタ列に入っている数字に対応する。このカウンタ列に入っている数字は、共有化バッファ170におけるインデックスを示しており、この数字を利用することで、各XPath式に対するバッファを行うことが可能となる。XMLデータ130の格納個数がXPath式の数となっていた方式に比べ、XPath式の数に関係なく1つの共有化バッファ170を格納するだけで済む。
図4は、TANが持つバッファ構造の一例を示す説明図である。バッファは、(start、end)という区間を表現する形で積み上げていく。バッファする区間は、述語に影響を受け複数持つべき場合があるので、図4のようにスタックを用いて管理する。1つ目の<book>が出現したときのカウンタは、2である。1つ目の</book>が出現するのは、23である。2つ目の<book>が出現したときのカウンタは、24である。2つ目の</book>が出現するのは、42である。このようにして、出力するべきバッファを共有化バッファ170のアドレスとして保持することで、バッファ処理にかかるメモリ使用量を大幅に削減することが可能となる。 FIG. 4 is an explanatory diagram showing an example of the buffer structure of the TAN. The buffer is stacked in a form that represents the interval (start, end). Since there are cases where a plurality of sections to be buffered should be influenced by the predicate, they are managed using a stack as shown in FIG. The counter when the first <book> appears is 2. The first </ book> appears at 23. The counter when the second <book> appears is 24. The second </ book> appears at 42. In this way, holding the buffer to be output as the address of the shared buffer 170 makes it possible to greatly reduce the amount of memory used for buffer processing.
図7は、後記するフィルタリング処理のサブルーチン「PAN処理」の実行例を示す説明図である。この説明図は、図6で示されている共有化インデックスに対して、図2(b)のXMLデータ130が入力されたときを想定する。図8は、後記するフィルタリング処理のサブルーチン「SN処理」の実行例を示す説明図である。この説明図は、図2(a)のXMLデータ130に対して実行した一例を示す。 FIG. 7 is an explanatory diagram showing an execution example of a subroutine “PAN process” of the filtering process described later. This explanatory diagram assumes that the XML data 130 of FIG. 2B is input to the shared index shown in FIG. FIG. 8 is an explanatory diagram showing an execution example of a subroutine “SN process” of the filtering process described later. This explanatory diagram shows an example executed for the XML data 130 of FIG.
図9は、分岐XPath式を分割しターゲットパスおよび述語の絶対パスおよびそれぞれのスコープパスの構築処理を示すフローチャートである。3つのXPath式(式3、式4、式5)を考える。以下では、これらのXPath式をもとにして説明を行う。
FIG. 9 is a flowchart showing the process of building the target path, the absolute path of the predicate, and each scope path by dividing the branch XPath expression. Consider three XPath equations (
まず、パス抽出装置160は、複数の分岐XPath式を入力し(S102)、全てのXPath式を処理したなら(S104,Yes)、処理を終了する(S106)。つまり、入力された分岐XPath式の数だけ、それぞれの分岐XPath式に対応する変数P,変数Tの組み合わせを出力する。 First, the path extraction device 160 inputs a plurality of branch XPath expressions (S102), and if all the XPath expressions are processed (S104, Yes), the process ends (S106). That is, combinations of variables P and T corresponding to each branch XPath expression are output as many as the number of input branch XPath expressions.
次に、パス抽出装置160は、全てのXPath式を処理していないなら(S104,No)、分岐XPath式のPAPおよびPSPを格納できる変数P、ならびに、TAPおよびTSPを格納できる変数Tを、分岐XPath式1つに対して1つずつ用意する(S108)。分岐XPath式から述語を全て抜いたものをTAPとして変数Tに追加し(S110)、分岐XPath式のルートから見て、一番最初に出現した述語までのコンテキストパスをTSPとして、変数Tに追加する(S112)。 Next, if all the XPath expressions are not processed (S104, No), the path extraction device 160 stores the variable P that can store the PAP and PSP of the branch XPath expression and the variable T that can store the TAP and TSP. One for each branch XPath expression is prepared (S108). Add all predicates from the branch XPath expression to the variable T as TAP (S110), and add to the variable T as the TSP the context path to the predicate that appears first from the root of the branch XPath expression. (S112).
そして、パス抽出装置160は、全ての述語を処理していないなら(S114,No)、選択されている述語についてのPAPおよびPSPを変数Pに追加する(S116)。具体的には、述語までの分岐XPath式から全ての述語を抜いたものをPSPとして変数Pに追加し、PSPと述語に含まれている相対パスを単純に結合したパスをPAPとして、変数Pに追加する。全ての述語を処理したなら(S114,Yes)、処理をS104に戻す。 If all the predicates are not processed (S114, No), the path extracting device 160 adds the PAP and PSP for the selected predicate to the variable P (S116). Specifically, the one obtained by removing all predicates from the branch XPath expression up to the predicate is added as a PSP to the variable P, and the path simply combining the relative path included in the PSP and the predicate is defined as the PAP. Add to If all the predicates have been processed (S114, Yes), the process returns to S104.
図10および図11は、共有化インデックスの構築処理を示すフローチャートである。共有化インデックスにおいて、そのノードは、共有化インデックスをグラフ構造で表したときの節点として定義される。共有化インデックスのリンクは、ノード間をエッジ(辺)で結合したものである。述語が複数存在する場合には、それらの述語はandまたはorで結合される。LNとは、この述語の結合を表現するために用いることができる。 10 and 11 are flowcharts showing the shared index construction process. In the shared index, the node is defined as a node when the shared index is represented by a graph structure. A shared index link is obtained by connecting nodes with edges. When there are a plurality of predicates, these predicates are combined with and or or. LN can be used to express this combination of predicates.
まず、共有化インデックス構築装置150は、全ての分岐XPath式について、分岐XPath式から抽出される各パス(TAP,TSP,PAP,PSP)を入力し(S202)、全ての分岐XPath式を処理したなら(S204,Yes)、その時点で構築されている共有化インデックスを出力して、終了する(S206)。 First, the shared index construction device 150 inputs each path (TAP, TSP, PAP, PSP) extracted from the branch XPath expression for all branch XPath expressions (S202), and processes all the branch XPath expressions. If so (S204, Yes), the shared index constructed at that time is output, and the process ends (S206).
次に、共有化インデックス構築装置150は、全ての分岐XPath式を処理していないなら(S204,No)、TAPからTANを作成し(S208)、TANとリンクするTSNが共有化インデックスに存在しないなら(S210,No)、TSNを作成する(S212)。なお、TANは、分岐XPath式に含まれる全ての述語について、LNを用いた木構造により、述語の持つ条件を判断しバッファの出力を行うものである。 Next, if all the branch XPath expressions are not processed (S204, No), the shared index construction apparatus 150 creates a TAN from the TAP (S208), and there is no TSN linked to the TAN in the shared index. If so (S210, No), a TSN is created (S212). Note that TAN determines the conditions of the predicate for all predicates included in the branch XPath expression by a tree structure using LN and outputs the buffer.
そして、共有化インデックス構築装置150は、TANとTSNとをリンクし(S214)、LNを保持するための変数Pを用意する(S216)。変数Pは、1つのLNをルートとして持つような木構造を構築するために利用される。 The shared index construction device 150 links TAN and TSN (S214), and prepares a variable P for holding LN (S216). The variable P is used to construct a tree structure having one LN as a root.
さらに、共有化インデックス構築装置150は、変数Pに含まれるのは、ただ1つのLNなら(図11のS218,Yes)、その1つのLNをルートとして持つような木構造を構築できたことになり、LNとTANとをリンクし(図10のS220)、処理をS204に戻す。これにより、1つの分岐XPath式を共有化インデックスへ組み込むことができたことになる。 Furthermore, if the shared index construction device 150 includes only one LN in the variable P (S218, Yes in FIG. 11), it can construct a tree structure having that one LN as a root. Thus, LN and TAN are linked (S220 in FIG. 10), and the process returns to S204. As a result, one branch XPath expression can be incorporated into the shared index.
そして、共有化インデックス構築装置150は、変数Pに含まれるのがただ1つのLNでないとき(図11のS218,No)、選択された分岐XPath式の全ての述語に対して処理が完了しておらず(S222,No)、PANが存在しないなら(S224,No)、PANを作成し、変数Pに追加する(S226)。 When the shared index construction apparatus 150 does not include only one LN in the variable P (S218, No in FIG. 11), the processing is completed for all the predicates of the selected branch XPath expression. If no PAN exists (S224, No), a PAN is created and added to the variable P (S226).
さらに、共有化インデックス構築装置150は、PSNが存在しないなら(S228,No)、PSNを作成する(S230)。そして、共有化インデックス構築装置150は、PSNとPANとをリンクし(S232)、処理をS218に戻す。 Furthermore, if the PSN does not exist (S228, No), the shared index construction apparatus 150 creates a PSN (S230). Then, the shared index construction device 150 links the PSN and the PAN (S232), and returns the process to S218.
そして、共有化インデックス構築装置150は、S222またはS224の条件を満たし、既に存在する共有化インデックス中に同じLNを持つ述語が存在しないなら(S234,No)、変数Pに新たに作成したPANを追加し(S236)、処理をS218に戻す。新たに作成したPANは、論理演算子と、PANと、変数Pに含まれるPANまたはLNから任意にひとつ選択したノードと、を格納するノードである。一方、述語が存在するなら(S234,Yes)、存在したLNを変数Pに追加し、そのLNに格納されているLNおよびPANを変数Pから削除し(S238)、処理をS218に戻す。 Then, the shared index construction device 150 satisfies the condition of S222 or S224, and if there is no predicate having the same LN in the existing shared index (S234, No), the newly created PAN is stored in the variable P. Add (S236), and return the process to S218. The newly created PAN is a node that stores a logical operator, a PAN, and a node arbitrarily selected from PAN or LN included in the variable P. On the other hand, if there is a predicate (S234, Yes), the existing LN is added to the variable P, the LN and PAN stored in the LN are deleted from the variable P (S238), and the process returns to S218.
図12は、共有化バッファ170の構築処理を示すフローチャートである。 FIG. 12 is a flowchart showing the construction process of the shared buffer 170.
まず、共有化バッファ管理装置180は、分岐無XPath式処理装置200のコールバックにより(S302)、処理が起動される。次に、共有化バッファ管理装置180は、endDocument()の呼び出しにより(S304,Yes)、終了する(S322)。 First, the shared buffer management device 180 is activated by the callback of the branchless XPath processing device 200 (S302). Next, the shared buffer management device 180 terminates by calling endDocument () (S304, Yes) (S322).
そして、共有化バッファ管理装置180は、endDocument()の呼び出しではなく(S304,No)、新しいXMLドキュメントが入力された場合には、startDocument()の呼び出しにより(S306,Yes)、バッファの順番を示すカウンタ変数Cを用意し、C=0で初期化する(S308)。 Then, the shared buffer management device 180 does not call endDocument () (S304, No). When a new XML document is input, the shared buffer management device 180 changes the buffer order by calling startDocument () (S306, Yes). A counter variable C is prepared and initialized with C = 0 (S308).
さらに、共有化バッファ管理装置180は、startDocument()の呼び出しではなく(S306,No)、startElement(var)の呼び出しにより(S310,Yes)、カウンタCをインクリメントし、カウンタCおよび引数varで与えられたデータの組を共有化バッファ170に追加する(S312)。 Further, the shared buffer management device 180 increments the counter C by calling startElement (var) (S310, Yes) instead of calling startDocument () (S306, No), and is given by the counter C and the argument var. The data set is added to the shared buffer 170 (S312).
そして、共有化バッファ管理装置180は、startElement(var)の呼び出しではなく(S310,No)、endElement(var)の呼び出しにより(S314,Yes)、カウンタCをインクリメントし、カウンタCおよび引数varで与えられたデータの組を共有化バッファ170に追加する(S316)。 Then, the shared buffer management device 180 increments the counter C by calling endElement (var) (S314, No) instead of calling startElement (var) (S314, No), and gives the counter C and the argument var. The obtained data set is added to the shared buffer 170 (S316).
さらに、共有化バッファ管理装置180は、endElement(var)の呼び出しではなく(S314,No)、character(var)の呼び出しにより(S318,Yes)、カウンタCをインクリメントし、カウンタCおよび引数varで与えられたデータの組を共有化バッファ170に追加する(S320)。character(var)の呼び出しではないときは(S318,No)、処理をS302に戻す。 Further, the shared buffer management device 180 increments the counter C by calling character (var) (S318, Yes) instead of calling endElement (var) (S314, No), and gives it by the counter C and the argument var. The set of data is added to the shared buffer 170 (S320). If it is not a call for character (var) (S318, No), the process returns to S302.
図13は、共有化インデックスと共有化バッファ170を用いてフィルタリングする処理を示すフローチャートである。 FIG. 13 is a flowchart showing processing for filtering using the shared index and shared buffer 170.
まず、共有化インデックス検索装置140は、分岐無XPath式処理装置200のコールバックにより(S402)、処理が起動され、全てのコールバックを処理したなら(S404,Yes)、終了する(S406)。XPath式処理装置190は、共有化バッファ管理装置180と同様に、コールバック関数を利用して分岐無XPath式処理装置200の処理結果を受け渡す。 First, the shared index search device 140 is activated by the callback of the branchless XPath processing device 200 (S402) and has processed all callbacks (S404, Yes), and ends (S406). Similar to the shared buffer management device 180, the XPath processing device 190 passes the processing result of the branchless XPath processing device 200 using a callback function.
次に、共有化インデックス検索装置140は、全てのコールバックを処理していないとき(S404,No)、コールバックに対して、全TANを処理していないなら(S408,No)、未処理であるTANを引数として、サブルーチン「TAN処理」を実行する(S410)。 Next, when the shared index search device 140 has not processed all the callbacks (S404, No), if it has not processed all TANs for the callback (S408, No), it is unprocessed. The subroutine “TAN processing” is executed with a certain TAN as an argument (S410).
そして、共有化インデックス検索装置140は、全TANを処理し(S408,Yes)、コールバックに対して、全PANを処理していないなら(S412,No)、未処理であるPANを引数として、サブルーチン「PAN処理」を実行する(S414)。 Then, the shared index search device 140 processes all TANs (S408, Yes). If all PANs are not processed for the callback (S412, No), the unprocessed PAN is used as an argument. The subroutine “PAN process” is executed (S414).
さらに、共有化インデックス検索装置140は、全PANを処理し(S412,Yes)、コールバックに対して、全SNを処理していないなら(S416,No)、未処理であるSNを引数として、サブルーチン「SN処理」を実行する(S418)。全SNを処理したなら(S416,Yes)、処理をS404に戻す。 Furthermore, the shared index search device 140 processes all PANs (S412, Yes), and if not all SNs are processed for the callback (S416, No), the unprocessed SN is used as an argument. The subroutine “SN process” is executed (S418). If all the SNs have been processed (S416, Yes), the process returns to S404.
図14は、サブルーチン「TAN処理」を示すフローチャートである。 FIG. 14 is a flowchart showing a subroutine “TAN process”.
まず、共有化インデックス検索装置140は、分岐無XPath式処理装置200のコールバックにより(S502)、処理が起動され、全てのコールバック関数呼び出しが終了したなら(S504,Yes)、終了する(S506)。 First, the shared index search device 140 is activated when the callback of the branchless XPath processing device 200 is called back (S502), and when all the callback function calls are completed (S504, Yes), the processing ends (S506). ).
次に、共有化インデックス検索装置140は、全てのコールバック関数呼び出しが終了していないなら(S504,No)、startDocument()の呼び出しにより(S508,Yes)、カウンタCを用意してC=0で初期化する(S510)。 Next, if all the callback function calls have not been completed (S504, No), the shared index search device 140 prepares a counter C by calling startDocument () (S508, C = 0). (S510).
そして、共有化インデックス検索装置140は、startDocument()の呼び出しではなく(S508,No)、startElement(var)の呼び出しにより(S512,Yes)、カウンタCをインクリメントする(S514)。さらに、共有化インデックス検索装置140は、startElement(var)の呼び出しではなく(S512,No)、endElement(var)の呼び出しにより(S516,Yes)、カウンタCをインクリメントする(S518)。そして、共有化インデックス検索装置140は、endElement(var)の呼び出しではなく(S516,No)、character(var)の呼び出しにより(S520,Yes)、カウンタCをインクリメントする(S522)。 Then, the shared index search device 140 increments the counter C by calling startElement (var) (S512, Yes) instead of calling startDocument () (S508, No) (S514). Furthermore, the shared index search device 140 increments the counter C by calling endElement (var) (S516, Yes) instead of calling startElement (var) (S512, No) (S518). Then, the shared index search device 140 increments the counter C by calling character (var) (S520, Yes) instead of calling endElement (var) (S516, No) (S522).
なお、startElement、endElement、character関数では、共有化バッファ管理装置180と同じカウンタ値を持たせるために変数Cに対するインクリメントを行っている。これにより、該当するXPath式のバッファを行うにあたって、共有化バッファ170の持つカウンタ値を持ってバッファリングすることが可能となる。 In the startElement, endElement, and character functions, the variable C is incremented to have the same counter value as the shared buffer management device 180. As a result, when performing the corresponding XPath buffer, it is possible to perform buffering with the counter value of the shared buffer 170.
さらに、共有化インデックス検索装置140は、character(var)の呼び出しではなく(S520,No)、startContext()の呼び出しにより(S524,Yes)、バッファを追加し、スタートアドレスにカウンタCの値+1を代入する(S526)。 Furthermore, the shared index search device 140 adds a buffer not by calling character (var) (S520, No) but by calling startContext () (S524, Yes), and adds the value of the counter C to the start address + 1. Is substituted (S526).
そして、共有化インデックス検索装置140は、startContext()の呼び出しではなく(S524,No)、endContext()の呼び出しにより(S528,Yes)、バッファのエンドアドレスにカウンタCの値を代入する(S530)。このときは、endContext関数が呼び出されたときのカウンタの値までバッファすることになる。endContext()の呼び出しではないなら(S528,No)、処理をS502に戻す。 Then, the shared index search device 140 substitutes the value of the counter C for the end address of the buffer (S530) by calling endContext () instead of calling startContext () (S524, No) (S530). . In this case, the counter value is buffered when the endContext function is called. If it is not a call to endContext () (S528, No), the process returns to S502.
図15は、サブルーチン「PAN処理」を示すフローチャートである。ここでは、共有化インデックスを用いて、述語の条件に適合している分岐XPath式が何であるかを決定していく。 FIG. 15 is a flowchart showing a subroutine “PAN process”. Here, the shared index is used to determine what the branch XPath expression is suitable for the predicate condition.
まず、共有化インデックス検索装置140は、分岐無XPath式処理装置200のコールバックにより(S602)、処理が起動され、全てのコールバック関数呼び出しが終了したなら(S604,Yes)、終了する(S606)。 First, the shared index search device 140 is activated when the callback of the branchless XPath processing device 200 is called back (S602) and all the callback function calls are finished (S604, Yes), and is finished (S606). ).
次に、共有化インデックス検索装置140は、全てのコールバック関数呼び出しが終了しておらず(S604,No)、character(var)の呼び出しでなく(S608,No)、startContext()の呼び出しなら(S610,Yes)、述語の持つ条件を検査することを示すフラグEVALにtureをセットする(S612)。PANが分岐無XPath式処理装置200から、startContext、endContext関数を通じて呼び出された場合には、条件を評価するかどうかを決定する。startContextでは、述語の絶対パスが評価されるべき区間に入ったことを示している。 Next, the shared index search device 140 has not finished calling all the callback functions (S604, No), is not calling character (var) (S608, No), and is calling startContext () ( S610, Yes), “ture” is set to the flag EVAL indicating that the condition of the predicate is to be checked (S612). When the PAN is called from the branchless XPath processing device 200 through the startContext and endContext functions, it is determined whether or not the condition is to be evaluated. startContext indicates that the absolute path of the predicate has entered an interval to be evaluated.
そして、共有化インデックス検索装置140は、startContext()の呼び出しでなく(S610,No)、endContext()の呼び出しにより(S614,Yes)、述語の持つ条件を検査することを示すフラグEVALにfalseをセットする(S616)。endContextでは、述語の絶対パスが評価されるべき区間から外れたことを示している。それぞれの状態をEVALフラグによって表す。処理をS604に戻す。 Then, the shared index search device 140 sets false to the flag EVAL indicating that the condition of the predicate is to be checked by calling endContext () (S614, Yes) instead of calling startContext () (S610, No). Set (S616). endContext indicates that the absolute path of the predicate is out of the interval to be evaluated. Each state is represented by an EVAL flag. The process returns to S604.
さらに、共有化インデックス検索装置140は、character(var)の呼び出しがあり(S608,Yes)、EVAL=false(S618,Yes)またはPANが持つ全ての条件を処理した(S620,Yes)なら処理をS604に戻し、EVAL=falseでなく(S618,No)、PANが持つ全ての条件を処理していないなら(S620,No)、以下の処理を行う。 Further, the shared index search device 140 calls character (var) (S608, Yes), and if EVAL = false (S618, Yes) or all conditions of the PAN are processed (S620, Yes), the process is performed. Returning to S604, if EVAL = false (S618, No) and all the conditions of the PAN have not been processed (S620, No), the following processing is performed.
つまり、共有化インデックス検索装置140は、条件を満たすcharacter関数の引数varが述語ノードの条件を満たしているかどうかを評価し(S622)、条件を満たしていない(S622,No)なら、条件を満たしていないノードの親ノードヘリンクを通じて条件を満たしていないことを通知し(S624)、通知された親ノードは、その通知により自分の状態が変化した場合には、さらに上位の親ノードヘ通知を行う。一方、条件を満たしている(S622,Yes)なら、条件を満たしたノードの親ノード(演算子ノード)ヘリンクを通じて条件を満たしたこと(条件部が真であること)を通知し(S626)、通知された側の親ノードは、さらに親ノードヘと通知を行う。S618に処理を戻す。 That is, the shared index search device 140 evaluates whether the argument var of the character function that satisfies the condition satisfies the predicate node condition (S622). If the condition is not satisfied (S622, No), the condition is satisfied. Notify the condition that the condition is not satisfied through the link to the parent node of the node that has not been notified (S624), and if the notified parent node changes its state, the notification is sent to a higher-order parent node. . On the other hand, if the condition is satisfied (S622, Yes), the fact that the condition is satisfied (the condition part is true) is notified through the parent node (operator node) of the node that satisfies the condition (S626), The notified parent node further notifies the parent node. The process returns to S618.
図16は、サブルーチン「SN処理」を示すフローチャートである。具体的には、スコープパスを用いて、ターゲットパスの出力管理、述語の評価が偽である場合のターゲットパスのノードに格納されているバッファからの削除、共有化インデックスの保持情報クリアを行うためのフローチャートが示されている。簡単のため、次の分岐XPath式を考える。
/bib/book[price<=2100][publication<=2000]/authors/author
複数の分岐XPath式がある場合においても、それぞれの分岐XPath式に対して、共有化インデックスと共有化バッファ170とを用いて同様に処理することが可能となる。
FIG. 16 is a flowchart showing a subroutine “SN process”. Specifically, to use the scope path to perform output management of the target path, deletion from the buffer stored in the target path node when the predicate evaluation is false, and clearing the shared index holding information The flowchart of is shown. For simplicity, consider the following branch XPath expression.
/ bib / book [price <= 2100] [publication <= 2000] / authors / author
Even when there are a plurality of branch XPath expressions, it is possible to perform the same processing for each branch XPath expression using the shared index and the shared buffer 170.
まず、共有化インデックス検索装置140は、分岐無XPath式処理装置200のコールバックにより(S702)、処理が起動され、全てのコールバック関数呼び出しが終了したなら(S704,Yes)、終了する(S706)。 First, the shared index search device 140 is started when the callback of the branchless XPath processing device 200 is called back (S702) and all the callback function calls are finished (S704, Yes), and is finished (S706). ).
次に、共有化インデックス検索装置140は、全てのコールバック関数呼び出しが終了していないなら(S704,No)、startDocument()の呼び出しにより(S708,Yes)、カウンタCを用意し,C=Oで初期化する(S710)。カウンタCは、共有化バッファ170のカウンタを利用するために処理される。また、スコープの区間を表現するstart,end変数を用意し、0で初期化する。 Next, if all the callback function calls have not ended (S704, No), the shared index search device 140 prepares a counter C by calling startDocument () (S708, Yes), and C = O (S710). Counter C is processed to use the counter of shared buffer 170. In addition, start and end variables representing the scope section are prepared and initialized with 0.
そして、共有化インデックス検索装置140は、startDocument()の呼び出しではなく(S708,No)、startElement(var)の呼び出しにより(S712,Yes)、カウンタCをインクリメントする(S714)。さらに、共有化インデックス検索装置140は、startElement(var)の呼び出しではなく(S712,No)、endElement(var)の呼び出しにより(S716,Yes)、カウンタCをインクリメントする(S718)。そして、共有化インデックス検索装置140は、endElement(var)の呼び出しではなく(S716,No)、character(var)の呼び出しにより(S720,Yes)、カウンタCをインクリメントする(S722)。 Then, the shared index search device 140 increments the counter C by calling startElement (var) (S712, Yes) instead of calling startDocument () (S708, No) (S714). Furthermore, the shared index search device 140 increments the counter C by calling endElement (var) (S716, Yes) instead of calling startElement (var) (S712, No) (S718). The shared index search device 140 increments the counter C by calling character (var) (S720, Yes) instead of calling endElement (var) (S716, No) (S722).
さらに、共有化インデックス検索装置140は、character(var)の呼び出しではなく(S720,No)、startContext()の呼び出しにより(S724,Yes)、startにC+1を代入する(S726)。そして、共有化インデックス検索装置140は、startContext()の呼び出しではなく(S724,No)、endContext()の呼び出しにより(S728,Yes)、endにCを代入する(S730)。startContextとendContext関数が呼び出されると、まず、スコープの範囲を決定することができて、それを変数startとendにセットする。endContext()の呼び出しではないときは(S728,No)、処理をS702に戻す。 Further, the shared index search device 140 substitutes C + 1 for start (S726) by calling startContext () instead of calling character (var) (S720, No) (S726). The shared index search device 140 substitutes C for end (S730) by calling endContext () instead of calling startContext () (S724, No) (S730). When the startContext and endContext functions are called, you can first determine the scope range and set it to the variables start and end. If it is not a call to endContext () (S728, No), the process returns to S702.
さらに、共有化インデックス検索装置140は、SNにリンクする全てのPANに対して処理しておらず(S732,No)、SNとリンクする全てのPANの持つ条件が偽である場合には、この述語を条件として持つ全てのTANのバッファからstartアドレス、endアドレスに含まれるバッファを全てクリアし(S734)、述語ノードとそれに関連する演算子ノードを偽にセットする。 Furthermore, the shared index search device 140 does not process all PANs linked to the SN (S732, No), and if the condition of all PANs linked to the SN is false, this All the buffers included in the start address and end address are cleared from all TAN buffers having predicates as conditions (S734), and the predicate node and its associated operator node are set to false.
そして、共有化インデックス検索装置140は、SNにリンクする全てのPANに対して処理し(S732,Yes)、TSNにリンクする全てのTANに対して処理していないなら(S736,No)、SNとリンクする全てのTANがバッファリングしている共有化バッファ170の区間(start、end)を出力し(S738)、TANにリンクする全てのPANおよびLNを偽にセットする。TSNにリンクする全てのTANに対して処理したなら(S736,No)、処理をS702に戻す。 Then, the shared index search device 140 processes all PANs linked to SN (S732, Yes), and does not process all TANs linked to TSN (S736, No). The section (start, end) of the shared buffer 170 in which all TANs linked to the TAN are buffered is output (S738), and all PANs and LNs linked to the TANs are set to false. If all TANs linked to the TSN have been processed (S736, No), the process returns to S702.
以上説明した本発明と、以下に示す比較例とを比較する。 The present invention described above is compared with the following comparative examples.
図17は、比較例に関するXPath式から作成されるオートマトンを示す状態遷移図である。既存のSAXベースの複数のXPath式処理装置190(非特許文献3参照)は、式6のようなXPath式が与えられたときに、図17のようなオートマトンを作成する。
/bib/book[contains(title/text(),‘XML')][publication>=1999 and publication<=2000] …式6
オートマトンとは、状態遷移図のようなものである。丸で示されているのは状態であり、矢印に付随して書いてあるのは状態が移るための条件である。状態0は、初期状態を示している。状態0から状態1に移るためには、bib要素がくることが必要である。状態1から状態2へ行くためには、状態1においてbook要素がくることが必要である。
FIG. 17 is a state transition diagram showing an automaton created from the XPath expression related to the comparative example. A plurality of existing SAX-based XPath processing apparatuses 190 (see Non-Patent Document 3) creates an automaton as shown in FIG. 17 when an XPath expression such as
/ bib / book [contains (title / text (), 'XML')] [publication> = 1999 and publication <= 2000]…
An automaton is like a state transition diagram. The state indicated by the circle is the state, and what is written accompanying the arrow is the condition for changing the state.
状態2においては、ε(イプシロン)遷移と呼ばれる遷移が行われる。この遷移は、状態2に遷移が生じた場合には、自動的に矢印の先の状態へ遷移することを示している。つまり、状態2に遷移すると状態3、5、7にそれぞれ遷移する。状態3から状態4へは式6の最初の条件に対応している([contains(title/text(),‘XML')])。タイトルタグに挟まれたテキストの中に“XML”という文字列が含まれている場合には、状態4へ遷移する。状態5から状態6、状態7から8はそれぞれ、[publication>=1999][publication<=2000]に対応している。
In
最終的に、状態4、状態6、状態8が全て満たされている場合には、式6を満たしているXMLデータ130であるといえる。この際、既存技術ではpublicationという同一の検索対象ノードに対して2回の条件判断処理を行っている。複数のXPath式まで本数を増やせば、同じ検索対象ノードに対して条件の数だけ処理を行うことは効率が非常に悪い。
Finally, when all of the
一方、本発明は図6に例示する共有化インデックスにおいて、XPath式の数やXPath式に含まれる述語の数に比例してXMLデータ130と述語との比較回数が比例するのではなく、重複するデータを統合することにより、比較回数が抑制されている。 On the other hand, according to the present invention, in the shared index illustrated in FIG. 6, the number of comparisons between the XML data 130 and the predicate is not proportional to the number of XPath expressions or the number of predicates included in the XPath expression, but overlaps. By integrating the data, the number of comparisons is suppressed.
110 XPath式登録装置
120 XPath式格納装置
130 XMLデータ
140 共有化インデックス検索装置
150 共有化インデックス構築装置
160 パス抽出装置
170 共有化バッファ
180 共有化バッファ管理装置
190 XPath式処理装置
200 分岐無XPath式処理装置
110 XPath type registration device 120 XPath type storage device 130 XML data 140 Shared index search device 150 Shared index construction device 160 Path extraction device 170 Shared buffer 180 Shared buffer management device 190 XPath type processing device 200 Branchless XPath type processing apparatus
Claims (1)
前記XPath式処理装置は、XPath式格納手段と、パス抽出手段と、共有化インデックス構築手段と、共有化バッファ管理手段と、XPath式処理手段と、を有し、
前記XPath式格納手段は、入力された複数の分岐XPath式を記憶手段に格納し、
前記パス抽出手段は、前記XPath式格納手段により前記記憶手段に格納された分岐XPath式ごとに、
分岐XPath式の述語の条件を満たしたときに返すパスをターゲットパスの絶対パスとし、
分岐XPath式の一番左にある述語のコンテキストパスをターゲットパスのスコープパスとし、
相対パスで表現されている述語と述語のコンテキストパスとを結合して述語の絶対パスとし、
述語のコンテキストパスを述語のスコープパスとして、それぞれ抽出し、
前記共有化インデックス構築手段は、
前記パス抽出手段により抽出された前記ターゲットパスの絶対パスからTAN(Target Absolute Node)を生成し、
前記パス抽出手段により抽出された前記ターゲットパスのスコープパスからTSN(Target Scope Node)を生成し、
前記パス抽出手段により抽出された前記述語の絶対パスからPAN(Predicate Absolute Node)を生成し、
前記パス抽出手段により抽出された前記述語のスコープパスからPSN(Predicate Scope Node)を生成し、
同じ分岐XPath式から抽出される前記TANおよび前記TSNの組のうちのパスが一致する組が複数存在するときには、それらの組を1つの組へと統合し、
同じ分岐XPath式から抽出される前記PANおよび前記PSNの組のうちのパスが一致する組が複数存在するときには、それらの組を1つの組へと統合し、
前記TSNおよび前記PSNをSN(Scope Node)とし、パスが一致するSNが複数存在するときには、それらを1つのSNへと統合し、
抽出元の前記分岐XPath式から生成され、ノードの組み合わせにより、前記分岐XPath式を表現することができ、同じ抽出元の分岐XPath式から抽出される前記TANと当該TANが示す絶対パスに対応するスコープパスに該当する前記SNとをリンクで接続し、前記同じ抽出元の分岐XPath式から抽出される前記PANと当該PANが示す絶対パスに対応するスコープパスに該当する前記SNとをリンクで接続し、前記同じ抽出元の分岐XPath式から抽出される前記TANと前記PANとを、その同じ抽出元の分岐XPath式で示されている論理和または論理積を表す論理記号で接続することで、複数の分岐XPath式から1つの共有化インデックスを構築し、
前記共有化バッファ管理手段は、入力されたXMLデータの構成要素ごとにその出現順序に従って順番に番号を割り当てた共有化バッファを、前記共有化インデックスの前記TANごとに構築するとともに、その各TANの共有化バッファに各TANが示すターゲットパスの範囲分のXMLデータを格納し、
前記XPath式処理手段は、
入力された前記XMLデータをSAXパーサで構文解析することにより、コールバック関数を発生させ、
前記共有化インデックスの前記SNが示すスコープパスの終了が前記コールバック関数により通知されると、
前記共有化インデックスにおける、前記通知された前記SNからリンクで接続される前記PANが示す述語の真偽判定を行い、
前記述語の真偽判定を行った前記PANからリンクで接続される前記TANについて、そのTANにリンクする前記PANの判定結果が偽であるときには、そのTANの共有化バッファから前記SNが示すスコープパスの範囲分のXMLデータを削除するとともに、前記通知された前記SNからリンクで接続される全ての前記PANに対して前記述語の真偽判定を行った後に、前記通知された前記SNからリンクで接続される全ての前記TANについて、そのTANの共有化バッファからそのTANが示すターゲットパスの範囲分のXMLデータのうちの削除されなかった範囲分のXMLデータをフィルタリング結果として出力することを特徴とするXPath式処理装置。
An XPath-type processing apparatus that processes a branch XPath expression for filtering XML data,
The XPath type processing device includes an XPath type storage means, a path extraction means, a shared index construction means, a shared buffer management means, and an XPath type processing means,
The XPath expression storage means stores a plurality of input branch XPath expressions in a storage means,
The path extraction means is provided for each branch XPath expression stored in the storage means by the XPath expression storage means.
The path to be returned when the predicate condition of the branch XPath expression is satisfied is the absolute path of the target path,
The scope path of the target path is the context path of the predicate at the leftmost of the branch XPath expression.
By combining the predicate expressed by the relative path and the context path of the predicate, the absolute path of the predicate is obtained.
Extract the context path of the predicate as the scope path of the predicate,
The shared index construction means includes:
Generate a TAN (Target Absolute Node) from the absolute path of the target path extracted by the path extraction means,
A TSN (Target Scope Node) is generated from the scope path of the target path extracted by the path extraction means,
Generate a PAN (Predicate Absolute Node) from the absolute path of the previous description word extracted by the path extraction means,
A PSN (Predicate Scope Node) is generated from the scope path of the previous description word extracted by the path extraction means,
When there are a plurality of pairs having the same path among the TAN and TSN pairs extracted from the same branch XPath expression, these sets are combined into one set,
When there are a plurality of pairs having the same path among the PAN and PSN pairs extracted from the same branch XPath expression, these sets are merged into one set;
The TSN and the PSN are SNs (Scope Nodes), and when there are multiple SNs with matching paths, they are integrated into one SN,
The branch XPath expression generated from the extraction source branch XPath expression can be expressed by a combination of nodes, and corresponds to the TAN extracted from the same extraction source branch XPath expression and the absolute path indicated by the TAN. The SN corresponding to the scope path is connected by a link, and the PAN extracted from the branch XPath expression of the same extraction source and the SN corresponding to the scope path corresponding to the absolute path indicated by the PAN are connected by a link. The TAN and the PAN extracted from the same extraction source branch XPath expression are connected with a logical symbol representing a logical sum or logical product indicated by the same extraction source branch XPath expression, Construct one shared index from multiple branch XPath expressions,
The shared buffer management means constructs, for each TAN of the shared index, a shared buffer in which numbers are assigned in order according to the appearance order for each component of the input XML data. XML data for the range of the target path indicated by each TAN is stored in the shared buffer,
The XPath processing means is:
By parsing the input XML data with a SAX parser, a callback function is generated,
When the end of the scope path indicated by the SN of the shared index is notified by the callback function,
In the shared index, the authenticity determination of the predicate indicated by the PAN connected by a link from the notified SN is performed,
When the determination result of the PAN linked to the TAN is false for the TAN connected by a link from the PAN that has performed the authenticity determination of the previous description word, the scope indicated by the SN from the shared buffer of the TAN After deleting the XML data for the range of the path, and after determining the authenticity of the previous descriptive word for all the PANs connected by links from the notified SN, from the notified SN For all the TANs connected by the link, output the XML data for the range not deleted from the XML data for the range of the target path indicated by the TAN from the TAN shared buffer as a filtering result. A featured XPath processing device.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2005218239A JP4519028B2 (en) | 2005-07-28 | 2005-07-28 | XPath processing equipment |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2005218239A JP4519028B2 (en) | 2005-07-28 | 2005-07-28 | XPath processing equipment |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| JP2007034763A JP2007034763A (en) | 2007-02-08 |
| JP4519028B2 true JP4519028B2 (en) | 2010-08-04 |
Family
ID=37793934
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP2005218239A Expired - Lifetime JP4519028B2 (en) | 2005-07-28 | 2005-07-28 | XPath processing equipment |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JP4519028B2 (en) |
Families Citing this family (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| KR100941971B1 (en) * | 2007-08-03 | 2010-02-11 | 한국전자통신연구원 | Query Representation Device and Method for Multimedia Retrieval |
| US7996444B2 (en) | 2008-02-18 | 2011-08-09 | International Business Machines Corporation | Creation of pre-filters for more efficient X-path processing |
| US8612945B2 (en) | 2008-05-13 | 2013-12-17 | Nec Corporation | XML processing device, XML processing method, and XML processing program |
| JP5637896B2 (en) * | 2011-02-24 | 2014-12-10 | 富士通株式会社 | Window processing apparatus, method and program |
-
2005
- 2005-07-28 JP JP2005218239A patent/JP4519028B2/en not_active Expired - Lifetime
Also Published As
| Publication number | Publication date |
|---|---|
| JP2007034763A (en) | 2007-02-08 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| JP4716709B2 (en) | Structured document processing apparatus, structured document processing method, and program | |
| US8255394B2 (en) | Apparatus, system, and method for efficient content indexing of streaming XML document content | |
| CN106982150B (en) | A Hadoop-based mobile internet user behavior analysis method | |
| US8024291B2 (en) | Message generator | |
| Brughmans | Networks of networks: a citation network analysis of the adoption, use, and adaptation of formal network techniques in archaeology | |
| US9064032B2 (en) | Blended match mode DFA scanning | |
| JP2009104591A (en) | Web document clustering method and system | |
| WO2006116612A2 (en) | Method, system and apparatus for a parser for use in the processing of structured documents | |
| US20100049693A1 (en) | System and method of cache based xml publish/subscribe | |
| CN105653732A (en) | Automatic table establishment method and system based on metadata | |
| JP5121146B2 (en) | Structured document management apparatus, structured document management program, and structured document management method | |
| KR20140038206A (en) | Apparatus and method for real-time event processing based on unstructured data | |
| WO2017177872A1 (en) | Data collection method and apparatus, and storage medium | |
| US20190108393A1 (en) | Method and apparatus for retrieving image-text block from web page | |
| JP2013045208A (en) | Data generation method, device and program, retrieval processing method, and device and program | |
| CN104462532A (en) | Method and device for extracting webpage text | |
| JP4519028B2 (en) | XPath processing equipment | |
| JP4523561B2 (en) | XPath processing equipment | |
| CN103201739B (en) | Messaging device | |
| JP6103021B2 (en) | Data generation method, apparatus and program, search processing method, apparatus and program | |
| CN113761840A (en) | Intelligent document processing method, system, computer device and medium | |
| CN113868485A (en) | Data loading method and device | |
| JP2008090404A (en) | Document search apparatus, document search method, and document search program | |
| CN112799666B (en) | Container cluster view automatic construction method, system, computer equipment and media | |
| JP2007011998A (en) | XPath processing method, XPath processing device, XPath processing program, storage medium storing the program, and automaton |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20090407 |
|
| A521 | Request for written amendment filed |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20090604 |
|
| A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20090825 |
|
| A521 | Request for written amendment filed |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20091026 |
|
| A02 | Decision of refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A02 Effective date: 20091124 |
|
| A521 | Request for written amendment filed |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20100208 |
|
| A911 | Transfer to examiner for re-examination before appeal (zenchi) |
Free format text: JAPANESE INTERMEDIATE CODE: A911 Effective date: 20100303 |
|
| TRDD | Decision of grant or rejection written | ||
| A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 Effective date: 20100513 |
|
| A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 |
|
| A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20100518 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20130528 Year of fee payment: 3 |
|
| R150 | Certificate of patent or registration of utility model |
Free format text: JAPANESE INTERMEDIATE CODE: R150 Ref document number: 4519028 Country of ref document: JP |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20140528 Year of fee payment: 4 |
|
| S531 | Written request for registration of change of domicile |
Free format text: JAPANESE INTERMEDIATE CODE: R313531 |
|
| R350 | Written notification of registration of transfer |
Free format text: JAPANESE INTERMEDIATE CODE: R350 |
|
| EXPY | Cancellation because of completion of term |