coucbase connect 2015 体験談

32
Couchbase Connect 2015 験験 験験験験験験験 験験験 Couchbase MeetUP Tokyo - #14 2015-07-22

Upload: takashi-saito

Post on 18-Aug-2015

65 views

Category:

Technology


0 download

TRANSCRIPT

Couchbase Connect2015

体験談

株式会社ゴーズ 齋藤隆

Couchbase MeetUP Tokyo - #142015-07-22

Takashisite Programmer / Designer

株式会社ゴーズhttp://www.g-ptr.com/

株式会社ゴーズhttp://www.g-ptr.com/

2015 / 06 / 02 – 04Livi’s Studium @ Santa Clara

http://connect15.couchbase.com/sessions/

CBC15 - KEYWORD

Offline First (Offline First is the new Mobile First / GE Software)

IoT / BigData / (Realtime) Analytics

N1QL ( JSON + SQL)

DEMO

©2015 Couchbase Inc. 24

WHAT ARE WE BUILDING?

©2015 Couchbase Inc. 25

WHAT ARE WE BUILDING?

airline_24 { "id": "24", "type": "airline", "iata": "AA", "callsign": "American Airlines", ]}

route_5966 { "id": "5966", "type": "route", "airlineid": "airline_24", "from": ”LAX", "to": ”SFO", "stops": "0", "schedule": [ …

]}

©2015 Couchbase Inc. 26

COMBINE ROUTE WITH AIRLINE

airline_24 { "id": "24", "type": "airline", "iata": "AA", "callsign": "American Airlines", ]}

route_5966 { "id": "5966", "type": "route", "airlineid": "airline_24", "from": ”LAX", "to": ”SFO", "stops": "0", "schedule": [ …

]}

1. Read route_5966 document from Couchbase2. Parse JSON3. Pull out “airlineid” field4. Read airline_24 document from Couchbase

5. Parse JSON6. Pull out “callsign”7. Display airline name8. Throw away 2 objects

©2015 Couchbase Inc. 27

COMBINE ROUTE WITH AIRLINE

airline_24 { "id": "24", "type": "airline", "iata": "AA", "callsign": "American Airlines", ]}

route_5966 { "id": "5966", "type": "route", "airlineid": "airline_24", "from": ”LAX", "to": ”SFO", "stops": "0", "schedule": [ …

]}

With Couchbase 4.0 and N1QL:

SELECT airline.callsign, route.from, route.to

FROM `travel-db` route

JOIN `travel-db` airline ON KEYS route.airlineid

WHERE route.from=`LAX` AND route.to=`SFO`

©2015 Couchbase Inc. 28

UNNEST

route_5966 { "id": "5966", "type": "route", "airlineid": "airline_24", "from": ”LAX", "to": ”SFO", "stops": "0", "schedule": [ {"day": 1, "utc": "06:58:00", "flight": "AA348"}, {"day": 1, "utc": "09:30:00", "flight": "AA868"}, {"day": 1, "utc": "20:47:00", "flight": "AA483"},

{"day": 1, "utc": "06:58:00", "flight": "AA348"}, {"day": 2, "utc": "09:30:00", "flight": "AA868"}, {"day": 2, "utc": "20:47:00", "flight": "AA483"},

{"day": 3, "utc": "06:58:00", "flight": "AA348"}, {"day": 3, "utc": "09:30:00", "flight": "AA868"}, {"day": 3, "utc": "20:47:00", "flight": "AA483"},

... ]}

©2015 Couchbase Inc.

RETURN FLIGHTS FOR A PARTICULAR DAY

4. Foreach in “schedule”:a. Does it match requested day? Y/Nb. Does it match requested day? Y/Nc. Does it match requested day? Y/Nd. Does it match requested day? Y/Ne. Does it match requested day? Y/Nf. Does it match requested day? Y/Ng. Does it match requested day? Y/N

5. Display matching day, route and airline names

6. Throw away objects

For each requested route:

1. Read in “route” document from Couchbase:a. Instantiate objectb. Handle errorsc. Manage memory

2. Parse JSON:a. Map transcoderb. Manage versioningc. Handle missing values

3. Read in “schedule” objecta. Instantiate objectb. Handle errorsc. Manage memory

©2015 Couchbase Inc.

RETURN FLIGHTS FOR A PARTICULAR DAY

route_5966 { "id": "5966", "type": "route", "airlineid": "airline_24", "from": ”LAX", "to": ”SFO", "stops": "0", "schedule": [ {"day": 1, "utc": "06:58:00", "flight": "AA348"}, {"day": 1, "utc": "09:30:00", "flight": "AA868"}, {"day": 1, "utc": "20:47:00", "flight": "AA483"},

{"day": 1, "utc": "06:58:00", "flight": "AA348"}, {"day": 2, "utc": "09:30:00", "flight": "AA868"}, {"day": 2, "utc": "20:47:00", "flight": "AA483"},

SELECT airline.callsign, schedule.flight, schedule.utc, route.from, route.to

FROM `travel-sample` routeUNNEST route.schedule scheduleJOIN `travel-sample` airline ON KEYS route.airlineidWHERE route.from=`LAX` AND route.to=`SFO` AND schedule.day= `1`

まとめ(来年もやるのかわかりませんが)

来年はみなさんもぜひご参加を

株式会社ゴーズhttp://www.g-ptr.com/

WE’RE HIRING!新しいことに興味のある人探してます!