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
期刊:
Proceedings of the 20th ACM SIGPLAN International Conference on Functional Programming
影响因子:
--
通讯作者:
Nada Amin
Nada Amin
中科院分区:
--
文献类型:
--
作者:
Tiark Rompf;Nada Amin

文献摘要

参考文献

被引文献

相似文献

我们介绍了SQL查询处理器的设计和实施,该处理器的表现优于现有数据库系统,并以大约500行的Scala代码编写 - 令人信服的案例研究,高级功能性编程可以轻松地击败C用于Systems-Systems级别的编程,其中最后一滴性能很重要。关键推动器是向生成编程的观点转变。查询引擎的核心是用Scala编写的关系代数操作的解释器。使用开源LMS框架(轻量级模块化分期),我们将该解释器付出了很少的努力。为此,我们利用了一个被称为Futamura Projivitions的部分评估的古老而广为人知的结果,该评估指出,该计划可以将解释器专门为任何给定的输入程序进行专业的计划等效。在此珍珠中,我们讨论了LMS编程模式,例如混合阶段数据结构(例如带有静态模式和动态字段组件的数据记录)以及生成低级C代码的技术,包括专业的数据结构和数据加载原始人。
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