Functional pearl: a SQL to C compiler in 500 lines of code
Functional pearl: a SQL to C compiler in 500 lines of code
复制标题
Function Pearl:500 行代码的 SQL 到 C 编译器
DOI:
10.1145/2784731.2784760
复制
发表时间:
2015
期刊:
影响因子:
--
通讯作者:
Nada Amin
中科院分区:
文献类型:
--
作者:
Tiark Rompf;Nada Amin
We present the design and implementation of a SQL query processor that outperforms existing database systems and is written in just about 500 lines of Scala code -- a convincing case study that high-level functional programming can handily beat C for systems-level programming where the last drop of performance matters. The key enabler is a shift in perspective towards generative programming. The core of the query engine is an interpreter for relational algebra operations, written in Scala. Using the open-source LMS Framework (Lightweight Modular Staging), we turn this interpreter into a query compiler with very low effort. To do so, we capitalize on an old and widely known result from partial evaluation known as Futamura projections, which state that a program that can specialize an interpreter to any given input program is equivalent to a compiler. In this pearl, we discuss LMS programming patterns such as mixed-stage data structures (e.g. data records with static schema and dynamic field components) and techniques to generate low-level C code, including specialized data structures and data loading primitives.
DOI:
10.14778/2002938.2002940
发表时间:
2011
期刊:
Proc. VLDB Endow.
影响因子:
--
作者:
T. Neumann
通讯作者:
T. Neumann