0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
TableInfo.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; version 3 of the
9  * License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
22 #include "Common/Compat.h"
23 #include "Common/DynamicBuffer.h"
24 #include "Common/Error.h"
25 #include "Common/Logger.h"
26 #include "Common/StringExt.h"
27 
28 #include <cstdlib>
29 #include "Common/ScopeGuard.h"
30 #include "Hyperspace/Session.h"
31 
32 #include "TableInfo.h"
33 
34 using namespace Hyperspace;
35 
36 namespace Tools {
37 namespace client {
38 namespace rangeserver {
39 
40  TableInfo::TableInfo(const String &toplevel_dir, const String &table_id)
41  : m_toplevel_dir(toplevel_dir) {
42  m_table.set_id(table_id);
43  }
44 
46  String table_file = m_toplevel_dir + "/tables/" + m_table.id;
47  DynamicBuffer valbuf(0);
48 
49  hyperspace->attr_get(table_file, "schema", valbuf);
50 
51  m_schema.reset( Schema::new_instance((const char *)valbuf.base) );
52 
53  m_table.generation = m_schema->get_generation();
54  }
55 
56 }}}
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
A dynamic, resizable and reference counted memory buffer.
Definition: DynamicBuffer.h:42
Hyperspace definitions
A dynamic, resizable memory buffer.
std::shared_ptr< Session > SessionPtr
Definition: Session.h:734
Logging routines and macros.
TableIdentifierManaged m_table
Definition: TableInfo.h:46
Compatibility Macros for C/C++.
TableInfo(const TableIdentifier *identifier, SchemaPtr &schema, bool maintenance_disabled)
Constructor.
Definition: TableInfo.cc:35
void set_id(const std::string &new_name)
uint8_t * base
Pointer to the allocated memory buffer.
Forward declarations.
void load(Hyperspace::SessionPtr &hyperspace)
Definition: TableInfo.cc:45
String extensions and helpers: sets, maps, append operators etc.
Error codes, Exception handling, error logging.
Executes user-defined functions when leaving the current scope.