Regular Programming Over Data Streams
Total Page:16
File Type:pdf, Size:1020Kb
University of Pennsylvania ScholarlyCommons Publicly Accessible Penn Dissertations 2017 Regular Programming Over Data Streams Mukund Raghothaman University of Pennsylvania, [email protected] Follow this and additional works at: https://repository.upenn.edu/edissertations Part of the Computer Sciences Commons Recommended Citation Raghothaman, Mukund, "Regular Programming Over Data Streams" (2017). Publicly Accessible Penn Dissertations. 2540. https://repository.upenn.edu/edissertations/2540 This paper is posted at ScholarlyCommons. https://repository.upenn.edu/edissertations/2540 For more information, please contact [email protected]. Regular Programming Over Data Streams Abstract Data streams arise in a variety of applications, such as feeds from financial markets, event streams from sensors and medical devices, logs produced by long-running programs, click-streams from websites, and packet sequences passing through internet routers. In this thesis, we are concerned with computing quantitative statistics over these streams, and with expressing transformations in the related domain of strings. Many string transformations are instances of simple patterns, such as inserting, deleting and replacing substrings, or applying a function to each element in the stream. Over data streams, the task is usually to compute some simple quantitative statistic, such as counting the number of occurrences of a pattern or the mean time between occurrences of an event. There has traditionally been limited programming language support for stream processing, and programmers are forced to write low-level code, by manually maintaining state and updating it on seeing each new input element. This sacrifices both ease of expression and amenability to static analysis. We propose a simple, expressive programming model for stream transformations, with strong theoretical foundations and fast evaluation algorithms. We present two concrete systems: DReX, to express string-to-string transformations, and quantitative regular expressions (QREs) for numerical queries. Both formalisms start with a set of basic functions and a small collection of hierarchically composable combinators, analogous to the operations of regular expressions. The operators are simple to describe, and can be used to combine small, easy-to-understand expressions into more complicated expressions. The functions expressible using DReX and QREs coincide with the class of regular string transformations, which is a robust class with multiple characterizations and appealing closure properties (under composition, input reversal, and regular look-ahead). We present a single-pass linear-time evaluation algorithm for function expressions, and study efficient approximate representations of numerical terms, so that some numerical QREs can also be evaluated with sub-linear memory requirements. Degree Type Dissertation Degree Name Doctor of Philosophy (PhD) Graduate Group Computer and Information Science First Advisor Rajeev Alur Keywords Data streams, Programming languages, Quantitative analysis, Regular expressions Subject Categories Computer Sciences This dissertation is available at ScholarlyCommons: https://repository.upenn.edu/edissertations/2540 REGULAR PROGRAMMING OVER DATA STREAMS Mukund Raghothaman A DISSERTATION in Computer and Information Science Presented to the Faculties of the University of Pennsylvania in Partial Fulfillment of the Requirements for the Degree of Doctor of Philosophy 2017 Supervisor of Dissertation Graduate Group Chairperson Rajeev Alur Lyle Ungar Zisman Family Professor of Professor of Computer and Computer and Information Science Information Science Dissertation Committee Susan Davidson, Weiss Professor of Computer and Information Science Sanjeev Khanna, Henry Salvatori Professor of Computer and Information Science Benjamin Pierce, Henry Salvatori Professor of Computer and Information Science Moshe Vardi, Karen Ostrum George Distinguished Service Professor in Computational Engineering, Rice University Acknowledgements First and foremost, I would like to thank my advisor, Rajeev Alur. This thesis would not have been possible without his support and guidance. My thesis committee consisted of Susan Davidson, Sanjeev Khanna, Benjamin Pierce, and Moshe Vardi: I thank them for the careful reading of this document and suggestions for improvement. I would also like to thank Youssef Hamadi and Yi Wei for hosting me at Microsoft Research Cambridge for two exciting and productive summers. One of the best parts about working with Rajeev is the wonderful group of postdocs and research scientists he assembles. Dana Fisman, Kostas Mamouras, and Arjun Radhakrishna deserve special mention: their keen eye for detail has contributed immeasurably towards making this a more rigorous and better presented thesis. Christos Stergiou, Ashutosh Trivedi, and Jyotirmoy Deshmukh provided great guidance at various stages of this Ph.D. journey. Jyotirmoy was the one who pushed me to follow up what would become my first research paper, and continues to be a rich source of technical problems and an excellent sounding board for ideas. Over six years and innumerable cups of coffee, Abhishek Udupa and I have become close friends and professional collaborators. The cohort of Rajeev’s Ph.D. students—Abhishek, Loris D’Antoni, Salar Moarref, Yifei Yuan, and Nimit Singhania—formed an amazing and lively peer group with which to discuss research problems. My office-mates in GRW 571—Salar, Nan Zheng, Kai Hong, and Shaheen Jabbari—have each contributed in their little way to the successful completion of this thesis. Arjun Ravi Narayan taught me a lot: from writing code to economics trivia and general wisdom about life. Mike Felker greatly simplified and helped me navigate the bureaucracy associated with being an international Ph.D. student. Outside the department, Varun Aggarwala, Carin Molenaar, the ECE Lobby from college, and Abhishek Anand were all always there. Finally, I thank my parents, my grandmother, and my brother, without whom I would not even have begun work on this thesis. For them, no words of gratitude will ever be enough. Mukund Raghothaman March 8, 2017 ii ABSTRACT REGULAR PROGRAMMING OVER DATA STREAMS Mukund Raghothaman Rajeev Alur Data streams arise in a variety of applications, such as feeds from financial markets, event streams from sensors and medical devices, logs produced by long-running programs, click-streams from websites, and packet sequences passing through internet routers. In this thesis, we are concerned with computing quantitative statistics over these streams, and with expressing transformations in the related domain of strings. Many string transformations are instances of simple patterns, such as inserting, deleting and replacing substrings, or applying a function to each element in the stream. Over data streams, the task is usually to compute some simple quantitative statistic, such as counting the number of occurrences of a pattern or the mean time between occurrences of an event. There has traditionally been limited programming language support for stream processing, and programmers are forced to write low-level code, by manually maintaining state and updating it on seeing each new input element. This sacrifices both ease of expression and amenability to static analysis. We propose a simple, expressive programming model for stream transformations, with strong theoretical foundations and fast evaluation algorithms. We present two concrete systems: DReX, to express string-to-string transformations, and quantitative regular expressions (QREs) for numerical queries. Both formalisms start with a set of basic functions and a small collection of hierarchically composable combinators, analogous to the operations of regular expressions. The operators are simple to describe, and can be used to combine small, easy-to-understand expressions into more complicated expressions. iii iv The functions expressible using DReX and QREs coincide with the class of regular string transformations, which is a robust class with multiple characterizations and appealing closure properties (under composition, input reversal, and regular look-ahead). We present a single- pass linear-time evaluation algorithm for function expressions, and study efficient approximate representations of numerical terms, so that some numerical QREs can also be evaluated with sub-linear memory requirements. This thesis is based on material drawn from the following publications: 1. Rajeev Alur, Adam Freilich, and Mukund Raghothaman. Regular combinators for string transformations. In Proceedings of the Joint Meeting of the 23rd EACSL Annual Conference on Computer Science Logic and the 29th Annual ACM/IEEE Symposium on Logic in Computer Science, CSL-LICS 2014, pages 9:1–9:10. ACM, 2014. 2. Rajeev Alur, Loris D’Antoni, and Mukund Raghothaman. DReX: A declarative language for efficiently evaluating regular string transformations. In Proceedings of the 42nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2015, pages 125–137. ACM, 2015. 3. Rajeev Alur, Dana Fisman, and Mukund Raghothaman. Regular programming for quantitative properties of data streams. In Peter Thiemann, editor, Programming Languages and Systems: Proceedings of the 25th European Symposium on Programming, ESOP 2016, pages 15–40. Springer, 2016. 4. Rajeev Alur, Sanjeev Khanna, Zachary Ives, Konstantinos Mamouras, and Mukund Raghothaman. StreamQRE: Modular specification and efficient evaluation of quantita- tive queries over streaming data.