The Java Query Language Darren Willis, David J. Pearce and James Noble Victoria University of Wellington, New Zealand.

Slides:



Advertisements
Similar presentations
Query optimisation.
Advertisements

Examples of Physical Query Plan Alternatives
JQL : The Java Query Language Darren Willis, David J Pearce, James Noble.
Introduction to Database Systems1 Records and Files Storage Technology: Topic 3.
CS 540 Database Management Systems
Mutability SWE 332 Fall 2011 Paul Ammann. SWE 3322 Data Abstraction Operation Categories Creators Create objects of a data abstraction Producers Create.
Relationship Aspects David J. Pearce and James Noble Victoria University of Wellington, New Zealand.
Query Evaluation. An SQL query and its RA equiv. Employees (sin INT, ename VARCHAR(20), rating INT, age REAL) Maintenances (sin INT, planeId INT, day.
Query Evaluation. SQL to ERA SQL queries are translated into extended relational algebra. Query evaluation plans are represented as trees of relational.
CSC1016 Coursework Clarification Derek Mortimer March 2010.
CS263 Lecture 19 Query Optimisation.  Motivation for Query Optimisation  Phases of Query Processing  Query Trees  RA Transformation Rules  Heuristic.
© 2006 Pearson Addison-Wesley. All rights reserved7 B-1 Chapter 7 (continued) Stacks.
Introduction to Java, OO and IDEs ICW Lecture 2 Errol Thompson Room 134.
Wednesday, 10/9/02, Slide #1 CS 106 Intro to CS 1 Wednesday, 10/9/02  QUESTIONS ??  Today:  Discuss HW #02  Discuss test question types  Review 
APPLAUS: A Privacy-Preserving Location Proof Updating System for Location-based Services Zhichao Zhu and Guohong Cao Department of Computer Science and.
T HE Q UERY C OMPILER Prepared by : Ankit Patel (226)
1 Applied CyberInfrastructure Concepts ISTA 420/520 Fall Nirav Merchant Bio Computing & iPlant Collaborative Eric Lyons.
Query Processing Presented by Aung S. Win.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Debugging Support.
CMPS 3223 Theory of Computation Automata, Computability, & Complexity by Elaine Rich ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Slides provided.
Implementing a Language with Flow-Sensitive and Structural Subtyping on the JVM David J. Pearce and James Noble Victoria University of Wellington.
Module 7 Reading SQL Server® 2008 R2 Execution Plans.
Designing classes How to write classes in a way that they are easily understandable, maintainable and reusable 3.0.
Putting it all together: LINQ as an Example. The Problem: SQL in Code Programs often connect to database servers. Database servers only “speak” SQL. Programs.
Ashwani Roy Understanding Graphical Execution Plans Level 200.
Event Management & ITIL V3
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Programing Basics COMP.
8 October, 2001DBIS4 - RLC108 Object Query Language The need for ad hoc querying What SQL does What OQL must do OQL syntax and examples.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Programing Basics COMP.
Optimization in XSLT and XQuery Michael Kay. 2 Challenges XSLT/XQuery are high-level declarative languages: performance depends on good optimization Performance.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Exam and Lecture Overview.
School of Engineering and Computer Science, Victoria University of Wellington COMP 103 Linked Structures.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Efficient RDF Storage and Retrieval in Jena2 Written by: Kevin Wilkinson, Craig Sayers, Harumi Kuno, Dave Reynolds Presented by: Umer Fareed 파리드.
Chapter 11 Hash Tables © John Urrutia 2014, All Rights Reserved1.
Gordana Rakić, Zoran Budimac
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
Building Java Programs Bonus Slides Hashing. 2 Recall: ADTs (11.1) abstract data type (ADT): A specification of a collection of data and the operations.
Relational Operator Evaluation. Overview Application Programmer (e.g., business analyst, Data architect) Sophisticated Application Programmer (e.g.,
Chapter 6 Object-Oriented Design Part 2. © 2004 Pearson Addison-Wesley. All rights reserved2/20 The this Reference The this reference allows an object.
Non-static classes 1.  a utility class has features (fields and methods) that are all static  all features belong to the class  therefore, you do not.
Saving the World from Bad Beans Dave Clarke, Utrecht Michael Richmond, IBM ARC James Noble, VUW.
Advance Database Systems Query Optimization Ch 15 Department of Computer Science The University of Lahore.
Programmeren 1 6 september 2010 HOORCOLLEGE 2: INTERACTIE EN CONDITIES PROGRAMMEREN 1 6 SEPTEMBER 2009 Software Systems - Programming - Week.
Query Processing CS 405G Introduction to Database Systems.
Aspect Oriented Security Tim Hollebeek, Ph.D.
Functional Programming IN NON-FUNCTIONAL LANGUAGES.
An Effective SPARQL Support over Relational Database Jing Lu, Feng Cao, Li Ma, Yong Yu, Yue Pan SWDB-ODBIS 2007 SNU IDB Lab. Hyewon Lim July 30 th, 2009.
CIS 200 Test 01 Review. Built-In Types Properties  Exposed “Variables” or accessible values of an object  Can have access controlled via scope modifiers.
CS 540 Database Management Systems
Collections and Iteration Week 13.  Collections  ArrayList objects  Using loops with collections Collections and Iteration CONCEPTS COVERED THIS WEEK.
Java Bytecode Verification Types Chris Male, David J. Pearce, Alex Potanin and Constantine Dymnikov Victoria University of Wellington, New.
The Big Picture Chapter 3. A decision problem is simply a problem for which the answer is yes or no (True or False). A decision procedure answers a decision.
Chapter 18 Query Processing and Optimization. Chapter Outline u Introduction. u Using Heuristics in Query Optimization –Query Trees and Query Graphs –Transformation.
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Programing Basics COMP.
Lecture 9:FXML and Useful Java Collections Michael Hsu CSULA.
JDBC.
Building Java Programs Generics, hashing reading: 18.1.
COMP 103 Linked Structures
Applied CyberInfrastructure Concepts Fall 2017
Prepared by : Ankit Patel (226)
Objects First with Java CITS1001
Introduction to Execution Plans
Examples of Physical Query Plan Alternatives
Introduction to Execution Plans
Introduction to Execution Plans
Introduction to Execution Plans
Presentation transcript:

The Java Query Language Darren Willis, David J. Pearce and James Noble Victoria University of Wellington, New Zealand

What is the Java Query Language? Prototype extension to Java –Provides first-class query constructs –Supports standard database optimisations –Also experimented with caching optimisations Key Idea: –By changing loops into queries we allow the system to perform more aggressive optimisations

JQL Syntax Query Expression: For loop query: for(Robot r : robots | !r.isDead()) { r.method(); } List f(List students) { return [ Student s : students | s == jim ]; }

For each query, JQL constructs pipeline on-the-fly: –Selecting good join ordering and join types improves performance –E.g. hash join versus nested-loop join r = [String x:words, Integer y:lengths | x.length().equals(y) && x.length() > 1]

Understanding Program Loops Many loops in Java can be converted into JQL queries: for(Robot r : robots) { if(!r.isDead()) { r.method(); } } for(Robot r : robots | !r.isDead()) { r.method(); }

for(Robot r : robots) { if(!r.isDead()) { r.method(); } } for(Robot r : robots) { r.out.close(); } for(Robot r : robots) { if(!r.isDead()) { for(Robot dead : deadRobots) { if(!= dead.team) { r.doSomething();} }}} (Level 1 Filter) (Level 2 Filter) (Unfiltered)

ZK = 45KLoc RSSOwl= 46KLoc Freemind = 70KLoc Robocode = 23KLoc, Chungles = 4KLoc SoapUI = 68KLoc

Part 2 Caching and Incrementalisation

Robocode

Caching + Incrementalisation class Battle { private List robots;... public List robots() { return robots; } } void scan() { for(Robot r : battle.robots()) { if(r!=null && r!=this && !r.isDead() && …) {... }}

class Battle { private List robots; private List liveRobots;... public List robots() { return robots; } public List aliveRobots() { return liveRobots; }} void scan() { for(Robot r : battle.aliveRobots()) { if(r!=this && …) {... }} Caching + Incrementalisation

Incrementalisation When caching we must incrementalise: class Battle { private List robots, aliveRobots;... public void addRobot(Robot r) { robots.add(r); if(!r.isDead()) { aliveRobots.add(r); }} public void robotDied(Robot r) { aliveRobots.remove(r); }}

Caching + Incrementalisation in JQL xs=[ Student s : students | s == jim ]; Key Idea: –Cache + Incrementalise queries’ result set –Thus, subsequent evaluations can reuse it Issues: –Don’t want to cache everything! –Don’t want to exhaust memory! Problems: –How to correctly incrementalise? –What about methods?

Prototype Implementation Cache Manager –Decides when to start/stop caching queries –Tracks object updates and incrementalises cached results Object Updates: –E.g. Object added to collection, field updated, etc. –Re-evaluate query pipeline using just this object Caching Heuristics: –Always on - every query always cached –Ratio – enable caching when query/update ratio high enough

Prototype Implementation Dependency Tracking: –How to know when object update occurs? –How to know if object update affects cache? –(the latter requires knowledge of the object graph) Our (Simplistic) Approach: –Use Aspect/J to monitor object updates –Only track fields –Ignore object graph; instead prevent multi-level indirection in queries! –Prevent caching if methods used in query!

Further Reading Caching and Incrementalisation in the Java Query Language. Darren Willis, David J. Pearce and James Noble. In Proc OOPSLA, 2008 (to appear). Efficient Object Querying in Java. Darren Willis, David J. Pearce and James Noble. In Proc ECOOP, 2006.

Conclusion Short Story: –Many loops can be turned into queries –Queries can be optimised using database style optimisations –Queries could also be optimised using caching and incrementalisation –Such optimisations make real programs go faster