SlideShare a Scribd company logo
SqliteToRealm
작은 경험 이야기
Who?
Pluu / Pluulove
Android Developer
http://pluu.github.io/
Screen
Why?
● 웹툰 앱 소스 GitHub 공개
● 내 소스인데 엉망이다
● 바꿔보고 싶은 걸 바꿔보자
그냥!!
Modify
● jsoup
● butterknife
● glide
● sqlbrite
● rxandroid
● okhttp
● jsoup
● butterknife
● glide
● realm
● otto
● rxandroid
Save
● Favorite Info
● Read Info
Favorite
Service Name : String
Toon ID : String
Read
Service Name : String
Toon ID : String
Episode ID : String
Sqlbrite
● by square
● SQLiteOpenHelper + Reactive
○ A lightweight wrapper around SQLiteOpenHelper which introduces reactive stream semantics to
SQL operation
Sqlbrite
Rx Square
믿고 쓰는dalinaum 님
최정열 님
Sqlbrite Code
BriteDatabase db = sqlBrite.wrapDatabaseHelper(openHelper);
Observable<Query> users = db.createQuery("users", "SELECT * FROM users");
users.subscribe(new Action1<Query>() {
@Override public void call(Query query) {
Cursor cursor = query.run();
// TODO parse data...
}
});
Realm
● Core NDK
● Realm != Sqlite
● Sqlite Migration Guide X
○ Realm 0.84.2
SqliteToRealm
● https://github.
com/jixaCo/Sqlit
eToRealm
● https://realm.
io/addons/ > Java
> Tools >
SqliteToRealm
SqliteToRealm.java
public void pushSynonymsToWords() {
SqliteHelper dbs = SqliteHelper.getInstance();
RealmHelper dbr = RealmHelper.getIntance();
List<Word> rawWords = getAllRawWords();
List<List<String>> records = dbs.getRecords("synonym");
List<IntPair> synonyms = new ArrayList<>();
for(List<String> record : records){
if(null == record.get(0) || null == record.get(1))
continue;
IntPair pair = new IntPair(Integer.parseInt(record.get(0)),Integer.parseInt(record.get(1)));
synonyms.add(pair);
}
dbr.addSynonymToWords(synonyms);
}
SqliteToRealm
Sqlite Realm
● Open Sqlite
● Get Data
● Close Sqlite
● Realm.getInsatance(Context)
● beginTransaction()
● Add Data
● commitTransaction()
Um ...
● Realm 사용
○ SPEED
○ ORM
● 기존 sqlite 관련 파일을 지울 수 없음
○ SQLiteOpenHelper
○ Item Class
● 한국 페이지에는 부재인 ADD-ON 페이지
Extend Um ...
● APK SIZE
○ ABI Split 으로 해결 가능
○ Reducing your Android APK size When Using Native Libraries
● 큰 데이터 (수만 건)
○ 트랜잭션에서 처리하는 단위가 큰 경우 OOM 발생
○ 100~200 단위 처리
● Realm version에 맞는 Proguard 처리
Link : Twitterクライアントの内部DBをSQLiteからRealmに移行したときのノウハウまとめ
Link : Realm導入によるAPK肥大化を防ぐ(Split APK)
Extend Um ...
● Insert, 20 Count
○ 150ms → 100ms
● Search, 4 Count
○ 14ms → 8ms or 17ms → 10ms or or or
● Insert, 16 Count (62kb)
○ 97ms → 38ms
Link : Twitterクライアントの内部DBをSQLiteからRealmに移行したときのノウハウまとめ
recommended
처음부터 Realm
● Realm != Sqlite
Rx + Preference
● 초기 작업 + 1
● 실행 시 SqliteToRealm 필요
● Preference 에 Flag 등록
- End -

More Related Content

PDF
Kafka Connect implementation at GumGum
PDF
MongoDB - Warehouse and Aggregator of Events
PDF
Monitoring your shiny new docker environment
PDF
JEEConf. Vanilla java
PDF
Managing Data and Operation Distribution In MongoDB
PDF
Cassandra meetup slides - Oct 15 Santa Monica Coloft
PDF
Tweaking performance on high-load projects
PDF
Handling 20 billion requests a month
Kafka Connect implementation at GumGum
MongoDB - Warehouse and Aggregator of Events
Monitoring your shiny new docker environment
JEEConf. Vanilla java
Managing Data and Operation Distribution In MongoDB
Cassandra meetup slides - Oct 15 Santa Monica Coloft
Tweaking performance on high-load projects
Handling 20 billion requests a month

What's hot (20)

PDF
Gnocchi v4 (preview)
PDF
BitRot (The silent corruption of data on disk ) detection in GlusterFS (Glust...
PDF
An High Available Database for OpenStack Cloud Production by Pacemaker, Coros...
PDF
20140513_jeffyang_demo_openstack
PDF
Cassandra at Glogster
PDF
Gnocchi Profiling 2.1.x
PPT
JVM performance options. How it works
TXT
Alkylog
TXT
Alkylog
PDF
Triggers in MongoDB
PDF
Big data @ Hootsuite analtyics
PDF
Gnocchi Profiling v2
PDF
Wikimedia Content API: A Cassandra Use-case
PDF
Wikimedia Content API: A Cassandra Use-case
PPTX
Deep dumpster diving 2010
PPTX
MongoDB IoT City Tour EINDHOVEN: Managing the Database Complexity
PPTX
Weather of the Century: Design and Performance
PDF
Rook: Storage for Containers in Containers – data://disrupted® 2020
PDF
Cotap Tech Talks: Roderic Campbell, Minority Report UX with an Apple Watch
PDF
PTD and beyond
Gnocchi v4 (preview)
BitRot (The silent corruption of data on disk ) detection in GlusterFS (Glust...
An High Available Database for OpenStack Cloud Production by Pacemaker, Coros...
20140513_jeffyang_demo_openstack
Cassandra at Glogster
Gnocchi Profiling 2.1.x
JVM performance options. How it works
Alkylog
Alkylog
Triggers in MongoDB
Big data @ Hootsuite analtyics
Gnocchi Profiling v2
Wikimedia Content API: A Cassandra Use-case
Wikimedia Content API: A Cassandra Use-case
Deep dumpster diving 2010
MongoDB IoT City Tour EINDHOVEN: Managing the Database Complexity
Weather of the Century: Design and Performance
Rook: Storage for Containers in Containers – data://disrupted® 2020
Cotap Tech Talks: Roderic Campbell, Minority Report UX with an Apple Watch
PTD and beyond
Ad

Recently uploaded (20)

PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Machine learning based COVID-19 study performance prediction
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPT
Teaching material agriculture food technology
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Machine Learning_overview_presentation.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Programs and apps: productivity, graphics, security and other tools
Machine learning based COVID-19 study performance prediction
Reach Out and Touch Someone: Haptics and Empathic Computing
MIND Revenue Release Quarter 2 2025 Press Release
Diabetes mellitus diagnosis method based random forest with bat algorithm
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Teaching material agriculture food technology
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Review of recent advances in non-invasive hemoglobin estimation
“AI and Expert System Decision Support & Business Intelligence Systems”
Assigned Numbers - 2025 - Bluetooth® Document
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Network Security Unit 5.pdf for BCA BBA.
Machine Learning_overview_presentation.pptx
Ad

SqliteToRealm

  • 2. Who? Pluu / Pluulove Android Developer http://pluu.github.io/
  • 4. Why? ● 웹툰 앱 소스 GitHub 공개 ● 내 소스인데 엉망이다 ● 바꿔보고 싶은 걸 바꿔보자 그냥!!
  • 5. Modify ● jsoup ● butterknife ● glide ● sqlbrite ● rxandroid ● okhttp ● jsoup ● butterknife ● glide ● realm ● otto ● rxandroid
  • 6. Save ● Favorite Info ● Read Info Favorite Service Name : String Toon ID : String Read Service Name : String Toon ID : String Episode ID : String
  • 7. Sqlbrite ● by square ● SQLiteOpenHelper + Reactive ○ A lightweight wrapper around SQLiteOpenHelper which introduces reactive stream semantics to SQL operation
  • 9. Sqlbrite Code BriteDatabase db = sqlBrite.wrapDatabaseHelper(openHelper); Observable<Query> users = db.createQuery("users", "SELECT * FROM users"); users.subscribe(new Action1<Query>() { @Override public void call(Query query) { Cursor cursor = query.run(); // TODO parse data... } });
  • 10. Realm ● Core NDK ● Realm != Sqlite ● Sqlite Migration Guide X ○ Realm 0.84.2
  • 12. SqliteToRealm.java public void pushSynonymsToWords() { SqliteHelper dbs = SqliteHelper.getInstance(); RealmHelper dbr = RealmHelper.getIntance(); List<Word> rawWords = getAllRawWords(); List<List<String>> records = dbs.getRecords("synonym"); List<IntPair> synonyms = new ArrayList<>(); for(List<String> record : records){ if(null == record.get(0) || null == record.get(1)) continue; IntPair pair = new IntPair(Integer.parseInt(record.get(0)),Integer.parseInt(record.get(1))); synonyms.add(pair); } dbr.addSynonymToWords(synonyms); }
  • 13. SqliteToRealm Sqlite Realm ● Open Sqlite ● Get Data ● Close Sqlite ● Realm.getInsatance(Context) ● beginTransaction() ● Add Data ● commitTransaction()
  • 14. Um ... ● Realm 사용 ○ SPEED ○ ORM ● 기존 sqlite 관련 파일을 지울 수 없음 ○ SQLiteOpenHelper ○ Item Class ● 한국 페이지에는 부재인 ADD-ON 페이지
  • 15. Extend Um ... ● APK SIZE ○ ABI Split 으로 해결 가능 ○ Reducing your Android APK size When Using Native Libraries ● 큰 데이터 (수만 건) ○ 트랜잭션에서 처리하는 단위가 큰 경우 OOM 발생 ○ 100~200 단위 처리 ● Realm version에 맞는 Proguard 처리 Link : Twitterクライアントの内部DBをSQLiteからRealmに移行したときのノウハウまとめ Link : Realm導入によるAPK肥大化を防ぐ(Split APK)
  • 16. Extend Um ... ● Insert, 20 Count ○ 150ms → 100ms ● Search, 4 Count ○ 14ms → 8ms or 17ms → 10ms or or or ● Insert, 16 Count (62kb) ○ 97ms → 38ms Link : Twitterクライアントの内部DBをSQLiteからRealmに移行したときのノウハウまとめ
  • 17. recommended 처음부터 Realm ● Realm != Sqlite Rx + Preference ● 초기 작업 + 1 ● 실행 시 SqliteToRealm 필요 ● Preference 에 Flag 등록