SlideShare a Scribd company logo
1 of 20
Download to read offline
Supersonic Query Engine API
A short introduction
(onufry@google.com,
tkaftal@google.com)
Introduction
Supersonic is a query engine library for efficient columnar data
processing.
Supersonic is all about speed.
The library uses many low-level, cache-aware optimisations in
order to achieve this goal.
It also has a robust and conveniet API - the aim of this
document is to provide a quick overview of how Supersonic
should be used.
Operations
The basic Supersonic class used to perform any operation is
called (surprise) "Operation".
Examples of Operations include Compute, Filter, Sort,
HashJoin and more.
Operations
The basic Supersonic class used to perform any operation is
called (surprise) "Operation".
Examples of Operations include Compute, Filter, Sort,
HashJoin and more.
In the typical case to create an operation we need:
● a child operation (or children), that supply data
● a projector (a description which of the output columns we
should pass on)
● usually some more stuff (an Expression in Compute, an
ordering description in Sort)
Operations - how to use them
Run an operation factory

Create a Cursor out of the
operation

Pull results using Next
Operations - how to use them
Run an operation factory

(input: child (i.e. data source),
projector, usually
specification)
returns: Operation

Create a Cursor out of the
operation

(ties the columns of the child
to the cursor, preparation for
evaluation)
returns: a Failure or Cursor

Pull results using Next

(pulls data from the cursor)
returns: a Failure or View
Computation example
Expression* expression = (...);
Operation* data_source = (...);
Operation* computation =
Compute(expression, data_source);
FailureOrOwned<Cursor> cursor =
computation->CreateCursor();
// error handling.
PROPAGATE_ON_FAILURE(cursor);
ResultView out_data = cursor.get()->Next();
// (now consume the results somehow).
Filtering example, with column
selection
Expression* predicate = (...);
Operation* data_source = (...);
Projector* projector = (...);
Operation* filter = Filter(
predicate, projector, data_source);
// memory management.
filter->SetBufferAllocator(
HeapBufferAllocator::Get(), false);
FailureOrOwned<Cursor> bound_filter =
filter->CreateCursor();
ResultView data = bound_filter.get()->Next();
Where does the data come from?
Supersonic does not currently provide a built-in data storage
format.
There is a strong intention of developing one.

As of now, data can be persisted in memory, using Tables.
Where does the data come from?
TupleSchema schema = (...);
Table table = Table(
schema, HeapBufferAllocator::Get());

Operation* table_input = new ScanView(
table->view());
Where does the data come from?
A more low-level approach:
TupleSchema schema = (...);
Table table = Table(
schema, HeapBufferAllocator::Get());
// Now you can add rows to this table using
// AppendRow, the specifics are in
// supersonic/cursor/infrastructure/row.h
FailureOrOwned<Cursor> cursor =
table.CreateCursor();
Failure recognition
Operation creation does not fail (in general).
Creating a Cursor can fail. Thus, a FailureOr<Cursor> is
returned from CreateCursor. This is a lightweight template.
Success is checked for by .is_failure(), and the result
retrieved through .get(). On failure we can analyze the
problem by .exception().
The typical "propagation" case is handled through
the PROPAGATE_ON_FAILURE(result); macro.
(that's a macro because we want to handle stack traces).

There's also a FailureOrOwned<T>, the equivalent of
scoped_ptr<T> (just as FailureOr<T> is the equivalent of T).
Expressions
Operation

Expression

CreateCursor

Bind

Cursor

BoundExpression

Next

Evaluate

ResultView

FailureOr<View>
Expression - where do I get the data?
In Operations, we assumed the child Cursor was the supplier of
the data.
However, in Expressions usually we supply data ourselves,
View by View (as an Expression is a part of a Cursor, and we
"hold" the root of the Expression tree, and not the leaves).
Thus, while Next() had no arguments, Evaluate(const
View&) takes an input View, which is then passed down, and
appropriate expressions (for instance NamedAttribute)
extract the appropriate View columns as their result Views.
Evaluating Expressions
Expression* column_a = NamedAttribute("a");
Expression* column_b = NamedAttribute("b");
Expression* plus = Plus(column_a, column_b);
TupleSchema input;
input.AddAttribute("a", INT32, NOT_NULLABLE);
input.AddAttribute("b", UINT32, NULLABLE);
FailureOrOwned<BoundExpression> bound_plus =
plus->Bind(input,
HeapBufferAllocator::Get(),
1000);
FailureOrReference<const View> output =
bound_plus->Evaluate(some_view);
Computation example with Expression
Expression* expression = Plus(
NamedAttribute("a"), NamedAttribute("b"));
Operation* data_source = (...);
Operation* computation = Compute(expression,
data_source);
computation->SetBufferAllocator(
HeapBufferAllocator::Get(), false);
FailureOrOwned<Cursor> cursor =
computation->CreateCursor();
ResultView out_data = cursor.get()->Next();
Object and data lifetime
Each supersonic Cursor/Expression/Operation/etc. owns its
children, and takes care of freeing them when it is itself
destroyed.
After calling Evaluate, the new View that is created overwrites
the old one - an Expression has space for only one block of
Evaluation results (this might change in the structured API).
Similarly, calling Next on a Cursor invalidates the old data.
Object and data lifetime
Expression* expression =
Plus(AttributeAt(0), AttributeAt(1));
BoundExpression* bound = expression.Bind(...);
ResultView result = bound.Evaluate(input1);
const View* view_pointer = &result.get();
bound.Evaluate(input2);
Now view_pointer points to a View containing the results of the
second Evaluation. The view encapsulates data that is physically
stored in a block that is a member of the BoundExpression and
gets overwritten with every Evaluate call.
The same goes for Cursors and calling Next().
How to copy data for reusal?
const View& result =
bound.Evaluate(some_view).get();
TupleSchema schema = result.result_schema();
// Prepare new block, same schema as our View
Block* new_space = new Block(schema,
HeapBufferAllocator::Get());
// Allocate same number of rows as our View.
new_space->Reallocate(result.row_count());
// Prepare a copier (the last true denotes a
// deep copy.
ViewCopier copier(schema, schema,
NO_SELECTOR, true);
// And copy the data.
copier.Copy(result.row_count(), result, NULL,
0, new_space);
What next?
To see some fully-fledged working examples download the
source and go to
supersonic/test/guide

More Related Content

What's hot

How to analyze and tune sql queries for better performance vts2016
How to analyze and tune sql queries for better performance vts2016How to analyze and tune sql queries for better performance vts2016
How to analyze and tune sql queries for better performance vts2016oysteing
 
Python Pandas for Data Science cheatsheet
Python Pandas for Data Science cheatsheet Python Pandas for Data Science cheatsheet
Python Pandas for Data Science cheatsheet Dr. Volkan OBAN
 
Scikit-learn Cheatsheet-Python
Scikit-learn Cheatsheet-PythonScikit-learn Cheatsheet-Python
Scikit-learn Cheatsheet-PythonDr. Volkan OBAN
 
Histogram Support in MySQL 8.0
Histogram Support in MySQL 8.0Histogram Support in MySQL 8.0
Histogram Support in MySQL 8.0oysteing
 
simple linear regression
simple linear regressionsimple linear regression
simple linear regressionAkhilesh Joshi
 
MySQL Optimizer: What’s New in 8.0
MySQL Optimizer: What’s New in 8.0MySQL Optimizer: What’s New in 8.0
MySQL Optimizer: What’s New in 8.0oysteing
 
Pandas Cheat Sheet
Pandas Cheat SheetPandas Cheat Sheet
Pandas Cheat SheetACASH1011
 
Ds lab manual by s.k.rath
Ds lab manual by s.k.rathDs lab manual by s.k.rath
Ds lab manual by s.k.rathSANTOSH RATH
 
Pointers and Dynamic Memory Allocation
Pointers and Dynamic Memory AllocationPointers and Dynamic Memory Allocation
Pointers and Dynamic Memory AllocationRabin BK
 
Data visualization by Kenneth Odoh
Data visualization by Kenneth OdohData visualization by Kenneth Odoh
Data visualization by Kenneth Odohpyconfi
 
Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...
Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...
Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...Edureka!
 
Intoduction to dynamic memory allocation
Intoduction to dynamic memory allocationIntoduction to dynamic memory allocation
Intoduction to dynamic memory allocationUtsav276
 
Scientific Computing with Python - NumPy | WeiYuan
Scientific Computing with Python - NumPy | WeiYuanScientific Computing with Python - NumPy | WeiYuan
Scientific Computing with Python - NumPy | WeiYuanWei-Yuan Chang
 
computer notes - Data Structures - 9
computer notes - Data Structures - 9computer notes - Data Structures - 9
computer notes - Data Structures - 9ecomputernotes
 
Data structure lab manual
Data structure lab manualData structure lab manual
Data structure lab manualnikshaikh786
 
13. dynamic allocation
13. dynamic allocation13. dynamic allocation
13. dynamic allocation웅식 전
 
Blank Row Find and Select
Blank Row Find and SelectBlank Row Find and Select
Blank Row Find and SelectRobert Burns
 

What's hot (20)

How to analyze and tune sql queries for better performance vts2016
How to analyze and tune sql queries for better performance vts2016How to analyze and tune sql queries for better performance vts2016
How to analyze and tune sql queries for better performance vts2016
 
Python Pandas for Data Science cheatsheet
Python Pandas for Data Science cheatsheet Python Pandas for Data Science cheatsheet
Python Pandas for Data Science cheatsheet
 
Scikit-learn Cheatsheet-Python
Scikit-learn Cheatsheet-PythonScikit-learn Cheatsheet-Python
Scikit-learn Cheatsheet-Python
 
Histogram Support in MySQL 8.0
Histogram Support in MySQL 8.0Histogram Support in MySQL 8.0
Histogram Support in MySQL 8.0
 
Numpy python cheat_sheet
Numpy python cheat_sheetNumpy python cheat_sheet
Numpy python cheat_sheet
 
simple linear regression
simple linear regressionsimple linear regression
simple linear regression
 
MySQL Optimizer: What’s New in 8.0
MySQL Optimizer: What’s New in 8.0MySQL Optimizer: What’s New in 8.0
MySQL Optimizer: What’s New in 8.0
 
Pandas Cheat Sheet
Pandas Cheat SheetPandas Cheat Sheet
Pandas Cheat Sheet
 
2 a networkflow
2 a networkflow2 a networkflow
2 a networkflow
 
Ds lab manual by s.k.rath
Ds lab manual by s.k.rathDs lab manual by s.k.rath
Ds lab manual by s.k.rath
 
Pointers and Dynamic Memory Allocation
Pointers and Dynamic Memory AllocationPointers and Dynamic Memory Allocation
Pointers and Dynamic Memory Allocation
 
Data visualization by Kenneth Odoh
Data visualization by Kenneth OdohData visualization by Kenneth Odoh
Data visualization by Kenneth Odoh
 
Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...
Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...
Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...
 
Intoduction to dynamic memory allocation
Intoduction to dynamic memory allocationIntoduction to dynamic memory allocation
Intoduction to dynamic memory allocation
 
Scientific Computing with Python - NumPy | WeiYuan
Scientific Computing with Python - NumPy | WeiYuanScientific Computing with Python - NumPy | WeiYuan
Scientific Computing with Python - NumPy | WeiYuan
 
computer notes - Data Structures - 9
computer notes - Data Structures - 9computer notes - Data Structures - 9
computer notes - Data Structures - 9
 
C sharp 8
C sharp 8C sharp 8
C sharp 8
 
Data structure lab manual
Data structure lab manualData structure lab manual
Data structure lab manual
 
13. dynamic allocation
13. dynamic allocation13. dynamic allocation
13. dynamic allocation
 
Blank Row Find and Select
Blank Row Find and SelectBlank Row Find and Select
Blank Row Find and Select
 

Similar to Api presentation

An ADF Special Report
An ADF Special Report An ADF Special Report
An ADF Special Report Luc Bors
 
CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...
CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...
CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...DataStax
 
The life of a query (oracle edition)
The life of a query (oracle edition)The life of a query (oracle edition)
The life of a query (oracle edition)maclean liu
 
How to Bring Common UI Patterns to ADF
How to Bring Common UI Patterns to ADF How to Bring Common UI Patterns to ADF
How to Bring Common UI Patterns to ADF Luc Bors
 
Coherence SIG: Advanced usage of indexes in coherence
Coherence SIG: Advanced usage of indexes in coherenceCoherence SIG: Advanced usage of indexes in coherence
Coherence SIG: Advanced usage of indexes in coherencearagozin
 
Tony jambu (obscure) tools of the trade for tuning oracle sq ls
Tony jambu   (obscure) tools of the trade for tuning oracle sq lsTony jambu   (obscure) tools of the trade for tuning oracle sq ls
Tony jambu (obscure) tools of the trade for tuning oracle sq lsInSync Conference
 
Practical Google App Engine Applications In Py
Practical Google App Engine Applications In PyPractical Google App Engine Applications In Py
Practical Google App Engine Applications In PyEric ShangKuan
 
Bubbles – Virtual Data Objects
Bubbles – Virtual Data ObjectsBubbles – Virtual Data Objects
Bubbles – Virtual Data ObjectsStefan Urbanek
 
Write Faster SQL with Trino.pdf
Write Faster SQL with Trino.pdfWrite Faster SQL with Trino.pdf
Write Faster SQL with Trino.pdfEric Xiao
 
CBStreams - Java Streams for ColdFusion (CFML)
CBStreams - Java Streams for ColdFusion (CFML)CBStreams - Java Streams for ColdFusion (CFML)
CBStreams - Java Streams for ColdFusion (CFML)Ortus Solutions, Corp
 
ITB2019 CBStreams : Accelerate your Functional Programming with the power of ...
ITB2019 CBStreams : Accelerate your Functional Programming with the power of ...ITB2019 CBStreams : Accelerate your Functional Programming with the power of ...
ITB2019 CBStreams : Accelerate your Functional Programming with the power of ...Ortus Solutions, Corp
 
Tips and Tricks of Developing .NET Application
Tips and Tricks of Developing .NET ApplicationTips and Tricks of Developing .NET Application
Tips and Tricks of Developing .NET ApplicationJoni
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with ClojureDmitry Buzdin
 
Myth busters - performance tuning 101 2007
Myth busters - performance tuning 101 2007Myth busters - performance tuning 101 2007
Myth busters - performance tuning 101 2007paulguerin
 
U-SQL Query Execution and Performance Tuning
U-SQL Query Execution and Performance TuningU-SQL Query Execution and Performance Tuning
U-SQL Query Execution and Performance TuningMichael Rys
 

Similar to Api presentation (20)

An ADF Special Report
An ADF Special Report An ADF Special Report
An ADF Special Report
 
Reporting solutions for ADF Applications
Reporting solutions for ADF ApplicationsReporting solutions for ADF Applications
Reporting solutions for ADF Applications
 
CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...
CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...
CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...
 
The life of a query (oracle edition)
The life of a query (oracle edition)The life of a query (oracle edition)
The life of a query (oracle edition)
 
How to Bring Common UI Patterns to ADF
How to Bring Common UI Patterns to ADF How to Bring Common UI Patterns to ADF
How to Bring Common UI Patterns to ADF
 
Coherence SIG: Advanced usage of indexes in coherence
Coherence SIG: Advanced usage of indexes in coherenceCoherence SIG: Advanced usage of indexes in coherence
Coherence SIG: Advanced usage of indexes in coherence
 
What is new in Java 8
What is new in Java 8What is new in Java 8
What is new in Java 8
 
How te bring common UI patterns to ADF
How te bring common UI patterns to ADFHow te bring common UI patterns to ADF
How te bring common UI patterns to ADF
 
Tony jambu (obscure) tools of the trade for tuning oracle sq ls
Tony jambu   (obscure) tools of the trade for tuning oracle sq lsTony jambu   (obscure) tools of the trade for tuning oracle sq ls
Tony jambu (obscure) tools of the trade for tuning oracle sq ls
 
Practical Google App Engine Applications In Py
Practical Google App Engine Applications In PyPractical Google App Engine Applications In Py
Practical Google App Engine Applications In Py
 
Bubbles – Virtual Data Objects
Bubbles – Virtual Data ObjectsBubbles – Virtual Data Objects
Bubbles – Virtual Data Objects
 
Write Faster SQL with Trino.pdf
Write Faster SQL with Trino.pdfWrite Faster SQL with Trino.pdf
Write Faster SQL with Trino.pdf
 
JQuery Flot
JQuery FlotJQuery Flot
JQuery Flot
 
CBStreams - Java Streams for ColdFusion (CFML)
CBStreams - Java Streams for ColdFusion (CFML)CBStreams - Java Streams for ColdFusion (CFML)
CBStreams - Java Streams for ColdFusion (CFML)
 
ITB2019 CBStreams : Accelerate your Functional Programming with the power of ...
ITB2019 CBStreams : Accelerate your Functional Programming with the power of ...ITB2019 CBStreams : Accelerate your Functional Programming with the power of ...
ITB2019 CBStreams : Accelerate your Functional Programming with the power of ...
 
Tips and Tricks of Developing .NET Application
Tips and Tricks of Developing .NET ApplicationTips and Tricks of Developing .NET Application
Tips and Tricks of Developing .NET Application
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
QB Into the Box 2018
QB Into the Box 2018QB Into the Box 2018
QB Into the Box 2018
 
Myth busters - performance tuning 101 2007
Myth busters - performance tuning 101 2007Myth busters - performance tuning 101 2007
Myth busters - performance tuning 101 2007
 
U-SQL Query Execution and Performance Tuning
U-SQL Query Execution and Performance TuningU-SQL Query Execution and Performance Tuning
U-SQL Query Execution and Performance Tuning
 

More from Susant Sahani

How to debug systemd problems fedora project
How to debug systemd problems   fedora projectHow to debug systemd problems   fedora project
How to debug systemd problems fedora projectSusant Sahani
 
Systemd vs-sys vinit-cheatsheet.jpg
Systemd vs-sys vinit-cheatsheet.jpgSystemd vs-sys vinit-cheatsheet.jpg
Systemd vs-sys vinit-cheatsheet.jpgSusant Sahani
 
Systemd for administrators
Systemd for administratorsSystemd for administrators
Systemd for administratorsSusant Sahani
 
Systemd mlug-20140614
Systemd mlug-20140614Systemd mlug-20140614
Systemd mlug-20140614Susant Sahani
 
Summit demystifying systemd1
Summit demystifying systemd1Summit demystifying systemd1
Summit demystifying systemd1Susant Sahani
 
Systemd evolution revolution_regression
Systemd evolution revolution_regressionSystemd evolution revolution_regression
Systemd evolution revolution_regressionSusant Sahani
 
Systemd for administrators
Systemd for administratorsSystemd for administrators
Systemd for administratorsSusant Sahani
 
Interface between kernel and user space
Interface between kernel and user spaceInterface between kernel and user space
Interface between kernel and user spaceSusant Sahani
 
Van jaconson netchannels
Van jaconson netchannelsVan jaconson netchannels
Van jaconson netchannelsSusant Sahani
 
Synchronization linux
Synchronization linuxSynchronization linux
Synchronization linuxSusant Sahani
 

More from Susant Sahani (20)

systemd
systemdsystemd
systemd
 
systemd
systemdsystemd
systemd
 
How to debug systemd problems fedora project
How to debug systemd problems   fedora projectHow to debug systemd problems   fedora project
How to debug systemd problems fedora project
 
Systemd vs-sys vinit-cheatsheet.jpg
Systemd vs-sys vinit-cheatsheet.jpgSystemd vs-sys vinit-cheatsheet.jpg
Systemd vs-sys vinit-cheatsheet.jpg
 
Systemd cheatsheet
Systemd cheatsheetSystemd cheatsheet
Systemd cheatsheet
 
Systemd
SystemdSystemd
Systemd
 
Systemd for administrators
Systemd for administratorsSystemd for administrators
Systemd for administrators
 
Pdf c1t tlawaxb
Pdf c1t tlawaxbPdf c1t tlawaxb
Pdf c1t tlawaxb
 
Systemd mlug-20140614
Systemd mlug-20140614Systemd mlug-20140614
Systemd mlug-20140614
 
Summit demystifying systemd1
Summit demystifying systemd1Summit demystifying systemd1
Summit demystifying systemd1
 
Systemd evolution revolution_regression
Systemd evolution revolution_regressionSystemd evolution revolution_regression
Systemd evolution revolution_regression
 
Systemd for administrators
Systemd for administratorsSystemd for administrators
Systemd for administrators
 
Systemd poettering
Systemd poetteringSystemd poettering
Systemd poettering
 
Interface between kernel and user space
Interface between kernel and user spaceInterface between kernel and user space
Interface between kernel and user space
 
Week3 binary trees
Week3 binary treesWeek3 binary trees
Week3 binary trees
 
Van jaconson netchannels
Van jaconson netchannelsVan jaconson netchannels
Van jaconson netchannels
 
Trees
TreesTrees
Trees
 
Synchronization linux
Synchronization linuxSynchronization linux
Synchronization linux
 
Demo preorder-stack
Demo preorder-stackDemo preorder-stack
Demo preorder-stack
 
Bacnet white paper
Bacnet white paperBacnet white paper
Bacnet white paper
 

Recently uploaded

Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 

Recently uploaded (20)

Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 

Api presentation

  • 1. Supersonic Query Engine API A short introduction (onufry@google.com, tkaftal@google.com)
  • 2. Introduction Supersonic is a query engine library for efficient columnar data processing. Supersonic is all about speed. The library uses many low-level, cache-aware optimisations in order to achieve this goal. It also has a robust and conveniet API - the aim of this document is to provide a quick overview of how Supersonic should be used.
  • 3. Operations The basic Supersonic class used to perform any operation is called (surprise) "Operation". Examples of Operations include Compute, Filter, Sort, HashJoin and more.
  • 4. Operations The basic Supersonic class used to perform any operation is called (surprise) "Operation". Examples of Operations include Compute, Filter, Sort, HashJoin and more. In the typical case to create an operation we need: ● a child operation (or children), that supply data ● a projector (a description which of the output columns we should pass on) ● usually some more stuff (an Expression in Compute, an ordering description in Sort)
  • 5. Operations - how to use them Run an operation factory Create a Cursor out of the operation Pull results using Next
  • 6. Operations - how to use them Run an operation factory (input: child (i.e. data source), projector, usually specification) returns: Operation Create a Cursor out of the operation (ties the columns of the child to the cursor, preparation for evaluation) returns: a Failure or Cursor Pull results using Next (pulls data from the cursor) returns: a Failure or View
  • 7. Computation example Expression* expression = (...); Operation* data_source = (...); Operation* computation = Compute(expression, data_source); FailureOrOwned<Cursor> cursor = computation->CreateCursor(); // error handling. PROPAGATE_ON_FAILURE(cursor); ResultView out_data = cursor.get()->Next(); // (now consume the results somehow).
  • 8. Filtering example, with column selection Expression* predicate = (...); Operation* data_source = (...); Projector* projector = (...); Operation* filter = Filter( predicate, projector, data_source); // memory management. filter->SetBufferAllocator( HeapBufferAllocator::Get(), false); FailureOrOwned<Cursor> bound_filter = filter->CreateCursor(); ResultView data = bound_filter.get()->Next();
  • 9. Where does the data come from? Supersonic does not currently provide a built-in data storage format. There is a strong intention of developing one. As of now, data can be persisted in memory, using Tables.
  • 10. Where does the data come from? TupleSchema schema = (...); Table table = Table( schema, HeapBufferAllocator::Get()); Operation* table_input = new ScanView( table->view());
  • 11. Where does the data come from? A more low-level approach: TupleSchema schema = (...); Table table = Table( schema, HeapBufferAllocator::Get()); // Now you can add rows to this table using // AppendRow, the specifics are in // supersonic/cursor/infrastructure/row.h FailureOrOwned<Cursor> cursor = table.CreateCursor();
  • 12. Failure recognition Operation creation does not fail (in general). Creating a Cursor can fail. Thus, a FailureOr<Cursor> is returned from CreateCursor. This is a lightweight template. Success is checked for by .is_failure(), and the result retrieved through .get(). On failure we can analyze the problem by .exception(). The typical "propagation" case is handled through the PROPAGATE_ON_FAILURE(result); macro. (that's a macro because we want to handle stack traces). There's also a FailureOrOwned<T>, the equivalent of scoped_ptr<T> (just as FailureOr<T> is the equivalent of T).
  • 14. Expression - where do I get the data? In Operations, we assumed the child Cursor was the supplier of the data. However, in Expressions usually we supply data ourselves, View by View (as an Expression is a part of a Cursor, and we "hold" the root of the Expression tree, and not the leaves). Thus, while Next() had no arguments, Evaluate(const View&) takes an input View, which is then passed down, and appropriate expressions (for instance NamedAttribute) extract the appropriate View columns as their result Views.
  • 15. Evaluating Expressions Expression* column_a = NamedAttribute("a"); Expression* column_b = NamedAttribute("b"); Expression* plus = Plus(column_a, column_b); TupleSchema input; input.AddAttribute("a", INT32, NOT_NULLABLE); input.AddAttribute("b", UINT32, NULLABLE); FailureOrOwned<BoundExpression> bound_plus = plus->Bind(input, HeapBufferAllocator::Get(), 1000); FailureOrReference<const View> output = bound_plus->Evaluate(some_view);
  • 16. Computation example with Expression Expression* expression = Plus( NamedAttribute("a"), NamedAttribute("b")); Operation* data_source = (...); Operation* computation = Compute(expression, data_source); computation->SetBufferAllocator( HeapBufferAllocator::Get(), false); FailureOrOwned<Cursor> cursor = computation->CreateCursor(); ResultView out_data = cursor.get()->Next();
  • 17. Object and data lifetime Each supersonic Cursor/Expression/Operation/etc. owns its children, and takes care of freeing them when it is itself destroyed. After calling Evaluate, the new View that is created overwrites the old one - an Expression has space for only one block of Evaluation results (this might change in the structured API). Similarly, calling Next on a Cursor invalidates the old data.
  • 18. Object and data lifetime Expression* expression = Plus(AttributeAt(0), AttributeAt(1)); BoundExpression* bound = expression.Bind(...); ResultView result = bound.Evaluate(input1); const View* view_pointer = &result.get(); bound.Evaluate(input2); Now view_pointer points to a View containing the results of the second Evaluation. The view encapsulates data that is physically stored in a block that is a member of the BoundExpression and gets overwritten with every Evaluate call. The same goes for Cursors and calling Next().
  • 19. How to copy data for reusal? const View& result = bound.Evaluate(some_view).get(); TupleSchema schema = result.result_schema(); // Prepare new block, same schema as our View Block* new_space = new Block(schema, HeapBufferAllocator::Get()); // Allocate same number of rows as our View. new_space->Reallocate(result.row_count()); // Prepare a copier (the last true denotes a // deep copy. ViewCopier copier(schema, schema, NO_SELECTOR, true); // And copy the data. copier.Copy(result.row_count(), result, NULL, 0, new_space);
  • 20. What next? To see some fully-fledged working examples download the source and go to supersonic/test/guide