libfoedus-core
FOEDUS Core Library
sequential_storage.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_SEQUENTIAL_SEQUENTIAL_STORAGE_HPP_
19 #define FOEDUS_STORAGE_SEQUENTIAL_SEQUENTIAL_STORAGE_HPP_
20 
21 #include <iosfwd>
22 #include <string>
23 
24 #include "foedus/attachable.hpp"
25 #include "foedus/cxx11.hpp"
26 #include "foedus/fwd.hpp"
27 #include "foedus/storage/fwd.hpp"
32 #include "foedus/thread/fwd.hpp"
33 
34 namespace foedus {
35 namespace storage {
36 namespace sequential {
41 class SequentialStorage CXX11_FINAL : public Storage<SequentialStorageControlBlock> {
42  public:
46 
49  SequentialStorage(Engine* engine, StorageControlBlock* control_block);
50  SequentialStorage(Engine* engine, StorageId id);
51  SequentialStorage(Engine* engine, const StorageName& name);
54 
55  // Storage interface
57  ErrorStack create(const Metadata &metadata);
58  ErrorStack load(const StorageControlBlock& snapshot_block);
59  ErrorStack drop();
60 
61  // this storage type doesn't use moved bit
62 
76  ErrorCode append_record(thread::Thread* context, const void *payload, uint16_t payload_count);
77 
81  void apply_append_record(thread::Thread* context, const SequentialAppendLogType* log_entry);
82 
95  Epoch get_truncate_epoch() const;
96 
115  ErrorStack truncate(Epoch new_truncate_epoch, Epoch* commit_epoch);
116  void apply_truncate(const SequentialTruncateLogType& the_log);
117 
118  friend std::ostream& operator<<(std::ostream& o, const SequentialStorage& v);
119 };
120 } // namespace sequential
121 } // namespace storage
122 } // namespace foedus
123 #endif // FOEDUS_STORAGE_SEQUENTIAL_SEQUENTIAL_STORAGE_HPP_
friend std::ostream & operator<<(std::ostream &o, const SequentialStorage &v)
ErrorCode append_record(thread::Thread *context, const void *payload, uint16_t payload_count)
Append one record to this sequential storage.
Definitions of IDs in this package and a few related constant values.
Lock-free list of records stored in the volatile part of sequential storage.
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
Represents one thread running on one NUMA core.
Definition: thread.hpp:48
void apply_truncate(const SequentialTruncateLogType &the_log)
Forward declarations of classes in root package.
Brings error stacktrace information as return value of functions.
Definition: error_stack.hpp:81
Represents a time epoch.
Definition: epoch.hpp:61
SequentialStorage & operator=(const SequentialStorage &other)
ErrorStack truncate(Epoch new_truncate_epoch, Epoch *commit_epoch)
Discards all records in this storage before the given epoch.
const SequentialMetadata * get_sequential_metadata() const
Metadata of one storage.
Definition: metadata.hpp:58
Represents an append/scan-only store.
Represents one key-value store.
Definition: storage.hpp:116
Forward declarations of classes in sequential storage package.
Forward declarations of classes in storage package.
ErrorStack create(const Metadata &metadata)
#define CXX11_FINAL
Used in public headers in place of "final" of C++11.
Definition: cxx11.hpp:131
Database engine object that holds all resources and provides APIs.
Definition: engine.hpp:109
Log type of CREATE SEQUENTIAL STORAGE operation.
Definitions of IDs in this package and a few related constant values.
Epoch get_truncate_epoch() const
This version doesn't protect the read in a xct.
ErrorCode optimistic_read_truncate_epoch(thread::Thread *context, Epoch *out) const
Obtains the current value of truncate-epoch in an OCC-fashion.
Log type of TRUNCATE SEQUENTIAL STORAGE operation.
void apply_append_record(thread::Thread *context, const SequentialAppendLogType *log_entry)
Used to apply the effect of appending to volatile list.
Log type of sequential-storage's append operation.
ErrorStack load(const StorageControlBlock &snapshot_block)
Forward declarations of classes in thread package.
A base layout of shared data for all storage types.
Definition: storage.hpp:53
ErrorCode
Enum of error codes defined in error_code.xmacro.
Definition: error_code.hpp:85