SlideShare a Scribd company logo
Running MRuby in a database Totally awesome, useful or just another pointless approach? Frank Celler, triAGENS, Cologne RuPy 2012, Brno 2012-11-16 www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
Agenda NoSQL database ArangoDB Use-Cases for actions mruby V8 or mruby? www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
NoSQL Databases Key/Value Store Document (Object) DB Graph Database www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
NoSQL Databases 2012-11-11: 150 DB on nosql-databases.org Key/Value Store Document (Object) DB Graph Database www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
NoSQL Databases 2012-11-11: 150 DB on nosql-databases.org Key/Value Store Document (Object) DB Graph Database Multi-Model Databases Polyglot Persistence www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
Multi-Model Open-Source Database Various Indexes: Skip-Lists, Hashes, Geo, Cap Language API/Drivers for big Ps, Ruby, JS Embedded JavaScript & Ruby engine Written in C/C++ Query Language for Joins and Sub-Structures www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
Query Language: FOR u in Users FOR u IN users LET rs = ( LET friends = ( FOR r in Recommendations FOR p in PATHS(user, relations, ``outbound´´, 1) FILTER r.rec_by == u._id && r.type == "Book" FILTER p._from == u._id RETURN r.book_title ) ) FILTER RETURN length(rs) >= 3 { user: u, closeFriends: friends } RETURN { "name" : u.name, "titles" : rs } (compare with UNQL / JSONiq) www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
Use-Cases for script languages GET /user/fceller function (req, res) { var user = db.users.byExample({ username: req.urlParameters.username }); ... deal with unknown user... enrich result user.age = ... compute user age from birthday ...; delete user.hashedPassword; actions.resultOk(req, res, actions.HTTP_OK, user); hide info } www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
Use-Cases for script languages GET /user/fceller/eccentricity function (req, res) { var user = db.users.byExample({ username: req.urlParameters.username }); ... deal with unknown user... needs every node var eccentricity = ... compute eccentricity ...; actions.resultOk(req, res, actions.HTTP_OK, eccentricity); } www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
Use-Cases for script languages Transactions Triggers Predefined Objects for AJAX www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
MRuby Matz's embeddable minimal implementation of Ruby language www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
MRuby RiteVM as core Minimal standard libraries quotes from Matz Embeddable C API No perfect languages, even Ruby Like to provide choices www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
MRuby vs V8 JavaScript is a “complicated” language for embedding C++ class hierarchies V8 itself is complex (isolates, contexts, handle scopes), but fast mruby is plain and simple C code documentation is sketchy for both www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
MRuby vs V8 def fact n; (n > 1) ? n*fact(n-1) : 1; end mruby: 20 time-units V8: 0.6 time-units php: 20 time-units Ruby 1.9 (int): 9 time-units www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
Why use MRuby? “Like to provide choices” i.e. if you don‘t like prototype inheritance “still young” i.e. instead of using RiteVM, compile to machine code www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
MRuby and LLVM def fact n; (n > 1) ? n*fact(n-1) : 1; end 000 OP_ENTER    1:0:0:0:0:0:0 001 OP_MOVE     R4      R1 002 OP_LOADI    R5      1 003 OP_LOADNIL  R6 004 OP_GT       R4      '>'     1 005 OP_JMPNOT   R4      017 006 OP_MOVE     R4      R1 007 OP_LOADSELF R5 008 OP_MOVE     R6      R1 009 OP_LOADI    R7      1 010 OP_LOADNIL  R8 011 OP_SUB      R6      '-'     1 012 OP_LOADNIL  R7 013 OP_SEND     R5      'fact' 1 014 OP_LOADNIL  R6 015 OP_MUL      R4      '*'     1 016 OP_JMP              018 017 OP_LOADI    R4      1 018 OP_RETURN   R4 www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
MRuby and LLVM CASE(OP_SUB) { /* A B C R(A) := R(A)-R(A+1) (Syms[B]=:-,C=1)*/ int a = GETARG_A(i); /* need to check if op is overridden */ switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) { case TYPES2(MRB_TT_FIXNUM,MRB_TT_FIXNUM): { mrb_int x, y, z; x = mrb_fixnum(regs[a]); y = mrb_fixnum(regs[a+1]); z = x - y; if (((x < 0) ^ (y < 0)) == 0 && (x < 0) != (z < 0)) { /* integer overflow */ SET_FLT_VALUE(regs[a], (mrb_float)x - (mrb_float)y); break; } SET_INT_VALUE(regs[a], z); } break; Simply replacing OP codes by machine code already gives a factor of 2 www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
Why use MRuby? If you have use-cases for scripts in ArangoDB (or any other database), mruby will eventually be an alternative Otherwise, use a language driver (aka Ashikawa for Ruby) and CRuby or JRuby www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
Thank You! Stay in Touch: Fork me on github Google Group: ArangoDB Twitter: @fceller & @arangodb www.arangodb.org www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12

More Related Content

What's hot (20)

PDF
A Graph Database That Scales - ArangoDB 3.7 Release Webinar
ArangoDB Database
 
PDF
Multi-model databases and node.js
Max Neunhöffer
 
PPTX
A Little SPARQL in your Analytics
Dr. Neil Brittliff
 
PPTX
Comparison with storing data using NoSQL(CouchDB) and a relational database.
eross77
 
PDF
Visualize your graph database
Michael Hackstein
 
PDF
Small Overview of Skype Database Tools
elliando dias
 
PPTX
Solid pods and the future of the spatial web
Kurt Cagle
 
PPTX
An introduction to Nosql
greprep
 
PDF
OrientDB: Unlock the Value of Document Data Relationships
Fabrizio Fortino
 
PPTX
PostgreSQL - Object Relational Database
Mubashar Iqbal
 
PDF
MongoDB is the MashupDB
Wynn Netherland
 
PDF
Introduction to RDFa
Ivan Herman
 
PPTX
RDFa Tutorial
Ivan Herman
 
PPT
Catmandu Librecat
Patrick Hochstenbach
 
ODP
State of the Semantic Web
Ivan Herman
 
PDF
DataFrame: Spark's new abstraction for data science by Reynold Xin of Databricks
Data Con LA
 
PPTX
RDF SHACL, Annotations, and Data Frames
Kurt Cagle
 
PDF
OrientDB & Node.js Overview - JS.Everywhere() KW
gmccarvell
 
PDF
Visualizing Web Data Query Results
Anja Jentzsch
 
PDF
Big Data Processing using Apache Spark and Clojure
Dr. Christian Betz
 
A Graph Database That Scales - ArangoDB 3.7 Release Webinar
ArangoDB Database
 
Multi-model databases and node.js
Max Neunhöffer
 
A Little SPARQL in your Analytics
Dr. Neil Brittliff
 
Comparison with storing data using NoSQL(CouchDB) and a relational database.
eross77
 
Visualize your graph database
Michael Hackstein
 
Small Overview of Skype Database Tools
elliando dias
 
Solid pods and the future of the spatial web
Kurt Cagle
 
An introduction to Nosql
greprep
 
OrientDB: Unlock the Value of Document Data Relationships
Fabrizio Fortino
 
PostgreSQL - Object Relational Database
Mubashar Iqbal
 
MongoDB is the MashupDB
Wynn Netherland
 
Introduction to RDFa
Ivan Herman
 
RDFa Tutorial
Ivan Herman
 
Catmandu Librecat
Patrick Hochstenbach
 
State of the Semantic Web
Ivan Herman
 
DataFrame: Spark's new abstraction for data science by Reynold Xin of Databricks
Data Con LA
 
RDF SHACL, Annotations, and Data Frames
Kurt Cagle
 
OrientDB & Node.js Overview - JS.Everywhere() KW
gmccarvell
 
Visualizing Web Data Query Results
Anja Jentzsch
 
Big Data Processing using Apache Spark and Clojure
Dr. Christian Betz
 

Viewers also liked (20)

PDF
Backbone using Extensible Database APIs over HTTP
Max Neunhöffer
 
PDF
Hotcode 2013: Javascript in a database (Part 2)
ArangoDB Database
 
PDF
Complex queries in a distributed multi-model database
Max Neunhöffer
 
PDF
GraphDatabases and what we can use them for
Michael Hackstein
 
PDF
Extensible Database APIs and their role in Software Architecture
Max Neunhöffer
 
PDF
Domain Driven Design & NoSQL
ArangoDB Database
 
PDF
ArangoDB – Persistência Poliglota e Banco de Dados Multi-Modelos
Helder Santana
 
PDF
Domain Driven Design & NoSQL
ArangoDB Database
 
PDF
Multi model-databases
ArangoDB Database
 
PDF
Jan Steemann: Modelling data in a schema free world (Talk held at Froscon, 2...
ArangoDB Database
 
PDF
Processing large-scale graphs with Google(TM) Pregel by MICHAEL HACKSTEIN at...
Big Data Spain
 
PDF
Overhauling a database engine in 2 months
Max Neunhöffer
 
PDF
guacamole: an Object Document Mapper for ArangoDB
Max Neunhöffer
 
PDF
Domain driven design @FrOSCon
ArangoDB Database
 
PDF
Processing large-scale graphs with Google Pregel
Max Neunhöffer
 
PDF
Wir sind aber nicht Twitter
ArangoDB Database
 
PDF
Domain Driven Design and NoSQL TLV
ArangoDB Database
 
PDF
Introduction to ArangoDB (nosql matters Barcelona 2012)
ArangoDB Database
 
PDF
CAP and the Architectural Consequences by martin Schönert
ArangoDB Database
 
PDF
Introduction to column oriented databases
ArangoDB Database
 
Backbone using Extensible Database APIs over HTTP
Max Neunhöffer
 
Hotcode 2013: Javascript in a database (Part 2)
ArangoDB Database
 
Complex queries in a distributed multi-model database
Max Neunhöffer
 
GraphDatabases and what we can use them for
Michael Hackstein
 
Extensible Database APIs and their role in Software Architecture
Max Neunhöffer
 
Domain Driven Design & NoSQL
ArangoDB Database
 
ArangoDB – Persistência Poliglota e Banco de Dados Multi-Modelos
Helder Santana
 
Domain Driven Design & NoSQL
ArangoDB Database
 
Multi model-databases
ArangoDB Database
 
Jan Steemann: Modelling data in a schema free world (Talk held at Froscon, 2...
ArangoDB Database
 
Processing large-scale graphs with Google(TM) Pregel by MICHAEL HACKSTEIN at...
Big Data Spain
 
Overhauling a database engine in 2 months
Max Neunhöffer
 
guacamole: an Object Document Mapper for ArangoDB
Max Neunhöffer
 
Domain driven design @FrOSCon
ArangoDB Database
 
Processing large-scale graphs with Google Pregel
Max Neunhöffer
 
Wir sind aber nicht Twitter
ArangoDB Database
 
Domain Driven Design and NoSQL TLV
ArangoDB Database
 
Introduction to ArangoDB (nosql matters Barcelona 2012)
ArangoDB Database
 
CAP and the Architectural Consequences by martin Schönert
ArangoDB Database
 
Introduction to column oriented databases
ArangoDB Database
 
Ad

Similar to Running MRuby in a Database - ArangoDB - RuPy 2012 (20)

PPTX
Drill dchug-29 nov2012
MapR Technologies
 
PDF
CloudFoundry and MongoDb, a marriage made in heaven
Patrick Chanezon
 
PDF
Nosql and newsql
Zhongke Chen
 
PPTX
Realtime Analytics with MongoDB Counters (mongonyc 2012)
Scott Hernandez
 
PPTX
PhillyDB Talk - Beyond Batch
boorad
 
PDF
Drupal and the rise of the documents
Claudio Beatrice
 
PDF
Hbase: Introduction to column oriented databases
Luis Cipriani
 
PDF
StORM preview
David Chandler
 
KEY
NOSQL, CouchDB, and the Cloud
boorad
 
PDF
Big Data for Mobile
BugSense
 
KEY
DevNation Atlanta
boorad
 
PDF
Bar Camp Auckland - Mongo DB Presentation BCA4
John Ballinger
 
PPTX
Drill Bay Area HUG 2012-09-19
jasonfrantz
 
PDF
Sep 2012 HUG: Apache Drill for Interactive Analysis
Yahoo Developer Network
 
PDF
Apache Drill @ PJUG, Jan 15, 2013
Gera Shegalov
 
PPTX
Drill at the Chug 9-19-12
Ted Dunning
 
PDF
MongoGraph - MongoDB Meets the Semantic Web
DATAVERSITY
 
PDF
Deep dive into the native multi model database ArangoDB
ArangoDB Database
 
PDF
FP Days: Down the Clojure Rabbit Hole
Christophe Grand
 
PDF
BRAINREPUBLIC - Powered by no-SQL
Andreas Jung
 
Drill dchug-29 nov2012
MapR Technologies
 
CloudFoundry and MongoDb, a marriage made in heaven
Patrick Chanezon
 
Nosql and newsql
Zhongke Chen
 
Realtime Analytics with MongoDB Counters (mongonyc 2012)
Scott Hernandez
 
PhillyDB Talk - Beyond Batch
boorad
 
Drupal and the rise of the documents
Claudio Beatrice
 
Hbase: Introduction to column oriented databases
Luis Cipriani
 
StORM preview
David Chandler
 
NOSQL, CouchDB, and the Cloud
boorad
 
Big Data for Mobile
BugSense
 
DevNation Atlanta
boorad
 
Bar Camp Auckland - Mongo DB Presentation BCA4
John Ballinger
 
Drill Bay Area HUG 2012-09-19
jasonfrantz
 
Sep 2012 HUG: Apache Drill for Interactive Analysis
Yahoo Developer Network
 
Apache Drill @ PJUG, Jan 15, 2013
Gera Shegalov
 
Drill at the Chug 9-19-12
Ted Dunning
 
MongoGraph - MongoDB Meets the Semantic Web
DATAVERSITY
 
Deep dive into the native multi model database ArangoDB
ArangoDB Database
 
FP Days: Down the Clojure Rabbit Hole
Christophe Grand
 
BRAINREPUBLIC - Powered by no-SQL
Andreas Jung
 
Ad

More from ArangoDB Database (20)

PPTX
ATO 2022 - Machine Learning + Graph Databases for Better Recommendations (3)....
ArangoDB Database
 
PPTX
Machine Learning + Graph Databases for Better Recommendations V2 08/20/2022
ArangoDB Database
 
PPTX
Machine Learning + Graph Databases for Better Recommendations V1 08/06/2022
ArangoDB Database
 
PPTX
ArangoDB 3.9 - Further Powering Graphs at Scale
ArangoDB Database
 
PDF
GraphSage vs Pinsage #InsideArangoDB
ArangoDB Database
 
PDF
Webinar: ArangoDB 3.8 Preview - Analytics at Scale
ArangoDB Database
 
PDF
Graph Analytics with ArangoDB
ArangoDB Database
 
PDF
Getting Started with ArangoDB Oasis
ArangoDB Database
 
PDF
Custom Pregel Algorithms in ArangoDB
ArangoDB Database
 
PPTX
Hacktoberfest 2020 - Intro to Knowledge Graphs
ArangoDB Database
 
PDF
gVisor, Kata Containers, Firecracker, Docker: Who is Who in the Container Space?
ArangoDB Database
 
PDF
ArangoML Pipeline Cloud - Managed Machine Learning Metadata
ArangoDB Database
 
PDF
ArangoDB 3.7 Roadmap: Performance at Scale
ArangoDB Database
 
PDF
Webinar: What to expect from ArangoDB Oasis
ArangoDB Database
 
PDF
ArangoDB 3.5 Feature Overview Webinar - Sept 12, 2019
ArangoDB Database
 
PDF
3.5 webinar
ArangoDB Database
 
PDF
Webinar: How native multi model works in ArangoDB
ArangoDB Database
 
PDF
An introduction to multi-model databases
ArangoDB Database
 
PDF
Running complex data queries in a distributed system
ArangoDB Database
 
PDF
Guacamole Fiesta: What do avocados and databases have in common?
ArangoDB Database
 
ATO 2022 - Machine Learning + Graph Databases for Better Recommendations (3)....
ArangoDB Database
 
Machine Learning + Graph Databases for Better Recommendations V2 08/20/2022
ArangoDB Database
 
Machine Learning + Graph Databases for Better Recommendations V1 08/06/2022
ArangoDB Database
 
ArangoDB 3.9 - Further Powering Graphs at Scale
ArangoDB Database
 
GraphSage vs Pinsage #InsideArangoDB
ArangoDB Database
 
Webinar: ArangoDB 3.8 Preview - Analytics at Scale
ArangoDB Database
 
Graph Analytics with ArangoDB
ArangoDB Database
 
Getting Started with ArangoDB Oasis
ArangoDB Database
 
Custom Pregel Algorithms in ArangoDB
ArangoDB Database
 
Hacktoberfest 2020 - Intro to Knowledge Graphs
ArangoDB Database
 
gVisor, Kata Containers, Firecracker, Docker: Who is Who in the Container Space?
ArangoDB Database
 
ArangoML Pipeline Cloud - Managed Machine Learning Metadata
ArangoDB Database
 
ArangoDB 3.7 Roadmap: Performance at Scale
ArangoDB Database
 
Webinar: What to expect from ArangoDB Oasis
ArangoDB Database
 
ArangoDB 3.5 Feature Overview Webinar - Sept 12, 2019
ArangoDB Database
 
3.5 webinar
ArangoDB Database
 
Webinar: How native multi model works in ArangoDB
ArangoDB Database
 
An introduction to multi-model databases
ArangoDB Database
 
Running complex data queries in a distributed system
ArangoDB Database
 
Guacamole Fiesta: What do avocados and databases have in common?
ArangoDB Database
 

Recently uploaded (20)

PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 

Running MRuby in a Database - ArangoDB - RuPy 2012

  • 1. Running MRuby in a database Totally awesome, useful or just another pointless approach? Frank Celler, triAGENS, Cologne RuPy 2012, Brno 2012-11-16 www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
  • 2. Agenda NoSQL database ArangoDB Use-Cases for actions mruby V8 or mruby? www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
  • 3. NoSQL Databases Key/Value Store Document (Object) DB Graph Database www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
  • 4. NoSQL Databases 2012-11-11: 150 DB on nosql-databases.org Key/Value Store Document (Object) DB Graph Database www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
  • 5. NoSQL Databases 2012-11-11: 150 DB on nosql-databases.org Key/Value Store Document (Object) DB Graph Database Multi-Model Databases Polyglot Persistence www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
  • 6. Multi-Model Open-Source Database Various Indexes: Skip-Lists, Hashes, Geo, Cap Language API/Drivers for big Ps, Ruby, JS Embedded JavaScript & Ruby engine Written in C/C++ Query Language for Joins and Sub-Structures www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
  • 7. Query Language: FOR u in Users FOR u IN users LET rs = ( LET friends = ( FOR r in Recommendations FOR p in PATHS(user, relations, ``outbound´´, 1) FILTER r.rec_by == u._id && r.type == "Book" FILTER p._from == u._id RETURN r.book_title ) ) FILTER RETURN length(rs) >= 3 { user: u, closeFriends: friends } RETURN { "name" : u.name, "titles" : rs } (compare with UNQL / JSONiq) www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
  • 8. Use-Cases for script languages GET /user/fceller function (req, res) { var user = db.users.byExample({ username: req.urlParameters.username }); ... deal with unknown user... enrich result user.age = ... compute user age from birthday ...; delete user.hashedPassword; actions.resultOk(req, res, actions.HTTP_OK, user); hide info } www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
  • 9. Use-Cases for script languages GET /user/fceller/eccentricity function (req, res) { var user = db.users.byExample({ username: req.urlParameters.username }); ... deal with unknown user... needs every node var eccentricity = ... compute eccentricity ...; actions.resultOk(req, res, actions.HTTP_OK, eccentricity); } www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
  • 10. Use-Cases for script languages Transactions Triggers Predefined Objects for AJAX www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
  • 11. MRuby Matz's embeddable minimal implementation of Ruby language www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
  • 12. MRuby RiteVM as core Minimal standard libraries quotes from Matz Embeddable C API No perfect languages, even Ruby Like to provide choices www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
  • 13. MRuby vs V8 JavaScript is a “complicated” language for embedding C++ class hierarchies V8 itself is complex (isolates, contexts, handle scopes), but fast mruby is plain and simple C code documentation is sketchy for both www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
  • 14. MRuby vs V8 def fact n; (n > 1) ? n*fact(n-1) : 1; end mruby: 20 time-units V8: 0.6 time-units php: 20 time-units Ruby 1.9 (int): 9 time-units www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
  • 15. Why use MRuby? “Like to provide choices” i.e. if you don‘t like prototype inheritance “still young” i.e. instead of using RiteVM, compile to machine code www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
  • 16. MRuby and LLVM def fact n; (n > 1) ? n*fact(n-1) : 1; end 000 OP_ENTER    1:0:0:0:0:0:0 001 OP_MOVE     R4      R1 002 OP_LOADI    R5      1 003 OP_LOADNIL  R6 004 OP_GT       R4      '>'     1 005 OP_JMPNOT   R4      017 006 OP_MOVE     R4      R1 007 OP_LOADSELF R5 008 OP_MOVE     R6      R1 009 OP_LOADI    R7      1 010 OP_LOADNIL  R8 011 OP_SUB      R6      '-'     1 012 OP_LOADNIL  R7 013 OP_SEND     R5      'fact' 1 014 OP_LOADNIL  R6 015 OP_MUL      R4      '*'     1 016 OP_JMP              018 017 OP_LOADI    R4      1 018 OP_RETURN   R4 www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
  • 17. MRuby and LLVM CASE(OP_SUB) { /* A B C R(A) := R(A)-R(A+1) (Syms[B]=:-,C=1)*/ int a = GETARG_A(i); /* need to check if op is overridden */ switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) { case TYPES2(MRB_TT_FIXNUM,MRB_TT_FIXNUM): { mrb_int x, y, z; x = mrb_fixnum(regs[a]); y = mrb_fixnum(regs[a+1]); z = x - y; if (((x < 0) ^ (y < 0)) == 0 && (x < 0) != (z < 0)) { /* integer overflow */ SET_FLT_VALUE(regs[a], (mrb_float)x - (mrb_float)y); break; } SET_INT_VALUE(regs[a], z); } break; Simply replacing OP codes by machine code already gives a factor of 2 www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
  • 18. Why use MRuby? If you have use-cases for scripts in ArangoDB (or any other database), mruby will eventually be an alternative Otherwise, use a language driver (aka Ashikawa for Ruby) and CRuby or JRuby www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12
  • 19. Thank You! Stay in Touch: Fork me on github Google Group: ArangoDB Twitter: @fceller & @arangodb www.arangodb.org www.arangodb.org (c) f.celler@triagens.de Mittwoch, 14. November 12