169
Migrating Speedment to Java 9 Dan Lawesson, @dan_lawesson CSO, Speedment, Inc

Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

  • Upload
    others

  • View
    9

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Migrating Speedment to Java 9

Dan Lawesson , @dan_lawesson CSO, Speedment, Inc

Page 2: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

About Us

Page 3: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

About Us

Dan Lawesson, PhD • AI, model-based diagnosis • CSO with S as in Science • 20 years of Java experience • Previous lives: telecom and

automotive IoT

Page 4: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

About Us

Dan Lawesson, PhD • AI, model-based diagnosis • CSO with S as in Science • 20 years of Java experience • Previous lives: telecom and

automotive IoT

Spire • Speedment Open Source mascot • Lives on GitHub • 2 years of mascot experience

Page 5: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Outline

Page 6: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Outline

• Speedment

• Jigsaw

• Jigsawing Speedment

Page 7: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Speedment

Page 8: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Speedment

Speedment is

Page 9: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Speedment

Speedment is• a Streams API ORM

Page 10: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Speedment

Speedment is• a Streams API ORM• using in-JVM memory acceleration

Page 11: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Speedment

Speedment is• a Streams API ORM• using in-JVM memory acceleration• and Code Generation,

Page 12: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Speedment

Speedment is• a Streams API ORM• using in-JVM memory acceleration• and Code Generation,• with modular design

Page 13: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Speedment

Speedment is• a Streams API ORM• using in-JVM memory acceleration• and Code Generation,• with modular design

Oracle Java Magazine May-June pages 34-40

Page 14: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Speedment

Speedment is• a Streams API ORM• using in-JVM memory acceleration• and Code Generation,• with modular design

Oracle Java Magazine May-June pages 34-40

Page 15: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration
Page 16: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Compile-time Code Generation Tool

Page 17: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Compile-time Code Generation Tool

Page 18: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration
Page 19: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Querying the Database using Streams

Page 20: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Querying the Database using Streams

• Queries are expressed using the standard Java 8 Stream API

Page 21: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Querying the Database using Streams

• Queries are expressed using the standard Java 8 Stream API

• Streams are analyzed to produce high-performance queries

Page 22: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Expressing Queries as Streams

customers.stream().filter(Customer.REGION.equal(Region.NORTH_AMERICA)).filter(Customer.REGISTERED.greaterOrEqual(startOfYear)).count();

Page 23: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Expressing Queries as Streams

customers.stream().filter(Customer.REGION.equal(Region.NORTH_AMERICA)).filter(Customer.REGISTERED.greaterOrEqual(startOfYear)).count();

Standard Stream API

Page 24: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Expressing Queries as Streams

customers.stream().filter(Customer.REGION.equal(Region.NORTH_AMERICA)).filter(Customer.REGISTERED.greaterOrEqual(startOfYear)).count();

Standard Stream APIFull Type-Safety

Page 25: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Expressing Queries as Streams

customers.stream().filter(Customer.REGION.equal(Region.NORTH_AMERICA)).filter(Customer.REGISTERED.greaterOrEqual(startOfYear)).count();

Standard Stream API Generated Enum ConstantsFull Type-Safety

Page 26: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Expressing Queries as Streams

customers.stream().filter(Customer.REGION.equal(Region.NORTH_AMERICA)).filter(Customer.REGISTERED.greaterOrEqual(startOfYear)).count();

Standard Stream API Generated Enum Constants

Only 1 value is loaded from DB

Full Type-Safety

Page 27: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Expressing Queries as Streams

customers.stream().filter(Customer.REGION.equal(Region.NORTH_AMERICA)).filter(Customer.REGISTERED.greaterOrEqual(startOfYear)).count();

Standard Stream API Generated Enum Constants

Only 1 value is loaded from DB

Full Type-Safety

SELECTCOUNT('id')FROM'customer' WHERE'customer'.'region'=‘NorthAmerica’ AND'customer'.'registered'>=‘2016-01-01’;

Page 28: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Querying the Database using Streams

SELECT * FROM 'customer'

REGION.equal(NORTH_AMERICA)

REGISTERED.greaterOrEqual(2016-01-01)

count()

Source

Filter

Filter

Term.

Pipeline

Page 29: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Querying the Database using Streams

SELECT * FROM 'customer' WHERE 'customer'.'region' = ‘North America’

REGION.equal(NORTH_AMERICA)

REGISTERED.greaterOrEqual(2016-01-01)

count()

Source

Filter

Filter

Term.

Pipeline

Page 30: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Querying the Database using Streams

SELECT * FROM 'customer' WHERE 'customer'.'region' = ‘North America’ AND 'customer'.'registered' >= ‘2016-01-01’;

REGISTERED.greaterOrEqual(2016-01-01)

count()

Source

Filter

Term.

Pipeline

Page 31: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Querying the Database using Streams

SELECT COUNT('id') FROM 'customer' WHERE 'customer'.'region' = ‘North America’ AND 'customer'.'registered' >= ‘2016-01-01’;

count()

Source

Term.

Pipeline

Page 32: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Querying the Database using Streams

SELECT COUNT('id') FROM 'customer' WHERE 'customer'.'region' = ‘North America’ AND 'customer'.'registered' >= ‘2016-01-01’;

SourcePipeline

Page 33: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Expressing Queries as Streams//GetsthesecondpageofcustomersinNorthAmerica//sortedbynameintheformofaJSONarray

Page 34: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Expressing Queries as Streams//GetsthesecondpageofcustomersinNorthAmerica//sortedbynameintheformofaJSONarray

customers.stream().filter(REGION.equal(Region.NORTH_AMERICA)).sorted(NAME.comparator()).skip(10).limit(10)//JVMfromhere….collect(toJson(encode.allOf(customers)))

[{”id”:11,”name”:…},{…},…]

Page 35: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Parallelism as Expected for a Stream//Supportsparallelismoncustomexecutors//withfullcontrolofthreadworkitemlayout

Page 36: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Parallelism as Expected for a Stream//Supportsparallelismoncustomexecutors//withfullcontrolofthreadworkitemlayout

customers.stream().parallel().filter(REGION.equal(Region.NORTH_AMERICA)).forEach(expensiveOperatation());

Page 37: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

QueryingOptional<Hare>oldHare=hares.stream().filter(Hare.AGE.greaterThan(5)).findAny();

Page 38: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

QueryingOptional<Hare>oldHare=hares.stream().filter(Hare.AGE.greaterThan(5)).findAny();

Predicate Builder

Page 39: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

QueryingOptional<Hare>oldHare=hares.stream().filter(Hare.AGE.greaterThan(5)).findAny();

Predicate Builder

SELECT id, name, color, age FROM hare WHERE (age > 5) LIMIT 1;

Page 40: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Entities are Linked//FindtheowneroftheorangecarrotOptional<Hare>hare=carrots.stream().filter(Carrot.NAME.equal("Orange")).map(hares.finderBy(Carrot.OWNER)).findAny();

//FindonecarrotownedbyHarry//CarrotisaforeignkeytableOptional<Carrot>carrot=hares.stream().filter(Hare.NAME.equal("Harry")).flatMap(carrots.finderBackwardsBy(Carrot.OWNER)).findAny();

Page 41: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Joins

Map<Hare,List<Carrot>>join=carrots.stream().collect(groupingBy(hares.finderBy(Carrot.OWNER)));

Page 42: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Joins

Map<Hare,List<Carrot>>join=carrots.stream().collect(groupingBy(hares.finderBy(Carrot.OWNER)));

Standard Java 8

Page 43: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Joins

Map<Hare,List<Carrot>>join=carrots.stream().collect(groupingBy(hares.finderBy(Carrot.OWNER)));

Standard Java 8

Page 44: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Imperative vs Declarative

Page 45: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Imperative vs Declarative

SQL describes what rather than how

Page 46: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Imperative vs Declarative

SQL describes what rather than how

database engine figures out the how

Page 47: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Imperative vs Declarative

SQL describes what rather than how

database engine figures out the how

Streams are also declarative - a result is described

Page 48: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Imperative vs Declarative

SQL describes what rather than how

database engine figures out the how

Streams are also declarative - a result is described

framework takes pipeline as input and determines the how

Page 49: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Typical ORM + Java Streams Application

Page 50: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Typical ORM + Java Streams Application

Explicit SQL + Java Stream is an imperative two step program:

Page 51: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Typical ORM + Java Streams Application

Explicit SQL + Java Stream is an imperative two step program:

1. Compute Result Set SELECTxFROMyWHEREz

Page 52: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Typical ORM + Java Streams Application

Explicit SQL + Java Stream is an imperative two step program:

1. Compute Result Set SELECTxFROMyWHEREz

2. Stream over Result Set rs.stream().filter…

Page 53: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Speedment - Breaking the Language Barrier

Page 54: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Speedment - Breaking the Language Barrier

Java Stream expressing both database and JVM operations ->

Page 55: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Speedment - Breaking the Language Barrier

Java Stream expressing both database and JVM operations ->

the program is declarative,

Page 56: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Speedment - Breaking the Language Barrier

Java Stream expressing both database and JVM operations ->

the program is declarative,

the runtime determines the DB-JVM work split.

Page 57: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Speedment - Fully Declarative DB Applications

Page 58: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Speedment - Fully Declarative DB Applications

Fully declarative ->

Page 59: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Speedment - Fully Declarative DB Applications

Fully declarative ->

Speedment Enterprise: add in-memory-acceleration

Page 60: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Speedment - Fully Declarative DB Applications

Fully declarative ->

Speedment Enterprise: add in-memory-acceleration

without changing anything in the stream application.

Page 61: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Jigsaw

Page 62: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Jigsaw

Page 63: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Jigsaw

• Modules - an abstraction on top of packages • Strong Encapsulation • Reliable Configuration

Page 64: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Jigsaw

• Modules - an abstraction on top of packages • Strong Encapsulation • Reliable Configuration

Page 65: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration
Page 66: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Split Packages

Reliable configuration - a package may only belong to one module

Page 67: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Split Packages

Reliable configuration - a package may only belong to one module

Page 68: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Split Packages

Reliable configuration - a package may only belong to one module

Page 69: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Split Packages

Reliable configuration - a package may only belong to one module

X

Page 70: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration
Page 71: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Automatic Modules

Page 72: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Automatic Modules

• Smooth transition to Java 9

Page 73: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Automatic Modules

• Smooth transition to Java 9• Move the Java 8 JAR from class path to module path

Page 74: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Automatic Modules

• Smooth transition to Java 9• Move the Java 8 JAR from class path to module path• The JAR automatically becomes a module

Page 75: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration
Page 76: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Automatic modules vs split packages

• Maven puts dependencies on the module path

Page 77: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Automatic modules vs split packages

• Maven puts dependencies on the module path • Java 8 to 9 portability -> automatic modules

Page 78: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Automatic modules vs split packages

• Maven puts dependencies on the module path • Java 8 to 9 portability -> automatic modules• Automatic modules give split packages

Page 79: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Automatic modules vs split packages

• Maven puts dependencies on the module path • Java 8 to 9 portability -> automatic modules• Automatic modules give split packages• But reliable configuration means no split packages

Page 80: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Automatic modules vs split packages

• Maven puts dependencies on the module path • Java 8 to 9 portability -> automatic modules• Automatic modules give split packages• But reliable configuration means no split packages

Page 81: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Some Other Jigsaw Controversies

Page 82: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Some Other Jigsaw Controversies

• Works for JDK != works for applications

- Restricts current application domain use cases

Page 83: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Some Other Jigsaw Controversies

• Works for JDK != works for applications

- Restricts current application domain use cases

• sun.misc.Unsafe- ”Should not be used” vs ”A key for Java real-world success”

Page 84: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Some Other Jigsaw Controversies

• Works for JDK != works for applications

- Restricts current application domain use cases

• sun.misc.Unsafe- ”Should not be used” vs ”A key for Java real-world success”

• Fundamentally different compared to e.g. OSGi- lazy loading, dynamic package adding, split packages

Page 85: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Jigsawing the Java 8 Application

Page 86: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Jigsawing the Java 8 Application

• Run Java 8 under Java 9 is super easy

Page 87: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Jigsawing the Java 8 Application

• Run Java 8 under Java 9 is super easy

java–cp<…>–jarapp.jar

Page 88: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Jigsawing the Java 8 Application

• Run Java 8 under Java 9 is super easy

java–cp<…>–jarapp.jar

• The challenge is to move from cp to mp

Page 89: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Inter module dependencies

Page 90: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Inter module dependencies

Dependencies explicitly given in module-info.java

Page 91: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Inter module dependencies

Dependencies explicitly given in module-info.java

module com.speedment.common { requires com.foo.bar; // a module we depend on exports com.speedment.common.invariant; // a package we expose to the user }

Page 92: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

A Straight-Forward Modularization Approach

class path module path

Page 93: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

A Straight-Forward Modularization Approach

1. All JARs on class path <alljars>

class path module path

Page 94: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

A Straight-Forward Modularization Approach

1. All JARs on class path <alljars>

2. App as a monolithic module <alldeps>myapp.jar

class path module path

Page 95: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

A Straight-Forward Modularization Approach

1. All JARs on class path <alljars>

2. App as a monolithic module <alldeps>myapp.jar

3. Declare dependencies

class path module path

Page 96: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

A Straight-Forward Modularization Approach

1. All JARs on class path <alljars>

2. App as a monolithic module <alldeps>myapp.jar

3. Declare dependencies 4. Move some JARs from cp to mp <deps>->

class path module path

Page 97: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

A Straight-Forward Modularization Approach

1. All JARs on class path <alljars>

2. App as a monolithic module <alldeps>myapp.jar

3. Declare dependencies 4. Move some JARs from cp to mp <deps>->

5. Modularize app

class path module path

Page 98: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

The Speedment Java 8 Modules

Page 99: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

The Speedment Java 8 Modules

Speedment pom.xml

Page 100: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

The Speedment Java 8 Modules

Speedment pom.xml

<modules> <module>common-parent</module> <module>runtime-parent</module> <module>generator-parent</module> <module>tool-parent</module> <module>build-parent</module> <module>plugin-parent</module> <module>connector-parent</module> <module>archetype-parent</module> <module>example-parent</module> </modules>

Page 101: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

The Modules of the Speedment common Module

Page 102: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

The Modules of the Speedment common Module

Speedment common/pom.xml

Page 103: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

The Modules of the Speedment common Module

Speedment common/pom.xml <modules> <module>invariant</module> <module>function</module> <module>json</module> <module>tuple</module> <module>logger</module> <module>codegen</module> <module>codegenxml</module> <module>injector</module> <module>rest</module> <module>lazy</module> <module>mapstream</module> <module>mutablestream</module> <module>singletonstream</module> <module>common-all</module> <module>annotation</module> <module>benchmark</module> <module>combinatorics</module> <module>collection</module> </modules>

Page 104: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Automatic Jigsawing Script Outline

Page 105: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Automatic Jigsawing Script Outline

• Create separate directories for the modules

Page 106: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Automatic Jigsawing Script Outline

• Create separate directories for the modules• Move source code packages to respective modules

Page 107: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Automatic Jigsawing Script Outline

• Create separate directories for the modules• Move source code packages to respective modules • Add empty module-info.java

Page 108: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Automatic Jigsawing Script Outline

• Create separate directories for the modules• Move source code packages to respective modules • Add empty module-info.java• Loop:

1. Compile

Page 109: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Automatic Jigsawing Script Outline

• Create separate directories for the modules• Move source code packages to respective modules • Add empty module-info.java• Loop:

1. Compile2. Parse and fix errors

Page 110: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Automatic Jigsawing Script Outline

• Create separate directories for the modules• Move source code packages to respective modules • Add empty module-info.java• Loop:

1. Compile2. Parse and fix errors3. git add4. git commit

Page 111: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Automatic Jigsawing - add requires

Page 112: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Automatic Jigsawing - add requires

Missing Speedment internal dependency

\[ERROR\].*\(package(.*)isdeclaredinmodule(.*),butmodulecom.speedment.(.*)\.(.*)doesnotreadit\)

Fix:

modulecom.speedment.X{+requirescom.speedment.Y;}

Page 113: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Automatic Jigsawing - add exports

Page 114: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Automatic Jigsawing - add exports

Missing Speedment internal visibility

\[ERROR\].*\(packagecom.speedment.(.*)\.(.*)isdeclaredinmodulecom.speedment.(.*)\.(.*),whichdoesnotexportit\)

Fix:

modulecom.speedment.Y{+exportscom.speedment.X;}

Page 115: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Automatic Jigsawing - patch (ab)use of JDK API

Page 116: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Automatic Jigsawing - patch (ab)use of JDK API

Speedment usage of non-public JDK API

\[ERROR\].*\(package(.*)isdeclaredinmodule(.*),whichdoesnotexportittomodulecom.speedment.(.*)\.(.*)\)

Temporary workaround: add exports in the pom file

<artifactId>maven-compiler-plugin</artifactId>+<configuration>+<compilerArgs>+<arg>—add-exports</arg><arg>java.base/sun.nio.ch=com.speedment.…+</compilerArgs>+</configuration>

Page 117: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Automatic Jigsawing - remove OSGi bundling

Page 118: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Automatic Jigsawing - remove OSGi bundling

Maven does not currently coexist well with OSGi bundling and Jigsaw

\[ERROR\].*Manifestcom\.speedment\.([^:]*)\:([^:]*)\:[^:]*\:.*\:Invalidclassfilemodule-info\.class\(java\.lang\.ArrayIndexOutOfBoundsException\:19\)

Temporary workaround: comment out the bundling

-<packaging>bundle</packaging>+<packaging>jar</packaging>…<plugins>+<!--<plugin><groupId>org.apache.felix</groupId>…

Page 119: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Speedment Open Source - the Easy Case

Page 120: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Speedment Open Source - the Easy Case

• No usage of sun.misc.Unsafe

Page 121: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Speedment Open Source - the Easy Case

• No usage of sun.misc.Unsafe

• No third party dependencies

Page 122: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Speedment Open Source - the Easy Case

• No usage of sun.misc.Unsafe

• No third party dependencies- JDK dependencies on module path - no automatic modules

Page 123: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Speedment Open Source - the Easy Case

• No usage of sun.misc.Unsafe

• No third party dependencies- JDK dependencies on module path - no automatic modules- Automatic script creates workarounds that will need revisiting

Page 124: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Speedment Open Source - the Easy Case

• No usage of sun.misc.Unsafe

• No third party dependencies- JDK dependencies on module path - no automatic modules- Automatic script creates workarounds that will need revisiting

• No reflection

Page 125: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

No Reflection in Speedment

Page 126: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

No Reflection in Speedment

• O/R mapping -> reflection

Page 127: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

No Reflection in Speedment

• O/R mapping -> reflection- instantiate user code

Page 128: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

No Reflection in Speedment

• O/R mapping -> reflection- instantiate user code

• Code Generation to the Rescue!

Page 129: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Speedment Enterprise - a Jigsaw Puzzle

Page 130: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Speedment Enterprise - a Jigsaw Puzzle

Uses sun.misc.Unsafe

Page 131: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Speedment Enterprise - a Jigsaw Puzzle

Uses sun.misc.Unsafe• DirectBuffer.cleaner()- for predictable cleanup

Page 132: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Speedment Enterprise - a Jigsaw Puzzle

Uses sun.misc.Unsafe• DirectBuffer.cleaner()- for predictable cleanup• DirectBuffer.address()- for efficient off-heap byte arrays

Page 133: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Speedment Enterprise - a Jigsaw Puzzle

Uses sun.misc.Unsafe• DirectBuffer.cleaner()- for predictable cleanup• DirectBuffer.address()- for efficient off-heap byte arrays

Third party dependencies

Page 134: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Speedment Enterprise - a Jigsaw Puzzle

Uses sun.misc.Unsafe• DirectBuffer.cleaner()- for predictable cleanup• DirectBuffer.address()- for efficient off-heap byte arrays

Third party dependencies• Depends on Third Party JARs

Page 135: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Speedment Enterprise - a Jigsaw Puzzle

Uses sun.misc.Unsafe• DirectBuffer.cleaner()- for predictable cleanup• DirectBuffer.address()- for efficient off-heap byte arrays

Third party dependencies• Depends on Third Party JARs • Automatic modules with split packages

Page 136: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Awaiting Community Progress

Page 137: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Awaiting Community Progress

• OSGi bundles

Page 138: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Awaiting Community Progress

• OSGi bundles

• Third Party Dependencies

Page 139: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Awaiting Community Progress

• OSGi bundles

• Third Party Dependencies - Split packages

Page 140: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Awaiting Community Progress

• OSGi bundles

• Third Party Dependencies - Split packages- Concealed package conflicts

Page 141: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Awaiting Community Progress

• OSGi bundles

• Third Party Dependencies - Split packages- Concealed package conflicts- Duplicate package names

Page 142: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Awaiting Community Progress

• OSGi bundles

• Third Party Dependencies - Split packages- Concealed package conflicts- Duplicate package names

• Spring Integration

Page 143: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Awaiting Community Progress

• OSGi bundles

• Third Party Dependencies - Split packages- Concealed package conflicts- Duplicate package names

• Spring Integration

• Unit test frameworks

Page 144: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Conclusions

Page 145: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Conclusions

Lean Principle – "Defer Commitment" or "Decide as late as possible”

Page 146: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Conclusions

Lean Principle – "Defer Commitment" or "Decide as late as possible”

Time well spent:• refine application modularity,

Page 147: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Conclusions

Lean Principle – "Defer Commitment" or "Decide as late as possible”

Time well spent:• refine application modularity,• rework references to non-open parts of the JDK and

Page 148: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Conclusions

Lean Principle – "Defer Commitment" or "Decide as late as possible”

Time well spent:• refine application modularity,• rework references to non-open parts of the JDK and • revisit design decisions regarding Unsafe.

Page 149: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Conclusions

Lean Principle – "Defer Commitment" or "Decide as late as possible”

Time well spent:• refine application modularity,• rework references to non-open parts of the JDK and • revisit design decisions regarding Unsafe.

Postpone Decisions (S.E.P.): • Working around third party dependencies

Page 150: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Conclusions

Lean Principle – "Defer Commitment" or "Decide as late as possible”

Time well spent:• refine application modularity,• rework references to non-open parts of the JDK and • revisit design decisions regarding Unsafe.

Postpone Decisions (S.E.P.): • Working around third party dependencies• Spring Integration

Page 151: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Conclusions

Lean Principle – "Defer Commitment" or "Decide as late as possible”

Time well spent:• refine application modularity,• rework references to non-open parts of the JDK and • revisit design decisions regarding Unsafe.

Postpone Decisions (S.E.P.): • Working around third party dependencies• Spring Integration• OSGi bundling

Page 152: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Try Speedmentgithub.com/speedment/speedmentwww.speedment.com/initializer/

Page 153: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Q&A

@speedment

@dan_lawesson

Page 154: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Extra Slides for Q&A

Page 155: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Many-to-Many

Map<Human,List<Hare>>humanFriends=friends.stream().collect(groupingBy(humans.finderBy(Friend.HUMAN),//Classifiermapping(hares.finderBy(Friend.HARE),//FriendtoHarefindertoList()//Downstreamaggregationw.Listcollector)));

Page 156: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Many-to-Many

Map<Human,List<Hare>>humanFriends=friends.stream().collect(groupingBy(humans.finderBy(Friend.HUMAN),//Classifiermapping(hares.finderBy(Friend.HARE),//FriendtoHarefindertoList()//Downstreamaggregationw.Listcollector)));

Standard Java 8

Page 157: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Updatehares.stream().filter(Hare.ID.equal(42))//AllHareswithID=42(justone).map(Hare.AGE.setTo(10))//Appliesasetter.forEach(hares.updater());//Appliestheupdaterfunction

Page 158: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Updatehares.stream().filter(Hare.ID.equal(42))//AllHareswithID=42(justone).map(Hare.AGE.setTo(10))//Appliesasetter.forEach(hares.updater());//Appliestheupdaterfunction

Standard Java 8

Page 159: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Database Connectors

Page 160: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Beyond Open-Source

• Speedment Enterprise • Run your database queries orders of magnitude faster!

• 10x, 100x, 1 000x, 10 000x, …

• Use the same Stream API

Page 161: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

How is This Possible?

• No changes to user-written code • Alternative stream source • Data is stored in-memory • Generates optimized serializers

for off-heap storage

Page 162: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

In-JVM-Memory, JMH Benchmarks(*)BenchmarkModeCntScoreErrorUnits SpeedmentBenchmark.findStartsWithavgt200≈10⁻⁵s/op SpeedmentBenchmark.findStartsWithSqlavgt200≈10⁻⁴s/op

SpeedmentBenchmark.joinavgt2000.476±0.005s/op SpeedmentBenchmark.joinSqlavgt2005.174±0.010s/op

SpeedmentBenchmark.sortavgt200≈10⁻⁶s/op SpeedmentBenchmark.sortSqlavgt200≈10⁻⁴s/op

SpeedmentBenchmark.scrollSortedavgt200≈10⁻⁵s/op SpeedmentBenchmark.scrollSortedSqlavgt20024.661±0.670s/op

SpeedmentBenchmark.countavgt180≈10⁻⁸s/op SpeedmentBenchmark.countSqlavgt2005.143±0.012s/op

(*) Preliminary results, Mac Book Pro, 2.2 GHz i7, 16GB, MySQL 5.7.16 standard with indexes on all relevant columns.

Page 163: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

In-JVM-Memory, JMH Benchmarks(*)BenchmarkModeCntScoreErrorUnits SpeedmentBenchmark.findStartsWithavgt200≈10⁻⁵s/op SpeedmentBenchmark.findStartsWithSqlavgt200≈10⁻⁴s/op

SpeedmentBenchmark.joinavgt2000.476±0.005s/op SpeedmentBenchmark.joinSqlavgt2005.174±0.010s/op

SpeedmentBenchmark.sortavgt200≈10⁻⁶s/op SpeedmentBenchmark.sortSqlavgt200≈10⁻⁴s/op

SpeedmentBenchmark.scrollSortedavgt200≈10⁻⁵s/op SpeedmentBenchmark.scrollSortedSqlavgt20024.661±0.670s/op

SpeedmentBenchmark.countavgt180≈10⁻⁸s/op SpeedmentBenchmark.countSqlavgt2005.143±0.012s/op

(*) Preliminary results, Mac Book Pro, 2.2 GHz i7, 16GB, MySQL 5.7.16 standard with indexes on all relevant columns.

10x

Page 164: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

In-JVM-Memory, JMH Benchmarks(*)BenchmarkModeCntScoreErrorUnits SpeedmentBenchmark.findStartsWithavgt200≈10⁻⁵s/op SpeedmentBenchmark.findStartsWithSqlavgt200≈10⁻⁴s/op

SpeedmentBenchmark.joinavgt2000.476±0.005s/op SpeedmentBenchmark.joinSqlavgt2005.174±0.010s/op

SpeedmentBenchmark.sortavgt200≈10⁻⁶s/op SpeedmentBenchmark.sortSqlavgt200≈10⁻⁴s/op

SpeedmentBenchmark.scrollSortedavgt200≈10⁻⁵s/op SpeedmentBenchmark.scrollSortedSqlavgt20024.661±0.670s/op

SpeedmentBenchmark.countavgt180≈10⁻⁸s/op SpeedmentBenchmark.countSqlavgt2005.143±0.012s/op

(*) Preliminary results, Mac Book Pro, 2.2 GHz i7, 16GB, MySQL 5.7.16 standard with indexes on all relevant columns.

10x

>10x

Page 165: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

In-JVM-Memory, JMH Benchmarks(*)BenchmarkModeCntScoreErrorUnits SpeedmentBenchmark.findStartsWithavgt200≈10⁻⁵s/op SpeedmentBenchmark.findStartsWithSqlavgt200≈10⁻⁴s/op

SpeedmentBenchmark.joinavgt2000.476±0.005s/op SpeedmentBenchmark.joinSqlavgt2005.174±0.010s/op

SpeedmentBenchmark.sortavgt200≈10⁻⁶s/op SpeedmentBenchmark.sortSqlavgt200≈10⁻⁴s/op

SpeedmentBenchmark.scrollSortedavgt200≈10⁻⁵s/op SpeedmentBenchmark.scrollSortedSqlavgt20024.661±0.670s/op

SpeedmentBenchmark.countavgt180≈10⁻⁸s/op SpeedmentBenchmark.countSqlavgt2005.143±0.012s/op

(*) Preliminary results, Mac Book Pro, 2.2 GHz i7, 16GB, MySQL 5.7.16 standard with indexes on all relevant columns.

10x

>10x

100x

Page 166: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

In-JVM-Memory, JMH Benchmarks(*)BenchmarkModeCntScoreErrorUnits SpeedmentBenchmark.findStartsWithavgt200≈10⁻⁵s/op SpeedmentBenchmark.findStartsWithSqlavgt200≈10⁻⁴s/op

SpeedmentBenchmark.joinavgt2000.476±0.005s/op SpeedmentBenchmark.joinSqlavgt2005.174±0.010s/op

SpeedmentBenchmark.sortavgt200≈10⁻⁶s/op SpeedmentBenchmark.sortSqlavgt200≈10⁻⁴s/op

SpeedmentBenchmark.scrollSortedavgt200≈10⁻⁵s/op SpeedmentBenchmark.scrollSortedSqlavgt20024.661±0.670s/op

SpeedmentBenchmark.countavgt180≈10⁻⁸s/op SpeedmentBenchmark.countSqlavgt2005.143±0.012s/op

(*) Preliminary results, Mac Book Pro, 2.2 GHz i7, 16GB, MySQL 5.7.16 standard with indexes on all relevant columns.

10x

>10x

100x

2,000,000x

Page 167: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

In-JVM-Memory, JMH Benchmarks(*)BenchmarkModeCntScoreErrorUnits SpeedmentBenchmark.findStartsWithavgt200≈10⁻⁵s/op SpeedmentBenchmark.findStartsWithSqlavgt200≈10⁻⁴s/op

SpeedmentBenchmark.joinavgt2000.476±0.005s/op SpeedmentBenchmark.joinSqlavgt2005.174±0.010s/op

SpeedmentBenchmark.sortavgt200≈10⁻⁶s/op SpeedmentBenchmark.sortSqlavgt200≈10⁻⁴s/op

SpeedmentBenchmark.scrollSortedavgt200≈10⁻⁵s/op SpeedmentBenchmark.scrollSortedSqlavgt20024.661±0.670s/op

SpeedmentBenchmark.countavgt180≈10⁻⁸s/op SpeedmentBenchmark.countSqlavgt2005.143±0.012s/op

(*) Preliminary results, Mac Book Pro, 2.2 GHz i7, 16GB, MySQL 5.7.16 standard with indexes on all relevant columns.

10x

>10x

100x

2,000,000x

500,000,000x

Page 168: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Gitkraken view of Jigsawing Script Commits

Page 169: Migrating Speedment to Java 9 · 2017. 8. 14. · Migrating Speedment to Java 9 ... Speedment - Fully Declarative DB Applications Fully declarative -> Speedment Enterprise: add in-memory-acceleration

Gitkraken view of Jigsawing Script Commits