typesafe nosql @ topconf 2012

55

Upload: maciek-prochniak

Post on 28-Nov-2014

99 views

Category:

Software


1 download

DESCRIPTION

TypeSafe NoSQL @ TopConf 2012

TRANSCRIPT

Page 1: TypeSafe NoSQL @ TopConf 2012
Page 2: TypeSafe NoSQL @ TopConf 2012

Maciek Próchniak

Algebraic topologyhocolim

Group cohomology

Monads

GWTTouK

CamelOSGi

CQRS

Scala

Page 3: TypeSafe NoSQL @ TopConf 2012

Typesafe

Page 4: TypeSafe NoSQL @ TopConf 2012

Steve Yegge - Google

Software engineering has its own political axis, ranging from conservative to liberal

Scala (...): Hardcore conservative.

NoSQL - liberal

Page 5: TypeSafe NoSQL @ TopConf 2012

Typesafe NoSQL?

Page 6: TypeSafe NoSQL @ TopConf 2012
Page 7: TypeSafe NoSQL @ TopConf 2012

Supplier

Page 8: TypeSafe NoSQL @ TopConf 2012

Typesafe OrientDB

Page 9: TypeSafe NoSQL @ TopConf 2012

Why OrientDB?

ScalabilityDocument

JSON

Super-Fast Schema-less

Sharding

Graph RB+Tree Indexes

Page 10: TypeSafe NoSQL @ TopConf 2012

Why OrientDB?

notSoNoSQLJava

Page 11: TypeSafe NoSQL @ TopConf 2012

Consistency

Partition toleranceAvailability

Page 12: TypeSafe NoSQL @ TopConf 2012

P - do you really need it?

Page 13: TypeSafe NoSQL @ TopConf 2012

Data model

Supplier

Details Email

Supplier

Trucks

Page 14: TypeSafe NoSQL @ TopConf 2012

memory/local/remote

Page 15: TypeSafe NoSQL @ TopConf 2012

Native Java API

Page 16: TypeSafe NoSQL @ TopConf 2012

JDBC Driver!

Page 17: TypeSafe NoSQL @ TopConf 2012

SQL - examples

select from suppliers

select from suppliers where name = 'Henry'

select trucks[0] from suppliers

Page 18: TypeSafe NoSQL @ TopConf 2012

SQL - examples

select from suppliers where details.status = 'Important'

select from suppliers where trucks[capacity = 5].size() > 3

select from suppliers where trucks contains (capacity = 2)

Page 19: TypeSafe NoSQL @ TopConf 2012

Typesafe queries for NoSQL

Page 20: TypeSafe NoSQL @ TopConf 2012

SQL with compile time checking?

● i(my)Batis

● Hibernate

● Hades

Page 21: TypeSafe NoSQL @ TopConf 2012

SQL with compile time checking?

● QueryDSL

● jOOQ

● OneWebSQL

Page 22: TypeSafe NoSQL @ TopConf 2012

Goal

Page 23: TypeSafe NoSQL @ TopConf 2012
Page 24: TypeSafe NoSQL @ TopConf 2012

.Net

LINQ makes a query a first-class language construct in C# and Visual Basic.

var results = from c in Suppliers where c.size < 10 select new {c.name, c.address};

Page 25: TypeSafe NoSQL @ TopConf 2012

JVM?

... makes a query a first-class language construct in Java

... makes a query a first-class language construct in Scala

Page 26: TypeSafe NoSQL @ TopConf 2012

Typesafe queries for OrientDB using

Slick

Page 27: TypeSafe NoSQL @ TopConf 2012

Scala can do better!

Scala

Language

Intergration

Connectivity

Kit

Page 28: TypeSafe NoSQL @ TopConf 2012

Architecture

Query Compiler

Lifted embedding Direct embedding

MySQLPostgreSQL

SQLServer OrientDB

WebService?

Page 29: TypeSafe NoSQL @ TopConf 2012

Lifted embedding

Page 30: TypeSafe NoSQL @ TopConf 2012

Lifted embedding - meta

Page 31: TypeSafe NoSQL @ TopConf 2012

Lifted embedding - meta

Page 32: TypeSafe NoSQL @ TopConf 2012

Lifted embedding - meta

Page 33: TypeSafe NoSQL @ TopConf 2012

Lifted embedding - query

Page 34: TypeSafe NoSQL @ TopConf 2012

Lifted embedding - query

Page 35: TypeSafe NoSQL @ TopConf 2012

Can we do better?

Page 36: TypeSafe NoSQL @ TopConf 2012
Page 37: TypeSafe NoSQL @ TopConf 2012

Scala 2.10 - macros

● Compile time metaprogramming

● Transformations of AST

● Great for DSL and like

Page 38: TypeSafe NoSQL @ TopConf 2012

Macros in Slick

Page 39: TypeSafe NoSQL @ TopConf 2012

Macro expansion

.filter(s => s.name == "Henry")

"filter", Supplier, Function( List("s"), Apply( Select("s", "name"), "==",

List(Literal(Constant("Henry")))))

Page 40: TypeSafe NoSQL @ TopConf 2012

Translation to Query AST

"filter", Supplier, Function( List("s"), Apply( Select("s", "name"), "==",

List(Literal(Constant("Henry")))))

Slick Query AST

Page 41: TypeSafe NoSQL @ TopConf 2012

Direct embedding - meta

Page 42: TypeSafe NoSQL @ TopConf 2012

Direct embedding - query

Page 43: TypeSafe NoSQL @ TopConf 2012

Direct embedding - query

Page 44: TypeSafe NoSQL @ TopConf 2012

Type safety?

Page 45: TypeSafe NoSQL @ TopConf 2012

Composability?

Page 46: TypeSafe NoSQL @ TopConf 2012

Additional functions?

● CONTAINS operator

● Relations

● In-memory implementation

Page 47: TypeSafe NoSQL @ TopConf 2012

Impact: testability

Unit

Functional

Integration

H2/??

Mock

DevBase

Page 48: TypeSafe NoSQL @ TopConf 2012

Impact: testability

Unit

Functional

Integration

memory:

memory-slick

local:/remote:

Page 49: TypeSafe NoSQL @ TopConf 2012

Impact: design

DBLogicDAO

findByNamefindByClientAndName

findByCompany...

Page 50: TypeSafe NoSQL @ TopConf 2012

Impact: design

DBLogicDAO

query

Page 51: TypeSafe NoSQL @ TopConf 2012

Typesafe queries for NoSQL

are possiblewith

Slick & OrientDB

Page 52: TypeSafe NoSQL @ TopConf 2012

Call for action

● OrientDB - help crossing the chasm

● Slick - better direct embedding?

● slick-orientDB - everything ;)

Page 54: TypeSafe NoSQL @ TopConf 2012

Tänan :)

Page 55: TypeSafe NoSQL @ TopConf 2012