SlideShare ist ein Scribd-Unternehmen logo
1 von 27
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

20141001 delapsley-oc-openstack-final
20141001 delapsley-oc-openstack-final20141001 delapsley-oc-openstack-final
20141001 delapsley-oc-openstack-final
David Lapsley
 
iOS for ERREST - alternative version
iOS for ERREST - alternative versioniOS for ERREST - alternative version
iOS for ERREST - alternative version
WO Community
 
【前端Mvc】之豆瓣说实践
【前端Mvc】之豆瓣说实践【前端Mvc】之豆瓣说实践
【前端Mvc】之豆瓣说实践
taobao.com
 

Was ist angesagt? (20)

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

Andere mochten auch (8)

Achilles presentation
Achilles presentationAchilles presentation
Achilles presentation
 
Cassandra Drivers and Tools
Cassandra Drivers and ToolsCassandra Drivers and Tools
Cassandra Drivers and Tools
 
Cassandra introduction apache con 2014 budapest
Cassandra introduction apache con 2014 budapestCassandra introduction apache con 2014 budapest
Cassandra introduction apache con 2014 budapest
 
Cassandra NodeJS driver & NodeJS Paris
Cassandra NodeJS driver & NodeJS ParisCassandra NodeJS driver & NodeJS Paris
Cassandra NodeJS driver & NodeJS Paris
 
Cassandra data structures and algorithms
Cassandra data structures and algorithmsCassandra data structures and algorithms
Cassandra data structures and algorithms
 
Cassandra nice use cases and worst anti patterns
Cassandra nice use cases and worst anti patternsCassandra nice use cases and worst anti patterns
Cassandra nice use cases and worst anti patterns
 
Introduction to Cassandra & Data model
Introduction to Cassandra & Data modelIntroduction to Cassandra & Data model
Introduction to Cassandra & Data model
 
Cassandra techniques de modelisation avancee
Cassandra techniques de modelisation avanceeCassandra techniques de modelisation avancee
Cassandra techniques de modelisation avancee
 

Ähnlich wie Cassandra rapid prototyping with achilles

CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on Android
Sven Haiges
 
Developing your first application using FI-WARE
Developing your first application using FI-WAREDeveloping your first application using FI-WARE
Developing your first application using FI-WARE
Fermin Galan
 
Jquery dojo slides
Jquery dojo slidesJquery dojo slides
Jquery dojo slides
helenmga
 

Ähnlich wie Cassandra rapid prototyping with achilles (20)

Paris js extensions
Paris js extensionsParis js extensions
Paris js extensions
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on Android
 
Building Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture ComponentsBuilding Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture Components
 
Minicurso Android
Minicurso AndroidMinicurso Android
Minicurso Android
 
jQuery in the [Aol.] Enterprise
jQuery in the [Aol.] EnterprisejQuery in the [Aol.] Enterprise
jQuery in the [Aol.] Enterprise
 
#JavaFX.forReal() - ElsassJUG
#JavaFX.forReal() - ElsassJUG#JavaFX.forReal() - ElsassJUG
#JavaFX.forReal() - ElsassJUG
 
Android dev toolbox
Android dev toolboxAndroid dev toolbox
Android dev toolbox
 
Programming IoT Gateways in JavaScript with macchina.io
Programming IoT Gateways in JavaScript with macchina.ioProgramming IoT Gateways in JavaScript with macchina.io
Programming IoT Gateways in JavaScript with macchina.io
 
Michael Häusler – Everyday flink
Michael Häusler – Everyday flinkMichael Häusler – Everyday flink
Michael Häusler – Everyday flink
 
Persisting Data on SQLite using Room
Persisting Data on SQLite using RoomPersisting Data on SQLite using Room
Persisting Data on SQLite using Room
 
Android Architecture Components with Kotlin
Android Architecture Components with KotlinAndroid Architecture Components with Kotlin
Android Architecture Components with Kotlin
 
Play!ng with scala
Play!ng with scalaPlay!ng with scala
Play!ng with scala
 
Html5 For Jjugccc2009fall
Html5 For Jjugccc2009fallHtml5 For Jjugccc2009fall
Html5 For Jjugccc2009fall
 
Green dao
Green daoGreen dao
Green dao
 
Softshake - Offline applications
Softshake - Offline applicationsSoftshake - Offline applications
Softshake - Offline applications
 
Appcelerator titanium
Appcelerator titaniumAppcelerator titanium
Appcelerator titanium
 
From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)
 
Developing your first application using FI-WARE
Developing your first application using FI-WAREDeveloping your first application using FI-WARE
Developing your first application using FI-WARE
 
Teste de Integração com DbUnit e jIntegrity
Teste de Integração com DbUnit e jIntegrityTeste de Integração com DbUnit e jIntegrity
Teste de Integração com DbUnit e jIntegrity
 
Jquery dojo slides
Jquery dojo slidesJquery dojo slides
Jquery dojo slides
 

Mehr von Duyhai Doan

Mehr von Duyhai Doan (20)

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

Kürzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

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