libfoedus-core
FOEDUS Core Library
hash_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 <memory>
23 #include <ostream>
24 #include <string>
25 #include <utility>
26 
27 #include "foedus/assert_nd.hpp"
32 #include "foedus/thread/thread.hpp"
33 
34 namespace foedus {
35 namespace storage {
36 namespace hash {
37 
39  reinterpret_cast<CreateLogType*>(this)->apply_storage(engine, storage_id);
40 }
41 
43  reinterpret_cast<CreateLogType*>(this)->assert_valid();
45  ASSERT_ND(header_.get_type() == log::get_log_code<HashCreateLogType>());
46 }
47 std::ostream& operator<<(std::ostream& o, const HashCreateLogType& v) {
48  o << "<HashCreateLog>" << v.metadata_ << "</HashCreateLog>";
49  return o;
50 }
51 
52 std::ostream& operator<<(std::ostream& o, const HashInsertLogType& v) {
53  o << "<HashInsertLogType>"
54  << "<key_length_>" << v.key_length_ << "</key_length_>"
55  << "<key_>" << assorted::Top(v.get_key(), v.key_length_) << "</key_>"
56  << "<bin_bits_>" << static_cast<int>(v.bin_bits_) << "</bin_bits_>"
57  << "<hash_>" << assorted::Hex(v.hash_, 16) << "</hash_>"
58  << "<payload_count_>" << v.payload_count_ << "</payload_count_>"
59  << "<payload_>" << assorted::Top(v.get_payload(), v.payload_count_) << "</payload_>"
60  << "</HashInsertLogType>";
61  return o;
62 }
63 
64 std::ostream& operator<<(std::ostream& o, const HashDeleteLogType& v) {
65  o << "<HashDeleteLogType>"
66  << "<key_length_>" << v.key_length_ << "</key_length_>"
67  << "<key_>" << assorted::Top(v.get_key(), v.key_length_) << "</key_>"
68  << "<bin_bits_>" << static_cast<int>(v.bin_bits_) << "</bin_bits_>"
69  << "<hash_>" << assorted::Hex(v.hash_, 16) << "</hash_>"
70  << "</HashDeleteLogType>";
71  return o;
72 }
73 
74 std::ostream& operator<<(std::ostream& o, const HashUpdateLogType& v) {
75  o << "<HashUpdateLogType>"
76  << "<key_length_>" << v.key_length_ << "</key_length_>"
77  << "<key_>" << assorted::Top(v.get_key(), v.key_length_) << "</key_>"
78  << "<bin_bits_>" << static_cast<int>(v.bin_bits_) << "</bin_bits_>"
79  << "<hash_>" << assorted::Hex(v.hash_, 16) << "</hash_>"
80  << "<payload_count_>" << v.payload_count_ << "</payload_count_>"
81  << "<payload_>" << assorted::Top(v.get_payload(), v.payload_count_) << "</payload_>"
82  << "</HashUpdateLogType>";
83  return o;
84 }
85 
86 std::ostream& operator<<(std::ostream& o, const HashOverwriteLogType& v) {
87  o << "<HashOverwriteLog>"
88  << "<key_length_>" << v.key_length_ << "</key_length_>"
89  << "<key_>" << assorted::Top(v.get_key(), v.key_length_) << "</key_>"
90  << "<bin_bits_>" << static_cast<int>(v.bin_bits_) << "</bin_bits_>"
91  << "<hash_>" << assorted::Hex(v.hash_, 16) << "</hash_>"
92  << "<payload_offset_>" << v.payload_offset_ << "</payload_offset_>"
93  << "<payload_count_>" << v.payload_count_ << "</payload_count_>"
94  << "<payload_>" << assorted::Top(v.get_payload(), v.payload_count_) << "</payload_>"
95  << "</HashOverwriteLog>";
96  return o;
97 }
98 
99 } // namespace hash
100 } // namespace storage
101 } // namespace foedus
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
uint8_t bin_bits_
this is not strictly needed here, but helps a bit.
void apply_storage(Engine *engine, StorageId storage_id)
std::ostream & operator<<(std::ostream &o, const HashCombo &v)
Definition: hash_combo.cpp:37
Declares common log types for all (or at least multiple) storage types.
Declares all log types used in this storage type.
Log type of hash-storage's update operation.
Database engine object that holds all resources and provides APIs.
Definition: engine.hpp:109
uint16_t log_length_
Byte size of this log entry including this header itself and everything.
Write only first few bytes to stream.
Log type of hash-storage's insert operation.
Log type of hash-storage's overwrite operation.
Convenient way of writing hex integers to stream.
LogCode get_type() const __attribute__((always_inline))
Convenience method to cast into LogCode.
HashValue hash_
Hash value of the key.
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
Log type of hash-storage's delete operation.
Log type of CREATE HASH STORAGE operation.