SlideShare uma empresa Scribd logo
1 de 35
Baixar para ler offline
Voyage by example 
tips and tricks on persisting object models
Esteban Lorenzano 
Pharo core developer 
INRIA - RMoD 
http://smallworks.eu
Why? 
• You already know about Voyage 
• You already attended to a tutorial last year 
• But there are some recurrent problems people find 
when trying to use it 
• And I’m still seeing a lot of people that could be 
using it and they chose other solutions
What is Voyage? (1) 
• Simple abstraction layer to map objects into a database 
- Very well suited for document databases, but in theory, 
the approach will work for other kind of repositories 
‣ There was (long time ago) a Voyage-GLORP backend 
‣ There was (even more time ago) a Voyage- 
ImageSegment backend 
- Voyage-Memory, Voyage-Mongo
What is Voyage? (2) 
• Did I said is simple? 
• it ensures object identity 
• it provides error handling 
• it implements a connection pool
Voyage principles 
• Behavioural complete (for common usage), but 
decoupled approach also possible. 
• Same design for different backends, but not a 
common abstraction 
- There is no such thing as a “voyage query 
language”, etc. 
- is a bit more work for users who want to switch, 
but a lot more happiness for the program itself
Voyage ultimate goal 
To be the GLORP for NoSQL databases
The problem to solve
Impedance mistmatch 
Class A Class B Class C 
Table A Table B Table C 
1..* 
*..* 
Ideal relational model
Impedance mistmatch 
aColection 
anObject otherObject 
firstObject 
secondObject 
thirdObject 
Real object model
Impedance mistmatch 
aColection 
anObject otherObject 
Real object model 
firstObject 
secondObject 
thirdObject
Impedance mistmatch 
aColection 
anObject otherObject 
Real object model 
firstObject 
secondObject 
thirdObject
So, what about those tips?
Think in objects
A simple model 
*..* 
Hero Power
Persist 
(Hero named: ‘Groot’) 
addPower: ((Power named: ‘Plant Control’) 
level: #epic; 
yourself); 
save.
Persist 
{ 
_id: OID(…), 
#version: …, 
#instanceOf: ‘Hero’, 
name: ‘Groot’, 
powers: [ { #collection: ‘Power’, __id: OID(…) } ] 
} 
! 
{ 
_id: OID(…), 
#version: …, 
#instanceOf: ‘Power’, 
name: ‘Plant Control’, 
level: #epic, 
heroes: [ #collection: ‘Hero’, __id: OID(…) ] 
}
Take control
A simple model 
(a bit more complete) 
*..* 
Hero Power 
1..* 
Equipment 
Container Pistol 
1..*
Persist 
(Hero named: ‘Star-lord’) 
addEquipment: (Container 
addItem: Pistol new; 
yourself); 
save.
Persist (1) 
{ 
_id: OID(…), 
#version: …, 
#instanceOf: ‘Hero’, 
name: ‘Star-lord’, 
powers: [], 
equipment: [ { 
#instanceOf: ‘Container’, 
‘items’, [ 
{ #instanceOf: ‘Pistol’ } ] } ] 
}
Persist (2) 
{ 
_id: OID(1), 
#version: …, 
#instanceOf: ‘Hero’, 
name: ‘Star-lord’, 
powers: [], 
equipment: [ { #collection: ‘Equipment’, __id: OID(2) } ] 
} 
! 
{ 
_id: OID(2), 
#version: …, 
#instanceOf: ‘Container’, 
items: [ { #collection: ‘Equipment’, __id: OID(3) } ] 
} 
! 
{ 
_id: OID(3), 
#version: …, 
#instanceOf: ‘Pistol’, 
}
Integrity is a 
consequence
Allowing missing content 
• We do not have foreign keys 
- So we cannot do things like “ON DELETE 
CASCADE” 
- Even delete validations are difficult 
‣ Imagine “hero” has a “power”,and I remove the 
“power”. How can the hero notice it?
Persist 
mongoContainer 
<mongoContainer> 
! 
^ VOMongoContainer new 
collectionName: ‘powers’; 
enableMissingContent; 
yourself
Querying smart
Query (1) 
Hero 
selectMany: [ :each | … ] 
sortBy: { #name -> VOOrder ascending } asDictionary 
limit: 100 
offset: 100
Query (2) 
Hero 
selectMany: { 
‘name’ -> { 
‘$regexp’ -> ‘^G.*’. 
‘$options’ -> ‘i’ 
} asDictionary 
} asDictionary
Adapt schemes
The “scheme is not mine” 
problem 
• You can move meta-information to your program 
• Magritte-Voyage gives you a lot of power 
• You can extend/modify parts of the updating 
system too (like versioning)
Meta-information 
{ 
_id: OID(…), 
#version: …, 
#instanceOf: ‘Hero’, 
name: ‘Star-lord’, 
powers: [], 
equipment: [ { 
#instanceOf: ‘Container’, 
‘items’, [ 
{ #instanceOf: ‘Pistol’ } ] } ] 
}
Meta-information 
{ 
_id: OID(…), 
#version: …, 
#instanceOf: ‘Hero’, 
name: ‘Star-lord’, 
powers: [], 
equipment: [ { 
#instanceOf: ‘Container’, 
‘items’, [ 
{ #instanceOf: ‘Pistol’ } ] } ] 
}
Meta-information 
{ 
_id: OID(…), 
name: ‘Star-lord’, 
powers: [], 
equipment: [ { 
‘items’, [ {} ] } ] 
}
Voyage 2.0 
• Root detection (enhance save & update) 
• Cyclic detection 
- Add strategy to persist cycles even without roots (It has some 
consequences (in querying, etc.), so it will be optional) 
• integrity validations 
- #removeWithDependencies 
• Materialisation customisations 
- #readRaw 
• Add backend: Riak
Use it today! 
Gofer it 
smalltalkhubUser: ‘Pharo’ project: ’MetaRepoForPharo30’; 
configurationOf: ‘VoyageMongo’; 
loadStable. 
Thanks!! 
Esteban Lorenzano - 2014

Mais conteúdo relacionado

Mais procurados

Evolving Software with Moose
Evolving Software with MooseEvolving Software with Moose
Evolving Software with Moose
Dave Cross
 
Creatively creating custom post types! word sesh2
Creatively creating custom post types!  word sesh2Creatively creating custom post types!  word sesh2
Creatively creating custom post types! word sesh2
techvoltz
 

Mais procurados (19)

Redis and Ohm
Redis and OhmRedis and Ohm
Redis and Ohm
 
Why Ruby?
Why Ruby? Why Ruby?
Why Ruby?
 
Smalltalk on rubinius
Smalltalk on rubiniusSmalltalk on rubinius
Smalltalk on rubinius
 
Designers Guide To jQuery
Designers Guide To jQueryDesigners Guide To jQuery
Designers Guide To jQuery
 
Evolving Software with Moose
Evolving Software with MooseEvolving Software with Moose
Evolving Software with Moose
 
Modern Perl
Modern PerlModern Perl
Modern Perl
 
Multitenant applications: How and Why
Multitenant applications: How and WhyMultitenant applications: How and Why
Multitenant applications: How and Why
 
Your JavaScript Library
Your JavaScript LibraryYour JavaScript Library
Your JavaScript Library
 
Creatively creating custom post types! word sesh2
Creatively creating custom post types!  word sesh2Creatively creating custom post types!  word sesh2
Creatively creating custom post types! word sesh2
 
Serializing Ruby Objects in Redis
Serializing Ruby Objects in RedisSerializing Ruby Objects in Redis
Serializing Ruby Objects in Redis
 
Sprockets
SprocketsSprockets
Sprockets
 
"The worst code I ever wrote"
"The worst code I ever wrote""The worst code I ever wrote"
"The worst code I ever wrote"
 
Essential YUI
Essential YUIEssential YUI
Essential YUI
 
Advanced Debugging with Xcode - Extending LLDB
Advanced Debugging with Xcode - Extending LLDBAdvanced Debugging with Xcode - Extending LLDB
Advanced Debugging with Xcode - Extending LLDB
 
Getting startedwith noir-clojureexchange-2011
Getting startedwith noir-clojureexchange-2011Getting startedwith noir-clojureexchange-2011
Getting startedwith noir-clojureexchange-2011
 
Joomla plugin & module develpment - Presented at Sydney JUG 09/04/2013
Joomla plugin & module develpment - Presented at Sydney JUG 09/04/2013Joomla plugin & module develpment - Presented at Sydney JUG 09/04/2013
Joomla plugin & module develpment - Presented at Sydney JUG 09/04/2013
 
Using Data That Isn't Yours
Using Data That Isn't YoursUsing Data That Isn't Yours
Using Data That Isn't Yours
 
Introduction to Ruby, Rails, and Ruby on Rails
Introduction to Ruby, Rails, and Ruby on RailsIntroduction to Ruby, Rails, and Ruby on Rails
Introduction to Ruby, Rails, and Ruby on Rails
 
The jQuery Divide
The jQuery DivideThe jQuery Divide
The jQuery Divide
 

Semelhante a Voyage by example

【前端Mvc】之豆瓣说实践
【前端Mvc】之豆瓣说实践【前端Mvc】之豆瓣说实践
【前端Mvc】之豆瓣说实践
taobao.com
 

Semelhante a Voyage by example (20)

Voyage by example
Voyage by exampleVoyage by example
Voyage by example
 
Django at Scale
Django at ScaleDjango at Scale
Django at Scale
 
Dependency injectionpreso
Dependency injectionpresoDependency injectionpreso
Dependency injectionpreso
 
Week3
Week3Week3
Week3
 
All of Javascript
All of JavascriptAll of Javascript
All of Javascript
 
Drupal 8: A story of growing up and getting off the island
Drupal 8: A story of growing up and getting off the islandDrupal 8: A story of growing up and getting off the island
Drupal 8: A story of growing up and getting off the island
 
All of javascript
All of javascriptAll of javascript
All of javascript
 
Questioning the status quo
Questioning the status quoQuestioning the status quo
Questioning the status quo
 
Dependency Injection Why is it awesome and Why should I care?
Dependency Injection Why is it awesome and Why should I care?Dependency Injection Why is it awesome and Why should I care?
Dependency Injection Why is it awesome and Why should I care?
 
Dependency Injection: Why is awesome and why should I care?
Dependency Injection: Why is awesome and why should I care?Dependency Injection: Why is awesome and why should I care?
Dependency Injection: Why is awesome and why should I care?
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
Design patterns
Design patternsDesign patterns
Design patterns
 
About Python
About PythonAbout Python
About Python
 
Everything is Permitted: Extending Built-ins
Everything is Permitted: Extending Built-insEverything is Permitted: Extending Built-ins
Everything is Permitted: Extending Built-ins
 
Scalable JavaScript Design Patterns
Scalable JavaScript Design PatternsScalable JavaScript Design Patterns
Scalable JavaScript Design Patterns
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
обзор Python
обзор Pythonобзор Python
обзор Python
 
Jvm internals
Jvm internalsJvm internals
Jvm internals
 
【前端Mvc】之豆瓣说实践
【前端Mvc】之豆瓣说实践【前端Mvc】之豆瓣说实践
【前端Mvc】之豆瓣说实践
 
Learn JS concepts by implementing jQuery
Learn JS concepts by implementing jQueryLearn JS concepts by implementing jQuery
Learn JS concepts by implementing jQuery
 

Mais de ESUG

Workshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingWorkshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programming
ESUG
 
The Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapThe Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and Roadmap
ESUG
 
Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...
ESUG
 
Analyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsAnalyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early results
ESUG
 
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
ESUG
 
A Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationA Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test Generation
ESUG
 
Creating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingCreating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic Programming
ESUG
 
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesThreaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
ESUG
 
Exploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportExploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience Report
ESUG
 
Pharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsPharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIs
ESUG
 
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseImproving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
ESUG
 
Pharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FuturePharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and Future
ESUG
 
A New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsA New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and Transformations
ESUG
 

Mais de ESUG (20)

Workshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingWorkshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programming
 
Technical documentation support in Pharo
Technical documentation support in PharoTechnical documentation support in Pharo
Technical documentation support in Pharo
 
The Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapThe Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and Roadmap
 
Sequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in PharoSequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in Pharo
 
Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...
 
Analyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsAnalyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early results
 
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
 
A Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationA Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test Generation
 
Creating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingCreating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic Programming
 
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesThreaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
 
Exploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportExploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience Report
 
Pharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsPharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIs
 
Garbage Collector Tuning
Garbage Collector TuningGarbage Collector Tuning
Garbage Collector Tuning
 
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseImproving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
 
Pharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FuturePharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and Future
 
thisContext in the Debugger
thisContext in the DebuggerthisContext in the Debugger
thisContext in the Debugger
 
Websockets for Fencing Score
Websockets for Fencing ScoreWebsockets for Fencing Score
Websockets for Fencing Score
 
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScriptShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
 
Advanced Object- Oriented Design Mooc
Advanced Object- Oriented Design MoocAdvanced Object- Oriented Design Mooc
Advanced Object- Oriented Design Mooc
 
A New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsA New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and Transformations
 

Último

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Último (20)

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 

Voyage by example

  • 1. Voyage by example tips and tricks on persisting object models
  • 2. Esteban Lorenzano Pharo core developer INRIA - RMoD http://smallworks.eu
  • 3. Why? • You already know about Voyage • You already attended to a tutorial last year • But there are some recurrent problems people find when trying to use it • And I’m still seeing a lot of people that could be using it and they chose other solutions
  • 4. What is Voyage? (1) • Simple abstraction layer to map objects into a database - Very well suited for document databases, but in theory, the approach will work for other kind of repositories ‣ There was (long time ago) a Voyage-GLORP backend ‣ There was (even more time ago) a Voyage- ImageSegment backend - Voyage-Memory, Voyage-Mongo
  • 5. What is Voyage? (2) • Did I said is simple? • it ensures object identity • it provides error handling • it implements a connection pool
  • 6. Voyage principles • Behavioural complete (for common usage), but decoupled approach also possible. • Same design for different backends, but not a common abstraction - There is no such thing as a “voyage query language”, etc. - is a bit more work for users who want to switch, but a lot more happiness for the program itself
  • 7. Voyage ultimate goal To be the GLORP for NoSQL databases
  • 9. Impedance mistmatch Class A Class B Class C Table A Table B Table C 1..* *..* Ideal relational model
  • 10. Impedance mistmatch aColection anObject otherObject firstObject secondObject thirdObject Real object model
  • 11. Impedance mistmatch aColection anObject otherObject Real object model firstObject secondObject thirdObject
  • 12. Impedance mistmatch aColection anObject otherObject Real object model firstObject secondObject thirdObject
  • 13. So, what about those tips?
  • 15. A simple model *..* Hero Power
  • 16. Persist (Hero named: ‘Groot’) addPower: ((Power named: ‘Plant Control’) level: #epic; yourself); save.
  • 17. Persist { _id: OID(…), #version: …, #instanceOf: ‘Hero’, name: ‘Groot’, powers: [ { #collection: ‘Power’, __id: OID(…) } ] } ! { _id: OID(…), #version: …, #instanceOf: ‘Power’, name: ‘Plant Control’, level: #epic, heroes: [ #collection: ‘Hero’, __id: OID(…) ] }
  • 19. A simple model (a bit more complete) *..* Hero Power 1..* Equipment Container Pistol 1..*
  • 20. Persist (Hero named: ‘Star-lord’) addEquipment: (Container addItem: Pistol new; yourself); save.
  • 21. Persist (1) { _id: OID(…), #version: …, #instanceOf: ‘Hero’, name: ‘Star-lord’, powers: [], equipment: [ { #instanceOf: ‘Container’, ‘items’, [ { #instanceOf: ‘Pistol’ } ] } ] }
  • 22. Persist (2) { _id: OID(1), #version: …, #instanceOf: ‘Hero’, name: ‘Star-lord’, powers: [], equipment: [ { #collection: ‘Equipment’, __id: OID(2) } ] } ! { _id: OID(2), #version: …, #instanceOf: ‘Container’, items: [ { #collection: ‘Equipment’, __id: OID(3) } ] } ! { _id: OID(3), #version: …, #instanceOf: ‘Pistol’, }
  • 23. Integrity is a consequence
  • 24. Allowing missing content • We do not have foreign keys - So we cannot do things like “ON DELETE CASCADE” - Even delete validations are difficult ‣ Imagine “hero” has a “power”,and I remove the “power”. How can the hero notice it?
  • 25. Persist mongoContainer <mongoContainer> ! ^ VOMongoContainer new collectionName: ‘powers’; enableMissingContent; yourself
  • 27. Query (1) Hero selectMany: [ :each | … ] sortBy: { #name -> VOOrder ascending } asDictionary limit: 100 offset: 100
  • 28. Query (2) Hero selectMany: { ‘name’ -> { ‘$regexp’ -> ‘^G.*’. ‘$options’ -> ‘i’ } asDictionary } asDictionary
  • 30. The “scheme is not mine” problem • You can move meta-information to your program • Magritte-Voyage gives you a lot of power • You can extend/modify parts of the updating system too (like versioning)
  • 31. Meta-information { _id: OID(…), #version: …, #instanceOf: ‘Hero’, name: ‘Star-lord’, powers: [], equipment: [ { #instanceOf: ‘Container’, ‘items’, [ { #instanceOf: ‘Pistol’ } ] } ] }
  • 32. Meta-information { _id: OID(…), #version: …, #instanceOf: ‘Hero’, name: ‘Star-lord’, powers: [], equipment: [ { #instanceOf: ‘Container’, ‘items’, [ { #instanceOf: ‘Pistol’ } ] } ] }
  • 33. Meta-information { _id: OID(…), name: ‘Star-lord’, powers: [], equipment: [ { ‘items’, [ {} ] } ] }
  • 34. Voyage 2.0 • Root detection (enhance save & update) • Cyclic detection - Add strategy to persist cycles even without roots (It has some consequences (in querying, etc.), so it will be optional) • integrity validations - #removeWithDependencies • Materialisation customisations - #readRaw • Add backend: Riak
  • 35. Use it today! Gofer it smalltalkhubUser: ‘Pharo’ project: ’MetaRepoForPharo30’; configurationOf: ‘VoyageMongo’; loadStable. Thanks!! Esteban Lorenzano - 2014