Cassandra Summit EU 2014 Lightning talk - Paging (no animation)

Post on 11-Jul-2015

981 views 3 download

Tags:

Transcript of Cassandra Summit EU 2014 Lightning talk - Paging (no animation)

©2013 DataStax Confidential. Do not distribute without consent.

Christopher Batey@chbatey

I want my data out: streaming + observable + paging

1

Who am I?•Technical Evangelist for Apache Cassandra• Founder of Stubbed Cassandra• Help out Apache Cassandra users• Previous: Senior software engineer @ BSkyB

Cassandra is great because…•What was once hard is now easy!•More and more features that aren’t part of

its core competency

Your favourite - OutOfMemory

Application CBig Query

Your favourite - OutOfMemory

Application CBig Query

Your favourite - OutOfMemory

Application CBig Query

Uh oh, OutOfMemory

Your favourite - OutOfMemory

Application CBig Query

Uh oh, OutOfMemory

Okay so 2 gb queries aren’t recommended?

Manual paging

WEB

Your Application

DAO

Lots of small queries

C*SuperBlocking Queue

Server side paging = awesome

Your favourite - OutOfMemory

Application CBig Query

Uh oh, OutOfMemory

Not so manual paging

Your Application

C*

Super awesome paging query!

ResultSet + Observable = Awesomepublic Observable<CustomerEvent> getCustomerEventsObservable(String customerId) { BoundStatement boundStatement = getEventsForCustomer.bind(customerId);

ListenableFuture<ResultSet> resultSetFuture = session.executeAsync(boundStatement);

Observable<ResultSet> observable = Observable.from(resultSetFuture, Schedulers.io()); Observable<Row> rowObservable = observable.flatMapIterable(result -> result);

return rowObservable.map(row -> new CustomerEvent( row.getString("customer_id"), row.getUUID("time"), row.getString("staff_id"), row.getString("store_type"), row.getString("event_type"), row.getMap("tags", String.class, String.class))); } p

ResultSet + Observable = AwesomeObservable<CustomerEvent> chbatey = customerEventDao.getCustomerEventsObservable("chbatey"); chbatey.doOnCompleted(() -> { try { outputStream.close(); } catch (IOException e) { } }); chbatey.subscribe(event -> {

try { outputStream.write(event.serialise()); } catch (IOException e) { } });

Manual paging

WEB

Your Application

DAO

Lots of small queries

C*SuperBlocking Queue

Thanks for listening

@chbateyhttp://christopher-batey.blogspot.co.uk