The DBToaster compiler is used to generate incremental maintenance (M3) programs. M3 programs can be executed in the following ways:
- Interpreter: The DBToaster compiler includes an internal M3 interpreter. When the interpreter is used, the M3 program is evaluated and results are printed at the end of evaluation. The interpreter is not especially efficient and should not be used in production systems, but is useful for query development and testing.
- 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. This mode is far more efficient than the interpreter, but compilation is slower.
- Source Code: The DBToaster compiler can also produce source code that can be linked into your own binary.
1. The DBToaster Interpreter
To use DBToaster to evaluate queries in its internal interpreter, invoke it with the -r flag and one or more SQL query files. The output of all queries in the file will be printed once all data has been processed. If any of the queries do not terminate (e.g., one or more data sources are sockets), then pressing control-c will terminate the process and print the most recent query results. For example, we can run the sample query RST (included in the distribution) on the interpreter.
2. Generating Standalone Binaries
To use DBToaster to create a standalone binary, invoke it with -c [binary name]. The binary can be invoked directly. Like the interpreter, it will print the results of all queries once all data has been processed.
Requirements: Note that in order to compile binaries, DBToaster will invoke g++. DBToaster relies on pthreads and several Boost libraries ("program_options", "serialization", "system", "filesystem", "chrono", and "thread"). These must all be in your binary, include, and respectively, library search paths. The -I and -L flags may be used to pass individual include and library paths (respectively) to g++, or the environment variables DBT_HDR, and DBT_LIB may be used to store a colon-separated list of search paths.
Additionally, if only the multi-threaded versions of the Boost libraries are available, as is the case with some Cygwin or MacPorts provided distributions, one also needs to add the -d MT flag when compiling queries to binaries.
The following command line will generate the rst executable:
Running the rst executable will produce the following output:
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.
Requirements: Note that in order to produce jar files, DBToaster will invoke the scalac compiler, which needs to be reacheable through the binary search paths of the system. Also, on Windows, make sure to use ; as the classpath separator instead of :.
3. 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++).