libfoedus-core
FOEDUS Core Library
sequential_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"
32 #include "foedus/thread/thread.hpp"
33 
34 namespace foedus {
35 namespace storage {
36 namespace sequential {
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<SequentialCreateLogType>());
46 }
47 std::ostream& operator<<(std::ostream& o, const SequentialCreateLogType& v) {
48  o << "<SequentialCreateLog>" << v.metadata_ << "</SequentialCreateLog>";
49  return o;
50 }
51 
53  SequentialStorage seq(engine, storage_id);
54  seq.apply_truncate(*this);
55 }
56 
59  ASSERT_ND(header_.get_type() == log::get_log_code<SequentialTruncateLogType>());
60 }
61 std::ostream& operator<<(std::ostream& o, const SequentialTruncateLogType& v) {
62  o << "<SequentialTruncateLog>"
63  << "<storage_id_>" << v.header_.storage_id_ << "</storage_id_>"
64  << "<new_truncate_epoch_>" << v.new_truncate_epoch_ << "</new_truncate_epoch_>"
65  << "</SequentialTruncateLog>";
66  return o;
67 }
68 
69 std::ostream& operator<<(std::ostream& o, const SequentialAppendLogType& v) {
70  o << "<SequentialAppendLog>"
71  << "<payload_count_>" << v.payload_count_ << "</payload_count_>";
72  // show first few bytes
73  o << "<data_>";
74  for (uint16_t i = 0; i < std::min<uint16_t>(8, v.payload_count_); ++i) {
75  o << i << ":" << static_cast<int>(v.payload_[i]) << " ";
76  }
77  o << "...</data_>";
78  o << "</SequentialAppendLog>";
79  return o;
80 }
81 
82 } // namespace sequential
83 } // namespace storage
84 } // namespace foedus
void apply_storage(Engine *engine, StorageId storage_id)
void apply_storage(Engine *engine, StorageId storage_id)
std::ostream & operator<<(std::ostream &o, const SequentialCursor &v)
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
void apply_truncate(const SequentialTruncateLogType &the_log)
Represents an append/scan-only store.
Declares common log types for all (or at least multiple) storage types.
Database engine object that holds all resources and provides APIs.
Definition: engine.hpp:109
Log type of CREATE SEQUENTIAL STORAGE operation.
uint16_t log_length_
Byte size of this log entry including this header itself and everything.
Declares all log types used in this storage type.
Log type of TRUNCATE SEQUENTIAL STORAGE operation.
storage::StorageId storage_id_
The storage this loggable operation mainly affects.
LogCode get_type() const __attribute__((always_inline))
Convenience method to cast into LogCode.
Base type for CREATE STORAGE operation.
Log type of sequential-storage's append 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