squeak dbx

38
Smalltalk Smalltalk Programmer Programmer Ing. Mariano Martínez Peck Ing. Mariano Martínez Peck [email protected] [email protected]

Upload: esug

Post on 20-May-2015

3.308 views

Category:

Technology


0 download

DESCRIPTION

Squeak DBX

TRANSCRIPT

Page 1: Squeak DBX

SmalltalkSmalltalkProgrammerProgrammer

Ing. Mariano Martínez Peck Ing. Mariano Martínez Peck [email protected]@gmail.com

Page 2: Squeak DBX

SqueakDBXSqueakDBX

The complete and The complete and open-source open-source solutionsolution to to

relational database relational database accessaccessMARKETING

MARKETING

Page 3: Squeak DBX

SqueakDBX teamSqueakDBX team Hernán Hernán CassinelliCassinelliGermán Germán

PalaciosPalaciosEsteban LorenzanoEsteban LorenzanoMariano Mariano M. PeckM. Peck

Page 4: Squeak DBX

F.A.QF.A.Q

Who are we?Who are we?

How did it begin?How did it begin?

What is actually SqueakDBX?What is actually SqueakDBX?

Page 5: Squeak DBX

RDBMS VS. OODBRDBMS VS. OODB

Please, don't fight ;)Please, don't fight ;)

Page 6: Squeak DBX

Anyway, we rather program in Anyway, we rather program in objects and use RDBMS than objects and use RDBMS than

using Java with RDBMSusing Java with RDBMS;);)

Page 7: Squeak DBX

SurveySurvey 1/21/2

How many times were you forced to use a How many times were you forced to use a particular database?particular database?

Page 8: Squeak DBX

SurveySurvey 2/22/2Which databases?Which databases?

Page 9: Squeak DBX

Squeak's current situationSqueak's current situation

Only MySQL and PostgreSQL native Only MySQL and PostgreSQL native drivers.drivers.

Limited ODBC driverLimited ODBC driver

Glorp in Squeak Glorp in Squeak

only works withonly works with

PostgreSQLPostgreSQL

Page 10: Squeak DBX

We are in trouble...We are in trouble...

Direct SQL queries: 20%Direct SQL queries: 20%

Using GLORP: 8.52%Using GLORP: 8.52%

Page 11: Squeak DBX

Our goalOur goal

Direct SQL queries: 100%Direct SQL queries: 100%

Using GLORP: 100%Using GLORP: 100%

Page 12: Squeak DBX

Our purposeOur purpose

Page 13: Squeak DBX

Oracle uses oci.h and libclntsh.Oracle uses oci.h and libclntsh.It has N functions. It has N functions. Examples: OCIHandleAlloc(), OCIServerAttach(), Examples: OCIHandleAlloc(), OCIServerAttach(), OCISessionEnd(), etc.OCISessionEnd(), etc.

MySQL uses mysql.h and libmysqlclient_r.MySQL uses mysql.h and libmysqlclient_r.It has M functions. It has M functions. Examples: mysql_real_connect(), mysql_server_end(),Examples: mysql_real_connect(), mysql_server_end(),mysql_real_query(), etc.mysql_real_query(), etc.

Oracle Oracle clientclient

librarylibrary

MySQL MySQL clientclient

librarylibrary

PosgreSQL PosgreSQL clientclient

librarylibrary

Sqlite Sqlite clientclient

librarylibrary

SQLServer SQLServer clientclient

librarylibrary

OpenDBX architecture OpenDBX architecture

Common APICommon APIfor all backends!!!for all backends!!!

Oracle Oracle clientclient

librarylibrary

Oracle Oracle clientclient

librarylibrary

MySQL MySQL clientclient

librarylibrary

MySQL MySQL clientclient

librarylibrary

PosgreSQL PosgreSQL clientclient

librarylibrary

PosgreSQL PosgreSQL clientclient

librarylibrary

Sqlite Sqlite clientclient

librarylibrary

Sqlite Sqlite clientclient

librarylibrary

SQLServer SQLServer clientclient

librarylibrary

SQLServer SQLServer clientclient

librarylibrary

Page 14: Squeak DBX

Why OpenDBX?Why OpenDBX?

It is fast It is fast

Simple to useSimple to use

FlexibleFlexible

Cross platform Cross platform

AsynchronoAsynchronous queriesus queries

Specific RDBMS featuresSpecific RDBMS features

Good documentationGood documentation

Page 15: Squeak DBX

PC2PC2PC1PC1

DatabaseDatabaseSqueak imageSqueak imageSqueak imageSqueak imageSqueak imageSqueak image

OpenDBXOpenDBXOpenDBXOpenDBX

DatabaseDatabaseClient LibraryClient Library

DatabaseDatabaseClient LibraryClient Library

Deployment and infrastructureDeployment and infrastructure

Page 16: Squeak DBX

||

#include <stdio.h>#include <stdio.h>static int mysql_odbx_get_option( odbx_t*)static int mysql_odbx_get_option( odbx_t*)

switch( option )switch( option )..........

#include <stdio.h>#include <stdio.h>static int mysql_odbx_get_option( odbx_t*)static int mysql_odbx_get_option( odbx_t*)

switch( option )switch( option )..........

Squeak imageSqueak image

OpenDBXOpenDBX

Smalltalk and CSmalltalk and C

Page 17: Squeak DBX

Smalltalk-C ConnectorSmalltalk-C Connector

FFI (Foreign Function Interface)FFI (Foreign Function Interface)

Main problem: Locks the entire VMMain problem: Locks the entire VM

Page 18: Squeak DBX

Squeak ODBC driver queriesSqueak ODBC driver queries

VM lockedVM lockedtimetime

Page 19: Squeak DBX

OpenDBX ConnectorOpenDBX Connector

FFI (Foreign Function Interface)FFI (Foreign Function Interface)

Main problem: Locks the entire VMMain problem: Locks the entire VM

Our solution: Our solution: ✔ Asynchronous queries✔ “Mini” VM locks✔ Retry schema✔ DBXQuerySettings>>timeout:

Page 20: Squeak DBX

SqueakDBX queriesSqueakDBX queries

VM lockedVM lockedtimetime

Page 21: Squeak DBX

Database access in SmalltalkDatabase access in Smalltalk

SqueakDBXSqueakDBX✔ One for all databasesOne for all databases

✔ Less time and effortLess time and effort

✔ Good performaceGood performace

✔ OSS and proprietaryOSS and proprietary

✗ Difficult to debugDifficult to debug

✗ Platform dependentPlatform dependent

✗ FFI locks the VMFFI locks the VM

Smalltalk driverSmalltalk driver✗ One for each databaseOne for each database

✗ More time and effortMore time and effort

✗ Performance issues?Performance issues?

✗ Only OSSOnly OSS

✔ Easier to debugEasier to debug

✔ Platform independentPlatform independent

✔ Non-lockingNon-locking

Page 22: Squeak DBX

SqueakDBX designSqueakDBX design

SqueakDBX Structure (API)SqueakDBX Structure (API)SqueakDBX Structure (API)SqueakDBX Structure (API)

SqueakDBX PlatformSqueakDBX PlatformSqueakDBX PlatformSqueakDBX Platform

OpenDBX ConnectorOpenDBX ConnectorOpenDBX ConnectorOpenDBX Connector

FFIFFIFFIFFI SqueakDBXPluginSqueakDBXPluginSqueakDBXPluginSqueakDBXPlugin

OpenDBXOpenDBX

{{DBXConnectionDBXConnectionDBXConnectionSettingsDBXConnectionSettingsDBXResultSetDBXResultSetDBXResultDBXResultDBXRowDBXRow......{{DBXPlatformDBXPlatformDBXSpecialOptionsDBXSpecialOptionsDBXErrorSeverityDBXErrorSeverityDBXTimeSpecDBXTimeSpec......

Page 23: Squeak DBX

ShowtimeShowtime

Page 24: Squeak DBX

Who can use SqueakDBX?Who can use SqueakDBX?

An applicationAn application

GlorpGlorp

Magritte-RDBMagritte-RDB

SqueakSaveSqueakSave

MoeMoe

Page 25: Squeak DBX

Current backends and OSCurrent backends and OS

Page 26: Squeak DBX

Benchmark for PostgreSQLBenchmark for PostgreSQL

InsertConverted Insert

Select100Select1000

0

200

400

600

800

1000

1200

1400

1600

1800

SqueakDBXNative

tests

ms

Page 27: Squeak DBX

Benchmark for MySQLBenchmark for MySQL

InsertConverted Insert

Select100Select1000

0

100

200

300

400

500

600

700

SqueakDBXNative

tests

ms

Page 28: Squeak DBX

FeaturesFeatures

Mini VM locksMini VM locks

SqueakDBXPluginSqueakDBXPlugin

Automatic fields conversionAutomatic fields conversion

Configurable logging/traceConfigurable logging/trace

Special RDBMS featuresSpecial RDBMS features

MultistatementsMultistatements

Automatic release of resourcesAutomatic release of resources

Page 29: Squeak DBX

What do we have?What do we have?

Enough unit testsEnough unit tests

Acceptable test coverageAcceptable test coverage

SmallLint runsSmallLint runs

Good enough designGood enough design

GLORP integrationGLORP integration

Page 30: Squeak DBX

DocumentationDocumentation

WebsiteWebsite

Documented codeDocumented code

Mailing listMailing list

BenchmarksBenchmarks

Page 31: Squeak DBX

What will comeWhat will come

Complete Glorp refactor and integrationComplete Glorp refactor and integration

More backends in more OSMore backends in more OS

Large objects supportLarge objects support

Better SPs and functions supportBetter SPs and functions support

Continue with SqueakDBXPluginContinue with SqueakDBXPlugin

Try Alien FFITry Alien FFI

Port to Smalltalk/X ?Port to Smalltalk/X ?

Page 32: Squeak DBX

Glorp progress Glorp progress

Port from Squeak to PharoPort from Squeak to Pharo

First refactor to SqueakDatabaseAccesorFirst refactor to SqueakDatabaseAccesor

Driver for native driverDriver for native driver

Driver for SqueakDBX (PostgreSQL)Driver for SqueakDBX (PostgreSQL)

Page 33: Squeak DBX

Glorp before SqueakDBXGlorp before SqueakDBX

Page 34: Squeak DBX

Glorp after SqueakDBXGlorp after SqueakDBX

Page 35: Squeak DBX

Special thanks to...Special thanks to...

Norbert SendetzkyNorbert Sendetzky

GLORPGLORP Alan KnightAlan Knight

Stéphane DucasseStéphane Ducasse

Page 36: Squeak DBX

aConnection execute: 'select * from questionsaConnection execute: 'select * from questionswhere has_answer = true'where has_answer = true'

Ing. Mariano Martínez Peck Ing. Mariano Martínez Peck [email protected]@gmail.com

Page 37: Squeak DBX

Thank you Thank you very muchvery much

Page 38: Squeak DBX