libfoedus-core
FOEDUS Core Library
masstree_metadata.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_MASSTREE_MASSTREE_METADATA_HPP_
19 #define FOEDUS_STORAGE_MASSTREE_MASSTREE_METADATA_HPP_
20 #include <stdint.h>
21 
22 #include <iosfwd>
23 #include <string>
24 
25 #include "foedus/cxx11.hpp"
26 #include "foedus/error_stack.hpp"
32 
33 namespace foedus {
34 namespace storage {
35 namespace masstree {
42  enum Constants {
44  };
46  Metadata(0, kMasstreeStorage, ""),
50  min_layer_hint_(0),
51  pad1_(0) {}
53  StorageId id,
54  const StorageName& name,
55  uint16_t border_early_split_threshold = 0,
56  uint16_t snapshot_drop_volatile_pages_layer_threshold = 0,
57  uint16_t snapshot_drop_volatile_pages_btree_levels = kDefaultDropVolatilePagesBtreeLevels,
58  Layer min_layer_hint = 0)
59  : Metadata(id, kMasstreeStorage, name),
60  border_early_split_threshold_(border_early_split_threshold),
61  snapshot_drop_volatile_pages_layer_threshold_(snapshot_drop_volatile_pages_layer_threshold),
62  snapshot_drop_volatile_pages_btree_levels_(snapshot_drop_volatile_pages_btree_levels),
63  min_layer_hint_(min_layer_hint),
64  pad1_(0) {
65  }
68  const StorageName& name,
69  uint16_t border_early_split_threshold = 0,
70  uint16_t snapshot_drop_volatile_pages_layer_threshold = 0,
71  uint16_t snapshot_drop_volatile_pages_btree_levels = kDefaultDropVolatilePagesBtreeLevels,
72  Layer min_layer_hint = 0)
73  : Metadata(0, kMasstreeStorage, name),
74  border_early_split_threshold_(border_early_split_threshold),
75  snapshot_drop_volatile_pages_layer_threshold_(snapshot_drop_volatile_pages_layer_threshold),
76  snapshot_drop_volatile_pages_btree_levels_(snapshot_drop_volatile_pages_btree_levels),
77  min_layer_hint_(min_layer_hint),
78  pad1_(0) {
79  }
80 
81  std::string describe() const;
82  friend std::ostream& operator<<(std::ostream& o, const MasstreeMetadata& v);
83 
95 
113 
127 
128  // just for valgrind when this metadata is written to file. ggr
129  uint8_t pad1_;
130 
132  bool should_aggresively_create_next_layer(Layer cur_layer, KeyLength remainder) const {
133  if (remainder <= sizeof(KeySlice)) {
134  return false; // anyway can't create a next layer.
135  }
136  return min_layer_hint_ > cur_layer;
137  }
138 };
139 
143  : MetadataSerializer(data), data_casted_(data) {}
146 };
147 
148 
149 } // namespace masstree
150 } // namespace storage
151 } // namespace foedus
152 #endif // FOEDUS_STORAGE_MASSTREE_MASSTREE_METADATA_HPP_
friend std::ostream & operator<<(std::ostream &o, const MasstreeMetadata &v)
Definitions of IDs in this package and a few related constant values.
uint32_t StorageId
Unique ID for storage.
Definition: storage_id.hpp:55
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
uint16_t snapshot_drop_volatile_pages_layer_threshold_
Number of B-trie layers of volatile pages to keep after each snapshotting.
MasstreeMetadata(const StorageName &name, uint16_t border_early_split_threshold=0, uint16_t snapshot_drop_volatile_pages_layer_threshold=0, uint16_t snapshot_drop_volatile_pages_btree_levels=kDefaultDropVolatilePagesBtreeLevels, Layer min_layer_hint=0)
This one is for newly creating a storage.
#define EXTERNALIZABLE(clazz)
Macro to declare/define essential methods for an externalizable class.
uint16_t border_early_split_threshold_
Kind of fill factor for border pages, bit different from usual B-tree.
uint64_t KeySlice
Each key slice is an 8-byte integer.
Definitions of IDs in this package and a few related constant values.
uint16_t KeyLength
Represents a byte-length of a key in this package.
Definition: masstree_id.hpp:69
MasstreeMetadata(StorageId id, const StorageName &name, uint16_t border_early_split_threshold=0, uint16_t snapshot_drop_volatile_pages_layer_threshold=0, uint16_t snapshot_drop_volatile_pages_btree_levels=kDefaultDropVolatilePagesBtreeLevels, Layer min_layer_hint=0)
Metadata of one storage.
Definition: metadata.hpp:58
uint8_t Layer
Represents the depth of a B-trie layer.
Definition: masstree_id.hpp:42
#define CXX11_FINAL
Used in public headers in place of "final" of C++11.
Definition: cxx11.hpp:131
Layer min_layer_hint_
Hints how many layers this storage will create for most of records.
uint16_t snapshot_drop_volatile_pages_btree_levels_
Volatile pages of this B-tree level or higher are always kept after each snapshotting.
Forward declarations of classes in masstree storage package.
bool should_aggresively_create_next_layer(Layer cur_layer, KeyLength remainder) const