SlideShare ist ein Scribd-Unternehmen logo
1 von 39
Downloaden Sie, um offline zu lesen
Working with Data
in Titanium

Presentation by:
PRATIK PATEL | CTO | TripLingo Labs | @prpatel PRATIK@mypatelspace.com
@prpatel
@TripLingo
TOPICS
• working with data
• Strategies: SQL & NOSQL
• architecture
• synchronization

PRATIK PATEL | CTO
TRANSFORMING
DATA
PRATIK PATEL | CTO
can be frustrating

PRATIK PATEL | CTO
Use the FUNC, Luke
• functional programming in
• break down the problem
• json is very flexible

JavaScript

PRATIK PATEL | CTO
take this

[{
      "id":30445,
      "speakerNames":"Pratik Patel",
      "smallImageSq":"/s/images/bio/
14890_Patel_20110408_052535_small_sq.jpg",
      "mediumImageSq":"/s/images/bio/
14890_Patel_20110408_052535_medium_sq.jpg",
      "roomId":1554,
      "ordinal":2,
      "showId":327,
      "slotId":7956,
      "featured":true,
      "modified":"2013-12-17T21:19:05",
      "topicId":3193,
      "eventId":null,
      "title":"Advanced JavaScript for Java Devs",
      "summary":"So you think you've picked up enough JavaScript to be dan
gerous, but feel like the whole prototypical language thing is still a mys
tery. In this session, we'll go from basic JavaScript to advanced JavaScri
pt. We'll discuss and code modular JavaScript with CommonJS. We'll look in
to the details of a prototype language and discuss things like parasitic i
nheritance. We'll also look at JavaScript libraries that will help you get
 the most out of JavaScript  not jQuery, but a library like UnderscoreJS and SugarJS.",
      "detail":"This is a fast paced session meant to bring you up to spee
d with the latest and greatest JavaScript techniques and tools. Whether yo
u're building client side JavaScript with HTML5 or Appcelerator Titanium, 
or serverside JavaScript with node.js, you'll come away with knowledge and patterns
 for how the pro's use JavaScript for building real apps.",
      "prerequisite":null,
      "workshopRequirements":null,
      "endTime":"2014-03-07T14:45:00",
      "startTime":"2014-03-07T13:15:00",
      "speakerIds":[
         14890
      ],
      "missingSlides":false,
      "dayNumber":0,
      "startTimeString":"Fri 01:15 PM",
      "roomName":"Room 2"
   }

make this
PRATIK PATEL | CTO
underscore.js
• use it
• master it
• think functional

PRATIK PATEL | CTO
map
• map is the name of a higher-order function

that applies a given function to each element
of a list, returning a list of results
• like doing a transformation

PRATIK PATEL | CTO
flatten
•Flattens a nested array (the nesting can be
to any depth)

PRATIK PATEL | CTO
sortBy
• sorts (duh!)
• can sort arrays and even an array of objects!

PRATIK PATEL | CTO
live coding
SQLite
&
NoSQL
SQLite
• Embedded sql-92 compliant db
• file based
• fast(!)

PRATIK PATEL | CTO
sqlite
var	
  db	
  =	
  Titanium.Database.open('mydb');	
  
!
db.execute('CREATE	
  TABLE	
  IF	
  NOT	
  EXISTS	
  DATABASETEST	
  	
  (ID	
  INTEGER,	
  NAME	
  
TEXT)');	
  
db.execute('DELETE	
  FROM	
  DATABASETEST');	
  
!
db.execute('INSERT	
  INTO	
  DATABASETEST	
  (ID,	
  NAME	
  )	
  VALUES(?,?)',1,'Name	
  
1');	
  
db.execute('UPDATE	
  DATABASETEST	
  SET	
  NAME	
  =	
  ?	
  WHERE	
  ID	
  =	
  ?',	
  updateName,	
  
updateId);	
  
var	
  rows	
  =	
  db.execute('SELECT	
  *	
  FROM	
  DATABASETEST');	
  
!
while	
  (rows.isValidRow())	
  
{	
  
	
   Titanium.API.info('ID:	
  '	
  +	
  rows.field(0)	
  +	
  '	
  NAME:	
  '	
  +	
  	
  
	
  	
  	
  rows.fieldByName('name')	
  +	
  '	
  COLUMN	
  NAME	
  '	
  +	
  rows.fieldName(0));	
  
	
   rows.next();	
  
}

PRATIK PATEL | CTO
SQLite
• Pre-bundling data
• fast!
• structured data

PRATIK PATEL | CTO
NOSQL OPTIONS
• SCuleJS - like mongodb
• MongloDB
• plain json as we saw!

PRATIK PATEL | CTO
PLAIN JSON
• can get alot of mileage out of this
• small = store using Ti.App.Properties!
• big = store in a file

PRATIK PATEL | CTO
SCULEJS / MongloDB
• Mongodb-like
• relationships
• advanced queries

PRATIK PATEL | CTO
SculeJS
var scollection = scule.factoryCollection('scule+dummy://test',
{secret:’mysecretkey'});	
!
scollection.save({ name : ‘pratik', session : 'javascript'}, 	
	 	 	 	 	 	 	 { name : ‘ket', session : 'design'	});	
!
scollection.find({$within:{name:’pratik’}}, {$limit:10, $sort:
{name:-1}}, function(results) {	
// do something with results here	
});	

PRATIK PATEL | CTO
now the boring stuff

PRATIK PATEL | CTO
SYNCHRONIZATION

PRATIK PATEL | CTO
PLAIN JSON + REST
• Standard REST endpoints
• You manage the sync yourself

PRATIK PATEL | CTO
SQLite
• You manage the sync yourself
• Manual conversion to/from SQL
• ORM’s for Titanium
• BUT: why not send the actual SQLite file
over the wire???

PRATIK PATEL | CTO
ARCHITECTURAL
CONSIDERATIONS

PRATIK PATEL | CTO
PERFORMANCE
• Large datasets - handle with care
• “cache” operations if possible

PRATIK PATEL | CTO
PERFORMANCE
• SQLite is native code = queries fast
• data extraction = expensive

PRATIK PATEL | CTO
PERFORMANCE
• JSON queries slow (non-indexed iteration)
• data extraction cost is ZERO
• SculeJS has indexed find ops

PRATIK PATEL | CTO
NETWORK
• Know what your users are running on
- 3G?
- Wireless?

PRATIK PATEL | CTO
NETWORK
• Speed over 3G networks is usually good
• LATENCY is the killer!
• Each request => 150-500ms latency

PRATIK PATEL | CTO
LOCAL STORAGE
• SQLite = File
• JSON can use Ti.App.Properties
• Props get loaded into MEMORY
• Not GC-able

PRATIK PATEL | CTO
WHAT ABOUT ALLOY?

PRATIK PATEL | CTO
i’m glad you asked

PRATIK PATEL | CTO
ALLOY + DATA
• Alloy uses Backbone models
• Backbone uses….

PRATIK PATEL | CTO
UNDERSCORE!

PRATIK PATEL | CTO
ALLOY + UNDERSCORE
• The code demo shown earlier just works
with ALLOY:
• collection.map
• collection.sortBy

PRATIK PATEL | CTO
ALLOY + SYNC
• Alloy uses Backbone models
• Backbone adapters
• Titanium specific adapters

PRATIK PATEL | CTO
AU REVOIR

PRATIK PATEL
@PRPATEL

PRATIK@mypatelspace.com

Weitere ähnliche Inhalte

Was ist angesagt?

2021 04-15 operational verification (with notes)
2021 04-15 operational verification (with notes)2021 04-15 operational verification (with notes)
2021 04-15 operational verification (with notes)
Puppet
 
Presto - Hadoop Conference Japan 2014
Presto - Hadoop Conference Japan 2014Presto - Hadoop Conference Japan 2014
Presto - Hadoop Conference Japan 2014
Sadayuki Furuhashi
 

Was ist angesagt? (18)

Building a Data Ingestion & Processing Pipeline with Spark & Airflow
Building a Data Ingestion & Processing Pipeline with Spark & AirflowBuilding a Data Ingestion & Processing Pipeline with Spark & Airflow
Building a Data Ingestion & Processing Pipeline with Spark & Airflow
 
Apache Airflow Introduction
Apache Airflow IntroductionApache Airflow Introduction
Apache Airflow Introduction
 
Embulk at Treasure Data
Embulk at Treasure DataEmbulk at Treasure Data
Embulk at Treasure Data
 
Airflow presentation
Airflow presentationAirflow presentation
Airflow presentation
 
Workflow Engines for Hadoop
Workflow Engines for HadoopWorkflow Engines for Hadoop
Workflow Engines for Hadoop
 
vBrownBag DevOps Series: Puppetinabox
vBrownBag DevOps Series: PuppetinaboxvBrownBag DevOps Series: Puppetinabox
vBrownBag DevOps Series: Puppetinabox
 
Puppetcamp r10kyaml
Puppetcamp r10kyamlPuppetcamp r10kyaml
Puppetcamp r10kyaml
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
 
Apache Airflow
Apache AirflowApache Airflow
Apache Airflow
 
Apache Airflow overview
Apache Airflow overviewApache Airflow overview
Apache Airflow overview
 
Apache Beam @ GCPUG.TW Flink.TW 20161006
Apache Beam @ GCPUG.TW Flink.TW 20161006Apache Beam @ GCPUG.TW Flink.TW 20161006
Apache Beam @ GCPUG.TW Flink.TW 20161006
 
2021 04-15 operational verification (with notes)
2021 04-15 operational verification (with notes)2021 04-15 operational verification (with notes)
2021 04-15 operational verification (with notes)
 
Airflow Clustering and High Availability
Airflow Clustering and High AvailabilityAirflow Clustering and High Availability
Airflow Clustering and High Availability
 
Paperclip
PaperclipPaperclip
Paperclip
 
GraphQL With Relay Part Deux
GraphQL With Relay Part DeuxGraphQL With Relay Part Deux
GraphQL With Relay Part Deux
 
EuroPython 2014 Devops Risk Mitigation
EuroPython 2014 Devops Risk MitigationEuroPython 2014 Devops Risk Mitigation
EuroPython 2014 Devops Risk Mitigation
 
GraphQL IndyJS April 2016
GraphQL IndyJS April 2016GraphQL IndyJS April 2016
GraphQL IndyJS April 2016
 
Presto - Hadoop Conference Japan 2014
Presto - Hadoop Conference Japan 2014Presto - Hadoop Conference Japan 2014
Presto - Hadoop Conference Japan 2014
 

Ähnlich wie Working with Data and Titanium

Ähnlich wie Working with Data and Titanium (20)

Kql and the content search web part
Kql and the content search web part Kql and the content search web part
Kql and the content search web part
 
Find Anything In Your APEX App - Fuzzy Search with Oracle Text
Find Anything In Your APEX App - Fuzzy Search with Oracle TextFind Anything In Your APEX App - Fuzzy Search with Oracle Text
Find Anything In Your APEX App - Fuzzy Search with Oracle Text
 
Techorama 2017 - Testing the unit, and beyond.
Techorama 2017 - Testing the unit, and beyond.Techorama 2017 - Testing the unit, and beyond.
Techorama 2017 - Testing the unit, and beyond.
 
JSLT: JSON querying and transformation
JSLT: JSON querying and transformationJSLT: JSON querying and transformation
JSLT: JSON querying and transformation
 
Demystifying NoSQL - All Things Open - October 2020
Demystifying NoSQL - All Things Open - October 2020Demystifying NoSQL - All Things Open - October 2020
Demystifying NoSQL - All Things Open - October 2020
 
Cross the Streams! Creating Streaming Data Pipelines with Apache Flink + Apac...
Cross the Streams! Creating Streaming Data Pipelines with Apache Flink + Apac...Cross the Streams! Creating Streaming Data Pipelines with Apache Flink + Apac...
Cross the Streams! Creating Streaming Data Pipelines with Apache Flink + Apac...
 
Php forum2015 tomas_final
Php forum2015 tomas_finalPhp forum2015 tomas_final
Php forum2015 tomas_final
 
Real World Performance - Data Warehouses
Real World Performance - Data WarehousesReal World Performance - Data Warehouses
Real World Performance - Data Warehouses
 
Ml pipelines with Apache spark and Apache beam - Ottawa Reactive meetup Augus...
Ml pipelines with Apache spark and Apache beam - Ottawa Reactive meetup Augus...Ml pipelines with Apache spark and Apache beam - Ottawa Reactive meetup Augus...
Ml pipelines with Apache spark and Apache beam - Ottawa Reactive meetup Augus...
 
Jump Start with Apache Spark 2.0 on Databricks
Jump Start with Apache Spark 2.0 on DatabricksJump Start with Apache Spark 2.0 on Databricks
Jump Start with Apache Spark 2.0 on Databricks
 
Oracle Application Express as add-on for Google Apps
Oracle Application Express as add-on for Google AppsOracle Application Express as add-on for Google Apps
Oracle Application Express as add-on for Google Apps
 
Tugdual Grall - From SQL to NoSQL in less than 40 min - NoSQL matters Paris 2015
Tugdual Grall - From SQL to NoSQL in less than 40 min - NoSQL matters Paris 2015Tugdual Grall - From SQL to NoSQL in less than 40 min - NoSQL matters Paris 2015
Tugdual Grall - From SQL to NoSQL in less than 40 min - NoSQL matters Paris 2015
 
Simon Elliston Ball – When to NoSQL and When to Know SQL - NoSQL matters Barc...
Simon Elliston Ball – When to NoSQL and When to Know SQL - NoSQL matters Barc...Simon Elliston Ball – When to NoSQL and When to Know SQL - NoSQL matters Barc...
Simon Elliston Ball – When to NoSQL and When to Know SQL - NoSQL matters Barc...
 
Autogenerate Awesome GraphQL Documentation with SpectaQL
Autogenerate Awesome GraphQL Documentation with SpectaQLAutogenerate Awesome GraphQL Documentation with SpectaQL
Autogenerate Awesome GraphQL Documentation with SpectaQL
 
Master tuning
Master   tuningMaster   tuning
Master tuning
 
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013
 
Bling css3
Bling css3Bling css3
Bling css3
 
Mobile Development Options
Mobile Development OptionsMobile Development Options
Mobile Development Options
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsOracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c  - New Features for Developers and DBAsOracle Database 12c  - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
 

Kürzlich hochgeladen

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Kürzlich hochgeladen (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 

Working with Data and Titanium