Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Realmという衝撃
Search
Takumi KASHIMA
August 27, 2015
Technology
0
35
Realmという衝撃
テックランチ
Takumi KASHIMA
August 27, 2015
Tweet
Share
More Decks by Takumi KASHIMA
See All by Takumi KASHIMA
Firebase Cloud Functionsを使ってみた話
kashima
0
3k
趣味でサービスを作った話
kashima
1
85
動画のあれこれ
kashima
0
69
ライブラリを作った話
kashima
0
57
朝活のすすめ
kashima
0
38
Other Decks in Technology
See All in Technology
AI前提のサービス運用ってなんだろう?
ryuichi1208
8
1.4k
マルチモーダル / AI Agent / LLMOps 3つの技術トレンドで理解するLLMの今後の展望
hirosatogamo
37
13k
The Rise of LLMOps
asei
9
1.8k
複雑なState管理からの脱却
sansantech
PRO
1
160
SRE×AIOpsを始めよう!GuardDutyによるお手軽脅威検出
amixedcolor
0
210
Terraform Stacks入門 #HashiTalks
msato
0
360
Platform Engineering for Software Developers and Architects
syntasso
1
530
IBC 2024 動画技術関連レポート / IBC 2024 Report
cyberagentdevelopers
PRO
1
120
あなたの知らない Function.prototype.toString() の世界
mizdra
PRO
2
460
初心者向けAWS Securityの勉強会mini Security-JAWSを9ヶ月ぐらい実施してきての近況
cmusudakeisuke
0
140
日経電子版のStoreKit2フルリニューアル
shimastripe
1
150
LINEヤフーにおけるPrerender技術の導入とその効果
narirou
1
180
Featured
See All Featured
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
Fireside Chat
paigeccino
34
3k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
Making Projects Easy
brettharned
115
5.9k
BBQ
matthewcrist
85
9.3k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
840
A Tale of Four Properties
chriscoyier
156
23k
[RailsConf 2023] Rails as a piece of cake
palkan
52
4.9k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
The Cost Of JavaScript in 2023
addyosmani
45
6.8k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Transcript
Realmͱ͍͏িܸ t-kashima
Realmͱ
None
None
None
Realmͱ ϞόΠϧσόΠεͷσʔλϕʔε গͳ͍ίʔυྔͰߴʹಈ࡞͢Δ ΫϩεϓϥοτϑΥʔϜʹରԠ͍ͯ͠Δ +BWB 0CKFDUJWF$ 4XJGU ެࣜͷαϙʔτ͕खް͍ (JUIVCɺ5XJUUFSɺP⒎DFIPVSTʜ
Office hours !LJTIJLBXB͞Μʹ࣭ʹ͚͑ͯΔ
Realmͷಛ σʔλσʔλϕʔεͷࢀরΛ࣋ͭ ݴޠͱͷੑ͕ߴ͍ 044ͷͨΊ։ൃਐḿ͕֬ೝͰ͖Δ
Realmͷ͍ํ
Model public class Dog extends RealmObject { private String name;
public String getName() { return name; } public void setName(String name) { this.name = name; } }
Insert Realm realm = Realm.getInstance(getContext()); Dog dog = realm.createObject(Dog.class); dog.setName("Rex");
realm.commitTransaction();
Query Realm realm = Realm.getInstance(context); RealmResults<Dog> dogs = realm.where(Dog.class) .contains("name",
"rex") .findAll();
Thread new Thread(new Runnable() { public void run() { Realm
realm = Realm.getInstance(context); RealmResults<Dog> dogs = realm.where(Dog.class) .contains("name", "rex") .findAll(); } }).start();
Transaction Realm realm = Realm.getInstance(getContext()); Dog dog = realm.createObject(Dog.class); try
{ dog.setName("Rex"); realm.commitTransaction(); } catch (Exception e) { realm.cancelTransaction(); }
Realmͷҹ
RealmΛͬͯخ͔ͬͨ͜͠ͱ εΩʔϚ͕ΫϥεͳͷͰ͔Γ͍͢ ΫΤϦ͕.POHP෩ʹൃߦͰ͖͍͍ͯ͢ 3FBMNࣗମͷ։ൃ͕׆ൃͰ͋Δ ͔݄ʹͷϝδϟʔόʔδϣϯΞοϓ ಛʹى͖͍ͯͳ͍
RealmΛͬͯࠔͬͨ͜ͱ MJNJUP⒎TFU͕ͳ͍ͷͰ42-ͩͱͭΒ͍ 3FBMN#SPXTFSͰΫΤϦͷൃߦ͕Ͱ͖ͳ͍ ϚΠάϨʔγϣϯػೳ͕΄ͱΜͲͳ͍ IUUQTHJUIVCDPNSFBMNSFBMNDPDPBJTTVFT
RealmͷϚΠάϨʔγϣϯ
public class Migration implements RealmMigration { @Override public long execute(Realm
realm, long version) { if (version == 0) { realm.getTable(Dog.class) .addColumn(ColumnType.INTEGER, "age"); version = 1; } return version; } } ࠷৽ʹͳΔΑ͏ͭͣͭίʔυʹॻ͍͍ͯ͘ ඪ४ͷϚΠάϨʔγϣϯ
͜ΕͭΒ͘ͳ͍Ͱ͔͢ʁ
ͭΒ͗͢Δ…
࡞Γ·ͨ͠ʂ
Monarch IUUQTHJUIVCDPNULBTIJNB.POBSDI
Monarchͱ 3BJMT෩ʹϚΠάϨʔγϣϯΛߦ͑Δ ϚΠάϨʔγϣϯϑΝΠϧΛॱ൪ʹ࣮ߦ͢Δ ϚΠάϨʔγϣϯ༰ΛϑΝΠϧʹॻ͚Δ 3BJMTͬͨ͜ͱͳ͍͚Ͳʜ
public class Migration implements RealmMigration { @Override public long execute(Realm
realm, long version) { if (version == 0) { realm.getTable(Dog.class) .addColumn(ColumnType.INTEGER, "age"); version = 1; } return version; } } ࠷৽ʹͳΔΑ͏ͭͣͭίʔυʹॻ͍͍ͯ͘ ඪ४ͷϚΠάϨʔγϣϯ ϑΝΠϧʹॻ͚Δ
Monarchͷ͍ํ
bundle exec monarch_migration generate addColumnDog age:int { "up": [ "addcolumn
Dog age:int" ] } } 1436076736_add_column_dog.json ϚΠάϨʔγϣϯϑΝΠϧͷ࡞
public class Migration implements RealmMigration { @Override public long execute(Realm
realm, long version) { HashMap<String, Class> classMap = new HashMap<String, Class>() { { put("Dog", Dog.class); } }; return Monarch.migration(getContext(), realm, version, schemeVersion, classMap); } } ϚΠάϨʔγϣϯ
͜ΕͰ࣮ફͭΒ͘ͳ͍
3FBMNϞόΠϧσʔλϕʔεͷٹੈओ ϚΠάϨʔγϣϯ.POBSDIͰΓΕ !LJTIJLBXB͞Μ࠷ߴ ·ͱΊ
Realm࠷ߴ