JNoSQL
Otávio Santana
@otaviojava
otaviojava@apache.org
NoSQL
● Database
● Doesn't use structure
● Not Transaction
● BASE
● Five different types
Key Value
● AmazonDynamo
● AmazonS3
● Redis
● Scalaris
● Voldemort
● Couchbase
● Hazelcast
valuekey
valuekey
valuekey
Document
● AmazonSimpleD
● ApacheCouchdb
● MongoDb
● Riak
● Couchbase
Column Family
● Hbase
● Cassandra
● Scylla
● Clouddata
● SimpleDb
● DynamoDB
Row-key Columns...
Apollo
Aphrodite
Ares
Sun
Duty
{Love, happy}
Duty
War
Duty
Sword
weapon
Color
Kratos
Dead Gods
13
Graph
● Neo4j
● InfoGrid
● Sones
● HyperGraphDB
Apollo Ares
Kratoswas killed by was killed by
Is brother
killed killed
Multi-Model
● OrientDB (graph, document)
● Couchbase (key value, document)
● Elasticsearch (document, graph)
● Cassandra (column family, graph - in progress)
SQL Key-value Document Column Graph
Table Bucket Collection Column
Family
Vertex and
Edge
Row Key/value
pair
Document Column Vertex
Column Key/value
pair
Key/value
pair
Vertex and
Edge property
Relationship Link Edge
Relational Application
DAO
API API API
Data Tier
Logic Tier
DAO
Logic Tier
Data Tier
JPA
JDBC
JPA
JDBC
JPA
JDBC
NoSQL Application
The Current Solution
● Spring Data
● Hibernate OGM
● TopLink
DAO
Solution Solution
JPA problem for NoSQL
● Saves Async
● Async Callback
● Time to Live (TTL)
● Consistency Level
● SQL based
● Diversity in NoSQL
The Challenge
● 4 Types
● Differents goals
● Differents behaviors
JNoSQL
● Mapping API
● Communication API
● No lock-in
● Divide and conquer
DAO
Mapping
Communication
Document
Key
Column
Graph
DIANA
ARTEMIS
JNoSQL
Data Tier
JNoSQL
● Eclipse Foundation
● Apache + Eclipse License
● API to each NoSQL type
● Configurable
● Extensible
Mapping
Communication DIANA
ARTEMIS
Why Diana?
● Goddess of the hunt, nature and
moon
● Fought in Troy
● Brave warrior and hunter
● Diana Rome = Artemis Greek
Diana
● API Communication layer
● Document, key-value, Column, Graph
● Universal Adapter
● Standard
Communication Issue
ODocument document = new ODocument(“collection”);
document.field(name, value);
JsonObject jsonObject = JsonObject.create();
jsonObject.put(name, value);
BaseDocument baseDocument = new
BaseDocument();
baseDocument.addAttribute(name, value);
Document document = new Document();
document.append(name, value);
Communication Issue
ODocument document = new ODocument(“collection”);
document.field(name, value);
JsonObject jsonObject = JsonObject.create();
jsonObject.put(name, value);
BaseDocument baseDocument = new
BaseDocument();
baseDocument.addAttribute(name, value);
Document document = new Document();
document.append(name, value);
Communication Issue
DocumentEntity entity =
DocumentEntity.of("documentCollection");
Document document = Document.of(name, value);
entity.add(document);
Issues
● insert vs save
● delete vs remove
● update vs merge
● find vs. search
● callback interface to
asynchronous callback
● long to seconds
● int to seconds
● long to milliseconds
● int to milliseconds
Diana Project
● Document API
● Graph API
● Key-value API
● Column API
● Four TCKs
Database
API
Implementation
TCK
Nomenclature
● Configuration
● Factory
● Manager
● Entity
● Value
Diversity
ColumnEntity entity = ColumnEntity.of(COLUMN_FAMILY);
Column id = Column.of("id", 10L);
entity.add(id);
entity.add(Column.of("version", 0.001));
entity.add(Column.of("name", "Diana"));
entity.add(Column.of("options", Arrays.asList(1, 2, 3)));
//mutiple implementation
columnEntityManager.save(entity);
ColumnQuery query = ColumnQuery.of(COLUMN_FAMILY);
query.addCondition(ColumnCondition.eq(id));
Optional<ColumnEntity> result = columnEntityManager.singleResult(query);
//cassandra only
List<ColumnEntity> entities = columnEntityManagerCassandra
.cql("select * from newKeySpace.newColumnFamily where id=10;");
columnEntityManagerCassandra.save(entity, ConsistencyLevel.ALL);
NoSQL Providers
JUGs/Communities
Artemis● CDI Based
● Diana Based
● Annotation Based
● Events to insert, delete, update
● Supports to Bean Validation
● Configurable and Extensible
● Query Method
Annotations
● MappedSuperclass
● Entity
● Column
@Entity("movie")
public class Movie {
@Column
private String name;
@Column
private long year;
@Column
private Set<String> actors;
interface PersonRepository extends Repository<Person> {
Person findByName(String name);
void deleteByName(String name);
Optional<Person> findByAge(Integer age);
List<Person> findByNameAndAge(String name, Integer age);
Set<Person> findByAgeAndName(Integer age, String name);
Stream<Person> findByNameAndAgeOrderByName(String name, Integer age);
Queue<Person> findByNameAndAgeOrderByAge(String name, Integer age);
}
Dynamic Query
Events
Movie
firePreEntity firePreAPI firePostAPI firePostEntity
Interceptor
Configurable and
extensible
● EventManager
● CrudOperation
● ClassRepresentations
● Converter
● Decorate
● Replace
@Entity("person")
public class Person {
@Column
private String name;
@Column
private Integer age;
@UDT("address")
@Column
private Address home;
}
interface PersonRepository extends CassandraRepository<Person> {
Person findByName(String name, ConsistencyLevel level);
void deleteByName(String name, ConsistencyLevel level);
@CQL("select * from Person")
List<Person> findAll();
@CQL("select * from Person where name = ?")
List<Person> findByName(String name);
}
Road Map
✓ Draft and code proposal
✓ Community Feedback
✓ Involve NoSQL Vendors
✓ Involve Solution
Vendors
✓ Eclipse Project
✓ Development
✓ JSR
Site
http://jnosql.org/
Code
https://github.com/JNOSQL
Mailing List
https://dev.eclipse.org/mailman/listinfo/jnosql-dev
Gitter
https://gitter.im/JNOSQL/developers
Wiki
https://wiki.eclipse.org/JNoSQL
Thank you
Otávio Santana
@otaviojava
osantana@tomitribe.com
otaviojava@apache.org

NoSQL, no Limits, lots of Fun!