15 #ifndef FILEBUF64_H |
15 #ifndef FILEBUF64_H |
16 #define FILEBUF64_H |
16 #define FILEBUF64_H |
17 |
17 |
18 #include <f32file.h> |
18 #include <f32file.h> |
19 #include <f32file64.h> |
19 #include <f32file64.h> |
20 |
|
21 //Forward declaration |
|
22 struct MFileInitializer64; |
|
23 |
20 |
24 /** |
21 /** |
25 The RFileBuf64 class provides buffered file read/write operations on a single RFile64 object. |
22 The RFileBuf64 class provides buffered file read/write operations on a single RFile64 object. |
26 RFileBuf64::Read() and RFileBuf64::Write() methods may boost the performance of the read/write file operations up to 30% |
23 RFileBuf64::Read() and RFileBuf64::Write() methods may boost the performance of the read/write file operations up to 30% |
27 if compared to their RFile64 equivalents. Especially this is true in the case of a set of sequential read or write |
24 if compared to their RFile64 equivalents. Especially this is true in the case of a set of sequential read or write |
45 methods: RFileBuf64::Create(), RFileBuf64::Open() or RFileBuf64::Temp(). |
42 methods: RFileBuf64::Create(), RFileBuf64::Open() or RFileBuf64::Temp(). |
46 |
43 |
47 In details, to create a file and access it through a RFileBuf64 object: |
44 In details, to create a file and access it through a RFileBuf64 object: |
48 |
45 |
49 RFs fs; |
46 RFs fs; |
50 //initialize the file session |
47 TInt err = fs.Connect(); |
|
48 //check the error |
51 ... |
49 ... |
52 RFileBuf64 fbuf(<N>); //<N> is the buffer capacity in bytes |
50 RFileBuf64 fbuf(<N>); //<N> is the buffer capacity in bytes |
53 TInt err = fbuf.Create(fs, <file name>, <file mode>); |
51 err = fbuf.Create(fs, <file name>, <file mode>); |
54 //check the error |
52 //check the error |
55 |
53 |
56 To open an existing file and access it through a RFileBuf64 object: |
54 To open an existing file and access it through a RFileBuf64 object: |
57 |
55 |
58 RFs fs; |
56 RFs fs; |
59 //initialize the file session |
57 TInt err = fs.Connect(); |
|
58 //check the error |
60 ... |
59 ... |
61 RFileBuf64 fbuf(<N>); //<N> is the buffer capacity in bytes |
60 RFileBuf64 fbuf(<N>); //<N> is the buffer capacity in bytes |
62 TInt err = fbuf.Open(fs, <file name>, <file mode>); |
61 err = fbuf.Open(fs, <file name>, <file mode>); |
63 //check the error |
62 //check the error |
64 |
63 |
65 To create a temporary file and access it through a RFileBuf64 object: |
64 To create a temporary file and access it through a RFileBuf64 object: |
66 |
65 |
67 RFs fs; |
66 RFs fs; |
68 //initialize the file session |
67 TInt err = fs.Connect(); |
|
68 //check the error |
69 ... |
69 ... |
70 RFileBuf64 fbuf(<N>); //<N> is the buffer capacity in bytes |
70 RFileBuf64 fbuf(<N>); //<N> is the buffer capacity in bytes |
71 TInt err = fbuf.Temp(fs, <path>, <file name>, <file mode>); |
71 err = fbuf.Temp(fs, <path>, <file name>, <file mode>); |
72 //check the error |
72 //check the error |
73 |
73 |
74 - if the RFileBuf64 object is initialised successfully, now the public RFileBuf64 methods can be called to perform |
74 - if the RFileBuf64 object is initialised successfully, now the public RFileBuf64 methods can be called to perform |
75 requested operations on the file: |
75 requested operations on the file: |
76 |
76 |
88 fbuf.Close(); |
88 fbuf.Close(); |
89 |
89 |
90 @endcode |
90 @endcode |
91 |
91 |
92 Implementation notes: the current RFileBuf64 implementation is optimised for use by the SQLite OS porting layer. |
92 Implementation notes: the current RFileBuf64 implementation is optimised for use by the SQLite OS porting layer. |
93 After a detailed investigation of the performed by SQLite file read/write operations it was found that buffering of |
93 After investigation of SQLite file read/write operations it was found that buffering of |
94 two or more logical file writes into a single physical file write has a positive impact (as expected) on the performance |
94 two or more logical file writes into a single physical file write has a positive impact (as expected) on the performance |
95 of the database write operations. But the picture is quite different for the file read operations. The database data is |
95 of the database write operations. But the picture is quite different for the file read operations. The database data is |
96 organised in pages with fixed size. After a database is created and set of insert/update/delete operations is performed |
96 organised in pages with fixed size. After a database is created and set of insert/update/delete operations is performed |
97 on it, after a while the database pages (identified by their numbers) are not sequential in the database file and using |
97 on it, after a while the database pages (identified by their numbers) are not sequential in the database file and using |
98 a read-ahead buffer with fixed size makes no sense because for each "page read" request of N bytes, the RFileBuf64 object |
98 a read-ahead buffer with fixed size makes no sense because for each "page read" request of N bytes, the RFileBuf64 object |