0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
Hypertable::NameIdMapper Class Reference

Easy mapping between a Table/Namespace name string to ids and vice versa. More...

#include <NameIdMapper.h>

Collaboration diagram for Hypertable::NameIdMapper:
Collaboration graph
[legend]

Public Types

enum  Flag { IS_NAMESPACE =0x0001, CREATE_INTERMEDIATE =0x0002 }
 

Public Member Functions

 NameIdMapper (Hyperspace::SessionPtr &hyperspace, const std::string &toplevel_dir)
 
bool name_to_id (const std::string &name, std::string &id, bool *is_namespacep=0)
 
bool id_to_name (const std::string &id, std::string &name, bool *is_namespacep=0)
 
void id_to_sublisting (const std::string &id, bool include_sub_entries, std::vector< NamespaceListing > &listing)
 
void add_mapping (const std::string &name, std::string &id, int flags=0, bool ignore_exists=false)
 Adds a new mapping. More...
 
void drop_mapping (const std::string &name)
 Drops a mapping. More...
 
bool exists_mapping (const std::string &name, bool *is_namespace)
 
void rename (const std::string &old_name, const std::string &new_name)
 Rename one entity, it doesn't recursively rename all entities under the path specified by old_name. More...
 
void add_entry (const std::string &names_parent, const std::string &names_entry, std::vector< uint64_t > &ids, bool is_namespace)
 

Protected Member Functions

bool do_mapping (const std::string &input, bool id_in, std::string &output, bool *is_namespacep)
 

Static Protected Member Functions

static void get_namespace_listing (const std::vector< Hyperspace::DirEntryAttr > &dir_listing, std::vector< NamespaceListing > &listing)
 

Protected Attributes

std::mutex m_mutex
 
Hyperspace::SessionPtr m_hyperspace
 
std::string m_toplevel_dir
 
std::string m_names_dir
 
std::string m_ids_dir
 
size_t m_prefix_components
 

Detailed Description

Easy mapping between a Table/Namespace name string to ids and vice versa.

Definition at line 45 of file NameIdMapper.h.

Member Enumeration Documentation

Enumerator
IS_NAMESPACE 
CREATE_INTERMEDIATE 

Definition at line 49 of file NameIdMapper.h.

Constructor & Destructor Documentation

Hypertable::NameIdMapper::NameIdMapper ( Hyperspace::SessionPtr hyperspace,
const std::string &  toplevel_dir 
)

Definition at line 40 of file NameIdMapper.cc.

Member Function Documentation

void Hypertable::NameIdMapper::add_entry ( const std::string &  names_parent,
const std::string &  names_entry,
std::vector< uint64_t > &  ids,
bool  is_namespace 
)

Definition at line 74 of file NameIdMapper.cc.

void Hypertable::NameIdMapper::add_mapping ( const std::string &  name,
std::string &  id,
int  flags = 0,
bool  ignore_exists = false 
)

Adds a new mapping.

Parameters
namename to map
idoutput parameter to hold newly mapped ID
flagscontrol falgs (IS_NAMESPACE and/or CREATE_INTERMEDIATE)
ignore_existsDon't throw an exception if mapping already exists

Definition at line 146 of file NameIdMapper.cc.

bool Hypertable::NameIdMapper::do_mapping ( const std::string &  input,
bool  id_in,
std::string &  output,
bool *  is_namespacep 
)
protected

Definition at line 289 of file NameIdMapper.cc.

void Hypertable::NameIdMapper::drop_mapping ( const std::string &  name)

Drops a mapping.

Parameters
namename to map

Definition at line 254 of file NameIdMapper.cc.

bool Hypertable::NameIdMapper::exists_mapping ( const std::string &  name,
bool *  is_namespace 
)
Parameters
namename to check for mapping
is_namespaceif mapping exists set to true if is namespace
Returns
true if mapping exists, false otherwise

Definition at line 282 of file NameIdMapper.cc.

void Hypertable::NameIdMapper::get_namespace_listing ( const std::vector< Hyperspace::DirEntryAttr > &  dir_listing,
std::vector< NamespaceListing > &  listing 
)
staticprotected

Definition at line 370 of file NameIdMapper.cc.

bool Hypertable::NameIdMapper::id_to_name ( const std::string &  id,
std::string &  name,
bool *  is_namespacep = 0 
)
Parameters
idthe id of the table/namespace
namereturned name of the table/namespace specified by id
is_namespacepSet to true if name corresponds to a namespace
Returns
true if mapping exists

Definition at line 69 of file NameIdMapper.cc.

void Hypertable::NameIdMapper::id_to_sublisting ( const std::string &  id,
bool  include_sub_entries,
std::vector< NamespaceListing > &  listing 
)
Parameters
idthe id of the namespace
include_sub_entriesinclude or not include all sub entries
listingreturned names of the table/namespaces contained within the namespace specified by id

Definition at line 355 of file NameIdMapper.cc.

bool Hypertable::NameIdMapper::name_to_id ( const std::string &  name,
std::string &  id,
bool *  is_namespacep = 0 
)
Parameters
namename of the table/namespace
idthe returned id of the table/namespace specified by name
is_namespacepSet to true if name corresponds to a namespace
Returns
true if mapping exists

Definition at line 64 of file NameIdMapper.cc.

void Hypertable::NameIdMapper::rename ( const std::string &  old_name,
const std::string &  new_name 
)

Rename one entity, it doesn't recursively rename all entities under the path specified by old_name.

Parameters
old_nameold name
new_namenew name

Definition at line 212 of file NameIdMapper.cc.

Member Data Documentation

Hyperspace::SessionPtr Hypertable::NameIdMapper::m_hyperspace
protected

Definition at line 113 of file NameIdMapper.h.

std::string Hypertable::NameIdMapper::m_ids_dir
protected

Definition at line 116 of file NameIdMapper.h.

std::mutex Hypertable::NameIdMapper::m_mutex
protected

Definition at line 112 of file NameIdMapper.h.

std::string Hypertable::NameIdMapper::m_names_dir
protected

Definition at line 115 of file NameIdMapper.h.

size_t Hypertable::NameIdMapper::m_prefix_components
protected

Definition at line 117 of file NameIdMapper.h.

std::string Hypertable::NameIdMapper::m_toplevel_dir
protected

Definition at line 114 of file NameIdMapper.h.


The documentation for this class was generated from the following files: