43 #include <boost/algorithm/string.hpp>
55 Namespace::Namespace(
const string &name,
const string &
id,
PropertiesPtr &props,
59 uint32_t timeout,
Client *client)
60 : m_name(name), m_id(id), m_props(props),
61 m_comm(conn_manager->get_comm()), m_conn_manager(conn_manager), m_hyperspace(hyperspace),
62 m_app_queue(app_queue), m_namemap(namemap), m_master_client(master_client),
63 m_range_locator(range_locator), m_table_cache(table_cache),
64 m_timeout_ms(timeout), m_client(client) {
77 string full_name = sub_name;
78 boost::trim_if(full_name, boost::is_any_of(
"/ "));
79 full_name =
m_name +
'/' + full_name;
86 boost::char_separator<char> sep(
"/");
92 for (Tokenizer::iterator tok_iter = tokens.begin();
93 tok_iter != tokens.end(); ++tok_iter)
94 if (tok_iter->size() > 0)
95 output += *tok_iter +
"/";
98 boost::trim_if(output, boost::is_any_of(
"/ "));
113 if (name.size() && name[0]==
'^')
126 if (name.size() && name[0]==
'^')
129 const string schema_str = schema->render_xml(
true);
137 if (name.size() && name[0]==
'^')
140 const string schema_str = schema->render_xml(
true);
147 if (name.size() && name[0]==
'^')
160 if (table->needs_index_table() && !table->has_index_table()) {
165 if (table->needs_qualifier_index_table()
166 && !table->has_qualifier_index_table()) {
168 table->set_qualifier_index_table(
_open_table(full_name, 0));
181 t->set_namespace(
this);
193 bool is_namespace =
false;
195 if (!
m_namemap->name_to_id(full_name, table_id, &is_namespace) ||
222 if (!
m_namemap->name_to_id(full_name, table_id, &is_namespace) ||
233 if (!
m_table_cache->get_schema_str(full_name, schema, with_ids))
250 if (name.size() && name[0]==
'^')
253 if (name.size() && name[0]==
'^')
271 if (name.size() && name[0]==
'^')
300 while (scanner->next(cell))
301 HT_ASSERT(!
"Rebuild index scan returned a cell");
312 m_namemap->id_to_sublisting(
m_id, include_sub_entries, listing);
333 table->get(tid, schema);
340 size_t rowlen = strlen(tid.
id)+2;
341 std::shared_ptr<char> start_row(
new char[rowlen], [](
char *p ) {
delete[] p; } );
342 std::shared_ptr<char> end_row(
new char[rowlen+strlen(
Key::END_ROW_MARKER)], [](
char *p ) {
delete[] p; } );
344 sprintf(start_row.get(),
"%s:", tid.
id);
351 scan_spec.
columns.push_back(
"Location");
352 scan_spec.
columns.push_back(
"StartRow");
354 ri.
start = start_row.get();
355 ri.
end = end_row.get();
366 while (scanner_ptr->next(cell)) {
368 if (strcmp(last_row.c_str(), cell.
row_key) && last_row !=
"") {
369 const char *ptr = strchr(last_row.c_str(),
':');
371 tsbuilder.set_end_row(ptr+1);
372 splits.push_back(tsbuilder.get());
382 tsbuilder.set_location(str);
383 ProxyMapT::iterator pmiter = proxy_map.find(str);
384 if (pmiter != proxy_map.end()) {
385 tsbuilder.set_ip_address( (*pmiter).second.addr.format_ipaddress() );
386 tsbuilder.set_hostname( (*pmiter).second.hostname );
392 tsbuilder.set_start_row(str);
403 splits.push_back(tsbuilder.get());
std::string get_qualifier_index_table_name(const std::string &table_name)
Retrieves system information (hardware, installation directory, etc)
std::string get_index_table_name(const std::string &table_name)
void get_table_splits(const std::string &name, TableSplitsContainer &splits)
Returns a list of existing table names.
TableCachePtr m_table_cache
TablePtr open_table(const std::string &name, int32_t flags=0)
Opens a table.
std::string String
A String is simply a typedef to std::string.
std::shared_ptr< RangeLocator > RangeLocatorPtr
Smart pointer to RangeLocator.
ApplicationQueueInterfacePtr m_app_queue
static const char * METADATA_NAME
Declarations for TableIdentifier and TableIdentifierManaged.
Po::typed_value< String > * str(String *v=0)
Lib::Master::ClientPtr m_master_client
void rebuild_indices(const std::string &table_name, TableParts table_parts)
Rebuild a table's indices.
void compact(const std::string &name, const std::string &row, uint32_t flags)
Performs a manual compaction.
std::string get_table_id(const std::string &name)
Returns the table identifier for a table.
static void canonicalize(String *original)
Get canonical format of name/id string.
ConnectionManagerPtr m_conn_manager
std::shared_ptr< TableScanner > TableScannerPtr
Smart pointer to TableScanner.
Represents a set of table parts (sub-tables).
TablePtr _open_table(const std::string &full_name, int32_t flags=0)
bool m_hyperspace_reconnect
Represents a row interval.
std::shared_ptr< Client > ClientPtr
Wrapper for TableIdentifier providing member storage.
Scan predicate and control specification.
std::string get_full_name(const std::string &sub_name)
std::shared_ptr< Session > SessionPtr
void get_listing(bool include_sub_entries, std::vector< NamespaceListing > &listing)
Returns a list of existing tables & namesspaces.
void create_table(const std::string &name, const std::string &schema_str)
Creates a table.
SchemaPtr get_schema(const std::string &name)
Returns a smart ptr to a schema object for a table.
std::shared_ptr< Properties > PropertiesPtr
TableParts rebuild_indices
A timer class to keep timeout states across AsyncComm related calls.
std::string m_toplevel_dir
Logging routines and macros.
std::unordered_map< String, ProxyAddressInfo > ProxyMapT
Forward mapping hash type from proxy name to ProxyAddressInfo.
Compatibility Macros for C/C++.
Initialization helper for applications.
std::shared_ptr< ApplicationQueueInterface > ApplicationQueueInterfacePtr
Smart pointer to ApplicationQueueInterface.
static String basename(String name, char separator= '/')
A posix-compliant basename() which strips directory names from a filename.
static Schema * new_instance(const std::string &buf)
Creates schema object from XML schema string.
#define HT_FATALF(msg,...)
std::shared_ptr< TableCache > TableCachePtr
Smart pointer to TableCache.
Declarations for HqlCommandInterpreter.
void get_proxy_map(ProxyMapT &proxy_map)
Returns the proxy map.
void alter_table(const std::string &table_name, SchemaPtr &schema, bool force)
Alter table schema.
bool exists_table(const std::string &name)
Checks if the table exists.
const char * column_family
boost::tokenizer< boost::char_separator< char > > Tokenizer
Internet address wrapper classes and utility functions.
RowIntervals row_intervals
std::string get_schema_str(const std::string &name, bool with_ids=false)
Returns the schema for a table.
Declarations for ReactorFactory.
This is a generic exception class for Hypertable.
void rename_table(const std::string &old_name, const std::string &new_name)
Renames a table.
NameIdMapperPtr m_namemap
std::shared_ptr< Schema > SchemaPtr
Smart pointer to Schema.
RangeLocatorPtr m_range_locator
std::shared_ptr< ConnectionManager > ConnectionManagerPtr
Smart pointer to ConnectionManager.
Hyperspace::SessionPtr m_hyperspace
Encapsulates decomposed key and value.
String extensions and helpers: sets, maps, append operators etc.
void drop_table(const std::string &name, bool if_exists)
Removes a table.
std::shared_ptr< NameIdMapper > NameIdMapperPtr
Smart pointer to NameIdMapper.
Error codes, Exception handling, error logging.
#define HT_THROW(_code_, _msg_)
static const char * END_ROW_MARKER
std::shared_ptr< Table > TablePtr
int code() const
Returns the error code.
void refresh_table(const std::string &name)
Refreshes the cached table entry.
Executes user-defined functions when leaving the current scope.