SlideShare uma empresa Scribd logo
1 de 34
1
X y
- Queries too slow
- Schemas change
- Complex relationships
- 3NF, BCNF…
- Nest SELECT, JOIN
- 1-n, 1-1, n-n
- Migration
- Synchonize
- Huge records
- …
SQLite problems
REALM
khacpv@gmail.com

15/05/2016
no-sqlite for mobile
Who am I?
3
Realm is
SQL
SELECT user.name, user.email
FROM user
INNER JOIN shop ON user.id = shop.userid

INNER JOIN city ON user.cityid = city.id
WHERE user.name = 'the flash'
No-SQL
Realm.getA().getC().getF();
A
B C
D E F
G
X
Z
y
4
Realm is
SQLite
SELECT user.name, user.email
FROM user
INNER JOIN shop ON user.id = shop.userid

INNER JOIN city ON user.cityid = city.id
WHERE user.name = 'khac'
No-SQLite
Realm.getA().getC().getF();
A
B C
D E F
G
X
Z
y
5
YOUR 

logo?
6
How: fastest?
7
Galaxy S4
8
Zenfone 5
9
Why: fastest?
10
Speed force
• Memory-mapped files
• C++ core
• B+ trees
• Column-oriented
• Bit-packing
Minimize I/O overhead

Cross-platform

Faster reads and writes

Queries > writes (no-sql)

Smaller file size
11
benchmark vs SQLite
http://static.realm.io/downloads/java/android-benchmark.zip 12
Architecture
Realm Object Store API
Realm Internal API
JNI
Realm Core
13
Method count
• Realm: ~1750
• Model class: +2x no. of fields
• Proxy class: + 2x no. of fields + 11
• Total: "it depends" (~2000)
Picasso: ~600

GSON: ~950

RxJava: ~3500
Retrofit: ~494
Support Lib: ~12300

OrmLite: ~2400
14
How: code?
15
get Realm
16
web:
version:
support:
contributors:
last release:
https://realm.io
0.90.1
xamarin, java, obj-c, swift, react-native
52+ (java)
7 days ago (13/05/2016)
classpath "io.realm:realm-gradle-plugin:0.90.1"
apply plugin: 'realm-android'
ProGuard!
Realtime
17
update realtime
Types fields
18
@Required
@Ignore
@RealmClass
@Index
@PrimaryKey
boolean
byte, short,int,long -> long
float
double
String
Date
byte[]
final
transient
volatile
Relationships
19
n…1
n…n
Queries
20
• equalTo
• greaterThan
• between
• contains
• beginWith
• beginGroup
• or
• not
• isEmpty
• distinct
• sum/ count
• min/ max/ average
• findAll/ findFirst
• sort
• …
Insert / Update
21
Delete
22
Configuration
23
1. Encrypt with key (AES-256)
2. Migration strategy
3. In memory mode
4. Default instance
5. isAutoRefresh() & waitForChange()
6. Create from JSON
https://nelenkov.blogspot.dk/2012/05/storing-application-secrets-in-androids.html
https://developer.android.com/training/articles/keystore.html
Thread
Realm
Realm
object
Realm
Results
Threads
24
RealmObject
A B C
Not yet Polymorphism
Debug
25
Crashlytics
Limitations
26
1. Class names: <= 57 letters*
2. Field names: <= 63 letters
3. Nest transactions -> not supported!
4. String & byte[] < 16Mb
*Realm auto append class_ at begin of class name
References
• https://realm.io/news/introducing-realm
• https://realm.io/users/chatwork
• https://github.com/realm
• http://www.slideshare.net/ChristianMelchior/realm-building-a-
mobile-database
• http://www.slideshare.net/dalinaum/realm-java
• https://en.wikipedia.org/wiki/Zero-copy
• https://en.wikipedia.org/wiki/Data_structure_alignment
27
Q & A
28
• Why do you choose Realm?
• Faster 5~10 times, especialy in write data
• Combine with ActiveAndroid
• Which data should be stored in Realm?
• The data need to be writen many times, ex: total
chats.
• Should remove ActiveAndroid to only play with Realm.
• Yes, it’s doesn’t complicated but ActiveAndroid has
value too.
• Easy to synchronize with data from server
• Yes, no problem
• Use for both Android & Ios?
• Yes
29
ChatWork
Ryutaro Miyashita
https://realm.io/users/chatwork/
30
Appendix
B+ Tree
31https://en.wikipedia.org/wiki/B%2B_tree
The primary value of a B+ tree is in storing data for
efficient retrieval in a block-oriented storage context in
particular, filesystems. (NTFS, EXT4, SQLite, Oracle …
Column Oriented
32http://arxiv.org/pdf/1105.4252.pdf
Memory-mapped
33
Memory-mapped I/O uses the same address bus to
address both memory and I/O devices
CPU
RAM
Hard Disk
I/O
https://en.wikipedia.org/wiki/Memory-mapped_file
http://www.slideshare.net/jpountz/how-does-lucene-store-your-data
http://lemire.me/blog/2012/03/06/how-fast-is-bit-packing/
Bit-packing
34
• Efficient technique to store blocks of small ints
• Supports random access
• Special case: bits per value = 1 is a bit set
• Say you want to store
• 5 30 1 1 10 12
• Raw data: 6 * 32 = 192 bits
• Packed : 6 * 5 = 30 bits (84% size reduction!)
0000 0000 0000 0000 0000 0000 0000 0101 = 5
0000 0000 0000 0000 0000 0000 0001 1110 = 30
0000 0000 0000 0000 0000 0000 0000 0001 = 1
0000 0000 0000 0000 0000 0000 0000 0001 = 1
0000 0000 0000 0000 0000 0000 0000 1010 = 10
0000 0000 0000 0000 0000 0000 0000 1100 = 12

Mais conteúdo relacionado

Mais procurados

The Evolution oF mobile phones - Sheik Nowheed
The Evolution oF mobile phones - Sheik NowheedThe Evolution oF mobile phones - Sheik Nowheed
The Evolution oF mobile phones - Sheik Nowheed
Sheik Mohammed Nowheed
 
Network Attached Storage (NAS)
Network Attached Storage (NAS)Network Attached Storage (NAS)
Network Attached Storage (NAS)
sandeepgodfather
 

Mais procurados (20)

Unit 6 Privacy and Data Protection 8 hr
Unit 6  Privacy and Data Protection 8 hrUnit 6  Privacy and Data Protection 8 hr
Unit 6 Privacy and Data Protection 8 hr
 
Database management systems
Database management systemsDatabase management systems
Database management systems
 
Overview on data privacy
Overview on data privacy Overview on data privacy
Overview on data privacy
 
Type of database models
Type of database modelsType of database models
Type of database models
 
Personal data protection bill
Personal data protection bill Personal data protection bill
Personal data protection bill
 
Privacy & Data Protection in the Digital World
Privacy & Data Protection in the Digital WorldPrivacy & Data Protection in the Digital World
Privacy & Data Protection in the Digital World
 
Privacy in the Digital Age
Privacy in the Digital AgePrivacy in the Digital Age
Privacy in the Digital Age
 
Personal Area Network
Personal Area NetworkPersonal Area Network
Personal Area Network
 
Introduction to Big Data
Introduction to Big Data Introduction to Big Data
Introduction to Big Data
 
The Evolution oF mobile phones - Sheik Nowheed
The Evolution oF mobile phones - Sheik NowheedThe Evolution oF mobile phones - Sheik Nowheed
The Evolution oF mobile phones - Sheik Nowheed
 
A brief introduction to data storage
A brief introduction to data storageA brief introduction to data storage
A brief introduction to data storage
 
Data Privacy: What you need to know about privacy, from compliance to ethics
Data Privacy: What you need to know about privacy, from compliance to ethicsData Privacy: What you need to know about privacy, from compliance to ethics
Data Privacy: What you need to know about privacy, from compliance to ethics
 
Ch 2-introduction to dbms
Ch 2-introduction to dbmsCh 2-introduction to dbms
Ch 2-introduction to dbms
 
Chapter 1 big data
Chapter 1 big dataChapter 1 big data
Chapter 1 big data
 
network fundamentals
network fundamentalsnetwork fundamentals
network fundamentals
 
Privacy & Data Protection
Privacy & Data ProtectionPrivacy & Data Protection
Privacy & Data Protection
 
Network Attached Storage (NAS)
Network Attached Storage (NAS)Network Attached Storage (NAS)
Network Attached Storage (NAS)
 
Data models
Data modelsData models
Data models
 
Distributed database
Distributed databaseDistributed database
Distributed database
 
Big data by Mithlesh sadh
Big data by Mithlesh sadhBig data by Mithlesh sadh
Big data by Mithlesh sadh
 

Semelhante a Realm Presentation

Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
Mohammad Qureshi
 

Semelhante a Realm Presentation (20)

Your backend architecture is what matters slideshare
Your backend architecture is what matters slideshareYour backend architecture is what matters slideshare
Your backend architecture is what matters slideshare
 
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...
 
Building production websites with Node.js on the Microsoft stack
Building production websites with Node.js on the Microsoft stackBuilding production websites with Node.js on the Microsoft stack
Building production websites with Node.js on the Microsoft stack
 
Mini-Training: Redis
Mini-Training: RedisMini-Training: Redis
Mini-Training: Redis
 
Node azure
Node azureNode azure
Node azure
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
 
OrientDB for real & Web App development
OrientDB for real & Web App developmentOrientDB for real & Web App development
OrientDB for real & Web App development
 
Chirp 2010: Scaling Twitter
Chirp 2010: Scaling TwitterChirp 2010: Scaling Twitter
Chirp 2010: Scaling Twitter
 
Remix
RemixRemix
Remix
 
Deploying and Managing PowerPivot for SharePoint
Deploying and Managing PowerPivot for SharePointDeploying and Managing PowerPivot for SharePoint
Deploying and Managing PowerPivot for SharePoint
 
Graph Database Use Cases - StampedeCon 2015
Graph Database Use Cases - StampedeCon 2015Graph Database Use Cases - StampedeCon 2015
Graph Database Use Cases - StampedeCon 2015
 
Graph database Use Cases
Graph database Use CasesGraph database Use Cases
Graph database Use Cases
 
Hotsos 2012
Hotsos 2012Hotsos 2012
Hotsos 2012
 
Works with persistent graphs using OrientDB
Works with persistent graphs using OrientDB Works with persistent graphs using OrientDB
Works with persistent graphs using OrientDB
 
Exploring Relay land
Exploring Relay landExploring Relay land
Exploring Relay land
 
Five Database Mistakes and how to fix them -- Confoo Vancouver
Five Database Mistakes and how to fix them -- Confoo VancouverFive Database Mistakes and how to fix them -- Confoo Vancouver
Five Database Mistakes and how to fix them -- Confoo Vancouver
 
Sql and Go
Sql and GoSql and Go
Sql and Go
 
Master tuning
Master   tuningMaster   tuning
Master tuning
 
Migration to ClickHouse. Practical guide, by Alexander Zaitsev
Migration to ClickHouse. Practical guide, by Alexander ZaitsevMigration to ClickHouse. Practical guide, by Alexander Zaitsev
Migration to ClickHouse. Practical guide, by Alexander Zaitsev
 
JavaOne_2010
JavaOne_2010JavaOne_2010
JavaOne_2010
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
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...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
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
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

Realm Presentation