google dev fest 2016 - realm database
TRANSCRIPT
Fast queriesOffline-first SecureCross platform
Benefits
safe threading
reactive architecture
community support
simplify
sync seamlessly
open sourceData push
browsable
auto migration
Trusted by Fortune 500 mainstays, innovative startups, and #1‑ranked app store successes,
Realm is built into apps used by hundreds of millions of people every day.
Over 1 billion users rely on Realm
Top apps are using Realm
Dubsmash Social Video, TV 1 - 5 M
Expensify Finance 1 - 5 M
Falcon Pro 3 Social 100 - 500 K
Tastely Food restaurant 10 - 50 M
Cabify Map-Navigation 1 - 5 M
Shyp Shipping 10 - 50 K
FiveStars Discover places 500K - 1M
8fit Health & Fitness 1 – 5 M
• C++ core
• B+ trees
• Bit-packing
• Column-oriented
• Memory-mapped files
Cross-platform
Queries > writes (no-sql)
Smaller file size
Faster reads and writes
Zero-copy
https://realm.io/news/threading-deep-dive
Why realm is fast?
B+ TreeThe 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 …)
https://en.wikipedia.org/wiki/B+_tree
Bit-packingEfficient technique to store blocks of small integers
• 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
http://lemire.me/blog/2012/03/06/how-fast-is-bit-packing http://www.slideshare.net/jpountz/how-does-lucene-store-your-data
Memory mapped files
File
Stack
Heap
Data
Text
Mapped filePointer
https://msdn.microsoft.com/en-us/library/ms810613.aspx
How to get Realm?
Web:
Version:
Support:
Stars:
https://realm.io
2.2.1 (Java - Android)
xamarin, java, obj-c, swift, react-native, javascript
6,525 (java), 9356 (cocoa)
classpath "io.realm:realm-gradle-plugin:2.2.1"
apply plugin: 'realm-android'
ProGuard!
QueriesequalTo
greaterThan
between
contains
beginWith
beginGroup
or
not
isEmpty
distinct
sum/ count
min/ max/ average
findAll/ findFirst
sort
…
Realm.io github.com/realm
Want to learn more? How it works & Getting started: realm.io/docs
Platforms: Java: github.com/realm/realm-java iOS: github.com/realm/realm-cocoa Javascript: github.com/realm/realm-js Xamarin: github.com/realm/realm-dotnet C++: github.com/realm/realm-core Server: github.com/realm/realm-mobile-platform
What's Next