Functional Pearl: A SQL to C Compiler in 500 Lines of Code

被引:0
|
作者
Rompf, Tiark [1 ]
Amin, Nada [2 ]
机构
[1] Purdue Univ, W Lafayette, IN 47907 USA
[2] Ecole Polytech Fed Lausanne, Lausanne, Switzerland
关键词
SQL; Query Compilation; Staging; Generative Programming; Futamura Projections;
D O I
暂无
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
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 opensource 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.
引用
收藏
页码:2 / 9
页数:8
相关论文
共 47 条
  • [21] Asserting Functional Equivalence between C Code and SCADE Models in Code-to-Model Transformations
    Toennemann, Jan
    Aniculaesei, Adina
    Rausch, Andreas
    PROCEEDINGS OF THE 5TH BRAZILIAN SYMPOSIUM ON SYSTEMATIC AND AUTOMATED SOFTWARE TESTING, SAST 2020, 2020, : 60 - 68
  • [22] ADA COMPILER YIELDS SOURCE CODE IN C, OPERATES ON BOTH 16-BIT AND 32-BIT COMPUTERS
    WALLER, L
    ELECTRONICS-US, 1983, 56 (14): : 49 - 50
  • [23] Ultra-fast aliasing analysis using CLA: A million lines of C code in a second
    Heintze, N
    Tardieu, O
    ACM SIGPLAN NOTICES, 2001, 36 (05) : 254 - 263
  • [24] COMPARTMENT GAS-INSULATED TRANSMISSION LINES (C-GIL) AT 500KV CLASS
    TAKUMA, T
    FUJINAMI, H
    YASHIMA, M
    KAWAMOTO, T
    HARA, M
    IEEE TRANSACTIONS ON POWER DELIVERY, 1989, 4 (01) : 1 - 7
  • [25] Effect of UV-C Treatment on Functional Properties of Pearl Millet Flour: Process Modelling and OptimisationEffect of UV-C Treatment on Functional Properties of Pearl Millet Flour: Process Modelling…P. Prashanth et al.
    P. Prashanth
    T. Jayasree Joshi
    Shagolshem Mukta Singh
    P. Srinivasa Rao
    Journal of Food Measurement and Characterization, 2025, 19 (2) : 1064 - 1078
  • [26] Functional analyses of C13orf19 in prostate cell lines
    不详
    EUROPEAN UROLOGY SUPPLEMENTS, 2006, 5 (02) : 125 - 125
  • [27] Deductive Functional Verification of Safety-Critical Embedded C-Code: An Experience Report
    Gurov, Dilian
    Lidstrom, Christian
    Nyberg, Mattias
    Westman, Jonas
    CRITICAL SYSTEMS: FORMAL METHODS AND AUTOMATED VERIFICATION (FMICS-AVOCS 2017), 2017, 10471 : 3 - 18
  • [28] Chianina: An Evolving Graph System for Flow- and Context-Sensitive Analyses of Million Lines of C Code
    Zuo, Zhiqiang
    Zhang, Yiyu
    Pan, Qiuhong
    Lu, Shenming
    Li, Yue
    Wang, Linzhang
    Li, Xuandong
    Xu, Guoqing Harry
    PROCEEDINGS OF THE 42ND ACM SIGPLAN INTERNATIONAL CONFERENCE ON PROGRAMMING LANGUAGE DESIGN AND IMPLEMENTATION (PLDI '21), 2021, : 914 - 929
  • [29] DECORATED MODELS, REPLICATION, AND ASSEMBLY LINES FOR BRONZE INDUSTRIAL PRODUCTION IN 500 B. C. E. CHINA
    Li, Kin Sum
    Wang, Quanyu
    Wilson, J. Keith
    Zhang, Fan Jeremy
    Cheung, Jody Ho Yee
    Chun, Tsz Hin
    Lam, Sum
    Pang, Mingyong
    Xie, Haoran
    Wei, Mingqiang
    Lee, Kin San
    EARLY CHINA, 2021, 44 : 109 - 142
  • [30] Optimizing analytical method in Health Functional Food code with adjustable chromatographic parameters: A case study of vitamin C
    Shin, Junghoon
    Jeong, Yooseong
    Choi, Yong Seok
    Han, Sang Beom
    Lee, Dong-Kyu
    ANALYTICAL SCIENCE AND TECHNOLOGY, 2024, 37 (03): : 143 - 154