Download presentation
Presentation is loading. Please wait.
Published byAshley Gaines Modified over 9 years ago
1
XML Query Processing Data Warehousing Lab. M.S. 2 Hyeyoung Cho
2
Laboratory Data Warehousing XML Data Warehouse Architecture exDB1 [Browser][WEB server][RDB server] exDB2 Servlet Star Schema, Materialized View, … exDB3 [External Database] Query Parser(tree node) Query Optimizer (optimal execution plan) Table, View, Index, … Transaction processing Recovery module OS level File sql html sql JDBC [XML server] Query Reporter (SQL stat. creation GUI, result display GUI / Graph) Data Warehouse Builder (Star Schema creation, ETL from RDB/File/XML doc.) R-table sql Oracle, MS-Sql, DB2… Query Processor Storage System (logical) Database (physical) XML format XSL menu
3
Laboratory Data Warehousing XQuery XML 질의를 위한 새로운 W3C 표준 XQuery 1.0(W3C Working Draft 02 May 2003) - http://www.w3.org/XML/Queryhttp://www.w3.org/XML/Query A query expression can be XPath expressions FLWR( ) expressions Quantified expressions Aggregation, conditional, sorting, … Group By Clause
4
Laboratory Data Warehousing XQuery FLWR expressions { For $b in doc("http://www.bn.com/bib.xml")/bib/book Where $b/publisher = "Addison-Wesley" and $b/@year > 1991 Return { $b/title } } List books published by Addison-Wesley after 1991, including their year and title. TCP/IP Illustrated Advanced Programming in the Unix environment
5
Laboratory Data Warehousing Steps in query processing parser other query form (regular expression) query plan generator execution plan evaluation engine query output data statistics about data query input transformation, index preprocessor parse tree optimizer optimized plan
6
Laboratory Data Warehousing compiler scanner (lexical analysis) parse tree semantic analysis abstract syntax tree target code generation modified intermediate form character stream parser (syntax analysis) token stream machine specific optimization assembler or machine code Intemediate code generation intermediate form optimization lex,scangen,…yacc,ecp,jack,…
7
Laboratory Data Warehousing parse tree x = 4 + 5 - 3 + 13
8
Laboratory Data Warehousing Lex and Yacc – Lex(1) Lex(lexical analyzer or scanner, 어휘분석기 ) 입력 스트림을 의미 단위인 token 으로 분리 Lex specification(pattern+action) 을 수행하는 함수 yylex() 를 포함하는 file(lex.yy.c) 생성 main() 함수내에서 yylex() 를 호출하여 사용
9
Laboratory Data Warehousing Lex and Yacc – Lex(2) Lex 프로그래밍 Lex 가 패턴관련 작동 지정 Lex 를 이 파일에 실행하여 스캐너용 C 코드 작성 $ lex (C 코드를 컴파일 및 링크 하여 스캐너 생성 )
10
Laboratory Data Warehousing Lex and Yacc – Yacc(1) Yacc(syntax analyzer or parser, 구문분석기 ) BNF 와 같은 형식의 rules 의 항목들로부터 parser 를 만들어내는 프로그램 Lex 가 생성한 어휘분석기 yylex() 를 호출하여 token 을 요구하고, 리턴되는 token 들을 받아 주 어진 문법 (token 간의 관계성 ) 에 부합하는지 검사
11
Laboratory Data Warehousing Lex and Yacc – Yacc(2) Yacc 컴파일러 작성.y 파일에 문법 작성 Input 을 처리하고 토큰을 파서로 전달할 lexical analyzer 작성 (Lex 사용가능 ) yyparse() 를 호출하여 파싱을 시작하는 함수작성 에러 처리 루틴 yyerror() 작성 Yacc 과 다른 관련 소스파일에서 만들어진 코드를 컴파일 및 링크 $ yacc
12
Laboratory Data Warehousing Lex and Yacc – 예제 (name.l) {name} { yylval = strdup(yytext); return NAME; } {eq} { return EQ; } {age} { yylval = strdup(yytext); return AGE; } % int yywrap() { return 1; } %{ #include "y.tab.h" #include extern char* yylval; %} char [A-Za-z] num [0-9] eq [=] name {char}+ age {num}+ % Verbatim copied codes Definition Section Rule Section : pattern + action User-Defined Code Section
13
Laboratory Data Warehousing Lex and Yacc – 예제 (name.y) file : record file | record ; record : NAME EQ AGE { printf("%s is %s years old!!!\n", $1, $3); } ; % int main() { yyparse(); return 0; } int yyerror(char *msg) { printf("Error encountered: %s \n", msg); } %{ #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 Rule Section : rule + action User Subroutine Section
14
Laboratory Data Warehousing Lex and Yacc for Java? Lex & Yacc : C/C++ parser 생성 Java source code 생성 tool BYacc/Java Jlex + CUP JavaCC
15
Laboratory Data Warehousing plan 1 차 개발 Simple XQuery processor 모듈 구현 (XQuery parser + XQuery executor) 2 차 개발 XQuery optimizer 구현 추가
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.