Cloudant Sync Libraries for iOS and Android Dan DeMichele, VP Product! Mike Rhodes, Lead Mobile Engineer
Agenda • Cloudant Sync Overview ! • Cloudant Sync Technical Overview! • Roadmap! • Q&A
2
Cloudant Highlights • Distributed Database as a Service (DBaaS)
• For developers of high-velocity web and mobile apps
• Ends drudgery of scale-it-yourself
• 20,000+ users
• Founded by big data scientists
• Recently acquired by IBM Run Keeper
3
Cloudant NoSQL DBaaS App Layer / Browser / Mobile App
REST (HTTPS)
Cloudant JSON API JSON CRUD
Incremental MapReduce
Lucene Search
2D, 3D Geospatial
MultiMaster Replication
Device Sync
Security
Monitoring
IO Control
Geo-Load Balancing
Indexed JSON Storage
Physical Storage @ IBM SoftLayer, Rackspace, Microsoft Azure, AWS 4
Why Cloudant Sync for iOS and Android? !
• Growing need for customers to develop native applications online and offline! • Android and iOS accounted for 93.8% of all smartphone shipments for the year [1]
• Need for a dead-simple, developer-friendly API to manage the storage of data on the device and server
• Syncing of data needs to move between many devices for a collaborative experience! • 90% of people move between devices to accomplish a goal, whether that’s on smartphones, PCs, tablets or TV [2] [1] IDC Worldwide Quarterly Mobile Phone Tracker! [2] Navigating the new multi-screen world study: Google Research
5
Store and Access Data Everywhere • Store and query data whether you’re online or offline! • Synchronize data between devices by replicating data from Cloudant or CouchDB!
Local
Storage
• Simplify large scale development and deployment by isolating data access on the device and server! • Geographically disperse your data across 35 global data centers to allow for easy access depending on location
Local
Storage
6
Simplify and Distribute More Efficiently • Isolate data to an individual on the local device and server! • Reduce network activity by syncing only the data needed by a user to their device! • Easily share data across devices based on user access! • Sync directly with Cloudant or CouchDB - No need for extra servers to manage sync between devices 7
Key Feature Highlights • Open source libraries for both Android and iOS! • API for the mobile developer, removing as much backend complexity as possible! • Creating, reading, updating, and deleting documents (CRUD)! • Full replication support for local device to Cloudant or CouchDB ! • Querying and indexing of the data on the local device! • Complements other MBaaS solutions such as Parse and Kinney! • Robust conflict resolution
8
Sync Use Case Scenarios Many use cases across industries and verticals. The most interesting ones all have to do with either offline access or syncing across multiple devices:! • Retail and POS! • Providing real time inventory information across stores and regions with frequently interrupted service! • Field Services! • Data querying and data input in remote areas or spotty service! • Trade Shows / Conferences! • Updates to the conference or sharing of data while moving from zone to zone with interrupted service 9
Architecture
Outline • Native code implementation in two languages: • Objective-C: iOS and OS X • Java: Android and other Java platforms !
• Reuses existing open-source code and platforms
11
Indexing
Overview • A more "search-like" API !
• Chosen to go this way because: • Speaking to app developers, more immediately useful • Experience with our own applications !
• Demonstrates how to use various library features to build an "extension" on the platform: changes feed, events…
14
Docs @{
},
@"country": @"Zambia",
@"area": @(752614)
!
@{
}
@"country": @"Zimbabwe",
@"area": @(390580)
15
Creating an index // Datastore is CouchDB database — pool // of JSON documents CDTDatastore *datastore = …;
// Standard alloc/init using datastore
CDTIndexManager *im = …; !
[im ensureIndexedWithIndexName:@"country" fieldName:@"country" error:&error]; 16
Querying NSDictionary *query; CDTQueryResult *result; !
query = @{@"country": @"Zambia"}; ! !
result =[im queryWithDictionary:q error:&error]; ! !
for (CDTDocumentRevision *rev in result) { NSLog(@"", rev.docId); } 17
Other queries !
@{ // Exact equality
@"country": @"Zambia", !
// One of
@"country": @[@"Zambia", @"Zimbabwe"], !
// >=
@"area": @{@"min": @(100000)}, !
//