Project

General

Profile

Persistent data » History » Version 12

Greg Burri, 09/07/2009 05:36 PM

1 10 Greg Burri
h1. Persistent data
2 1 Greg Burri
3 4 Greg Burri
h2. Files cache
4 1 Greg Burri
5 5 Greg Burri
This file contains all the shared files and theirs SHA-1 hashes. This file is saved in user space after an update of the file list, it is completely loaded at the start of Aybabtu. If some paths of some files doesn't match the shared directory they are discarded.
6 1 Greg Burri
7 9 Greg Burri
This file is saved as a binary file serialized by protocol buffer.
8
9 7 Greg Burri
You can see the proto file here : source:/application/Protos/files_cache.proto
10 1 Greg Burri
11 4 Greg Burri
h3. Size
12
13
Here is a size approximation for 50'000 files stored in 1 TB. The overhead of the file format is not taken in account.
14
15
<pre>
16
Nb of files : 50'0000
17
Total size : 1 TB
18
Chunk Size : 32 MB
19
Average file per directory : 50
20
Average filename and dirname length : 50 char
21
Size of a hash : 20B
22
</pre>
23
24
<pre>
25
AverageFileSize = 1*1024^4 / 50'000 = 21MB
26
Sha1Size = floor(AverageFileSize / 32MB) * 20 * 50'000 = 1 * 20 * 50'000 = 977kB
27
FilenameSize = 50'000 * 50 * 2 = 4.8MB (2 bytes per char)
28
DirnameSize = (50'000 / 50) * 50 * 2 = 97kB
29
30
TotalSize = 977kB + 4.8MB + 97kB = 5.9MB
31
</pre>
32
33 6 Greg Burri
h2. Queued files and directories
34 1 Greg Burri
35 9 Greg Burri
A file containing the queued files and directories is saved in user space. An item from the list may contains a remote peer id and/or the hashes which identify a file. 
36
37
As the file cache file (see above), this file is saved as a binary file serialized by protocol buffer.
38
39
For more details see the file : source:/application/Protos/queue.proto
40 8 Greg Burri
41 4 Greg Burri
42
h2. Configuration file
43
44 11 Greg Burri
here are the persisted data :
45
46
* The nick
47
* The shared folders in read-only 
48
* The shared folders in read-write
49
* Core address and password for remote core
50
51 12 Greg Burri
There is two ways to persist theses data :
52 11 Greg Burri
53
# Using of _QSettings_ : http://doc.trolltech.com/4.5/qsettings.html
54
# Using a custom file containing data serialized with _Protocol Buffer_ as the file cache
55
56
h3. Pros for the first method (_QSettings_)
57
58
* Easier to create, not necessary to create a file definition.
59
* Standard to Qt.
60
61
h3. Pros for the second method (_Protocol Buffer_)
62
63
* Same method as the two other files.
64
* All the persisted data is in the same place.