XQUERY THE GETTING STUFF DONE LANGUAGE Jim Fuller, Principle - - PowerPoint PPT Presentation

xquery the getting stuff done language
SMART_READER_LITE
LIVE PREVIEW

XQUERY THE GETTING STUFF DONE LANGUAGE Jim Fuller, Principle - - PowerPoint PPT Presentation

XQUERY THE GETTING STUFF DONE LANGUAGE Jim Fuller, Principle Consultant MarkLogic XQuery - The Ge,ng Stuff Done language Jim Fuller email: jim.fuller@marklogic.com twiBer:


slide-1
SLIDE 1

XQUERY – THE GETTING STUFF DONE LANGUAGE

Jim Fuller, Principle Consultant MarkLogic

slide-2
SLIDE 2

XQuery ¡-­‑ ¡The ¡Ge,ng ¡Stuff ¡Done ¡language ¡

Jim ¡Fuller ¡ email: ¡jim.fuller@marklogic.com ¡ ¡twiBer: ¡@xquery ¡ Principal ¡Consultant, ¡Europe ¡ 13/10/11 ¡

slide-3
SLIDE 3

I ¡will ¡try ¡XQuery ¡

slide-4
SLIDE 4

Agenda ¡

The ¡5 ¡W’s ¡ ¡-­‑ ¡5m ¡ Cool ¡Stuff ¡– ¡5m ¡ Xquery ¡Overview ¡– ¡15m ¡ Survey ¡Results ¡and ¡Analysis ¡– ¡10m ¡ Summary ¡– ¡5m ¡

slide-5
SLIDE 5

5W’s ¡Scien+fic ¡Method ¡

¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡

slide-6
SLIDE 6

What’s ¡the ¡problem ¡? ¡ ¡

slide-7
SLIDE 7

The ¡Mythical ¡Man ¡Month ¡

  • ­‑ ¡Fred ¡Brooks ¡

'All ¡programmers ¡are ¡op\mists.’ ¡ 'Adding ¡manpower ¡to ¡a ¡late ¡so]ware ¡project ¡makes ¡it ¡later.’ ¡ 'The ¡fundamental ¡problem ¡with ¡program ¡maintenance ¡is ¡that ¡ fixing ¡a ¡defect ¡has ¡a ¡substan\al ¡(20-­‑50 ¡percent) ¡chance ¡of ¡ introducing ¡another.’ ¡

slide-8
SLIDE 8

Problem ¡#1 ¡-­‑ ¡Programming ¡is ¡hard ¡

'building ¡so]ware ¡will ¡always ¡be ¡hard. ¡There ¡is ¡no ¡silver ¡bullet.' ¡

slide-9
SLIDE 9

Data ¡problems ¡

relaxing ¡constraints ¡in ¡vogue ¡ mul\farious ¡data ¡models ¡ impedance ¡mismatch ¡

slide-10
SLIDE 10

BigData ¡Opportunity ¡

* ¡h$p://gigaom.com/cloud/big-­‑data-­‑equals-­‑big-­‑opportuni:es-­‑for-­‑businesses-­‑infographic/ ¡ ¡

slide-11
SLIDE 11

BigData ¡Opportunity ¡

* ¡h$p://gigaom.com/cloud/big-­‑data-­‑equals-­‑big-­‑opportuni:es-­‑for-­‑businesses-­‑infographic/ ¡ ¡

slide-12
SLIDE 12

Problem ¡#2 ¡-­‑ ¡Your ¡boss ¡knows ¡about ¡the ¡Big ¡Data ¡opportunity ¡ managing ¡data ¡variability, ¡volume ¡& ¡velocity ¡is ¡hard ¡

slide-13
SLIDE 13

Why ¡again ¡.. ¡

Solu+on ¡#1: ¡ ¡Choosing ¡the ¡right ¡language ¡can ¡result ¡in ¡ 4-­‑5 ¡\mes ¡greater ¡produc\vity ¡ Solu+on ¡#2 ¡– ¡Choose ¡a ¡language ¡that ¡mi\gates ¡risks ¡ associated ¡with ¡BigData ¡

slide-14
SLIDE 14

XQuery ¡ ¡ Overview ¡

slide-15
SLIDE 15

I ¡will ¡try ¡XQuery ¡

slide-16
SLIDE 16

X ¡Q ¡u ¡e ¡r ¡y ¡ ¡ ¡ X ¡Q ¡u ¡e ¡r ¡y ¡ ¡ ¡

misconcep+ons ¡

slide-17
SLIDE 17

The dynamic functional language ¡

Domain ¡specific ¡language ¡ XPATH^2 ¡ Strongly ¡typed ¡

slide-18
SLIDE 18

SQL ¡like ¡–Inner ¡Join ¡

SELECT ¡* ¡FROM ¡employee, ¡department ¡ ¡WHERE ¡employee.DepartmentID ¡= ¡ ¡department.DepartmentID; ¡

for ¡$emp ¡in ¡//employee ¡ return ¡ ¡$emp[@id ¡eq ¡//dept/@id] ¡

slide-19
SLIDE 19

SQL ¡like ¡– ¡le] ¡Outer ¡Join ¡

for ¡$u ¡in ¡fn:collec\on(‘customers’) ¡ return ¡ ¡ <customer ¡id={$u/custno} ¡name=“{$u/name}”> ¡{ ¡ ¡ ¡for ¡$p ¡in ¡fn:collec\on(”purchaseorders”)//po ¡ ¡ ¡where ¡$u/custno ¡= ¡$p//custno ¡ ¡ ¡ ¡return ¡<po>{$p/@id}</po> ¡ ¡ } ¡</customer> ¡

slide-20
SLIDE 20

Func\ons ¡

declare ¡func\on ¡local:hello($name) ¡{ ¡ ¡ ¡concat("Hello ¡", ¡$name) ¡ }; ¡ ¡ local:hello(”Aarhus!") ¡

slide-21
SLIDE 21

Code ¡in ¡the ¡language ¡of ¡the ¡domain ¡

declare ¡func\on ¡local:test( ¡ ¡$a,$b,$c,$d,$e,$f,$g,$h,$i,$k){ ¡ ¡ ¡…..}; ¡ declare ¡func\on ¡local:test( ¡ ¡$a ¡as ¡element(record) ¡ ){ ¡……}; ¡

slide-22
SLIDE 22

Literals ¡and ¡Constructors ¡

xquery version "1.0"; let $names := ("Jim","Gabi","Vojtech","Norm","Nuno","Eric") return <names>{ for $name in $names return <name>{$name}</name> }</names> (: element {$computed-element-name}{ attribute {$computed-attr-name}{"some attr value"} } :)

slide-23
SLIDE 23

Inline ¡Caching ¡

xquery version "1.0-ml"; (: xquery memoization example for use with MarkLogic :) declare variable $cache := map:map(); declare function local:factorial($n as xs:integer) as xs:integer { if ($n < 0) then (0) else if ($n = 0) then (1) else $n * local:factorial($n - 1) }; declare function local:memoize($func,$var){ let $key := xdmp:md5(concat($func,string($var))) return if(map:get($cache,$key)) then (map:get($cache,$key), xdmp:log('cache hit')) else let $result := xdmp:apply($func,$var) return (map:put($cache,$key,$result), $result) }; let $memoize := xdmp:function(xs:QName("local:memoize")) let $factorial := xdmp:function(xs:QName("local:factorial")) let $a:= xdmp:apply($memoize, $factorial, 20) let $b:= xdmp:apply($memoize, $factorial, 20) let $c:= xdmp:apply($memoize, $factorial, 20) let $d:= xdmp:apply($memoize, $factorial, 20) let $e:= xdmp:apply($memoize, $factorial, 20) return $a
slide-24
SLIDE 24

Broad ¡applicability ¡

hBp://github.com/xquery/xquerydoc ¡– ¡XQuery ¡parsing ¡XQuery ¡ IBM ¡Developerworks ¡– ¡Classify ¡content ¡with ¡XQuery ¡ar\cle ¡ hBp://try.zorba-­‑xquery.com/ ¡

slide-25
SLIDE 25

XQuery ¡+ ¡database ¡

hBp://demo.exist-­‑db.org/exist/eXide/index.html ¡

slide-26
SLIDE 26

MarkLogic ¡ ¡

EVALUATION LAYER Evaluator

XSLT | XPath | XQuery

Shared-Nothing Protocol Buffer DATA LAYER Data Cache Compressed Storage

XML | Binary | Text

Indexes

Value | Structure | Text | Scalar | Metadata | Security | Geospatial | Reverse

Transaction Journal Transaction Controller

Multiversion Concurrency Control

APPLICATION SERVICES

HTTP | HTTPS | XDBC | WebDAV | REST | AJAX / JSON

Information Studio API Library Services API Search API

slide-27
SLIDE 27

XQuery ¡+ ¡database ¡

slide-28
SLIDE 28

Analysis ¡

slide-29
SLIDE 29

I ¡will ¡try ¡XQuery ¡

slide-30
SLIDE 30

Programming ¡Language ¡Produc\vity ¡

Data ¡compiled ¡from ¡studies ¡by ¡Prechelt ¡and ¡Garret ¡of ¡a ¡par:cular ¡string ¡ processing ¡problem ¡-­‑ ¡public ¡domain ¡2006. ¡ ¡

slide-31
SLIDE 31

Programming ¡Language ¡Produc\vity ¡

Data ¡compiled ¡from ¡studies ¡by ¡Prechelt ¡and ¡Garret ¡of ¡a ¡par:cular ¡string ¡ processing ¡problem ¡-­‑ ¡ ¡public ¡domain ¡2006. ¡ ¡

slide-32
SLIDE 32

Nooooo! ¡

#loc ¡per ¡FP ¡ = ¡ Lines ¡of ¡code ¡ Per ¡ Func\on ¡Point ¡ ¡ Methodology ¡

slide-33
SLIDE 33

Project ¡Uncertainty ¡Principle ¡

slide-34
SLIDE 34

An ¡empirical ¡comparison ¡of ¡C, ¡C++, ¡ Java, ¡Perl, ¡Python, ¡Rexx, ¡and ¡Tcl ¡for ¡a ¡ search/string-­‑processing ¡program ¡

Lutz ¡Prechelt ¡(prechelt@ira.uka.de) ¡Fakulta ¡̈t ¡fu ¡̈r ¡Informa\k ¡ Universita ¡̈t ¡Karlsruhe ¡

Language ¡ ¡#loc ¡per ¡Func+on ¡Point ¡ C ¡ 91 ¡ C++ ¡ 53 ¡ Java ¡ 54 ¡ Perl ¡ 21 ¡

* ¡Designing ¡and ¡wri\ng ¡programs ¡using ¡dynamic ¡languages ¡tended ¡to ¡ take ¡half ¡as ¡long ¡as ¡well ¡as ¡resul\ng ¡in ¡half ¡the ¡code. ¡ ¡

slide-35
SLIDE 35

Historical ¡#loc ¡per ¡FP ¡

Language ¡ ¡#loc ¡per ¡Func+on ¡Point ¡ Python ¡ 42-­‑47 ¡ Java ¡ 50-­‑80 ¡ Javascript ¡ 50-­‑55 ¡ C++ ¡ 59-­‑80 ¡ C ¡ 140 ¡ … ¡ … ¡

slide-36
SLIDE 36

Developing ¡an ¡Enterprise ¡Web ¡ Applica+on ¡in ¡Xquery ¡-­‑ ¡2009 ¡Mar\n ¡ Kaufmann, ¡Donald ¡Kossmann ¡

Java/J2EE ¡ XQuery ¡ Model ¡ 3100 ¡ 240 ¡ View ¡ 4100 ¡ 1500 ¡ Controller ¡ 900 ¡ 1180 ¡ 8100 ¡(?) ¡ 2920 ¡(3490) ¡

slide-37
SLIDE 37

* ¡28msec ¡– ¡2011 ¡ ¡ h\p://www.28msec.com/html/home ¡ Java ¡ XQuery ¡ SimpleDB ¡ 2905 ¡ 572 ¡ S3 ¡ 8589 ¡ 1469 ¡ SNS ¡ 2309 ¡ 455 ¡ 13803 ¡ 2496 ¡

slide-38
SLIDE 38

Review ¡11 ¡projects ¡ FP ¡Analysis ¡ Calc ¡FP ¡inputs/outputs ¡ Calc ¡VAF ¡(0.65 ¡+ ¡[ ¡(Ci) ¡/ ¡100]) ¡ AVP ¡= ¡VAF ¡* ¡sum(FP) ¡

* ¡FP ¡overview ¡-­‑ ¡hBp://www.so]waremetrics.com/fpafund.htm ¡

#loc ¡ using ¡cloc ¡

¡= ¡#loc ¡per ¡FP ¡

slide-39
SLIDE 39

Language ¡ ¡#loc ¡per ¡Func+on ¡Point ¡ Eiffel ¡ 21 ¡ SQL ¡ 13-­‑30 ¡ XQuery ¡ 27-­‑33 ¡ Haskell ¡ 38 ¡ Erlang ¡ 40 ¡ Python ¡ 42-­‑47 ¡ Java ¡ 50-­‑80 ¡ Javascript ¡ 50-­‑55 ¡ Scheme ¡ 53 ¡ C++ ¡ 59-­‑80 ¡ C ¡ 128-­‑140 ¡

slide-40
SLIDE 40

* ¡Cloudera– ¡2011 ¡ ¡ h\p://www.cloudera.com/videos/introduc+on-­‑to-­‑ apache-­‑pig ¡ locc ¡ hrs ¡ Java ¡ 200 ¡ 4 ¡ PigLa\n ¡ 10 ¡ .25 ¡

PigLa\n ¡is ¡a ¡DSL ¡for ¡data ¡for ¡apache ¡hadoop ¡

slide-41
SLIDE 41

Do ¡So]ware ¡Language ¡Engineers ¡ Evaluate ¡their ¡Languages? ¡ ¡

2011 ¡-­‑ ¡CITI, ¡Departamento ¡de ¡Informa ¡́\ca, ¡Faculdade ¡de ¡Ciˆencias ¡e ¡Tecnologia, ¡FCT, ¡ Universidade ¡Nova ¡de ¡Lisboa, ¡2829-­‑516 ¡Caparica, ¡Portugal ¡pedrohgabriel@gmail.com, {miguel.goulao,vasco.amaral}@di.fct.unl.pt ¡hBp://ci\.di.fct.unl.pt/ ¡

SLE ¡consistently ¡relax ¡language ¡evalua\on ¡ no ¡valida\on ¡from ¡users ¡ recommend ¡systema\c ¡approach ¡to ¡DSL ¡evalua\on ¡

slide-42
SLIDE 42

Xquery ¡2011 ¡Survey ¡

slide-43
SLIDE 43

Preferred ¡Programming ¡Language ¡

Xquery Java XSLT Javascript C++ python C Perl C# ruby php Haskell Scala Lisp Erlang 20 40 60 80

73% ¡ 55% ¡ 45% ¡ 32% ¡ 22% ¡

slide-44
SLIDE 44

Which ¡data ¡formats ¡do ¡you ¡use ¡the ¡ most ¡? ¡

XML Text RDBMS JSON Binaries (images, video, etc) Office documents Semantic web stuff (RDF , owl, etc..) 20 40 60 80 100 95% ¡ 40% ¡ 39% ¡ 32% ¡ 27% ¡ 18% ¡ 15% ¡

slide-45
SLIDE 45

WriBen ¡answers ¡

Do ¡you ¡have ¡any ¡opinions ¡if ¡XQuery ¡is ¡more ¡or ¡less ¡produc:ve ¡ language ¡versus ¡other ¡programming ¡languages ¡? ¡ What ¡was ¡different ¡about ¡learning ¡or ¡using ¡XQuery ¡versus ¡other ¡ programming ¡languages ¡? ¡ ¡

slide-46
SLIDE 46

Choose ¡an ¡op\on ¡that ¡you ¡most ¡ strongly ¡believe ¡in ¡… ¡

I love XML I am ok with XML but hate namespaces I love HTML5 and am ok with XML I am ok with JSON but hate javascript I hate JSON I love JSON I hate XML I love HTML5 and hate XML 20 40 60 80 100

66% ¡ 14% ¡ 10% ¡

slide-47
SLIDE 47

Do ¡you ¡think ¡XQuery ¡makes ¡you ¡a ¡ more ¡produc\ve ¡programmer ¡? ¡

Yes Maybe No Don’t Know 20 40 60 80 100

67% ¡ 14% ¡ 10% ¡ 8% ¡

slide-48
SLIDE 48

Is ¡XQuery ¡more ¡produc\ve ¡then ¡Java ¡in ¡ developing ¡web ¡based ¡data ¡applica\ons ¡? ¡

Yes Don’t know Maybe No 20 40 60 80 100

58% ¡ 22% ¡ 12% ¡ 8% ¡

slide-49
SLIDE 49

Cool ¡Stuff ¡ ¡

slide-50
SLIDE 50

I ¡will ¡try ¡XQuery ¡

slide-51
SLIDE 51

Corona ¡

Drop ¡in ¡replacement ¡for ¡NoSQL ¡with ¡no ¡compromise ¡ ¡ Open ¡Source ¡development ¡supported ¡by ¡ML ¡ ¡ WriBen ¡in ¡XQuery ¡

slide-52
SLIDE 52

BigData ¡

  • Show ¡ML ¡working ¡with ¡

– Xml ¡ – Text ¡ – Binaries ¡ ¡

  • Hadoop ¡connector ¡
slide-53
SLIDE 53

Summary ¡

slide-54
SLIDE 54

I ¡will ¡try ¡XQuery ¡

slide-55
SLIDE 55

Sanity ¡ ¡ Check ¡

slide-56
SLIDE 56

Xquery ¡job ¡search ¡indeed.com ¡

slide-57
SLIDE 57

Media ¡Customers ¡ Government Customers

MarkLogic ¡Customers ¡Know ¡

Financial ¡Services ¡and ¡Other ¡Customers ¡

slide-58
SLIDE 58

Finally ¡… ¡

slide-59
SLIDE 59

Disclaimer: ¡I ¡have ¡used ¡the ¡above ¡ subliminal ¡sugges:on ¡throughout ¡the ¡ presenta:on ¡ ¡ ¡

I ¡will ¡try ¡XQuery ¡

slide-60
SLIDE 60

Thank ¡you ¡...@xquery ¡Ques\ons ¡? ¡

slide-61
SLIDE 61

Tools ¡

slide-62
SLIDE 62

unstructured schema-less* easy evolution. xml or json. native search a database built

  • n a search engine?

c++ core ~ pb scale features acid, backups replication, query language (XQuery).

* they have this universal index thing. an inverted index that is structure aware

also stores: text and binaries no tables, rows, columns thinkin’ documents uris? looks like a filesystem

stop shredding your data start storing data as is

!!

slide-63
SLIDE 63

Resources ¡and ¡References ¡