libfoedus-core
FOEDUS Core Library
masstree_log_types.cpp
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  */
19 
20 #include <glog/logging.h>
21 
22 #include <algorithm>
23 #include <memory>
24 #include <ostream>
25 #include <string>
26 #include <utility>
27 
28 #include "foedus/assert_nd.hpp"
29 #include "foedus/engine.hpp"
35 #include "foedus/thread/thread.hpp"
36 
37 namespace foedus {
38 namespace storage {
39 namespace masstree {
40 
42  reinterpret_cast<CreateLogType*>(this)->apply_storage(engine, storage_id);
43 }
44 
46  reinterpret_cast<CreateLogType*>(this)->assert_valid();
48  ASSERT_ND(header_.get_type() == log::get_log_code<MasstreeCreateLogType>());
49 }
50 std::ostream& operator<<(std::ostream& o, const MasstreeCreateLogType& v) {
51  o << "<MasstreeCreateLog>" << v.metadata_ << "</MasstreeCreateLog>";
52  return o;
53 }
54 
55 std::ostream& operator<<(std::ostream& o, const MasstreeInsertLogType& v) {
56  o << "<MasstreeInsertLogType>"
57  << "<key_length_>" << v.key_length_ << "</key_length_>"
58  << "<key_>" << assorted::Top(v.get_key(), v.key_length_) << "</key_>"
59  << "<payload_count_>" << v.payload_count_ << "</payload_count_>"
60  << "<payload_>" << assorted::Top(v.get_payload(), v.payload_count_) << "</payload_>"
61  << "</MasstreeInsertLogType>";
62  return o;
63 }
64 
65 std::ostream& operator<<(std::ostream& o, const MasstreeDeleteLogType& v) {
66  o << "<MasstreeDeleteLogType>"
67  << "<key_length_>" << v.key_length_ << "</key_length_>"
68  << "<key_>" << assorted::Top(v.get_key(), v.key_length_) << "</key_>"
69  << "</MasstreeDeleteLogType>";
70  return o;
71 }
72 
73 std::ostream& operator<<(std::ostream& o, const MasstreeUpdateLogType& v) {
74  o << "<MasstreeUpdateLogType>"
75  << "<key_length_>" << v.key_length_ << "</key_length_>"
76  << "<key_>" << assorted::Top(v.get_key(), v.key_length_) << "</key_>"
77  << "<payload_count_>" << v.payload_count_ << "</payload_count_>"
78  << "<payload_>" << assorted::Top(v.get_payload(), v.payload_count_) << "</payload_>"
79  << "</MasstreeUpdateLogType>";
80  return o;
81 }
82 
83 std::ostream& operator<<(std::ostream& o, const MasstreeOverwriteLogType& v) {
84  o << "<MasstreeOverwriteLog>"
85  << "<key_length_>" << v.key_length_ << "</key_length_>"
86  << "<key_>" << assorted::Top(v.get_key(), v.key_length_) << "</key_>"
87  << "<payload_offset_>" << v.payload_offset_ << "</payload_offset_>"
88  << "<payload_count_>" << v.payload_count_ << "</payload_count_>"
89  << "<payload_>" << assorted::Top(v.get_payload(), v.payload_count_) << "</payload_>"
90  << "</MasstreeOverwriteLog>";
91  return o;
92 }
93 
94 } // namespace masstree
95 } // namespace storage
96 } // namespace foedus
std::ostream & operator<<(std::ostream &o, const MasstreeComposeContext::PathLevel &v)
Log type of CREATE MASSTREE STORAGE operation.
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
Declares all log types used in this storage type.
A few macros and helper methods related to byte endian-ness.
Log type of masstree-storage's insert operation.
Log type of masstree-storage's delete operation.
Declares common log types for all (or at least multiple) storage types.
Log type of masstree-storage's overwrite operation.
Database engine object that holds all resources and provides APIs.
Definition: engine.hpp:109
void apply_storage(Engine *engine, StorageId storage_id)
uint16_t log_length_
Byte size of this log entry including this header itself and everything.
Log type of masstree-storage's update operation.
Write only first few bytes to stream.
LogCode get_type() const __attribute__((always_inline))
Convenience method to cast into LogCode.
Base type for CREATE STORAGE operation.
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Definition: assert_nd.hpp:72