libfoedus-core
FOEDUS Core Library
array_metadata.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 <iostream>
21 #include <sstream>
22 #include <string>
23 
25 namespace foedus {
26 namespace storage {
27 namespace array {
28 std::string ArrayMetadata::describe() const {
29  std::stringstream o;
30  o << ArrayMetadataSerializer(const_cast<ArrayMetadata*>(this));
31  return o.str();
32 }
33 std::ostream& operator<<(std::ostream& o, const ArrayMetadata& v) {
34  o << ArrayMetadataSerializer(const_cast<ArrayMetadata*>(&v));
35  return o;
36 }
37 
38 ErrorStack ArrayMetadataSerializer::load(tinyxml2::XMLElement* element) {
39  CHECK_ERROR(load_base(element));
40  CHECK_ERROR(get_element(element, "payload_size_", &data_casted_->payload_size_))
42  element,
43  "snapshot_drop_volatile_pages_threshold_",
45  CHECK_ERROR(get_element(element, "array_size_", &data_casted_->array_size_))
46  return kRetOk;
47 }
48 
49 ErrorStack ArrayMetadataSerializer::save(tinyxml2::XMLElement* element) const {
50  CHECK_ERROR(save_base(element));
51  CHECK_ERROR(add_element(element, "payload_size_", "", data_casted_->payload_size_));
53  element,
54  "snapshot_drop_volatile_pages_threshold_",
55  "",
57  CHECK_ERROR(add_element(element, "array_size_", "", data_casted_->array_size_));
58  return kRetOk;
59 }
60 
61 } // namespace array
62 } // namespace storage
63 } // namespace foedus
ArrayOffset array_size_
Size of this array.
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
ErrorStack load_base(tinyxml2::XMLElement *element)
common routine for the implementation of load()
Definition: metadata.cpp:50
Brings error stacktrace information as return value of functions.
Definition: error_stack.hpp:81
ErrorStack save(tinyxml2::XMLElement *element) const override
Writes the content of this object to the given XML element.
Metadata of an array storage.
std::ostream & operator<<(std::ostream &o, const ArrayCreateLogType &v)
ErrorStack save_base(tinyxml2::XMLElement *element) const
common routine for the implementation of save()
Definition: metadata.cpp:66
#define CHECK_ERROR(x)
This macro calls x and checks its returned value.
const ErrorStack kRetOk
Normal return value for no-error case.
static ErrorStack get_element(tinyxml2::XMLElement *parent, const std::string &tag, T *out, bool optional=false, T value=0)
Only declaration in header.
ErrorStack load(tinyxml2::XMLElement *element) override
Reads the content of this object from the given XML element.
uint16_t snapshot_drop_volatile_pages_threshold_
Number of levels of volatile pages to keep after each snapshotting.
uint16_t payload_size_
byte size of one record in this array storage without internal overheads
static ErrorStack add_element(tinyxml2::XMLElement *parent, const std::string &tag, const std::string &comment, T value)
Only declaration in header.