SlideShare a Scribd company logo
1 of 38
Download to read offline
AVRO
LA PUISSANCE DU BINAIRE, LA SOUPLESSE
DU JSON
MYSELF
Alexandre Victoor
Architecte à la SGCIB
alexvictoor@gmail.com
https://github.com/alexvictoor
@alex_victoor
Install-Package Microsoft.Hadoop.Avro
UN FICHIER AVRO
           
{
    "type":"record",
    "namespace": "DevoxxFR.Example",
    "name":"Trade",
    "fields":
        [
            { "name":"ClientId", "type":"int" },
            { "name":"Nominal", "type":"double" },
            { "name":"Date", "type":"string" }
        ]
}
         
           
{
    "type":"record",
    "namespace": "DevoxxFR.Example",
    "name":"Trade",
    "fields":
        [
            { "name":"ClientId", "type":"int" },
            { "name":"Nominal", "type":"double" },
            { "name":"Date", "type":"string" },                              
            {
                "name":"product",    
                "type":
                    ["null", {
                        "type":"record",
                        "namespace":"DevoxxFR.Example",
                        "name":"Product",
                        "default":null,
         
           
java ­jar avro­tools.jar compile schema trade.avro
         
AVEC UN SEUL OBJECT
           
DatumWriter<Trade> writer = new SpecificDatumWriter<Trade>();
         
           
encoder = EncoderFactory.get().binaryEncoder(outputStream, null);
         
           
writer.write(trade, encoder);
         
PUIS POUR LIRE
           
DatumReader<Trade> reader = new SpecificDatumReader<Trade>();
         
           
decoder = DecoderFactory.get().binaryDecoder(inputStream, null);
         
           
trade = reader.read(null, decoder);
         
SANS GÉNÉRATION
           
GenericRecord record = new GenericData.Record(SCHEMA);
record.put("ProductId", 123);
record.put("Nominal", 42000);
         
           
DatumWriter<GenericRecord> datumWriter = new GenericDatumWriter<>(SCHEMA
         
           
DatumReader<GenericRecord> datumReader = new GenericDatumReader<>(SCHEMA
         
ECRIRE EN MASSE
ECRIRE EN MASSE
           
File avroDataFile; // on peut aussi utiliser un OutputStream
  
         
ECRIRE EN MASSE
           
File avroDataFile; // on peut aussi utiliser un OutputStream
DatumWriter<GenericRecord> datumWriter = new GenericDatumWriter<>();
 
         
ECRIRE EN MASSE
           
File avroDataFile; // on peut aussi utiliser un OutputStream
DatumWriter<GenericRecord> datumWriter = new GenericDatumWriter<>();
DataFileWriter<GenericRecord> dataFileWriter 
     = new DataFileWriter<>(datumWriter);
 
         
ECRIRE EN MASSE
           
File avroDataFile; // on peut aussi utiliser un OutputStream
DatumWriter<GenericRecord> datumWriter = new GenericDatumWriter<>();
DataFileWriter<GenericRecord> dataFileWriter 
     = new DataFileWriter<>(datumWriter);
dataFileWriter.setCodec(CodecFactory.snappyCodec());
 
         
ECRIRE EN MASSE
           
File avroDataFile; // on peut aussi utiliser un OutputStream
DatumWriter<GenericRecord> datumWriter = new GenericDatumWriter<>();
DataFileWriter<GenericRecord> dataFileWriter 
     = new DataFileWriter<>(datumWriter);
dataFileWriter.setCodec(CodecFactory.snappyCodec());
dataFileWriter.create(TRADE_SCHEMA, avroDataFile); 
 
         
ECRIRE EN MASSE
           
File avroDataFile; // on peut aussi utiliser un OutputStream
DatumWriter<GenericRecord> datumWriter = new GenericDatumWriter<>();
DataFileWriter<GenericRecord> dataFileWriter 
     = new DataFileWriter<>(datumWriter);
dataFileWriter.setCodec(CodecFactory.snappyCodec());
dataFileWriter.create(TRADE_SCHEMA, avroDataFile);
for (GenericRecord record : records) {
  dataFileWriter.append(record);
}
         
ET POUR LIRE ?
ET POUR LIRE ?
           
File avroDataFile; // on peut aussi utiliser un InputStream
 
         
ET POUR LIRE ?
           
File avroDataFile; // on peut aussi utiliser un InputStream
DatumReader<GenericRecord> datumReader = new GenericDatumReader<>();
 
         
ET POUR LIRE ?
           
File avroDataFile; // on peut aussi utiliser un InputStream
DatumReader<GenericRecord> datumReader = new GenericDatumReader<>();
DataFileReader<GenericRecord> dataFileReader 
    = new DataFileReader(avroDataFile, datumReader);
 
         
ET POUR LIRE ?
           
File avroDataFile; // on peut aussi utiliser un InputStream
DatumReader<GenericRecord> datumReader = new GenericDatumReader<>();
DataFileReader<GenericRecord> dataFileReader 
    = new DataFileReader(avroDataFile, datumReader);
for (GenericRecord record : dataFileReader) {
  // traitement sur chaque record
}
         
C'EST BIEN MAIS...
           
{
    "type":"record",
    "namespace": "DevoxxFR.Example",
    "name":"Trade",
    "fields":
        [
            { "name":"ClientId", "type":"int" },
            { "name":"Nominal", "type":"double" },
            { "name":"Date", "type":"string" },                              
            {
                "name":"product",    
                "type":
                    ["null", {
                        "type":"record",
                        "namespace": "DevoxxFR.Example",
                        "name":"Product",
            "default":null,
         
LA KILLER FEATURE
           
// la résolution de schema
new GenericDatumReader(writerSchema, readerSchema)
Writer Schema
Le schéma qui a été utilisé pour sérialiser
LA KILLER FEATURE
           
// la résolution de schema
new GenericDatumReader(writerSchema, readerSchema)
Reader Schema
Les données dont vous avez besoin
ENTRE 2 SCHEMAS, ON PEUT
- ajouter un champ
- supprimer un champ
- renommer un champ (avec un alias)
On ne peut pas changer le type d'un champ
COMPATIBLES ?
 
 
SchemaCompatibility
  .checkReaderWriterCompatibility(readerSchema, writerSchema)
D'AUTRES USAGES
- Event sourcing
- Echanges de messages entre applications
EVENT SOURCING
EVENT SOURCING
DEMO
TRADE
productId
quantity
nominal
date
TRADE
productId
quantity
nominal
date
tradingPlace
RESSOURCES
Ces slides :
Une variante "alt.net" de cette prez :
La spec avro :
Le tuto MS :
Le SDK MS Hadoop :
https://github.com/alexvictoor/AvroDevoxxFr
https://github.com/alexvictoor/AvroAltNet
http://avro.apache.org/docs/1.7.7/spec.html
http://bit.ly/1uYRX3I
http://hadoopsdk.codeplex.com/SourceControl/latest

More Related Content

What's hot

MongoDB Advanced Topics
MongoDB Advanced TopicsMongoDB Advanced Topics
MongoDB Advanced TopicsCésar Rodas
 
Beyond javascript using the features of tomorrow
Beyond javascript   using the features of tomorrowBeyond javascript   using the features of tomorrow
Beyond javascript using the features of tomorrowAlexander Varwijk
 
Big Data Everywhere Chicago: Unleash the Power of HBase Shell (Conversant)
Big Data Everywhere Chicago: Unleash the Power of HBase Shell (Conversant) Big Data Everywhere Chicago: Unleash the Power of HBase Shell (Conversant)
Big Data Everywhere Chicago: Unleash the Power of HBase Shell (Conversant) BigDataEverywhere
 
From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)Night Sailer
 
MongoDB: Easy Java Persistence with Morphia
MongoDB: Easy Java Persistence with MorphiaMongoDB: Easy Java Persistence with Morphia
MongoDB: Easy Java Persistence with MorphiaScott Hernandez
 
MongoDB Europe 2016 - ETL for Pros – Getting Data Into MongoDB The Right Way
MongoDB Europe 2016 - ETL for Pros – Getting Data Into MongoDB The Right WayMongoDB Europe 2016 - ETL for Pros – Getting Data Into MongoDB The Right Way
MongoDB Europe 2016 - ETL for Pros – Getting Data Into MongoDB The Right WayMongoDB
 
Hands on Hadoop and pig
Hands on Hadoop and pigHands on Hadoop and pig
Hands on Hadoop and pigSudar Muthu
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on AndroidSven Haiges
 
Functional Algebra: Monoids Applied
Functional Algebra: Monoids AppliedFunctional Algebra: Monoids Applied
Functional Algebra: Monoids AppliedSusan Potter
 
Quick beginner to Lower-Advanced guide/tutorial in PHP
Quick beginner to Lower-Advanced guide/tutorial in PHPQuick beginner to Lower-Advanced guide/tutorial in PHP
Quick beginner to Lower-Advanced guide/tutorial in PHPSanju Sony Kurian
 
MongoDB Europe 2016 - Advanced MongoDB Aggregation Pipelines
MongoDB Europe 2016 - Advanced MongoDB Aggregation PipelinesMongoDB Europe 2016 - Advanced MongoDB Aggregation Pipelines
MongoDB Europe 2016 - Advanced MongoDB Aggregation PipelinesMongoDB
 
Manifests of Future Past
Manifests of Future PastManifests of Future Past
Manifests of Future PastPuppet
 
Hands On Spring Data
Hands On Spring DataHands On Spring Data
Hands On Spring DataEric Bottard
 
MongoDB + Java - Everything you need to know
MongoDB + Java - Everything you need to know MongoDB + Java - Everything you need to know
MongoDB + Java - Everything you need to know Norberto Leite
 

What's hot (20)

MongoDB Advanced Topics
MongoDB Advanced TopicsMongoDB Advanced Topics
MongoDB Advanced Topics
 
Beyond javascript using the features of tomorrow
Beyond javascript   using the features of tomorrowBeyond javascript   using the features of tomorrow
Beyond javascript using the features of tomorrow
 
Solr @ Etsy - Apache Lucene Eurocon
Solr @ Etsy - Apache Lucene EuroconSolr @ Etsy - Apache Lucene Eurocon
Solr @ Etsy - Apache Lucene Eurocon
 
Big Data Everywhere Chicago: Unleash the Power of HBase Shell (Conversant)
Big Data Everywhere Chicago: Unleash the Power of HBase Shell (Conversant) Big Data Everywhere Chicago: Unleash the Power of HBase Shell (Conversant)
Big Data Everywhere Chicago: Unleash the Power of HBase Shell (Conversant)
 
Elastic search 검색
Elastic search 검색Elastic search 검색
Elastic search 검색
 
Indexing
IndexingIndexing
Indexing
 
Living with garbage
Living with garbageLiving with garbage
Living with garbage
 
From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)
 
MongoDB: Easy Java Persistence with Morphia
MongoDB: Easy Java Persistence with MorphiaMongoDB: Easy Java Persistence with Morphia
MongoDB: Easy Java Persistence with Morphia
 
08 php-files
08 php-files08 php-files
08 php-files
 
Spl Not A Bridge Too Far phpNW09
Spl Not A Bridge Too Far phpNW09Spl Not A Bridge Too Far phpNW09
Spl Not A Bridge Too Far phpNW09
 
MongoDB Europe 2016 - ETL for Pros – Getting Data Into MongoDB The Right Way
MongoDB Europe 2016 - ETL for Pros – Getting Data Into MongoDB The Right WayMongoDB Europe 2016 - ETL for Pros – Getting Data Into MongoDB The Right Way
MongoDB Europe 2016 - ETL for Pros – Getting Data Into MongoDB The Right Way
 
Hands on Hadoop and pig
Hands on Hadoop and pigHands on Hadoop and pig
Hands on Hadoop and pig
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on Android
 
Functional Algebra: Monoids Applied
Functional Algebra: Monoids AppliedFunctional Algebra: Monoids Applied
Functional Algebra: Monoids Applied
 
Quick beginner to Lower-Advanced guide/tutorial in PHP
Quick beginner to Lower-Advanced guide/tutorial in PHPQuick beginner to Lower-Advanced guide/tutorial in PHP
Quick beginner to Lower-Advanced guide/tutorial in PHP
 
MongoDB Europe 2016 - Advanced MongoDB Aggregation Pipelines
MongoDB Europe 2016 - Advanced MongoDB Aggregation PipelinesMongoDB Europe 2016 - Advanced MongoDB Aggregation Pipelines
MongoDB Europe 2016 - Advanced MongoDB Aggregation Pipelines
 
Manifests of Future Past
Manifests of Future PastManifests of Future Past
Manifests of Future Past
 
Hands On Spring Data
Hands On Spring DataHands On Spring Data
Hands On Spring Data
 
MongoDB + Java - Everything you need to know
MongoDB + Java - Everything you need to know MongoDB + Java - Everything you need to know
MongoDB + Java - Everything you need to know
 

Viewers also liked

Avro - More Than Just a Serialization Framework - CHUG - 20120416
Avro - More Than Just a Serialization Framework - CHUG - 20120416Avro - More Than Just a Serialization Framework - CHUG - 20120416
Avro - More Than Just a Serialization Framework - CHUG - 20120416Chicago Hadoop Users Group
 
Thrift vs Protocol Buffers vs Avro - Biased Comparison
Thrift vs Protocol Buffers vs Avro - Biased ComparisonThrift vs Protocol Buffers vs Avro - Biased Comparison
Thrift vs Protocol Buffers vs Avro - Biased ComparisonIgor Anishchenko
 
Data Serialization Using Google Protocol Buffers
Data Serialization Using Google Protocol BuffersData Serialization Using Google Protocol Buffers
Data Serialization Using Google Protocol BuffersWilliam Kibira
 
Serialization and performance by Sergey Morenets
Serialization and performance by Sergey MorenetsSerialization and performance by Sergey Morenets
Serialization and performance by Sergey MorenetsAlex Tumanoff
 
Apache Hadoop and HBase
Apache Hadoop and HBaseApache Hadoop and HBase
Apache Hadoop and HBaseCloudera, Inc.
 
Thomas Lamirault_Mohamed Amine Abdessemed -A brief history of time with Apac...
Thomas Lamirault_Mohamed Amine Abdessemed  -A brief history of time with Apac...Thomas Lamirault_Mohamed Amine Abdessemed  -A brief history of time with Apac...
Thomas Lamirault_Mohamed Amine Abdessemed -A brief history of time with Apac...Flink Forward
 
AVR_Course_Day4 introduction to microcontroller
AVR_Course_Day4 introduction to microcontrollerAVR_Course_Day4 introduction to microcontroller
AVR_Course_Day4 introduction to microcontrollerMohamed Ali
 
Cassandra Explained
Cassandra ExplainedCassandra Explained
Cassandra ExplainedEric Evans
 
Netty from the trenches
Netty from the trenchesNetty from the trenches
Netty from the trenchesJordi Gerona
 
Apache Kafka, Un système distribué de messagerie hautement performant
Apache Kafka, Un système distribué de messagerie hautement performantApache Kafka, Un système distribué de messagerie hautement performant
Apache Kafka, Un système distribué de messagerie hautement performantALTIC Altic
 
Choosing an HDFS data storage format- Avro vs. Parquet and more - StampedeCon...
Choosing an HDFS data storage format- Avro vs. Parquet and more - StampedeCon...Choosing an HDFS data storage format- Avro vs. Parquet and more - StampedeCon...
Choosing an HDFS data storage format- Avro vs. Parquet and more - StampedeCon...StampedeCon
 
An Introduction to Elastic Search.
An Introduction to Elastic Search.An Introduction to Elastic Search.
An Introduction to Elastic Search.Jurriaan Persyn
 

Viewers also liked (20)

Avro introduction
Avro introductionAvro introduction
Avro introduction
 
Avro - More Than Just a Serialization Framework - CHUG - 20120416
Avro - More Than Just a Serialization Framework - CHUG - 20120416Avro - More Than Just a Serialization Framework - CHUG - 20120416
Avro - More Than Just a Serialization Framework - CHUG - 20120416
 
Thrift vs Protocol Buffers vs Avro - Biased Comparison
Thrift vs Protocol Buffers vs Avro - Biased ComparisonThrift vs Protocol Buffers vs Avro - Biased Comparison
Thrift vs Protocol Buffers vs Avro - Biased Comparison
 
Avro intro
Avro introAvro intro
Avro intro
 
Data Serialization Using Google Protocol Buffers
Data Serialization Using Google Protocol BuffersData Serialization Using Google Protocol Buffers
Data Serialization Using Google Protocol Buffers
 
Google Protocol Buffers
Google Protocol BuffersGoogle Protocol Buffers
Google Protocol Buffers
 
Serialization and performance by Sergey Morenets
Serialization and performance by Sergey MorenetsSerialization and performance by Sergey Morenets
Serialization and performance by Sergey Morenets
 
3 apache-avro
3 apache-avro3 apache-avro
3 apache-avro
 
Apache Hadoop and HBase
Apache Hadoop and HBaseApache Hadoop and HBase
Apache Hadoop and HBase
 
Thomas Lamirault_Mohamed Amine Abdessemed -A brief history of time with Apac...
Thomas Lamirault_Mohamed Amine Abdessemed  -A brief history of time with Apac...Thomas Lamirault_Mohamed Amine Abdessemed  -A brief history of time with Apac...
Thomas Lamirault_Mohamed Amine Abdessemed -A brief history of time with Apac...
 
AVR_Course_Day4 introduction to microcontroller
AVR_Course_Day4 introduction to microcontrollerAVR_Course_Day4 introduction to microcontroller
AVR_Course_Day4 introduction to microcontroller
 
Facebook thrift
Facebook thriftFacebook thrift
Facebook thrift
 
Cassandra Explained
Cassandra ExplainedCassandra Explained
Cassandra Explained
 
Mongo DB
Mongo DBMongo DB
Mongo DB
 
File Format Benchmark - Avro, JSON, ORC & Parquet
File Format Benchmark - Avro, JSON, ORC & ParquetFile Format Benchmark - Avro, JSON, ORC & Parquet
File Format Benchmark - Avro, JSON, ORC & Parquet
 
CouchDB
CouchDBCouchDB
CouchDB
 
Netty from the trenches
Netty from the trenchesNetty from the trenches
Netty from the trenches
 
Apache Kafka, Un système distribué de messagerie hautement performant
Apache Kafka, Un système distribué de messagerie hautement performantApache Kafka, Un système distribué de messagerie hautement performant
Apache Kafka, Un système distribué de messagerie hautement performant
 
Choosing an HDFS data storage format- Avro vs. Parquet and more - StampedeCon...
Choosing an HDFS data storage format- Avro vs. Parquet and more - StampedeCon...Choosing an HDFS data storage format- Avro vs. Parquet and more - StampedeCon...
Choosing an HDFS data storage format- Avro vs. Parquet and more - StampedeCon...
 
An Introduction to Elastic Search.
An Introduction to Elastic Search.An Introduction to Elastic Search.
An Introduction to Elastic Search.
 

Similar to Avro, la puissance du binaire, la souplesse du JSON

EWD 3 Training Course Part 20: The DocumentNode Object
EWD 3 Training Course Part 20: The DocumentNode ObjectEWD 3 Training Course Part 20: The DocumentNode Object
EWD 3 Training Course Part 20: The DocumentNode ObjectRob Tweed
 
Google apps script database abstraction exposed version
Google apps script database abstraction   exposed versionGoogle apps script database abstraction   exposed version
Google apps script database abstraction exposed versionBruce McPherson
 
Modernizes your objective C - Oliviero
Modernizes your objective C - OlivieroModernizes your objective C - Oliviero
Modernizes your objective C - OlivieroCodemotion
 
The Ring programming language version 1.5.2 book - Part 44 of 181
The Ring programming language version 1.5.2 book - Part 44 of 181The Ring programming language version 1.5.2 book - Part 44 of 181
The Ring programming language version 1.5.2 book - Part 44 of 181Mahmoud Samir Fayed
 
Mongo+java (1)
Mongo+java (1)Mongo+java (1)
Mongo+java (1)MongoDB
 
TDC2017 | São Paulo - Trilha Java EE How we figured out we had a SRE team at ...
TDC2017 | São Paulo - Trilha Java EE How we figured out we had a SRE team at ...TDC2017 | São Paulo - Trilha Java EE How we figured out we had a SRE team at ...
TDC2017 | São Paulo - Trilha Java EE How we figured out we had a SRE team at ...tdc-globalcode
 
MongoDB Aggregation Framework
MongoDB Aggregation FrameworkMongoDB Aggregation Framework
MongoDB Aggregation FrameworkCaserta
 
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)James Titcumb
 
Peggy elasticsearch應用
Peggy elasticsearch應用Peggy elasticsearch應用
Peggy elasticsearch應用LearningTech
 
Cassandra 3.0 - JSON at scale - StampedeCon 2015
Cassandra 3.0 - JSON at scale - StampedeCon 2015Cassandra 3.0 - JSON at scale - StampedeCon 2015
Cassandra 3.0 - JSON at scale - StampedeCon 2015StampedeCon
 
MongoDB World 2018: Keynote
MongoDB World 2018: KeynoteMongoDB World 2018: Keynote
MongoDB World 2018: KeynoteMongoDB
 
Introducing DataWave
Introducing DataWaveIntroducing DataWave
Introducing DataWaveData Works MD
 
Paris js extensions
Paris js extensionsParis js extensions
Paris js extensionserwanl
 
Abusing text/template for data transformation
Abusing text/template for data transformationAbusing text/template for data transformation
Abusing text/template for data transformationArnaud Porterie
 
Architecture | Busy Java Developers Guide to NoSQL | Ted Neward
Architecture | Busy Java Developers Guide to NoSQL | Ted NewardArchitecture | Busy Java Developers Guide to NoSQL | Ted Neward
Architecture | Busy Java Developers Guide to NoSQL | Ted NewardJAX London
 
Micro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicateMicro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicateKiev ALT.NET
 
Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Guillaume Laforge
 
Constance et qualité du code dans une équipe - Rémi Prévost
Constance et qualité du code dans une équipe - Rémi PrévostConstance et qualité du code dans une équipe - Rémi Prévost
Constance et qualité du code dans une équipe - Rémi PrévostWeb à Québec
 

Similar to Avro, la puissance du binaire, la souplesse du JSON (20)

EWD 3 Training Course Part 20: The DocumentNode Object
EWD 3 Training Course Part 20: The DocumentNode ObjectEWD 3 Training Course Part 20: The DocumentNode Object
EWD 3 Training Course Part 20: The DocumentNode Object
 
Google apps script database abstraction exposed version
Google apps script database abstraction   exposed versionGoogle apps script database abstraction   exposed version
Google apps script database abstraction exposed version
 
Modernizes your objective C - Oliviero
Modernizes your objective C - OlivieroModernizes your objective C - Oliviero
Modernizes your objective C - Oliviero
 
The Ring programming language version 1.5.2 book - Part 44 of 181
The Ring programming language version 1.5.2 book - Part 44 of 181The Ring programming language version 1.5.2 book - Part 44 of 181
The Ring programming language version 1.5.2 book - Part 44 of 181
 
Mongo+java (1)
Mongo+java (1)Mongo+java (1)
Mongo+java (1)
 
TDC2017 | São Paulo - Trilha Java EE How we figured out we had a SRE team at ...
TDC2017 | São Paulo - Trilha Java EE How we figured out we had a SRE team at ...TDC2017 | São Paulo - Trilha Java EE How we figured out we had a SRE team at ...
TDC2017 | São Paulo - Trilha Java EE How we figured out we had a SRE team at ...
 
MongoDB Aggregation Framework
MongoDB Aggregation FrameworkMongoDB Aggregation Framework
MongoDB Aggregation Framework
 
DataMapper
DataMapperDataMapper
DataMapper
 
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
 
Peggy elasticsearch應用
Peggy elasticsearch應用Peggy elasticsearch應用
Peggy elasticsearch應用
 
Cassandra 3.0 - JSON at scale - StampedeCon 2015
Cassandra 3.0 - JSON at scale - StampedeCon 2015Cassandra 3.0 - JSON at scale - StampedeCon 2015
Cassandra 3.0 - JSON at scale - StampedeCon 2015
 
MongoDB World 2018: Keynote
MongoDB World 2018: KeynoteMongoDB World 2018: Keynote
MongoDB World 2018: Keynote
 
Introducing DataWave
Introducing DataWaveIntroducing DataWave
Introducing DataWave
 
Paris js extensions
Paris js extensionsParis js extensions
Paris js extensions
 
Abusing text/template for data transformation
Abusing text/template for data transformationAbusing text/template for data transformation
Abusing text/template for data transformation
 
Architecture | Busy Java Developers Guide to NoSQL | Ted Neward
Architecture | Busy Java Developers Guide to NoSQL | Ted NewardArchitecture | Busy Java Developers Guide to NoSQL | Ted Neward
Architecture | Busy Java Developers Guide to NoSQL | Ted Neward
 
Micro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicateMicro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicate
 
Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008
 
Constance et qualité du code dans une équipe - Rémi Prévost
Constance et qualité du code dans une équipe - Rémi PrévostConstance et qualité du code dans une équipe - Rémi Prévost
Constance et qualité du code dans une équipe - Rémi Prévost
 
PHP code examples
PHP code examplesPHP code examples
PHP code examples
 

Recently uploaded

Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Best Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfBest Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfIdiosysTechnologies1
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfLivetecs LLC
 

Recently uploaded (20)

Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Best Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfBest Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdf
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdf
 

Avro, la puissance du binaire, la souplesse du JSON

  • 1. AVRO LA PUISSANCE DU BINAIRE, LA SOUPLESSE DU JSON
  • 2. MYSELF Alexandre Victoor Architecte à la SGCIB alexvictoor@gmail.com https://github.com/alexvictoor @alex_victoor
  • 3.
  • 5.
  • 7.             {     "type":"record",     "namespace": "DevoxxFR.Example",     "name":"Trade",     "fields":         [             { "name":"ClientId", "type":"int" },             { "name":"Nominal", "type":"double" },             { "name":"Date", "type":"string" }         ] }          
  • 8.             {     "type":"record",     "namespace": "DevoxxFR.Example",     "name":"Trade",     "fields":         [             { "name":"ClientId", "type":"int" },             { "name":"Nominal", "type":"double" },             { "name":"Date", "type":"string" },                                           {                 "name":"product",                     "type":                     ["null", {                         "type":"record",                         "namespace":"DevoxxFR.Example",                         "name":"Product",                         "default":null,          
  • 9.             java ­jar avro­tools.jar compile schema trade.avro          
  • 10. AVEC UN SEUL OBJECT             DatumWriter<Trade> writer = new SpecificDatumWriter<Trade>();                       encoder = EncoderFactory.get().binaryEncoder(outputStream, null);                       writer.write(trade, encoder);          
  • 11. PUIS POUR LIRE             DatumReader<Trade> reader = new SpecificDatumReader<Trade>();                       decoder = DecoderFactory.get().binaryDecoder(inputStream, null);                       trade = reader.read(null, decoder);          
  • 12. SANS GÉNÉRATION             GenericRecord record = new GenericData.Record(SCHEMA); record.put("ProductId", 123); record.put("Nominal", 42000);                       DatumWriter<GenericRecord> datumWriter = new GenericDatumWriter<>(SCHEMA                       DatumReader<GenericRecord> datumReader = new GenericDatumReader<>(SCHEMA          
  • 14. ECRIRE EN MASSE             File avroDataFile; // on peut aussi utiliser un OutputStream             
  • 15. ECRIRE EN MASSE             File avroDataFile; // on peut aussi utiliser un OutputStream DatumWriter<GenericRecord> datumWriter = new GenericDatumWriter<>();            
  • 16. ECRIRE EN MASSE             File avroDataFile; // on peut aussi utiliser un OutputStream DatumWriter<GenericRecord> datumWriter = new GenericDatumWriter<>(); DataFileWriter<GenericRecord> dataFileWriter       = new DataFileWriter<>(datumWriter);            
  • 17. ECRIRE EN MASSE             File avroDataFile; // on peut aussi utiliser un OutputStream DatumWriter<GenericRecord> datumWriter = new GenericDatumWriter<>(); DataFileWriter<GenericRecord> dataFileWriter       = new DataFileWriter<>(datumWriter); dataFileWriter.setCodec(CodecFactory.snappyCodec());            
  • 18. ECRIRE EN MASSE             File avroDataFile; // on peut aussi utiliser un OutputStream DatumWriter<GenericRecord> datumWriter = new GenericDatumWriter<>(); DataFileWriter<GenericRecord> dataFileWriter       = new DataFileWriter<>(datumWriter); dataFileWriter.setCodec(CodecFactory.snappyCodec()); dataFileWriter.create(TRADE_SCHEMA, avroDataFile);             
  • 19. ECRIRE EN MASSE             File avroDataFile; // on peut aussi utiliser un OutputStream DatumWriter<GenericRecord> datumWriter = new GenericDatumWriter<>(); DataFileWriter<GenericRecord> dataFileWriter       = new DataFileWriter<>(datumWriter); dataFileWriter.setCodec(CodecFactory.snappyCodec()); dataFileWriter.create(TRADE_SCHEMA, avroDataFile); for (GenericRecord record : records) {   dataFileWriter.append(record); }          
  • 21. ET POUR LIRE ?             File avroDataFile; // on peut aussi utiliser un InputStream            
  • 22. ET POUR LIRE ?             File avroDataFile; // on peut aussi utiliser un InputStream DatumReader<GenericRecord> datumReader = new GenericDatumReader<>();            
  • 23. ET POUR LIRE ?             File avroDataFile; // on peut aussi utiliser un InputStream DatumReader<GenericRecord> datumReader = new GenericDatumReader<>(); DataFileReader<GenericRecord> dataFileReader      = new DataFileReader(avroDataFile, datumReader);            
  • 24. ET POUR LIRE ?             File avroDataFile; // on peut aussi utiliser un InputStream DatumReader<GenericRecord> datumReader = new GenericDatumReader<>(); DataFileReader<GenericRecord> dataFileReader      = new DataFileReader(avroDataFile, datumReader); for (GenericRecord record : dataFileReader) {   // traitement sur chaque record }          
  • 25. C'EST BIEN MAIS...             {     "type":"record",     "namespace": "DevoxxFR.Example",     "name":"Trade",     "fields":         [             { "name":"ClientId", "type":"int" },             { "name":"Nominal", "type":"double" },             { "name":"Date", "type":"string" },                                           {                 "name":"product",                     "type":                     ["null", {                         "type":"record",                         "namespace": "DevoxxFR.Example",                         "name":"Product",             "default":null,          
  • 26.
  • 27. LA KILLER FEATURE             // la résolution de schema new GenericDatumReader(writerSchema, readerSchema) Writer Schema Le schéma qui a été utilisé pour sérialiser
  • 28. LA KILLER FEATURE             // la résolution de schema new GenericDatumReader(writerSchema, readerSchema) Reader Schema Les données dont vous avez besoin
  • 29. ENTRE 2 SCHEMAS, ON PEUT - ajouter un champ - supprimer un champ - renommer un champ (avec un alias) On ne peut pas changer le type d'un champ
  • 31. D'AUTRES USAGES - Event sourcing - Echanges de messages entre applications
  • 35.
  • 36.
  • 37.
  • 38. RESSOURCES Ces slides : Une variante "alt.net" de cette prez : La spec avro : Le tuto MS : Le SDK MS Hadoop : https://github.com/alexvictoor/AvroDevoxxFr https://github.com/alexvictoor/AvroAltNet http://avro.apache.org/docs/1.7.7/spec.html http://bit.ly/1uYRX3I http://hadoopsdk.codeplex.com/SourceControl/latest