Groonga 3.0.9 Source Code Document
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
header.hpp
Go to the documentation of this file.
1 /* -*- c-basic-offset: 2 -*- */
2 /* Copyright(C) 2011 Brazil
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License version 2.1 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Lesser General Public License for more details.
12 
13  You should have received a copy of the GNU Lesser General Public
14  License along with this library; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #ifndef GRN_DAT_HPP_HEADER_HPP_
19 #define GRN_DAT_HPP_HEADER_HPP_
20 
21 #include "dat.hpp"
22 
23 namespace grn {
24 namespace dat {
25 
27  public:
29  : file_size_(0),
30  total_key_length_(0),
31  next_key_id_(grn::dat::MIN_KEY_ID),
32  max_key_id_(0),
33  num_keys_(0),
34  max_num_keys_(0),
35  num_phantoms_(0),
36  num_zombies_(0),
37  num_blocks_(0),
38  max_num_blocks_(0),
39  next_key_pos_(0),
40  key_buf_size_(0),
41  status_flags_(0) {
42  for (UInt32 i = 0; i <= MAX_BLOCK_LEVEL; ++i) {
43  leaders_[i] = INVALID_LEADER;
44  }
45  for (UInt32 i = 0; i < (sizeof(reserved_) / sizeof(*reserved_)); ++i) {
46  reserved_[i] = 0;
47  }
48  }
49 
50  UInt64 file_size() const {
51  return file_size_;
52  }
54  return total_key_length_;
55  }
56  UInt32 min_key_id() const {
57  return MIN_KEY_ID;
58  }
59  UInt32 next_key_id() const {
60  return next_key_id_;
61  }
62  UInt32 max_key_id() const {
63  return max_key_id_;
64  }
65  UInt32 num_keys() const {
66  return num_keys_;
67  }
68  UInt32 max_num_keys() const {
69  return max_num_keys_;
70  }
71  UInt32 num_nodes() const {
72  return num_blocks() * BLOCK_SIZE;
73  }
74  UInt32 num_phantoms() const {
75  return num_phantoms_;
76  }
77  UInt32 num_zombies() const {
78  return num_zombies_;
79  }
81  return max_num_blocks() * BLOCK_SIZE;
82  }
83  UInt32 num_blocks() const {
84  return num_blocks_;
85  }
87  return max_num_blocks_;
88  }
89  UInt32 next_key_pos() const {
90  return next_key_pos_;
91  }
92  UInt32 key_buf_size() const {
93  return key_buf_size_;
94  }
95  UInt32 status_flags() const {
96  return status_flags_;
97  }
100  return leaders_[i];
101  }
102 
105  file_size_ = x;
106  }
109  total_key_length_ = x;
110  }
113  next_key_id_ = x;
114  }
117  max_key_id_ = x;
118  }
121  num_keys_ = x;
122  }
125  max_num_keys_ = x;
126  }
128  GRN_DAT_DEBUG_THROW_IF(x > max_num_nodes());
129  num_phantoms_ = x;
130  }
132  GRN_DAT_DEBUG_THROW_IF(x > max_num_nodes());
133  num_zombies_ = x;
134  }
136  GRN_DAT_DEBUG_THROW_IF(x > max_num_blocks());
137  num_blocks_ = x;
138  }
141  max_num_blocks_ = x;
142  }
144  GRN_DAT_DEBUG_THROW_IF(x > key_buf_size());
145  next_key_pos_ = x;
146  }
149  key_buf_size_ = x;
150  }
152  status_flags_ = x;
153  }
156  GRN_DAT_DEBUG_THROW_IF((x != INVALID_LEADER) && (x >= num_blocks()));
157  leaders_[i] = x;
158  }
159 
160  private:
161  UInt64 file_size_;
162  UInt32 total_key_length_;
163  UInt32 next_key_id_;
164  UInt32 max_key_id_;
165  UInt32 num_keys_;
166  UInt32 max_num_keys_;
167  UInt32 num_phantoms_;
168  UInt32 num_zombies_;
169  UInt32 num_blocks_;
170  UInt32 max_num_blocks_;
171  UInt32 next_key_pos_;
172  UInt32 key_buf_size_;
173  UInt32 leaders_[MAX_BLOCK_LEVEL + 1];
174  UInt32 status_flags_;
175  UInt32 reserved_[12];
176 };
177 
178 } // namespace dat
179 } // namespace grn
180 
181 #endif // GRN_DAT_HPP_HEADER_HPP_