1 / 15

XML Query Processing

XML Query Processing. Data Warehousing Lab. M.S. 2 Hyeyoung Cho. XML Data Warehouse Architecture. [Browser]. [WEB server]. [RDB server]. [XML server]. Query Processor. Star Schema, Materialized View, …. Servlet. R-table. Query Parser(tree node)

mikaia
Télécharger la présentation

XML Query Processing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. XML Query Processing Data Warehousing Lab. M.S. 2 Hyeyoung Cho

  2. XML Data Warehouse Architecture [Browser] [WEB server] [RDB server] [XML server] Query Processor Star Schema, Materialized View, … Servlet R-table • Query Parser(tree node) • Query Optimizer (optimal execution plan) html XML format JDBC menu XSL sql sql • Oracle, MS-Sql, • DB2… Storage System (logical) • Query Reporter (SQL stat. creation GUI , result display GUI / Graph) • Data Warehouse Builder (Star Schema creation, ETL from RDB/File/XML doc.) sql • Table, View, Index, … • Transaction processing • Recovery module exDB1 exDB2 exDB3 [External Database] Database (physical) • OS level • File

  3. XQuery • XML 질의를 위한 새로운 W3C 표준 • XQuery 1.0(W3C Working Draft 02 May 2003) - http://www.w3.org/XML/Query • A query expression can be • XPath expressions • FLWR() expressions • Quantified expressions • Aggregation, conditional, sorting, … • Group By Clause

  4. XQuery • FLWR expressions List books published by Addison-Wesley after 1991, including their year and title. <bib> { For $b in doc("http://www.bn.com/bib.xml")/bib/book Where $b/publisher = "Addison-Wesley" and $b/@year > 1991 Return <book year="{ $b/@year }"> { $b/title } </book> } </bib> <bib> <book year="1994"> <title>TCP/IP Illustrated</title> </book> <book year="1992"> <title>Advanced Programming in the Unix environment</title> </book> </bib>

  5. Steps in query processing parser preprocessor query input parse tree other query form (regular expression) query plan generator transformation, index evaluation engine optimizer query output optimized plan execution plan data data statistics about data

  6. compiler scanner (lexical analysis) parser (syntax analysis) semantic analysis character stream token stream parse tree lex,scangen,… yacc,ecp,jack,… Intemediate code generation intermediate form abstract syntax tree modified intermediate form optimization target code generation machine specific optimization assembler or machine code

  7. parse tree • x = 4 + 5 - 3 + 13

  8. Lex and Yacc – Lex(1) • Lex(lexical analyzer or scanner,어휘분석기) • 입력 스트림을 의미 단위인 token으로 분리 • Lex specification(pattern+action)을 수행하는 함수 yylex()를 포함하는 file(lex.yy.c)생성 • main() 함수내에서 yylex()를 호출하여 사용

  9. Lex and Yacc – Lex(2) • Lex 프로그래밍 • Lex가 패턴관련 작동 지정 • Lex를 이 파일에 실행하여 스캐너용 C코드 작성 $ lex <file name.l> • (C코드를 컴파일 및 링크 하여 스캐너 생성)

  10. Lex and Yacc – Yacc(1) • Yacc(syntax analyzer or parser, 구문분석기) • BNF와 같은 형식의 rules의 항목들로부터 parser를 만들어내는 프로그램 • Lex가 생성한 어휘분석기 yylex()를 호출하여 token을 요구하고, 리턴되는 token들을 받아 주어진 문법(token간의 관계성)에 부합하는지 검사

  11. Lex and Yacc – Yacc(2) • Yacc 컴파일러 작성 • .y파일에 문법 작성 • Input을 처리하고 토큰을 파서로 전달할 lexical analyzer작성(Lex사용가능) • yyparse()를 호출하여 파싱을 시작하는 함수작성 • 에러 처리 루틴 yyerror()작성 • Yacc과 다른 관련 소스파일에서 만들어진 코드를 컴파일 및 링크 $ yacc <options> <filename.y>

  12. Lex and Yacc –예제(name.l) %{ #include "y.tab.h" #include <stdio.h> #include <string.h> extern char* yylval; %} char [A-Za-z] num [0-9] eq [=] name {char}+ age {num}+ %% Verbatim copied codes Rule Section : pattern + action {name} { yylval = strdup(yytext); return NAME; } {eq} { return EQ; } {age} { yylval = strdup(yytext); return AGE; } %% Definition Section User-Defined Code Section int yywrap() { return 1; }

  13. Lex and Yacc –예제(name.y) %{ #typedef char* string; /* to specify token types as char* */ #define YYSTYPE string /* a Yacc variable which has the value of returned token */ %} %token NAME EQ AGE %% Definition Section User Subroutine Section int main() { yyparse(); return 0; } int yyerror(char *msg) { printf("Error encountered: %s \n", msg); } file : record file | record ; record : NAME EQ AGE { printf("%s is %s years old!!!\n", $1, $3); } ; %% Rule Section : rule + action

  14. Lex and Yacc for Java? • Lex & Yacc : C/C++ parser 생성 • Java source code 생성 tool • BYacc/Java • Jlex + CUP • JavaCC

  15. plan • 1차 개발 • Simple XQuery processor 모듈 구현 (XQuery parser + XQuery executor) • 2차 개발 • XQuery optimizer 구현 추가

More Related