libfoedus-core
FOEDUS Core Library
sequential_id.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2015, Hewlett-Packard Development Company, LP.
3  * This program is free software; you can redistribute it and/or modify it
4  * under the terms of the GNU General Public License as published by the Free
5  * Software Foundation; either version 2 of the License, or (at your option)
6  * any later version.
7  *
8  * This program is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11  * more details. You should have received a copy of the GNU General Public
12  * License along with this program; if not, write to the Free Software
13  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14  *
15  * HP designates this particular file as subject to the "Classpath" exception
16  * as provided by HP in the LICENSE.txt file that accompanied this code.
17  */
18 #ifndef FOEDUS_STORAGE_SEQUENTIAL_SEQUENTIAL_ID_HPP_
19 #define FOEDUS_STORAGE_SEQUENTIAL_SEQUENTIAL_ID_HPP_
20 
26 #include <stdint.h>
27 
28 #include "foedus/epoch.hpp"
30 
31 namespace foedus {
32 namespace storage {
33 namespace sequential {
38 const uint16_t kMaxSlots = 1 << 15;
43 const uint16_t kHeaderSize = 64;
49 
54 const uint16_t kMaxPayload = kDataSize;
55 
60 const uint16_t kRootPageHeaderSize = 56;
61 
70  Epoch from_epoch_; // +4 -> 12
72  Epoch to_epoch_; // +4 -> 16
79  uint64_t page_count_; // +8 -> 24
80 };
81 
82 
83 
88 const uint16_t kRootPageMaxHeadPointers
90 
96 
104 const uint16_t kPointerPageCount = 1U << 6;
105 const uint16_t kPointersPerPage = 1U << 10;
106 
108 inline void get_pointer_page_and_index(uint16_t thread_id, uint16_t *page, uint16_t *index) {
109  *page = thread_id / kPointersPerPage;
110  *index = thread_id % kPointersPerPage;
111 }
112 
113 } // namespace sequential
114 } // namespace storage
115 } // namespace foedus
116 #endif // FOEDUS_STORAGE_SEQUENTIAL_SEQUENTIAL_ID_HPP_
Definitions of IDs in this package and a few related constant values.
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
SnapshotPagePointer page_id_
ID of the page that begins the linked list.
Represents a time epoch.
Definition: epoch.hpp:61
Epoch from_epoch_
Inclusive beginning of epochs in the pointed pages.
const uint16_t kRootPageMaxHeadPointers
Maximum number of head pointers in one root page.
Each pointer to a snapshot head page comes with a bit more information to help reading.
void get_pointer_page_and_index(uint16_t thread_id, uint16_t *page, uint16_t *index)
Calculate the page/index of the thread-private head/tail pointer.
const uint16_t kHeaderSize
Byte size of header in each data page of sequential storage.
uint64_t SnapshotPagePointer
Page ID of a snapshot page.
Definition: storage_id.hpp:79
const uint16_t kPointerPageCount
Each poiner page can contain 2^10 pointers (as the node is implicit, PagePoolOffset suffices) and we ...
uint64_t page_count_
In a sequential storage, all pages from the head page is guaranteed to be contiguous (that's how Sequ...
const uint16_t kDataSize
Byte size of data region in each data page of sequential storage.
const uint16_t kMaxPayload
Payload must be shorter than this length.
Epoch to_epoch_
Exclusive end of epochs in the pointed pages.
const uint16_t kRootPageHeaderSize
Byte size of header in each root page of sequential storage.
const uint16_t kRootPageDataSize
Byte size of data region in each root page of sequential storage.
const uint16_t kPageSize
A constant defining the page size (in bytes) of both snapshot pages and volatile pages.
Definition: storage_id.hpp:45
const uint16_t kMaxSlots
We have to represent the record count in 15 bits.