libfoedus-core
FOEDUS Core Library
array_storage.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 <ostream>
21 #include <string>
22 
23 #include "foedus/engine.hpp"
26 
27 namespace foedus {
28 namespace storage {
29 namespace array {
30 
33  : Storage<ArrayStorageControlBlock>(engine, control_block) {
35 }
37  : Storage<ArrayStorageControlBlock>(engine, control_block) {
39 }
41  : Storage<ArrayStorageControlBlock>(engine, id) {}
43  : Storage<ArrayStorageControlBlock>(engine, name) {}
45  : Storage<ArrayStorageControlBlock>(other.engine_, other.control_block_) {
46 }
48  engine_ = other.engine_;
50  return *this;
51 }
53  return ArrayStoragePimpl(this).create(metadata);
54 }
55 
57  return ArrayStoragePimpl(this).load(snapshot_block);
58 }
59 
60 std::ostream& operator<<(std::ostream& o, const ArrayStorage& v) {
61  o << "<ArrayStorage>"
62  << "<id>" << v.get_id() << "</id>"
63  << "<name>" << v.get_name() << "</name>"
64  << "<payload_size>" << v.get_payload_size() << "</payload_size>"
65  << "<array_size>" << v.get_array_size() << "</array_size>"
66  << "</ArrayStorage>";
67  return o;
68 }
69 
70 
72  thread::Thread* context,
73  bool install_volatile,
74  bool cache_snapshot,
75  ArrayOffset from,
76  ArrayOffset to) {
77  if (to == 0) {
78  to = get_array_size();
79  }
80  return ArrayStoragePimpl(this).prefetch_pages(
81  context,
82  install_volatile,
83  cache_snapshot,
84  from,
85  to);
86 }
87 
88 // most other methods are defined in pimpl.cpp to allow inlining
89 
90 } // namespace array
91 } // namespace storage
92 } // namespace foedus
StorageType get_type() const
Returns the type of this storage.
Definition: storage.hpp:150
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 a key-value store based on a dense and regular array.
Represents one thread running on one NUMA core.
Definition: thread.hpp:48
uint64_t ArrayOffset
The only key type in array storage.
Definition: array_id.hpp:48
ArrayStorage & operator=(const ArrayStorage &other)
uint16_t get_payload_size() const
Returns byte size of one record in this array storage without internal overheads. ...
Brings error stacktrace information as return value of functions.
Definition: error_stack.hpp:81
Engine * engine_
Most attachable object stores an engine pointer (local engine), so we define it here.
Definition: attachable.hpp:107
ErrorStack create(const Metadata &metadata)
ArrayOffset get_array_size() const
Returns the size of this array.
Metadata of one storage.
Definition: metadata.hpp:58
Represents one key-value store.
Definition: storage.hpp:116
ErrorCode prefetch_pages(thread::Thread *context, bool install_volatile, bool cache_snapshot, ArrayOffset from, ArrayOffset to)
defined in array_storage_prefetch.cpp
ArrayStorageControlBlock * control_block_
The shared data on shared memory that has been initialized in some SOC or master engine.
Definition: attachable.hpp:111
const StorageName & get_name() const
Returns the unique name of this storage.
Definition: storage.hpp:155
ErrorCode prefetch_pages(thread::Thread *context, bool install_volatile, bool cache_snapshot, ArrayOffset from, ArrayOffset to)
Prefetch data pages in this storage.
bool exists() const
Returns whether this storage is already created.
Definition: storage.hpp:169
Database engine object that holds all resources and provides APIs.
Definition: engine.hpp:109
StorageId get_id() const
Returns the unique ID of this storage.
Definition: storage.hpp:145
std::ostream & operator<<(std::ostream &o, const ArrayCreateLogType &v)
ErrorStack load(const StorageControlBlock &snapshot_block)
#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
ErrorStack create(const Metadata &metadata)
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
ErrorStack load(const StorageControlBlock &snapshot_block)