Contenu connexe Similaire à Cassandra Summit EU 2014 Lightning talk - Paging (no animation) (20) Plus de Christopher Batey (20) Cassandra Summit EU 2014 Lightning talk - Paging (no animation)1. I want my data out: streaming + observable +
paging
Christopher Batey
@chbatey
©2013 DataStax Confidential. Do not distribute without consent.
1
2. Who am I?
•Technical Evangelist for Apache Cassandra
• Founder of Stubbed Cassandra
• Help out Apache Cassandra users
• Previous: Senior software engineer @ BSkyB
3. Cassandra is great because…
• What was once hard is now easy!
• More and more features that aren’t part of
its core competency
9. Manual paging
WEB
Your Application
DAO
Lots of small queries
Super C*
Blocking
Queue
12. Not so manual paging
Your Application
Super awesome paging query!
C*
13. ResultSet + Observable = Awesome
public 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
14. ResultSet + Observable = Awesome
Observable<CustomerEvent> chbatey = customerEventDao.getCustomerEventsObservable("chbatey");
chbatey.doOnCompleted(() -> {
try { outputStream.close(); } catch (IOException e) { }
});
chbatey.subscribe(event -> {
try { outputStream.write(event.serialise()); } catch (IOException e) { }
});
15. Manual paging
WEB
Your Application
DAO
Lots of small queries
Super C*
Blocking
Queue