Skip to content
aantenan edited this page Oct 5, 2012 · 8 revisions

Welcome to the Espresso wiki!

Espresso is a simple SQL Engine that runs on top of an iterator, allowing you to select the elements that match a given where clause. It has been optimized to effectively handle very large collections in an efficient way through the use of Indexes, which are very light-weight sets that can be used to speed up references to commonly used attributes.

You don't have to do anything to add query capabilities to your collection - as long as you follow naming conventions for the "column names", Espresso can access the attribute values using reflection. For example, the condition last_name = 'Smith' will look for an attribute called lastName in the object stored in the collection.

The current implementation of Espresso is interpreted, i.e., the SQL where clause is parsed into a tree, which is then interpreted to return the collection of objects that match the supplied restriction. Having said that, we went through great lengths to optimize the interpreter, so performance is already pretty decent, even when handling millions of objects. This makes Espresso ideal to add SQL support on top of an in-memory cache.

At this point, we are working on generating bytecode to run the where clause, which should help performance even further - at a price: a class is generated for every query. Because of that, we will implement the bytecode as an addition, not a replacement, for the interpreted code: think of it as PreparedStatements. And just like prepared statements, we will support parameterized queries, so you can change parameters while reusing the structure.

A complete user's manual is in the makings, and it will be available soon. Meanwhile, feel free to download the code and look at the (fairly abundant) Javadocs. There is also a fair amount of unit tests showing how to use the library - for the time being - as well as a performance test you can run in your environment - it runs queries over a collection of 2 million elements and prints the total query time. This performance test also has a quick preview of what you can expect when the bytecode generation is fully implemented.

If you want to start using the library right away, you should be able to build it with Maven. The uploaded code requires Java 1.7 to compile (we will support 1.6 if there are requests for it), and it has only two runtime dependencies: antlr3 and BCEL 6.

Enjoy!

The Espresso team.

Getting Started

Clone this wiki locally