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

Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Recently uploaded (20)

Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

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