SlideShare a Scribd company logo
Cassandra rapid prototyping 
with Achilles 
www.achilles.io 1 
@doanduyhai
DuyHai DOAN 
Java/Cassandra freelance developer 
! 
! 
Daytime: + 
! 
! 
At night: + 
www.achilles.io 2 
@doanduyhai
What is Achilles ? 
Yet another C* object mapper 
www.achilles.io 3 
@doanduyhai
What is Achilles ? 
More than a C* object mapper 
www.achilles.io 4 
@doanduyhai
Demo 
TDD with Achilles 
www.achilles.io 5 
@doanduyhai
Main API 
•manager.insert(entity) 
! 
•manager.update(managedEntity) 
! 
•manager.remove(entity) 
! 
•manager.find(Entity.class, primaryKey) 
www.achilles.io 6 
@doanduyhai
Thread safety for persistence manager 
No JOINS means 
www.achilles.io 7 
@doanduyhai
Thread safety for persistence manager 
No JOINS means 
! 
! 
No complex object graph 
www.achilles.io 8 
@doanduyhai
Thread safety for persistence manager 
No JOINS means 
! 
! 
No complex object graph 
! 
! 
No state to keep 
www.achilles.io 9 
@doanduyhai
What’s about proxy ? 
proxifiedEntity = manager.find(Entity.class, primaryKey) 
Dirty check 
www.achilles.io 10 
@doanduyhai 
ProxifiedEntity 
Real 
Entity 
State 
Setters interception
Why proxies ? 
emc² Albert EINSTEIN GERMANY 
User einstein = manager.find(User.class,”emc²”); 
! 
einstein.setCountry(“USA”); 
! 
manager.insert(einstein); 
emc² Albert EINSTEIN GERMANY emc² Albert EINSTEIN USA 
www.achilles.io 11 
@doanduyhai 
Waste of space !!
Why proxies ? 
emc² Albert EINSTEIN GERMANY 
User einstein = manager.find(User.class,”emc²”); 
! 
einstein.setCountry(“USA”); 
! 
manager.update(einstein); 
emc² Albert EINSTEIN GERMANY USA 
www.achilles.io 12 
@doanduyhai
Slice query 
List<Message> entities = manager.sliceQuery(Message.class) 
.forSelect() 
.withPartitionComponents(10L) 
.fromClusterings(“forums”).toClusterings(“forums”, uuid1) 
.limit(10).fromInclusiveToExclusiveBounds() 
.get(); 
SELECT * FROM Message 
WHERE user_id = 10 
AND (message_folder) ≥ (‘forums’) 
AND (message_folder, date) < (‘forums’, uuid1) 
ORDER BY message_folder ASC LIMIT 10; 
www.achilles.io 13 
@doanduyhai
Typed query 
RegularStatement select = select().from(“user_messages”) 
.where(eq(“user_id”,bindMarker())) 
.and(gte(asList(“message_folder”), bindMarker())) 
.and(lt(asList(“message_folder”, “date”), bindMarker())) 
.limit(10); 
! 
List<Message> messages = manager.typedQuery(Message.class, select, 
userId, asList(“forums”), asList(“forums”, uuid1)) 
.get(); 
www.achilles.io 14 
@doanduyhai
Native query 
RegularStatement nativeQuery = new SimpleStatement(“SELECT * FROM Message 
WHERE … LIMIT 20”); 
! 
List<TypedMap> messages = manager.nativeQuery(nativeQuery).get(); 
! 
TypedMap firstMessage = messages.get(0); 
! 
// with normal Map<String, Object> 
// String interlocutor = (String) map.get(“interlocutor”); 
! 
String interlocutor = firstMessage.getTyped(“interlocutor”); 
String interlocutor = firstMessage.<String>getTyped(“interlocutor”); 
www.achilles.io 15 
@doanduyhai
Counter API 
Special proxy type 
www.achilles.io 16 
@doanduyhai 
public Long get(); 
! 
public void incr(); 
! 
public void incr(Long increment); 
! 
public void decr(); 
! 
public void decr(Long decrement);
Options 
•Setting C* special options 
•Apply to main API insert(), update(), remove() … 
www.achilles.io 17 
@doanduyhai 
manager.insert(user, 
OptionsBuilder 
.withConsistency(QUORUM) 
.ttl(10) 
.timestamp(1357949499999L) 
.ifNotExists() 
);
Lifecycle interceptors 
Hooks into persistence lifecycle 
www.achilles.io 18 
@doanduyhai 
public interface Interceptor<T> { 
public void onEvent(T entity); 
public List<Event> events(); 
} 
! 
public enum Event { 
PRE_PERSIST, POST_PERSIST, PRE_UPDATE, POST_UPDATE, PRE_REMOVE, 
POST_REMOVE, POST_LOAD; 
}
Bean Validation (JSR-303) 
Just a built-in interceptor, PRE_PERSIST, PRE_UPDATE 
@Entity(table = “entity”) 
public class Entity { 
@Id 
private Long id; 
! 
@Column 
@NotEmpty 
private String name; 
} 
www.achilles.io 19 
@doanduyhai
Batch mode 
C* 2.0 atomic batches 
Batch batch = manager.createBatch(); 
! 
batch.startBatch(); 
! 
batch.insert(new Entity(…..)); 
batch.update(…..); 
batch.remove(…..); 
batch.removeById(MyEntity.class, primaryKey); 
! 
batch.endBatch(); 
www.achilles.io 20 
@doanduyhai
Documentation 
•Comprehensive Github WIKI 
! 
•Twitter-clone demo app (demo.achilles.io) 
! 
•Versioned documentation (HTML & PDF) 
! 
•JavaDoc 
www.achilles.io 21 
@doanduyhai
Documentation 
www.achilles.io 22 
@doanduyhai
Asynchronous 
•Available for 
➡ main API ( insert(), update(), …) 
➡ slice queries 
➡ typed & native queries 
www.achilles.io 23 
@doanduyhai
Roadmap for future 
•C* 2.1 user defined types (UDT) & tuples 
! 
•Reactive programming (RxJava) 
! 
•Transparent search integration (ElasticSearch, Solr…) 
www.achilles.io 24 
@doanduyhai
Where to download ? 
•www.achilles.io 
! 
•Google “Achilles Cassandra” ☞ first result 
www.achilles.io 25 
@doanduyhai
Take away 
•More than a simple object mapper 
! 
•Productivity-oriented 
! 
•KISS 
! 
•Documented 
www.achilles.io 26 
@doanduyhai
! " 
Q & A 
www.achilles.io 27 @doanduyhai

More Related Content

PDF
Cassandra java libraries
PDF
Effective cassandra development with achilles
PDF
Understanding backbonejs
ODP
Indexed db
PPT
BackboneJs
PPTX
Save data in to sqlite
PPTX
Single page application 07
PDF
Dicoding Developer Coaching #27: Android | Membuat Aplikasi Support Online Ma...
Cassandra java libraries
Effective cassandra development with achilles
Understanding backbonejs
Indexed db
BackboneJs
Save data in to sqlite
Single page application 07
Dicoding Developer Coaching #27: Android | Membuat Aplikasi Support Online Ma...

What's hot (20)

PPTX
Backbonejs for beginners
PDF
Dicoding Developer Coaching #32: Android | Reactive Programming dengan RxJava...
ODP
Consume Spring Data Rest with Angularjs
PPTX
20141001 delapsley-oc-openstack-final
PPTX
Creating Single Page Web App using Backbone JS
PDF
Better Data Persistence on Android
PPTX
Hibernate Performance Tuning @JUG Thüringen
PDF
Backbone js in action
PDF
iOS for ERREST - alternative version
PDF
ERGroupware
PPTX
Data Management in Microsoft HDInsight: How to Move and Store Your Data
PPTX
Object Oriented Programing in JavaScript
KEY
【前端Mvc】之豆瓣说实践
PPT
Backbone js
PPT
Backbone.js
PDF
Backbone
PDF
第一次用Parse就深入淺出
PPTX
BackboneJS Training - Giving Backbone to your applications
PDF
React.js触ってみた 吉澤和香奈
PDF
In-depth changes to Drupal 8 javascript
Backbonejs for beginners
Dicoding Developer Coaching #32: Android | Reactive Programming dengan RxJava...
Consume Spring Data Rest with Angularjs
20141001 delapsley-oc-openstack-final
Creating Single Page Web App using Backbone JS
Better Data Persistence on Android
Hibernate Performance Tuning @JUG Thüringen
Backbone js in action
iOS for ERREST - alternative version
ERGroupware
Data Management in Microsoft HDInsight: How to Move and Store Your Data
Object Oriented Programing in JavaScript
【前端Mvc】之豆瓣说实践
Backbone js
Backbone.js
Backbone
第一次用Parse就深入淺出
BackboneJS Training - Giving Backbone to your applications
React.js触ってみた 吉澤和香奈
In-depth changes to Drupal 8 javascript
Ad

Viewers also liked (8)

PDF
Achilles presentation
PDF
Cassandra Drivers and Tools
PDF
Cassandra introduction apache con 2014 budapest
PDF
Cassandra NodeJS driver & NodeJS Paris
PDF
Cassandra data structures and algorithms
PDF
Cassandra nice use cases and worst anti patterns
PDF
Introduction to Cassandra & Data model
PDF
Cassandra techniques de modelisation avancee
Achilles presentation
Cassandra Drivers and Tools
Cassandra introduction apache con 2014 budapest
Cassandra NodeJS driver & NodeJS Paris
Cassandra data structures and algorithms
Cassandra nice use cases and worst anti patterns
Introduction to Cassandra & Data model
Cassandra techniques de modelisation avancee
Ad

Similar to Cassandra rapid prototyping with achilles (20)

PDF
Cassandra drivers and libraries
PDF
Hands On Spring Data
PPTX
Webinar: Strongly Typed Languages and Flexible Schemas
PPT
Architecture | Busy Java Developers Guide to NoSQL | Ted Neward
PPTX
Mongo sf easy java persistence
PPTX
MongoDB: Easy Java Persistence with Morphia
PDF
Naver_alternative_to_jpa
PDF
JPoint'15 Mom, I so wish Hibernate for my NoSQL database...
PPTX
Cassandra Java APIs Old and New – A Comparison
PDF
Webinar: MongoDB Persistence with Java and Morphia
PDF
Strongly Typed Languages and Flexible Schemas
PPTX
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
PPT
Introduction to NHibernate
PDF
NoSQL, no Limits, lots of Fun!
PDF
Alternatives of JPA/Hibernate
PPTX
JakartaData-JCon.pptx
PDF
JavaOne 2017 - JNoSQL: The Definitive Solution for Java and NoSQL Database [C...
PPTX
Spring & Hibernate
ODP
Working with jpa
PPTX
NoSQL: The first New Jakarta EE Specification (DWX 2019)
Cassandra drivers and libraries
Hands On Spring Data
Webinar: Strongly Typed Languages and Flexible Schemas
Architecture | Busy Java Developers Guide to NoSQL | Ted Neward
Mongo sf easy java persistence
MongoDB: Easy Java Persistence with Morphia
Naver_alternative_to_jpa
JPoint'15 Mom, I so wish Hibernate for my NoSQL database...
Cassandra Java APIs Old and New – A Comparison
Webinar: MongoDB Persistence with Java and Morphia
Strongly Typed Languages and Flexible Schemas
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
Introduction to NHibernate
NoSQL, no Limits, lots of Fun!
Alternatives of JPA/Hibernate
JakartaData-JCon.pptx
JavaOne 2017 - JNoSQL: The Definitive Solution for Java and NoSQL Database [C...
Spring & Hibernate
Working with jpa
NoSQL: The first New Jakarta EE Specification (DWX 2019)

More from Duyhai Doan (20)

PDF
Pourquoi Terraform n'est pas le bon outil pour les déploiements automatisés d...
PDF
Le futur d'apache cassandra
PDF
Big data 101 for beginners devoxxpl
PDF
Big data 101 for beginners riga dev days
PDF
Datastax enterprise presentation
PDF
Datastax day 2016 introduction to apache cassandra
PDF
Datastax day 2016 : Cassandra data modeling basics
PDF
Sasi, cassandra on the full text search ride At Voxxed Day Belgrade 2016
PDF
Apache cassandra in 2016
PDF
Spark zeppelin-cassandra at synchrotron
PDF
Sasi, cassandra on full text search ride
PDF
Cassandra 3 new features @ Geecon Krakow 2016
PDF
Algorithme distribués pour big data saison 2 @DevoxxFR 2016
PDF
Apache Zeppelin @DevoxxFR 2016
PDF
Cassandra 3 new features 2016
PDF
Cassandra introduction 2016
PDF
Spark cassandra integration 2016
PDF
Spark Cassandra 2016
PDF
Cassandra introduction 2016
PDF
Apache zeppelin the missing component for the big data ecosystem
Pourquoi Terraform n'est pas le bon outil pour les déploiements automatisés d...
Le futur d'apache cassandra
Big data 101 for beginners devoxxpl
Big data 101 for beginners riga dev days
Datastax enterprise presentation
Datastax day 2016 introduction to apache cassandra
Datastax day 2016 : Cassandra data modeling basics
Sasi, cassandra on the full text search ride At Voxxed Day Belgrade 2016
Apache cassandra in 2016
Spark zeppelin-cassandra at synchrotron
Sasi, cassandra on full text search ride
Cassandra 3 new features @ Geecon Krakow 2016
Algorithme distribués pour big data saison 2 @DevoxxFR 2016
Apache Zeppelin @DevoxxFR 2016
Cassandra 3 new features 2016
Cassandra introduction 2016
Spark cassandra integration 2016
Spark Cassandra 2016
Cassandra introduction 2016
Apache zeppelin the missing component for the big data ecosystem

Recently uploaded (20)

PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Getting Started with Data Integration: FME Form 101
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Machine Learning_overview_presentation.pptx
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Encapsulation theory and applications.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
cuic standard and advanced reporting.pdf
PPT
Teaching material agriculture food technology
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Reach Out and Touch Someone: Haptics and Empathic Computing
Encapsulation_ Review paper, used for researhc scholars
Getting Started with Data Integration: FME Form 101
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
MYSQL Presentation for SQL database connectivity
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Machine Learning_overview_presentation.pptx
Assigned Numbers - 2025 - Bluetooth® Document
Encapsulation theory and applications.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
cuic standard and advanced reporting.pdf
Teaching material agriculture food technology
Diabetes mellitus diagnosis method based random forest with bat algorithm
“AI and Expert System Decision Support & Business Intelligence Systems”

Cassandra rapid prototyping with achilles

  • 1. Cassandra rapid prototyping with Achilles www.achilles.io 1 @doanduyhai
  • 2. DuyHai DOAN Java/Cassandra freelance developer ! ! Daytime: + ! ! At night: + www.achilles.io 2 @doanduyhai
  • 3. What is Achilles ? Yet another C* object mapper www.achilles.io 3 @doanduyhai
  • 4. What is Achilles ? More than a C* object mapper www.achilles.io 4 @doanduyhai
  • 5. Demo TDD with Achilles www.achilles.io 5 @doanduyhai
  • 6. Main API •manager.insert(entity) ! •manager.update(managedEntity) ! •manager.remove(entity) ! •manager.find(Entity.class, primaryKey) www.achilles.io 6 @doanduyhai
  • 7. Thread safety for persistence manager No JOINS means www.achilles.io 7 @doanduyhai
  • 8. Thread safety for persistence manager No JOINS means ! ! No complex object graph www.achilles.io 8 @doanduyhai
  • 9. Thread safety for persistence manager No JOINS means ! ! No complex object graph ! ! No state to keep www.achilles.io 9 @doanduyhai
  • 10. What’s about proxy ? proxifiedEntity = manager.find(Entity.class, primaryKey) Dirty check www.achilles.io 10 @doanduyhai ProxifiedEntity Real Entity State Setters interception
  • 11. Why proxies ? emc² Albert EINSTEIN GERMANY User einstein = manager.find(User.class,”emc²”); ! einstein.setCountry(“USA”); ! manager.insert(einstein); emc² Albert EINSTEIN GERMANY emc² Albert EINSTEIN USA www.achilles.io 11 @doanduyhai Waste of space !!
  • 12. Why proxies ? emc² Albert EINSTEIN GERMANY User einstein = manager.find(User.class,”emc²”); ! einstein.setCountry(“USA”); ! manager.update(einstein); emc² Albert EINSTEIN GERMANY USA www.achilles.io 12 @doanduyhai
  • 13. Slice query List<Message> entities = manager.sliceQuery(Message.class) .forSelect() .withPartitionComponents(10L) .fromClusterings(“forums”).toClusterings(“forums”, uuid1) .limit(10).fromInclusiveToExclusiveBounds() .get(); SELECT * FROM Message WHERE user_id = 10 AND (message_folder) ≥ (‘forums’) AND (message_folder, date) < (‘forums’, uuid1) ORDER BY message_folder ASC LIMIT 10; www.achilles.io 13 @doanduyhai
  • 14. Typed query RegularStatement select = select().from(“user_messages”) .where(eq(“user_id”,bindMarker())) .and(gte(asList(“message_folder”), bindMarker())) .and(lt(asList(“message_folder”, “date”), bindMarker())) .limit(10); ! List<Message> messages = manager.typedQuery(Message.class, select, userId, asList(“forums”), asList(“forums”, uuid1)) .get(); www.achilles.io 14 @doanduyhai
  • 15. Native query RegularStatement nativeQuery = new SimpleStatement(“SELECT * FROM Message WHERE … LIMIT 20”); ! List<TypedMap> messages = manager.nativeQuery(nativeQuery).get(); ! TypedMap firstMessage = messages.get(0); ! // with normal Map<String, Object> // String interlocutor = (String) map.get(“interlocutor”); ! String interlocutor = firstMessage.getTyped(“interlocutor”); String interlocutor = firstMessage.<String>getTyped(“interlocutor”); www.achilles.io 15 @doanduyhai
  • 16. Counter API Special proxy type www.achilles.io 16 @doanduyhai public Long get(); ! public void incr(); ! public void incr(Long increment); ! public void decr(); ! public void decr(Long decrement);
  • 17. Options •Setting C* special options •Apply to main API insert(), update(), remove() … www.achilles.io 17 @doanduyhai manager.insert(user, OptionsBuilder .withConsistency(QUORUM) .ttl(10) .timestamp(1357949499999L) .ifNotExists() );
  • 18. Lifecycle interceptors Hooks into persistence lifecycle www.achilles.io 18 @doanduyhai public interface Interceptor<T> { public void onEvent(T entity); public List<Event> events(); } ! public enum Event { PRE_PERSIST, POST_PERSIST, PRE_UPDATE, POST_UPDATE, PRE_REMOVE, POST_REMOVE, POST_LOAD; }
  • 19. Bean Validation (JSR-303) Just a built-in interceptor, PRE_PERSIST, PRE_UPDATE @Entity(table = “entity”) public class Entity { @Id private Long id; ! @Column @NotEmpty private String name; } www.achilles.io 19 @doanduyhai
  • 20. Batch mode C* 2.0 atomic batches Batch batch = manager.createBatch(); ! batch.startBatch(); ! batch.insert(new Entity(…..)); batch.update(…..); batch.remove(…..); batch.removeById(MyEntity.class, primaryKey); ! batch.endBatch(); www.achilles.io 20 @doanduyhai
  • 21. Documentation •Comprehensive Github WIKI ! •Twitter-clone demo app (demo.achilles.io) ! •Versioned documentation (HTML & PDF) ! •JavaDoc www.achilles.io 21 @doanduyhai
  • 23. Asynchronous •Available for ➡ main API ( insert(), update(), …) ➡ slice queries ➡ typed & native queries www.achilles.io 23 @doanduyhai
  • 24. Roadmap for future •C* 2.1 user defined types (UDT) & tuples ! •Reactive programming (RxJava) ! •Transparent search integration (ElasticSearch, Solr…) www.achilles.io 24 @doanduyhai
  • 25. Where to download ? •www.achilles.io ! •Google “Achilles Cassandra” ☞ first result www.achilles.io 25 @doanduyhai
  • 26. Take away •More than a simple object mapper ! •Productivity-oriented ! •KISS ! •Documented www.achilles.io 26 @doanduyhai
  • 27. ! " Q & A www.achilles.io 27 @doanduyhai