Kein%20Folientitel - PowerPoint PPT Presentation

About This Presentation
Title:

Kein%20Folientitel

Description:

Serialisierung Benedict Fehringer Proseminar Programmiersysteme Betreuer: Guido Tack – PowerPoint PPT presentation

Number of Views:104
Avg rating:3.0/5.0
Slides: 41
Provided by: Sir144
Category:

less

Transcript and Presenter's Notes

Title: Kein%20Folientitel


1
Serialisierung
Benedict Fehringer
Proseminar Programmiersysteme Betreuer Guido Tack
2
Übersicht
  • Einführung
  • Datengraphen und abstrakter Speicher
  • Pickles (Unpickling, Pickling)
  • Bsp. in Java und Alice

3
Einführung
4
Was meint Serialisierung?
Serialisierung bedeutet, dass ein Datengraph in
eine eindimensionale (lineare)-Form gebracht
wird, so dass diese eindeutig in den
Ursprungs-Datengraph umgewandelt werden kann.
5
Wozu benötigt man Serialisierung?
  • Speichern
  • Transferieren
  • Compilieren

6
Umsetzung der Serialisierung in verschiedenen
Sprachen
  • CLU (eine Sprache, die von Pascal abstammt) (B.
    Liskov and St. Zilles, 1974)
  • JAVA (Roger Riggs, Jim Waldo, Ann Wollrath Sun
    Microsystems, Inc., 1996), Microsofts.NET
    Framework
  • Ruby oder Python
  • SML/NJ (A. W. Appel and D. B. MacQueen, 1994),
    OCaml, Alice
  • Mozart/Oz

7
Datengraphen und abstrakter Speicher
8
Bsp. für einen Datengraph
class A public string s public int i public B
b
class B public int j public A a
A x new A () B y new B () x.s aaa x.i
24 x.b y y.j 45 y.a x
9
Bsp. für einen Datengraph
Inhalt
Label
Adresse
object x
0 1 2 3 4
object x int string object y int
1 2 3 24 aaa 0 4 45
string aaa
object y
int 24
int 45
10
Datengraph (formal)
Ein Datengraph ist eine endliche Funktion g, so
dass gilt Ran(g) ? Lab x (Str ? Dom(g))
11
Abstrakter Speicher
  • Spezielle Datenstrukturen benötigen eine
    spezielle Repräsentation (Zahlen, Strings,
    Arrays,...) (kann zur Optimierung implementiert
    werden)

12
Pickles
13
Definitionen
Pickle - linear
- external

- Platform-unabhängige
Pickling - Umwandlung eines Datengraphen in
einen Pickle Unpickling - Umkehrvorgang zum
Pickling
14
Konstruktion/Unpickling von Datengraphen
  • Baum
  • azyklischer Graph
  • zyklischer Graph

15
Baum
Instruktion
Nachfolger
a
c
0
b
c
c
0
d
0
d
c
b
2
a
2
16
Baum
Instruktion
Nachfolger
a
c
0
b
c
c
0
d
0
d
c
b
2
a
2
17
Azyklischer Graph
Instruktion
Nachfolger
a
c
0
b
-
STORE 0
-
LOAD 0
d
c
0
d
2
b
2
a
18
Azyklischer Graph
Instruktion
Nachfolger
a
c
0
b
-
STORE 0
-
LOAD 0
d
c
0
d
2
b
2
a
19
Zyklischer Graph
Instruktion
Nachfolger
a
PROMISE 0 a
2
c
1
b
STORE 1
-
LOAD 1
-
d
c
0
d
b
2
FULFIL 0
2
20
Zyklischer Graph
Instruktion
Nachfolger
a
PROMISE 0 a
2
c
1
b
STORE 1
-
LOAD 1
-
d
c
0
d
b
2
FULFIL 0
2
21
Pickling
  • Schritt 1 Datengraph Pickle-Baum
  • Schritt 2 Pickle-Baum
    Postorder-Linearisierung
  • Schritt 3 Postorder-Linearisierung Pickle

22
Schritt 1
0 a
a
b
1 c
b
d
c
d
-gt 1
-gt 0
Datengraph
Pickle-Baum
23
Schritt 2
0 a
b
1 c
-gt 0
d
-gt 1
Pickle-Baum
Postorder-Linearisierung
24
Schritt 3
Postorder-Linearisierung
Bottom-up-Pickle
25
Top-Down-Pickles
  • Präorder statt Postorder Top-Down
    Pickle
  • Kein Promise/Fulfill nötig

26
Verschiedene Darstellungen eines Pickle-Bäume
0 a
0 a
b
1 c
b
-gt 1

d
d
1 c
-gt 0
-gt 1
-gt 0
27
Implementier-Details
  • Depth First Search
    (Graph Pickle-Baum Pickle)
  • Bestimmung der maximalen Stack-Höhe

28
Realisierung in JAVA und Alice
29
JAVA-Objekt-Modell
  • Klassen
  • Objekte
  • Felder
  • Methoden
  • ...

30
Pickling in Java
  • Objekte können serialisiert werden
  • Top-Down-Mechanismus
  • Pruning

31
Bsp. für Pickling in Java
import java.io.Serializablepublic class A
implements Serializablepublic int ipublic
string s
32
Bsp. für Pickling in Java
10 public class FlattenA20 30 public static
void main(String args)40 50 A a new
A()60 FileOutputStream fos new
FileOutputStream(aa.ser")70 ObjectOutputStream
out new ObjectOutputStream(fos)80
out.writeObject(a)90 out.close()100 110
33
Bsp. für Pickling in Java
10 public class InflateA20 30 public static
void main(String args)40 50 A a null60
FileInputStream fis null70 ObjectInputStream
in null80 try90 100 fis new
FileInputStream(aa.ser")110 in new
ObjectInputStream(fis)120 a
(A)in.readObject()130 in.close()140 150
catch(IOException ex) ERROR!!!160
catch(ClassNotFoundException ex) ERROR!!! 170
180
34
Pruning
  • der Programmierer kann selbst entscheiden,
    welcher Teil gepickelt werden soll und welcher
    nicht.
  • Die nicht zu Pickelndeln Teile müssen markiert
    werden

35
Bsp. für Pickling in Java
import java.io.Serializablepublic class A
implements Serializabletransient public int
ipublic string s
36
Pickling in Alice
  • Pickling beliebiger Daten
  • Typsicherheit
  • Anwendung z.B. Komponentensystem / Compiler

37
Bsp. für Pickling in Alice
signature NUM sig type t fun fromInt
int -gt t fun toInt t -gt int fun add
t t -gt t end
structure Num gt NUM struct type t int
fun toInt n n fun fromInt n n val
add op end
38
Bsp. für Pickling in Alice
Pickling Pickle.save string package -gt
unit Pickle.save ("Num." Pickle.extension,
pack Num gt NUM) Unpickling Pickle.load string
-gt package structure Num' unpack Pickle.load
("Num." Pickle.extension) NUM
39
Bsp. für Pickling in Alice
Achtung! Num'.add (Num.fromInt 4, Num.fromInt
5) 1.0-1.39 argument type mismatch t
t does not match argument type Num'.t
Num'.t because type Num.t does not unify with
Num'.t
40
Literaturverzeichnis
  • Guido Tack, Linearisation, Minimisation and
    Transformation of Data Graphs with Transients.
    Diplomarbeit, Saarbrücken, Mai 2003
  • Roger Riggs, Jim Waldo, Ann Wollrath Sun
    Microsystems, Inc., Pickling State in the Java
    System, Toronto, Ontario, Canada, June 1996
  • Java Object Serialization Specification.
    Available from http//java.sun.com/j2se/1.4/docs/g
    uide/serialization/, 2001.
  • The Alice Project. Available from
    http//www.ps.uni-sb.de/alice, 2003. Homepage at
    the Programming Systems Lab, Universität des
    Saarlandes, Saarbrücken.
Write a Comment
User Comments (0)
About PowerShow.com