次世代MobileデータベースRealm

 次世代MobileデータベースRealm

Developers Summit 2016

9bf923e39671cde83584e3e926296c13?s=128

Kishikawa Katsumi

February 19, 2016
Tweet

Transcript

  1. 如⚅➿.PCJMFر٦ةك٦أ 3FBMN

  2. IUUQTHJUIVCDPNLJTIJLBXBLBUTVNJ LJTIJLBXBLBUTVNJ IUUQCMPHLJTIJLBXBLBUTVNJDPN 3FBMN 5FDIOJDBM"EWJTPS 3FBMN*OD։

  3. None
  4. 3FBMNהכ⡦ַ

  5. ٌغ؎ٕرغ؎أ㼔欽ח倜׃ֻ⡲׵׸׋ر٦ةك٦أ 0CKFDUJWF$䎃剢։ +BWB䎃剢։ 4XJGU䎃剢։ ٌغ؎ٕ欽鷿ח剑黝⻉ׁ׸גְ׷ 鹼䒀ٗ٦س ئٗ؝ؾ٦ ط؎ذ؍ـ٥ؙٔٝ 3FBMNהכ⡦ַ

  6. ؔ٦فٝا٦أ  ぐ珏غ؎ٝر؍ؚٝ0CKDUJWF$4XJGU+BWBⰕꟚ׆׫  ⰻ鿇أزٖ٦آؒٝآٝת׮זֻⰕꟚ✮㹀 杝荈ؒٝآٝ42-JUF׾⢪׏גְזְ 3FBMNהכ⡦ַ

  7. 넝鸞ז⹛⡲ 农〾⻉׾垥彊鄲⪒ وٕثفٓحزؿؓ٦ي J04049"OESPJE +4JOCFUB /&5JODPNJOH 湫䠬涸דءٝفٕז"1* ♨㻝ז؟ه٦ز傈劤铂0, 3FBMNך暴ꞿ

  8. None
  9. 3FBMNِ٦ؠ٦

  10. 3FBMNָ⢪׻׸גְ׷،فٔ 傈劤穗幥倜耀ꨵ㶨晛 1JOUFSFTU $BNFSBO "8" 薉⽃铂؟فٔ 4ZODCZ8BOUFEMZ $IBUXPSL (SPVQPO GFBUIFSGPS5XJUUFS

    5XJUQBOF 'BMDPO1SP "QMPT J$PNJDT &JHIUCZ4BOTBO
  11. 넝鸞ז⹛⡲

  12. *OTFSU6QEBUF .7$$،٦ؗذؙثٍ ط؎ذ؍ـ٥ؙٔٝ 2VFSZ ئٗ؝ؾ٦ 鹼䒀ٗ٦س 넝鸞ז⹛⡲

  13. ػؿؓ٦وٝأ嫰鯰

  14. 傈劤Ⰻ㕂ך⡝䨽♰⟝׾嗚稊ׅ׷،فٔ

  15. HJUIVCDPNLJTIJLBXBLBUTVNJ3FBMN$PSF%BUB1FSGPSNBODF

  16. Realm CoreData શ݅औಘ 0.0004ඵ 8.01ඵ ෦෼Ұகݕࡧ 0.09ඵ 1.27ඵ ෦෼Ұகݕࡧʴιʔτ 0.09ඵ

    2.23ඵ ♰⟝ך⡝䨽ر٦ةך嗚稊鸞䏝
  17. Realm CoreData શ݅औಘ 12MB 65MB ෦෼Ұகݕࡧ 12MB 18MB ෦෼Ұகݕࡧʴιʔτ 12MB

    20MB ♰⟝ך⡝䨽ر٦ةך嗚稊ًٌٔ嶊顤
  18. 农〾⻉堣腉

  19. let key = NSMutableData(length: 64)! SecRandomCopyBytes(kSecRandomDefault, key.length, UnsafeMutablePointer<UInt8>(key.mutableBytes)) let config

    = Realm.Configuration(encryptionKey: key) let realm = try! Realm(configuration: config) 农〾⻉堣腉
  20. إٝءذ؍ـז䞔㜠ך⥂㶷 խ⦐➂䞔㜠ծ،ؕؐٝزز٦ؙٝזו 衼⡲埄זוד⥂隊ׁ׸׋ر٦ة 农〾⻉堣腉

  21. وٕثفٓحزؿؓ٦ي

  22. None
  23. class Article: Object { dynamic var id: Int = 0

    dynamic var title: String = "" dynamic var contents: String = "" dynamic var creationDate: NSDate = NSDate() dynamic var modificationDate: NSDate = NSDate() dynamic var deletionDate: NSDate? = nil dynamic var user: User? = nil let comments = List<Comment>() } ٌرٕذ٦ـٕ㹀纏 J04
  24. public class Article extends RealmObject { @PrimaryKey private int id;

    private String title; private String contents; private Date creationDate; private Date modificationDate; private Date deletionDate; private User user; private RealmList<Comment> user; } ٌرٕذ٦ـٕ㹀纏 "OESPJE
  25. let realm = try! Realm() // RealmίωΫγϣϯ let article =

    Article() article.title = titleTextfield.text article.contents = contentTextfield.text realm.write { // τϥϯβΫγϣϯ realm.add(article) } ر٦ةך⥂㶷 J04
  26. Realm realm = Realm.getInstance(this); // RealmίωΫγϣϯ realm.beginTransaction(); // τϥϯβΫγϣϯ։࢝ Article

    article = realm.createObject(Article.class); article.setText(titleTextfield.getText()); article.setContents(contentTextfield.getText()); realm.commitTransaction(); // τϥϯβΫγϣϯऴྃ ر٦ةך⥂㶷 "OESPJE
  27. let realm = try! Realm() letɹarticles = realm .objects(Article) .filter("user

    = %@", currentUser) .sorted("modificationDate", ascending: false) ؙؒٔ J04
  28. Realm realm = Realm.getInstance(this); RealmResults<Article> result = realm .where(Article.class) .equalTo("user.id",

    currentUser.getId()) .findAll() .sort("modificationDate", Sort.DESCENDING); ؙؒٔ "OESPJE
  29. Storage Engine ObjectStore API Objective-C Binging Java Binging Swift Binging

    C++ وٕثفٓحزؿؓ٦ي׾佄ִ׷ ،٦ؗذؙثٍ
  30. J04"OESPJE⚕倯ד3FBMNָ⢪׻׸גְ׷،فٔ "8" &JHIUCZ4BOTBO 㹺做،ٕغي׫גי J20/

  31. ٌغ؎ٕرغ؎أפך剑黝⻉ ך➬穈׫

  32. 䗡䎿׃׋鹼䒀ٗ٦س

  33. 颩ְغ؎ٝر؍ؚٝ堣圓ח״׷䗡䎿׃׋鹼䒀ٗ٦س فٗػذ؍ח،ؙإأׅ׷תדְַז׷ر٦ة׮⥂䭯׃זְ 㣐ꆀךر٦ة侧⼧ծ侧涰♰⟝ד׮넝鸞ח満ًٌٔד⸬桦״ֻ䪔ִ׷ 䗡䎿׃׋鹼䒀ٗ٦س

  34. పఈͨ͠஗Ԇϩʔυ articles = realm.objects(Article).filter("user = %@", currentUser)

  35. పఈͨ͠஗Ԇϩʔυ articles = realm.objects(Article) .filter("user = %@", currentUser)

  36. పఈͨ͠஗Ԇϩʔυ let allArticles = realm.objects(Article) let articles = allArticles.filter(“user =

    %@", currentUser)
  37. పఈͨ͠஗Ԇϩʔυ let allArticles = realm.objects(Article) let articles = allArticles.filter(“user =

    %@", currentUser) 3FTVMUT"SUJDMF 5BCMF"SUJDMF
  38. పఈͨ͠஗Ԇϩʔυ let allArticles = realm.objects(Article) let articles = allArticles.filter(“user =

    %@", currentUser) 3FTVMUT"SUJDMF 5BCMF"SUJDMF 3FTVMUT"SUJDMF 5BCMF"SUJDMF 2VFSZVTFS
  39. పఈͨ͠஗Ԇϩʔυ let articles = allArticles.filter(“user = %@", currentUser) let count

    = articles.count 3FTVMUT"SUJDMF 5BCMF"SUJDMF 2VFSZVTFS 3FTVMUT"SUJDMF 5BCMF"SUJDMF 2VFSZVTFS $PVOU 7JFX
  40. పఈͨ͠஗Ԇϩʔυ let count = articles.count let article = articles[0] 3FTVMUT"SUJDMF

    5BCMF"SUJDMF 2VFSZVTFS $PVOU 7JFX "SUJDMF 3PX*OEFY 3FTVMUT"SUJDMF 5BCMF"SUJDMF 2VFSZVTFS $PVOU 7JFX
  41. పఈͨ͠஗Ԇϩʔυ let article = articles[0] let title = article.title "SUJDMF

    3PX*OEFY 3FTVMUT"SUJDMF 5BCMF"SUJDMF 2VFSZVTFS $PVOU 7JFX "SUJDMF 3PX*OEFY 5JUMF(FUUFS 3FBMN 4USJOH 5JUMF
  42. ئٗ٥؝ؾ٦ ر٦ة׾♧ⴖ؝ؾ٦׃זְ

  43. .FNPSZNBQQFEؿ؋؎ٕ ًٌٔהر؍أؙ♳דずׄؿؓ٦وحزךر٦ة ׅץגךؙؒٔכؔؿإحزך乼⡲ فٗػذ؍ך،ؙإأדⴱ׭גر٦ة׾《䖤 ئٗ٥؝ؾ٦

  44. 3FBMN ׉ך➭ך03. 㹋ꥷח،ؙإأׅ׷鿇ⴓ ׌ֽر٦ة׾铣׫⳿ׅ ⟝侧ⴓך ؔـآؙؑز ָ⡲׵׸׷

  45. .7$$"SDIJUFDUVSF .VMUJ7FSTJPO$PODVSSFODZ$POUSPM

  46. .VMUJ7FSTJPO$PODVSSFODZ$POUSPM غ٦آّٝ㾶娖ח״׷زٓٝؠؙءّٝך盖椚 ぐزٓٝؠؙءّٝכծ֮׷儗挿ךأشحفءّحز 铣׫鴥׫כⴽך铣׫鴥׫ծ剅ֹ鴥׫׾ـٗحؙ׃זְ 剅ֹ鴥׫כ铣׫鴥׫׾ـٗحؙ׃זְ 剅ֹ鴥׫ה剅ֹ鴥׫כـٗحؙׅ׷ .7$$"SDIJUFDUVSF

  47. ꟼ鸬ך؝أزָ㸜ְ ط؎ذ؍ـ٥ؙٔٝ

  48. 3FBMNךر٦ة圓鸡כ䊬㣐ז# USFF 㼎ծ㼎㢳ךꟼ鸬׾荈搫ח邌植דֹ׷ ه؎ٝة׾籬ּ׌ֽծ؝أزך넝ְ+PJOכ♶銲 6*ך鿪さחさ׻ׇגر٦ة圓鸡׾㹀纏׃װְׅ ꟼ鸬ך؝أزָ㸜ְ

  49. ⵖꣲ✲갪חאְג

  50. 㛇劤涸ז俑㶵⴨הغ؎زꂁ⴨ծ傈➰ծ׉׃ג侧⦼㘗ך׫ ꂁ⴨װ鳤剅׾湫䱸⥂㶷דֹזְ㔐鼘瘻ؔـآؙؑزדٓحفׅ׷ 㼛勻涸חכ㢳圫זر٦ة㘗.BQ4FU 63- 㔿㹀鹌侧 FUD׾؟ه٦ز ٌرٕךⵖꣲ

  51. 䗳׆暴㹀ךؙٓأך؟ـؙٓأדזֽ׸לז׵זְ 3FBMNؔـآؙؑزכ鹼䒀ٗ٦سך㹋植ך׋׭ծفٗؗءה׃ג⹛⡲ׅ׷ ךדծ鸐䌢ךؔـآؙؑزה殯ז׷㜥さָ֮׷ أٖحس׾馄ִג3FBMNؔـآؙؑز׾床ֿׅהָדֹזְ 3FBMNؔـآؙؑزךⵖꣲ

  52. 宕竲⻉ׁ׸גְזְ⦼ח㼎ׅ׷ؙؒٔכ劢؟ه٦ز ꟼ侧זוד㢌䳔׃׋⦼׾勴⟝חׅ׷ծ醱侧ךؕٓيךさ鎘⦼׾勴⟝ח ׅ׷זו 宕竲⻉ׁ׸גְזְ⦼׾嗚稊穠卓ה׃ג㼪⳿ׅ׷ 䚍ⴽָˏ'ˏה.ד⥂㶷ׁ׸גְ׷הֹծ׉׸׊׸׾侧⦼ח㢌䳔׃ג侧ִ ♳־׷זו ؙؒٔךⵖꣲ

  53. J1IPOFזודכ֮׷玎䏝⟃♳ךؿ؋؎ٕ؟؎ؤחז׷הNNBQ ָ㣟 侁ׅ׷ؿ؋؎ٕ׾ًٌٔחوحؾؚٝדֹזְ رغ؎أ⣛㶷׌ָծ׌ְ׋ְ.#։ 㼛勻涸חծًٌٔوحفך眔㔲׾ⴓⶴׅ׷ֿהד㼎䘔✮㹀 ؿ؋؎ٕ؟؎ؤךⵖꣲ

  54. 3FBMNחאְג锃ץ׷ ⿫罋项俱

  55. ˖ Ⱅ䒭8FC؟؎ز!  IUUQTSFBMNJPKQ ˖ (JU)VC  IUUQTHJUIVCDPNSFBMNSFBMNDPDPB  IUUQTHJUIVCDPNSFBMNSFBMNKBWB

    ˖ ِ٦ؠ٦ؚٕ٦ف!  IUUQTXXXGBDFCPPLDPNHSPVQTSFBMNKQ ˖ ؟ه٦زثٍحز!  IUUQTMBDLSFBMNJP ˖ 5XJUUFS!  IUUQTUXJUUFSDPNSFBMN+BQBO ˖ ى٦ز،حف!  IUUQSFBMNDPOOQBTTDPN ⿫罋项俱
  56. 3FBMN+BQBONFFUVQ SFBMNDPOOQBTTDPN

  57. 3FBMN+BQBONFFUVQ SFBMNJPKQOFXT

  58. 3FBMN+BQBONFFUVQ SFBMNDPOOQBTTDPN ։ه٦ز吳䒭⠓爡銮倜㺊 ։ٖغٖآ٦ؤ吳䒭⠓爡幪靼ؼؕٔؒ ։4BOTBO吳䒭⠓爡邌⿫麣

  59. 3FBMNعٝؤؔٝ SFBMNDPOOQBTTDPN ։ٖغٖآ٦ؤ吳䒭⠓爡幪靼ؼؕٔؒ

  60. 3FBMN+BQBO6TFS(SPVQ GBDFCPPLDPNHSPVQTSFBMNKQ

  61. 1VCMJD3FBMN4MBDL! TMBDLSFBMNJP