directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1592980 - /directory/site/trunk/content/mavibot/user-guide/7.2-physical-storage.mdtext
Date Wed, 07 May 2014 11:51:13 GMT
Author: kayyagari
Date: Wed May  7 11:51:12 2014
New Revision: 1592980

URL: http://svn.apache.org/r1592980
Log:
re-wrote parts of the text

Modified:
    directory/site/trunk/content/mavibot/user-guide/7.2-physical-storage.mdtext

Modified: directory/site/trunk/content/mavibot/user-guide/7.2-physical-storage.mdtext
URL: http://svn.apache.org/viewvc/directory/site/trunk/content/mavibot/user-guide/7.2-physical-storage.mdtext?rev=1592980&r1=1592979&r2=1592980&view=diff
==============================================================================
--- directory/site/trunk/content/mavibot/user-guide/7.2-physical-storage.mdtext (original)
+++ directory/site/trunk/content/mavibot/user-guide/7.2-physical-storage.mdtext Wed May  7
11:51:12 2014
@@ -27,34 +27,32 @@ Notice: Licensed to the Apache Software 
 When associated with a RecordManager, Mavibot stores all the Btrees in one single file, which
is split in many physical pages, all having the same size. 
 
 >**Note**
->Currently, the choice was to use one single size for all the pages, regardless the data
we store into them. The rationnal is to
+>Currently, the choice was to use same size for all the pages, regardless of the data
stored into them. The rationnal is to
 >get close to the OS page size (frequently 512 bytes or 4096 bytes). This is not necessarily
the best choice though, let's say 
 >it's something we might want to change later.
 
 
 ## General file structure
 
-The file we use to store the data is a plain binary file, used to store all the BTrees. We
can store many btrees in one single file.
+The data is stored in a pure binary file. All btrees are stored in this single file.
 
-This file is considered as a fileSystem, with fixed size 'pages' (a page is an array of bytes).
The page size is arbitrary fixed when the RecordManager is created, and we will store every
logical data n those physical pages, which will require to spread the logical data in many
pages in most of the cases.
+This file is considered as a FileSystem, with fixed size 'pages' (a page is an array of bytes).
The page size is fixed when the RecordManager is created. The data represented in a logical
page may spread across many physical pages.
 
 ### PageIO
 
-Let's first introduce the *PageIO*, which is used to store the data on disk.
+A *PageIO* represents a physical block of the database file and contains complete or a part
of the logical page's data. PageIOs of a logical page are linked together.
 
-A *PageIO* contains some raw data. As we have to map some logical data that may be wider
than a physical fixed size *PageIO*, we use potentially more than one *PageIO* to store the
data, and we link the *PageIO*s alltogether.
-
-Each *PageIO* has a height bytes pointer at the beginning, pointing to the next PageIO (or
to nothing, if there is no more *PageIO* in the chain), plus an extra 4 bytes on the first
*PageIO* to define the number of bytes stored in the chain of PageIO. Here is the mapping
between a logical page and some PageIOs :
+Each *PageIO* has an eight byte pointer at the beginning, pointing to the next PageIO (or
to nothing, if it is the last *PageIO* in the chain), plus an extra 4 bytes on the first *PageIO*
to define the number of bytes stored in the chain of PageIO. Here is the mapping between a
logical page and some PageIOs :
 
 ![PageIO mapping](images/PageIOLogical.png)
 
-Every *PageIO*s are contiguous on disk, but the *PageIO*s used to store a logical page may
be located anywhere on the disk, they don't have to be continuous.
+All *PageIO*s are contiguous on disk, but the *PageIO*s used to store a logical page may
be located anywhere on the disk, they don't have to be continuous.
 
 Here is the structure of a *PageIO* on disk :
 
-* next page offset (8 bytes) : the offset of the next *PageIO*, or -1L if no more *PageIO*
is needed
-* data size (4 bytes) : for the first *PageIO*, the size of the stored data across all the
*PageIO*s used to store a page.
-* data (N bytes) : a block of data, which size will be min( PageSize - offset - data size,
data size) for the first *PageIO* or min( PageSize - offset, data size) for any other *PageIO*s
+* next page offset (8 bytes) : the offset of the next *PageIO*, or -1 if it is the last *PageIO*
+* data size (4 bytes) : the size of the data stored, this is only set in the first *PageIO*
of the chain of *PageIO*s used to store a logical page.
+* data (N bytes) : a block of data, whose size will be min( PageSize - offset - data size,
data size) for the first *PageIO* or min( PageSize - offset, data size) for any other *PageIO*s
 
 ## Logical structure mapping on disk
 
@@ -62,38 +60,35 @@ We will now describe how each logical st
 
 ### RecordManager header
 
-We keep a few bytes at the beginning of the file to store some critical information about
the RecordManager. Here is the list of stored informations :
+A few bytes at the beginning of the file are used to store some critical information about
the RecordManager. Here is the list of stored information details :
 
 * The *PageIO* size (in bytes)
 * The number of managed B-Trees
 * The offset of the first free page
 * The offset of the current B-tree of B-trees
-* The offset of the previous B-tree of B-trees, if we an update operation is being done
+* The offset of the previous B-tree of B-trees, if an update operation was performed
 * The offset of the current CopiedPages B-tree
-* The offset of the previous CopiedPages B-tree, if we an update operation is being done
+* The offset of the previous CopiedPages B-tree, if an update operation was performed
 
-Here is a picture that shows the header content in two different case (when an update operation
is not completed, and when it's completed) :
+Here is a picture that shows the header content in two different cases (when an update operation
is not completed, and when it's completed) :
 
 ![RecordManager header](images/RMHeader.png)
 
-We keep a track of the free pages (a free page is a PageIO that is not anymore used, for
instance because the data have been deleted.) This is done by keeping a link between each
PageIO and by pointing to the first feee PageIO and to the last free PageIO of this list.
-
-
-At startup, of course, we have no free pages, and those pointers contain the -1 offset.
+Recordmanager tracks the free pages (a free page is a PageIO that is not in use, for instance
when a key was deleted). This is done by linking each unused PageIO together and finally updating
the references of fisrt and last free pages. When there are no free pages these pointers contain
-1 as the offset value.
 
 This header is stored in a *PageIO*, at the very beginning of the file.
 
 ### The RecordManager structure
 
-The *RecordManager* manages *BTree*s, and we have to store them into *PageIO*s. How do we
do that ?
+Each *BTree* has a header that contains many details about it, and points to a *rootPage*
which is the current root (i.e., the root of the latest revision). 
 
-All the *BTree*s have a header that contains many informations about them, and point to a
*rootPage* which is the current root (so the root for the latest revision). As a *RecordManager*
can manage more than one *BTree*, we have to find a way to retreive all the *BTree*s at startup
: we use an internal link, so that a *BTree* points to the next btree. At startup, we read
the first *BTree* which is stored in the second *PageIO* in the file (so just after the RecordManager
header), then we read the next *BTree* pointed by the first *BTree*, and so on.
+The special BTree called 'btree of btrees'(a.k.a BoB) contains the names and revisions of
each managed BTree. To load the managed btrees during startup, this BoB is read to find the
latest revision of each BTree and the associated root page's offset based on which the btree
will be loaded.
 
 #### The B-tree info
 
-Each *B-tree* has some informations that never change over the time. Here is the list of
those informations :
+Each *B-tree* has some metadata that will never change after creation. Here is the list of
the details stored :
 
-* pageSize (4 bytes) : the number of elements we cans store in a *Node* or a *Leaf*. It's
not related in any possible way with the *PageIO* size.
+* pageSize (4 bytes) : the number of elements we cans store in a *Node* or a *Leaf*. It's
not related in any way with the *PageIO* size.
 * nameSize (4 bytes) : The *BTree* name size
 * name (nameSize bytes) : the *BTree* name
 * keySerializerSize (4 bytes) : The size of the java *FQCN* for the key serializer
@@ -102,46 +97,45 @@ Each *B-tree* has some informations that
 * valueSerializer (valueSerializerSize bytes): The java *FQCN* for the value serializer
 * dupsAllowed (1 byte): tells if the *BTree* can have duplicated values.
 
-As we can see, this header can have various length, and if one one the names is long, we
may need more than one PageIOs to store it.
-
-Note that a *B-tree* info can be stored on one or many *IOPage*s, depending on its size.
+Note that a *B-tree* info can be stored in one or many *IOPage*s, depending on its size.
 
 #### The BTree header
 
-We may have many versions of the *B-tree* header, one per revision (unless we overwrite it
when we don't need to keep many revisions on disk).
+There will be one *B-tree* header per revision.
 
-Each *BTree* has to keep many informations, which are :
+Each *BTree* has to maintain many details, such as :
 
-* revision (8 bytes) : the current revision for this *BTree*. This value is updated after
each modification in the *BTree*.
-* nbElems (8 bytes) : the total number of elements we have in the *BTree*. This is updated
after each modification either.
+* revision (8 bytes) : the current revision of the *BTree*. This value is updated after each
modification in the *BTree*.
+* nbElems (8 bytes) : the total number of elements we have in the *BTree*. This is updated
after each modification.
 * rootPage offset (8 bytes) : the position in the file where the *rootPage* is stored
 * btreeInfo offset (8 bytes) : the position of the *B-tree* info page in the file
 
-Here is a diagram which present the *B-tree header* and the *B-tree info* data structures
on disk :
+Here is a diagram which represents the *B-tree header* and the *B-tree info* data structures
on disk :
 
 ![BTreeHeader](images/btreeHeader.png)
 
-Note that they can be stored on one or many *IOPage*s, depending on its size.
+Note that they can be stored on one or more *IOPage*s, depending on the size.
 
-All in all, when we have more than one *BTree* stored in the file, the content of the file
which stores the *BTree* headers will look like this one :
+The below picture shows the contents of the btree headers present in the database file when
more than one btree is stored.
 
 ![BTrees](images/BTree.png)
 
-Note that each *B-tree Header* has one root page, even if it contains no data. In this schema,
we show the root page just after the *BTree* it is associated to, but after a few updates,
the root page may perfectly well be stored elsewhere on the disk.
+Note that each *B-tree Header* has one root page, even if it contains no data. In this picture,
the root page is shown just after the *BTree* it is associated with, but after a few updates,
the root page may be stored elsewhere on the disk.
 
 #### The Nodes and Leaves
 
-Nodes and Leaves are logical *BTree* pages which are serialized on disk into one to many
*PageIO*s. They have slightly different data structures, as *Node*s contains pointers to *Leaves*,
and no data, while *Leaves* contains data. In any case, both contain the keys. The *Node*
has one ore value than the *Leaf*, too.
+Nodes and Leaves are logical *BTree* pages which are stored in one or more *PageIO*s. They
have slightly different data structures, as *Node*s contain pointers to *Leaves*, and no data,
while *Leaves* contain data, but both contain the keys. The number of keys present in a *Node*
is higher
+than that of a *Leaf* by one.
 
-On disk, each *Node* and *Leaf* are stored in *PageIO*s, as we said. A *Node* will have pointers
to some other logical pages, and on disk, those pointers will be offset of the first *PageIO*
used to store the logical page it points to.
+On disk, a *Node* will have pointers to some other logical pages, those pointers will be
offset of the first *PageIO* used to store the logical page it points to.
 
-Here is the *Node* and *Leaf* data structures once serialized :
+The below picture shows a *Node* and *Leaf* after serialized to disk :
 
 ![Node and Leaf](images/nodeLeaf.png)
 
-Note that we store the size of the serialized data : this is necessary as we have to know
how many *PageIO*s will be needed to store the logical page.
+Note that this is necessary to store the size of the serialized data in order to know how
many *PageIO*s will be needed to store the logical page.
 
-The *rootPage* is just a *Node* or a *Leaf*.
+The *rootPage* can be either a *Node* or a *Leaf*.
 
 #### Potential improvement
 



Mime
View raw message