Date post: | 16-Jan-2015 |
Category: |
Technology |
Upload: | amd-developer-central |
View: | 407 times |
Download: | 3 times |
APU13 - Bringing Spa-APU13 - Bringing Spa-tial Love to your Javatial Love to your Java
ApplicationApplicationhttp://talks.thesteve0.comhttp://talks.thesteve0.com
Presented by:
Steven PoustySteven Pousty@TheSteve0 on Twitter, IRC,@TheSteve0 on Twitter, IRC,
and Githuband Githubhttp://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
AgendaAgendaA little about MongoDB Spatial1.Some JEE2.Learn a bit about PaaS3.See some demos4.
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
AssumptionsAssumptionsYou write Java code1.You will ask questions2.
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
Types of NoSQL datasTypes of NoSQL datastorestores
TYPE Document Key-Value Graph DataProcessing
EXAMPLE MongoDB,Couchbase
Redis,Riak,Memcahe
Neo4J Hadoop,Cassandra,Voldemort
USE-CASE Documentstorageand search
Cachingor ObjectStore
Relationshipsbetween"things"
Large dataprocessing
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
On to MongoOn to Mongo
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
A bit about MongoDBA bit about MongoDBA document is just a bunch of attributes andvalues - think of it like HashMapCan be nested - helps avoid joinsSchemalessReally good at fast writes - but you give upimmediate consistencyEasy to horizontally scale
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
Now some spatialNow some spatialThe spatial functionality Mongo currently has is:
Near ($near)1.Containment ($geoWithin)2.Intersection ($geoIntersects )3.
It is all laid out here:It is all laid out here:
and here:and here:Geospatial Indexes and Queries
Geospatial Index Internals
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
Two types of indices:Two types of indices:2D - for flat surfaces1.2dsphere - helps with coords on an earth likesphere
2.
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
Good to KnowGood to KnowAssumes coords. are between [-180 and 180)Can handle any 2D coordinatesHas methods to handle curvature of the earth(spherical)
to human readable unitsFormula to convert
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
How do you make itHow do you make itworkwork
1. Put coordinates into an array1. Put coordinates into an array{ loc : [ 50 , 30 ] }{ loc : { x : 50 , y : 30 } }{ loc : { foo : 50 , y : 30 } }{ loc : { lon : 40.739037, lat: 73.992964 } } If you use lattitude and longitude with a default
2. Make a 2D index2. Make a 2D index db.places.ensureIndex( { loc : "2d" } )
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
JEE - CDI and JAX-RSJEE - CDI and JAX-RSContext Dependency Injection - allows you tomake classes availble whenever you need themand let the calling class decide which class it wantsJAX-RS - the antiSOAP (three cheers). Makes itsuper easy to write REST like architectures
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
Let's look at some codeLet's look at some codeBuild a spatial checkin serviceBuild a spatial checkin service
for national parks in US andfor national parks in US andCanadaCanada
Java - JEE using CDI and JAX-RSJava - JEE using CDI and JAX-RS
The full map front end app can be found here
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
Let's spin up a JEELet's spin up a JEE(JBoss EAP) and Mon-(JBoss EAP) and Mon-
goDB servergoDB server
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
One Source to BindOne Source to BindThem AllThem All
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
But wait - there's moreBut wait - there's moreFree! No time limit1.3 gears (like servers) - each 512 Mb RAM, 1 Gbdisk
2.
Simple pricing3.
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
Let's wrap it upLet's wrap it upOpenshift makes life great for you1.Spatial is easy and fun with MongoDB2.Free!3.
Come hang out with us:#openshift on freenode irc
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf
http://presentations-thesteve0.rhcloud.com/amdjavamongo/index.html?print-pdf