Serialization. Informatik IT-Uddannelse og IT-Udvikling



Similar documents
Chair of Software Engineering. Java and C# in depth. Carlo A. Furia, Bertrand Meyer. C#: Persistence

Domain Driven Design. Informatik IT-Uddannelse og IT-Udvikling

Windows Forms 2.0 Data Binding. Informatik IT-Uddannelse og IT-Udvikling

Lecture 7: Class design for security

TWIN-TURBINE CENTRIFUGAL COMPRESSOR

AVRO - SERIALIZATION

Getting to know Apache Hadoop

Serialization in Java (Binary and XML)

Illustration 1: Diagram of program function and data flow

A Java-based system support for distributed applications on the Internet

ODMG-api Guide. Table of contents

Spark ΕΡΓΑΣΤΗΡΙΟ 10. Prepared by George Nikolaides 4/19/2015 1

Java 7 Recipes. Freddy Guime. vk» (,\['«** g!p#« Carl Dea. Josh Juneau. John O'Conner

PuttyRider. With great power comes great responsibility. # Pivoting from Windows to Linux in a penetration test. Adrian Furtunã, PhD adif2k8@gmail.

isppac-powr1220at8 I 2 C Hardware Verification Utility User s Guide

Storing Measurement Data

Machine Architecture and Number Systems. Major Computer Components. Schematic Diagram of a Computer. The CPU. The Bus. Main Memory.

Tutorial: Big Data Algorithms and Applications Under Hadoop KUNPENG ZHANG SIDDHARTHA BHATTACHARYYA

Apache Hadoop. Alexandru Costan

70-536VB:.NET Framework Application Development Foundation Course Introduction

Hijacking Arbitrary.NET Application Control Flow. Topher Timzen

Auditing manual. Archive Manager. Publication Date: November, 2015

High Performance XML Data Retrieval

Manual Software SPECTRO3-MONITORING V5.0

Architectures for massive data management

GetLibraryUserOrderList

MONITORING PERFORMANCE IN WINDOWS 7

Ontrack PowerControls V8.1 for SQL ReadMe

Hadoop at Yahoo! Owen O Malley Yahoo!, Grid Team owen@yahoo-inc.com

Jeffrey D. Ullman slides. MapReduce for data intensive computing

Hadoop WordCount Explained! IT332 Distributed Systems

In This Guide. Nitro Pro 9 - Deployment Guide

Cross-platform IL code manipulation library for runtime instrumentation of.net applications

An Introduction to MPLAB Integrated Development Environment

HexaCorp. White Paper. SOA with.net. Ser vice O rient ed Ar c hit ecture

How to Improve Database Connectivity With the Data Tools Platform. John Graham (Sybase Data Tooling) Brian Payton (IBM Information Management)

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. AVRO Tutorial

Original brief explanation

Data Analysis Software

This text refers to the 32bit version of Windows, unfortunately I don't have access to a 64bit development environment.

C++FA 5.1 PRACTICE MID-TERM EXAM

Optimizing Load Balance Using Parallel Migratable Objects

PM1122 INT DIGITAL INTERFACE REMOTE

Learn how to store and analyze Big Data Learn about the cloud and its services for Big Data

DiskPulse DISK CHANGE MONITOR

File I/O - Chapter 10. Many Stream Classes. Text Files vs Binary Files

Symantec Endpoint Protection Shared Insight Cache User Guide

User Guidance. CimTrak Integrity & Compliance Suite

HDFS. Hadoop Distributed File System

The Hadoop Distributed File System

Cache Configuration Reference

Mobile Application Languages XML, Java, J2ME and JavaCard Lesson 04 Java

The Hadoop Eco System Shanghai Data Science Meetup

Data-intensive computing systems

Hadoop: A Framework for Data- Intensive Distributed Computing. CS561-Spring 2012 WPI, Mohamed Y. Eltabakh

Binary storage of graphs and related data

Develop Software that Speaks and Listens

Input Output. 9.1 Why an IO Module is Needed? Chapter 9

Serializing Data with Protocol Buffers. Vinicius Vielmo Cogo Smalltalks, DI, FC/UL. February 12, 2014.

Connecting to WebSphere ESB and WebSphere Process Server

Monitor software for system A2 and W3

Package hive. January 10, 2011

Copyright 2013 Consona Corporation. All rights reserved

SMARTcontrol. Dashboard. from

Adobe Acrobat: Creating Interactive Forms

Acronis Backup & Recovery 10 Server for Windows. Workstation. Quick Start Guide

sndio OpenBSD audio & MIDI framework for music and desktop applications

Hadoop Memory Usage Model

ITDUMPS QUESTION & ANSWER. Accurate study guides, High passing rate! IT dumps provides update free of charge in one year!

Top 10 Oracle SQL Developer Tips and Tricks

The Flink Big Data Analytics Platform. Marton Balassi, Gyula Fora" {mbalassi,

How To Write A Map Reduce In Hadoop Hadooper (Ahemos)

Using Impatica for Power Point

Dynamic Web Programming BUILDING WEB APPLICATIONS USING ASP.NET, AJAX AND JAVASCRIPT

Dozer v User's Guide

Tuning Your GlassFish Performance Tips. Deep Singh Enterprise Java Performance Team Sun Microsystems, Inc.

EcgSoft. Software Developer s Guide to RestEcg. Innovative ECG Software info@ecg-soft.com

Object-Oriented Databases db4o: Part 2

Hadoop MapReduce: Review. Spring 2015, X. Zhang Fordham Univ.

Intel NAS Performance Toolkit

OTN Developer Day: Oracle Big Data. Hands On Lab Manual. Introduction to Oracle NoSQL Database

Introduction to Synoptic

Cloud Storage Backup for Storage as a Service with AT&T

CS54100: Database Systems

Multimedia im Netz Online Multimedia Winter semester 2015/16. Tutorial 03 Major Subject

THE BUSINESS VALUE OF AN ERP SYSTEM

CDH AND BUSINESS CONTINUITY:

#include <Gamer.h> Gamer gamer; void setup() { gamer.begin(); } void loop() {

Using SQL Server Management Studio

Important Notice. (c) Cloudera, Inc. All rights reserved.

VirtualXP Users Guide

Research of Railway Wagon Flow Forecast System Based on Hadoop-Hazelcast

The Fundamentals of Tuning OpenJDK

Features - Microsoft Data Protection Manager

HDFS Users Guide. Table of contents

Memory-to-memory session replication

Transcription:

Serialization

Morten Mertner Senior Consultant, Teknologisk Institut - Architect and Software Developer (C#) - Teacher - Speaker (conferences and gatherings) Certificeringer - MSCD.NET - MCT Open Source - Gentle.NET (object persistence framework / object-relational mapper) - MbUnit (unit test framework)

Agenda Serialization - what is serialization? - implementation Basic Serialization Custom Serialization Versioning

What is Serialization? Serialization - the process of converting an in-memory object graph into a linear sequence of bytes Purposes (what happens to the byte sequence) - send it to another process - send it to the clipboard, to be browsed or used by another application - send it to another machine - send it to a file on disk

Serialization Object Graph What is an object graph? - an object graph is a set of objects with some set of references to each other - the most obvious problem is how to represent the links between the objects in the Serialized stream 3 Dog 4 Cat 7 Cat 1 Mouse 9 Horse 2 Duck

Serialization Implementation CLR - has metadata on each type - property and field definitions - object memory layout - this metadata enables the default serialization mechanisms - shows the power of custom attributes and reflection Formatters decide what the output looks like - XML (default is to include public properties only) - binary (default is to include all members) - custom (you decide)

Serialization Example ArrayList list = new ArrayList(); for( int x=0; x< 10; x++ ) { list.add (x); } Stream s = (new File ("foo.bin")).open(filemode.create); BinaryFormatter bf = new BinaryFormatter(); bf.serialize( s, list ); s.close(); Stream s = (new File ("foo.bin")).open(filemode.open); BinaryFormatter bf = new BinaryFormatter(); ArrayList list = (ArrayList) bf.deserialize( s ); s.close();

Basic Serialization Types must be marked as [Serializable] - base class must also be serializable [Serializable] public class MyClass {} Exclude members from serialization using [NonSerialized] [Serializable] public class MyClass { [NonSerialized] IDbConnection connection; }

Custom Serialization ISerializable Events - IDeserializationCallback - Attributes Custom Formatters

Custom Serialization ISerializable Customize the serialization process - if a class implements ISerializable the default serialization mechanism will not be used ISerializable contains only one method void GetObjectData( SerializationInfo info, StreamingContext context ); // And an implied constructor that may be private private <TypeName>( SerializationInfo info, StreamingContext context );

Custom Serialization Events IDeserializationCallback (.NET 1.1) - provides a means to restore non-serialized members after deserialization is complete - mainly useful with custom formatter - example usage: restore database connection

Custom Serialization Events Applied as method attributes (.NET 2.0) - OnSerializingAttribute - OnSerializedAttribute - OnDeserializingAttribute - OnDeserializedAttribute Event handling method signature void <Method Name>( StreamingContext context ); Prefer serialization attributes over custom serialization

Custom Serialization Custom Formatter IFormatter interface - pluggable mechanism for using a different output format public interface IFormatter: { //Properties SerializationBinder Binder { get; set; } StreamingContext Context { get; set; } ISurrogateSelector SurrogateSelector { get; set; } //Methods object Deserialize(Stream serializationstream); void Serialize(Stream serializationstream, object graph); }

Serialization Versioning In.NET 1.1 - cannot change type definition once serialized - no internal mutability of metadata In.NET 2.0 - binary formatter silently ignores additional members in stream - allows removing of members - formatters can be told to ignore additional members in class - allows adding members - default is intolerant

Serialization Versioning OptionalField attribute - use it to toggle tolerance - can contain version information - reflect it in deserializing event and perform custom steps [AttributeUsage( AttributeTargets.Field, Inherited=false)] public sealed class OptionalFieldAttribute : Attribute { public int VersionAdded { get; set; } }

Serialization Versioning and Web Services Web Services - uses XML / SOAP formatter But... - contract is not allowed to change - contract is usually inflexible (no optional fields) Solution - interface (contract) refactoring

Serialization Final Words Serialization - powerful mechanism for persisting object graphs - easily customizable Generic Serialization - provides type safety - use SerializationUtil from IDesign - downloadable from http://www.idesign.net