DBToaster
Getting Started

The DBToaster compiler is used to generate incremental maintenance (M3) programs. M3 programs can be executed in the following ways:

  • Standalone Binaries: The DBToaster compiler can produce standalone binaries that evaluate the M3 program. This requires invoking a second stage compiler (g++ or scalac) to generate the final binary.
  • Source Code: The DBToaster compiler can also produce source code that can be linked into your own binary.

1. Requirements

Several dependencies are needed to run DBToaster.

1.1. Windows

We tested DBToaster successfully on:

1.2. OS X

  • Oracle JDK 7 (or above)
  • gcc-g++ 4.8 (or above)
  • Scala 2.10.2

For installing gcc (if you are using Homebrew), the following commands can be used:

$> brew tap homebrew/versions $> brew install gcc48

In order to tell DBToaster to use a custom C++ compiler, create a symlink gpp in the DBToaster directory that points to the compiler:

$> ln -s /usr/local/bin/g++-4.8 gpp

DBToaster detects that this link exists and uses it instead of g++.

1.3. Linux

The easiest way to use DBToaster on Linux is to install the following dependencies with the package manager of your choice:

  • Oracle JDK 7 (or above)
  • gcc-g++ 4.8 (or above)
  • Scala 2.10.2

Note: Other versions of the tools/packages might work as well but have not been tested.

2. Evaluating a simple query

DBToaster provides the -r flag which generates, compiles and evaluates a query in one simple step. This is a convenient way to check whether DBToaster and its dependencies have successfully been installed.

The following command evaluates the rst query that ships with DBToaster:

CREATE STREAM R(A int, B int) FROM FILE 'examples/data/simple/r.dat' LINE DELIMITED csv; CREATE STREAM S(B int, C int) FROM FILE 'examples/data/simple/s.dat' LINE DELIMITED csv; CREATE STREAM T(C int, D int) FROM FILE 'examples/data/simple/t.dat' LINE DELIMITED csv; SELECT sum(A*D) AS AtimesD FROM R,S,T WHERE R.B=S.B AND S.C=T.C; $> bin/dbtoaster -r examples/queries/simple/rst.sql <snap>     <ATIMESD>306</ATIMESD> </snap> real 0m0.019s user 0m0.002s sys 0m0.002s

3. Generating Standalone Binaries

To use DBToaster to create a standalone binary, invoke it with -c [binary name]. The binary can be invoked directly. It will print the results of all queries once all data has been processed.

The following command line will generate the rst executable:

$> bin/dbtoaster examples/queries/simple/rst.sql -c rst

Running the rst executable will produce the following output:

$> ./rst <snap>     <ATIMESD>306</ATIMESD> </snap>

To produce a scala jar file, invoke dbtoaster with -l scala, and the -c [binary name] flag as above. DBToaster will produce [binary name].jar, which can be run as a normal scala program. For more details, please refer to Scala Code Generation

4. Generating Source Code

DBToaster's primary role is the construction of code that can be linked in to existing applications. To generate a source file in C++ or Scala, invoke it with -l [language], replacing [language] with cpp or scala. If the optional -o flag is used to direct the generated code into a particular file, the target language will be auto-detected from the file suffix (".scala" for Scala, and ".h", ".hpp", or ".cpp" for C++).

$> bin/dbtoaster examples/queries/simple/rst.sql -o rst.cpp $> bin/dbtoaster examples/queries/simple/rst.sql -o rst.scala $> ls rst.hpp rst.scala
See Scala Code Generation and C++ Code Generation for details.