Documente Academic
Documente Profesional
Documente Cultură
Performance
Chapter 6
Jim Skon
MVNC
Data Compression
Reclaiming space in files
Fast Searching
Keysorting
MVNC
Data Compression
Data Compression
encoding information more efficiently
Many techniques exist
MVNC
Data Compression
MVNC
Data Compression
MVNC
Data Compression
MVNC
Data Compression
MVNC
Example:
Letter:
Prob:
Code:
a
0.4
1
b
0.1
010
c
0.1
011
d
e
f
g
0.1
0.1
0.1
0.1
0000 0001 0010 0011
MVNC
Data Compression
Irreversible Compression
Compression which losses some information
Example - compress a 400x400 image into a
100x100 image by averaging groups of 16
adjacent pixels
Saves space, but resolution of picture reduced
Used most often for visual or audio information
(which has inherient redundancy)
MVNC
Data Compression
Compression in UNIX
pack and unpack programs
MVNC
10
Suppose a record is
Added to to the middle?
Deleted from middle?
MVNC
11
MVNC
12
Occasional compaction
Dynamic maintanance
MVNC
13
Occasional compaction
MVNC
14
Dynamic maintanance
MVNC
15
Dynamic maintanance
MVNC
16
Fixed-length records
Variable-length records
MVNC
17
Fixed-length records
Simply maintain a stack of deleted records rooted
in header record
Deletion - add to front of list
Addition - use record at front of list
Minimal list maintanance cost
MVNC
18
Variable-length records
Store for each deleted record
Deletion Marker
link to nect deleted record
record size indicator
MVNC
19
Variable-length records
Insertion
Which deleted record?
Deletion
Add records to list (stack?)
Where
MVNC
20
MVNC
21
MVNC
22
MVNC
23
Best Fit
Use deleted record closest in size
Worst Fit
Use deleted record that is largest
No good when not breaking up records!
MVNC
24
MVNC
25
MVNC
26
Fast Searching
Binary Searching
O(log n), where n is number of records
requires file be sorted
MVNC
27
File Sorting
Sort in Ram
read in entire file - sort
Called internal sorting
Limited by size of memory
MVNC
28
MVNC
29
MVNC
30
Keysorting
MVNC
31
Keysorting
Advantages
Keys can be sorted in smaller space then whole
file
Faster to sort (swap!) keys then entire records
MVNC
32
Keysorting
Disadvantages
Still limited in size to key lists which fit in memory
Sequential processing cannot not take advantage
of buffering!
MVNC
33
Keysorting
MVNC
34
Advantages
Keys and pointers can be searched in memery.
Only one I/O per lookup!
File can be maintained in ANY order. Searching
and key order sequential processing still possible.
MVNC
35
Disadvantages
Sequential processing cannot not take advantage
of buffering!
Pinned records
Records in main file cannot change location without
invalidating index file!
Must either maintain index in parallel, or rebuild!
MVNC
36