0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Namespace.h
Go to the documentation of this file.
1 /* -*- c++ -*-
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 #ifndef Hypertable_Lib_Namespace_h
23 #define Hypertable_Lib_Namespace_h
24 
29 #include <Hypertable/Lib/Table.h>
36 
37 #include <Hyperspace/Session.h>
38 
41 
42 #include <Common/String.h>
43 
44 #include <boost/tokenizer.hpp>
45 
46 #include <memory>
47 
48 namespace Hypertable {
49 
50  class Comm;
51  class HqlInterpreter;
52  class Client;
53 
56 
57  class Namespace : public ClientObject {
58  public:
59 
64  Namespace(const std::string &name, const std::string &id, PropertiesPtr &props,
65  ConnectionManagerPtr &conn_manager, Hyperspace::SessionPtr &hyperspace,
66  ApplicationQueueInterfacePtr &app_queue, NameIdMapperPtr &namemap,
67  Lib::Master::ClientPtr &master_client, RangeLocatorPtr &range_locator,
68  TableCachePtr &table_cache, uint32_t timeout, Client *client);
69 
70  virtual ~Namespace() {}
71 
76  static void canonicalize(String *original);
77 
78  const std::string& get_name() const {
79  return m_name;
80  }
81 
82  const std::string& get_id() const {
83  return m_id;
84  }
85 
92  void compact(const std::string &name, const std::string &row, uint32_t flags);
93 
139  void create_table(const std::string &name, const std::string &schema_str);
140 
141  void create_table(const std::string &name, SchemaPtr &schema);
142 
148  void alter_table(const std::string &table_name, SchemaPtr &schema, bool force);
149 
150 #if 0
151 
194 #endif
195  void alter_table(const std::string &table_name, const std::string &schema_str, bool force);
196 
204  TablePtr open_table(const std::string &name, int32_t flags = 0);
205 
211  void refresh_table(const std::string &name);
212 
219  bool exists_table(const std::string &name);
220 
227  std::string get_table_id(const std::string &name);
228 
235  SchemaPtr get_schema(const std::string &name);
236 
244  std::string get_schema_str(const std::string &name, bool with_ids=false);
245 
252  void get_listing(bool include_sub_entries, std::vector<NamespaceListing> &listing);
253 
260  void rename_table(const std::string &old_name, const std::string &new_name);
261 
270  void drop_table(const std::string &name, bool if_exists);
271 
279  void rebuild_indices(const std::string &table_name, TableParts table_parts);
280 
287  void get_table_splits(const std::string &name, TableSplitsContainer &splits);
288 
293  return m_client;
294  }
295 
296  private:
297  std::string get_index_table_name(const std::string &table_name) {
298  std::string s="^";
299  return (s+table_name);
300  }
301 
302  std::string get_qualifier_index_table_name(const std::string &table_name) {
303  std::string s="^^";
304  return (s+table_name);
305  }
306 
307  void create_index_table(const std::string &primary_table_name);
308 
309  typedef boost::tokenizer<boost::char_separator<char> > Tokenizer;
310  std::string get_full_name(const std::string &sub_name);
311 
312  void initialize();
313  TablePtr _open_table(const std::string &full_name, int32_t flags = 0);
314 
315  std::string m_name;
316  std::string m_id;
325  std::string m_toplevel_dir;
328  uint32_t m_timeout_ms;
330  };
331 
333  typedef std::shared_ptr<Namespace> NamespacePtr;
334 
336 
337 }
338 
339 #endif // Hypertable_Lib_Namespace_h
std::string get_qualifier_index_table_name(const std::string &table_name)
Definition: Namespace.h:302
std::string get_index_table_name(const std::string &table_name)
Definition: Namespace.h:297
void get_table_splits(const std::string &name, TableSplitsContainer &splits)
Returns a list of existing table names.
Definition: Namespace.cc:316
TableCachePtr m_table_cache
Definition: Namespace.h:327
TablePtr open_table(const std::string &name, int32_t flags=0)
Opens a table.
Definition: Namespace.cc:155
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
std::shared_ptr< RangeLocator > RangeLocatorPtr
Smart pointer to RangeLocator.
Definition: RangeLocator.h:198
ApplicationQueueInterfacePtr m_app_queue
Definition: Namespace.h:321
Lib::Master::ClientPtr m_master_client
Definition: Namespace.h:323
void rebuild_indices(const std::string &table_name, TableParts table_parts)
Rebuild a table's indices.
Definition: Namespace.cc:286
void compact(const std::string &name, const std::string &row, uint32_t flags)
Performs a manual compaction.
Definition: Namespace.cc:102
std::string get_table_id(const std::string &name)
Returns the table identifier for a table.
Definition: Namespace.cc:217
static void canonicalize(String *original)
Get canonical format of name/id string.
Definition: Namespace.cc:84
ConnectionManagerPtr m_conn_manager
Definition: Namespace.h:319
Represents a set of table parts (sub-tables).
Definition: TableParts.h:47
TablePtr _open_table(const std::string &full_name, int32_t flags=0)
Definition: Namespace.cc:174
std::shared_ptr< Namespace > NamespacePtr
Shared smart pointer to Namespace.
Definition: Namespace.h:333
std::shared_ptr< Client > ClientPtr
Definition: Client.h:156
std::string get_full_name(const std::string &sub_name)
Definition: Namespace.cc:75
std::shared_ptr< Session > SessionPtr
Definition: Session.h:734
void get_listing(bool include_sub_entries, std::vector< NamespaceListing > &listing)
Returns a list of existing tables & namesspaces.
Definition: Namespace.cc:311
void create_table(const std::string &name, const std::string &schema_str)
Creates a table.
Definition: Namespace.cc:111
std::string m_name
Definition: Namespace.h:315
The API of HQL interpreter.
SchemaPtr get_schema(const std::string &name)
Returns a smart ptr to a schema object for a table.
Definition: Namespace.cc:238
std::shared_ptr< Properties > PropertiesPtr
Definition: Properties.h:447
std::string m_toplevel_dir
Definition: Namespace.h:325
Declarations for ClientObject.
std::shared_ptr< ApplicationQueueInterface > ApplicationQueueInterfacePtr
Smart pointer to ApplicationQueueInterface.
Client * get_client()
Returns a pointer to the client object which created this Namespace.
Definition: Namespace.h:292
virtual ~Namespace()
Definition: Namespace.h:70
Base class for Hypertable client objects.
Definition: ClientObject.h:44
void create_index_table(const std::string &primary_table_name)
Hypertable definitions
const std::string & get_id() const
Definition: Namespace.h:82
std::shared_ptr< TableCache > TableCachePtr
Smart pointer to TableCache.
Definition: TableCache.h:103
Entry point to AsyncComm service.
Definition: Comm.h:61
PropertiesPtr m_props
Definition: Namespace.h:317
Declarations for ConnectionManager.
void alter_table(const std::string &table_name, SchemaPtr &schema, bool force)
Alter table schema.
Definition: Namespace.cc:135
bool exists_table(const std::string &name)
Checks if the table exists.
Definition: Namespace.cc:189
boost::tokenizer< boost::char_separator< char > > Tokenizer
Definition: Namespace.h:309
std::string get_schema_str(const std::string &name, bool with_ids=false)
Returns the schema for a table.
Definition: Namespace.cc:228
void rename_table(const std::string &old_name, const std::string &new_name)
Renames a table.
Definition: Namespace.cc:248
Declarations for MasterClient This file contains declarations for MasterClient, a client interface cl...
A String class based on std::string.
NameIdMapperPtr m_namemap
Definition: Namespace.h:322
const std::string & get_name() const
Definition: Namespace.h:78
std::shared_ptr< Schema > SchemaPtr
Smart pointer to Schema.
Definition: Schema.h:465
Namespace(const std::string &name, const std::string &id, PropertiesPtr &props, ConnectionManagerPtr &conn_manager, Hyperspace::SessionPtr &hyperspace, ApplicationQueueInterfacePtr &app_queue, NameIdMapperPtr &namemap, Lib::Master::ClientPtr &master_client, RangeLocatorPtr &range_locator, TableCachePtr &table_cache, uint32_t timeout, Client *client)
Constructs the object.
Definition: Namespace.cc:55
Declarations for ApplicationQueueInterface.
std::string m_id
Definition: Namespace.h:316
RangeLocatorPtr m_range_locator
Definition: Namespace.h:324
std::shared_ptr< ConnectionManager > ConnectionManagerPtr
Smart pointer to ConnectionManager.
Hyperspace::SessionPtr m_hyperspace
Definition: Namespace.h:320
void drop_table(const std::string &name, bool if_exists)
Removes a table.
Definition: Namespace.cc:269
std::shared_ptr< NameIdMapper > NameIdMapperPtr
Smart pointer to NameIdMapper.
Definition: NameIdMapper.h:121
std::shared_ptr< Table > TablePtr
Definition: Table.h:53
void refresh_table(const std::string &name)
Refreshes the cached table entry.
Definition: Namespace.cc:185
Declarations for TableParts.