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

Holds set of range objects for a table. More...

#include <TableInfo.h>

Inheritance diagram for Hypertable::TableInfo:
Inheritance graph
[legend]
Collaboration diagram for Hypertable::TableInfo:
Collaboration graph
[legend]

Public Member Functions

 TableInfo (const TableIdentifier *identifier, SchemaPtr &schema, bool maintenance_disabled)
 Constructor. More...
 
virtual ~TableInfo ()
 Destructor. More...
 
virtual bool remove (const String &start_row, const String &end_row)
 Remove range with the given start and end row from the active set. More...
 
virtual void change_end_row (const String &start_row, const String &old_end_row, const String &new_end_row)
 Changes the end row of a range in the active set. More...
 
virtual void change_start_row (const String &old_start_row, const String &new_start_row, const String &end_row)
 Changes the start row of a range in the active set. More...
 
SchemaPtr get_schema ()
 Returns a pointer to the schema object. More...
 
bool maintenance_disabled ()
 Checks if maintenance has been disabled for this table. More...
 
void set_maintenance_disabled (bool val)
 Sets the maintenance disabled flag. More...
 
void update_schema (SchemaPtr &schema)
 Updates schema, propagating change to all ranges in active set. More...
 
bool get_range (const RangeSpec &range_spec, RangePtr &range)
 Returns range object corresponding to the given RangeSpec. More...
 
bool has_range (const RangeSpec &range_spec)
 Checks if range corresponding to the given RangeSpec exists in the active set. More...
 
bool remove_range (const RangeSpec &range_spec, RangePtr &range)
 Removes the range specified by the given RangeSpec from the active set. More...
 
void stage_range (const RangeSpec &range_spec, std::chrono::fast_clock::time_point deadline)
 Stages a range to being added. More...
 
void unstage_range (const RangeSpec &range_spec)
 Unstages a previously staged range. More...
 
void promote_staged_range (RangePtr &range)
 Promotes a range from the staged set to the active set. More...
 
void add_range (RangePtr &range, bool remove_if_exists=false)
 Adds a range to the active set. More...
 
bool find_containing_range (const String &row, RangePtr &range, String &start_row, String &end_row)
 Finds the range to which the given row belongs. More...
 
bool includes_row (const String &row) const
 Checks to see if a given row belongs to any of the ranges in the active set. More...
 
void get_ranges (Ranges &ranges)
 Fills Ranges vector with ranges from the active set. More...
 
size_t get_range_count ()
 Returns the number of ranges in the active set. More...
 
void clear ()
 Clears the active range set. More...
 
TableIdentifieridentifier ()
 Returns a reference to the table identifier. More...
 

Private Attributes

std::mutex m_mutex
 Mutex for serializing member access More...
 
std::condition_variable m_cond
 Condition variable signalled on m_staged_set change. More...
 
TableIdentifierManaged m_identifier
 Table identifier More...
 
SchemaPtr m_schema
 Table schema object More...
 
std::set< RangeInfom_active_set
 Set of active ranges. More...
 
std::set< RangeInfom_staged_set
 Set of staged ranges (soon to become active) More...
 
bool m_maintenance_disabled {}
 Flag indicating if maintenance is disabled for table. More...
 

Detailed Description

Holds set of range objects for a table.

Definition at line 118 of file TableInfo.h.

Constructor & Destructor Documentation

TableInfo::TableInfo ( const TableIdentifier identifier,
SchemaPtr schema,
bool  maintenance_disabled 
)

Constructor.

Parameters
identifierTable identifier
schemaSmart pointer to schema object
maintenance_disabledFlag indicating if maintenance is disabled for this table

Definition at line 35 of file TableInfo.cc.

virtual Hypertable::TableInfo::~TableInfo ( )
inlinevirtual

Destructor.

Definition at line 130 of file TableInfo.h.

Member Function Documentation

void TableInfo::add_range ( RangePtr range,
bool  remove_if_exists = false 
)

Adds a range to the active set.

This function first checks to see if the range info object corresponding to range exists in the active set. If it does and remove_if_exists is set to true, then it is removed, otherwise it will assert. Then a range info object is created from range and it is inserted into m_active_set.

Parameters
rangeRange object to add
remove_if_existsRemove existing entry if one exists

Definition at line 217 of file TableInfo.cc.

void TableInfo::change_end_row ( const String start_row,
const String old_end_row,
const String new_end_row 
)
virtual

Changes the end row of a range in the active set.

This function finds the range whose start and end row are start_row and old_end_row, respectively. It then removes the range info object from the set and re-inserts it with the end row set to new_end_row

Parameters
start_rowStart row of range to modify
old_end_rowEnd row of range to modify
new_end_rowNew end row for range

Implements Hypertable::RangeSet.

Definition at line 65 of file TableInfo.cc.

void TableInfo::change_start_row ( const String old_start_row,
const String new_start_row,
const String end_row 
)
virtual

Changes the start row of a range in the active set.

This function finds the range whose start and end row are old_start_row and end_row, respectively. It then removes the range info object from the set and re-inserts it with the start row set to new_start_row

Parameters
old_start_rowStart row of range to modify
new_start_rowNew start row for range
end_rowEnd row of range to modify

Implements Hypertable::RangeSet.

Definition at line 90 of file TableInfo.cc.

void TableInfo::clear ( )

Clears the active range set.

Definition at line 272 of file TableInfo.cc.

bool TableInfo::find_containing_range ( const String row,
RangePtr range,
String start_row,
String end_row 
)

Finds the range to which the given row belongs.

This function searches m_active_set for the range that should contain row. If found, range, start_row, and end_row are set with the range information and true is returned. If a matching range is not found, false is returned.

Parameters
rowRow key used to locate range
rangeReference to Range pointer to hold located range
start_rowStarting row of range
end_rowEnding row of range
Returns
true if found, false otherwise

Definition at line 234 of file TableInfo.cc.

bool TableInfo::get_range ( const RangeSpec range_spec,
RangePtr range 
)

Returns range object corresponding to the given RangeSpec.

Parameters
range_specRange specification
rangeReference to returned range object
Returns
true if found, false otherwise

Definition at line 116 of file TableInfo.cc.

size_t TableInfo::get_range_count ( )

Returns the number of ranges in the active set.

Returns
Number of ranges in the active set

Definition at line 266 of file TableInfo.cc.

void TableInfo::get_ranges ( Ranges ranges)

Fills Ranges vector with ranges from the active set.

Parameters
rangesAddress of range statistics vector

Definition at line 259 of file TableInfo.cc.

SchemaPtr Hypertable::TableInfo::get_schema ( )
inline

Returns a pointer to the schema object.

Returns
Smart pointer to the schema object

Definition at line 163 of file TableInfo.h.

bool TableInfo::has_range ( const RangeSpec range_spec)

Checks if range corresponding to the given RangeSpec exists in the active set.

Parameters
range_specrange specification
Returns
true if found, false otherwise

Definition at line 132 of file TableInfo.cc.

TableIdentifier& Hypertable::TableInfo::identifier ( )
inline

Returns a reference to the table identifier.

Returns
Reference to the table identifier.

Definition at line 285 of file TableInfo.h.

bool TableInfo::includes_row ( const String row) const

Checks to see if a given row belongs to any of the ranges in the active set.

This function searches m_active_set for the range that should contain row. If found, true is returned, otherwise false is returned.

Parameters
rowrow to lookup
Returns
true if range that should contain row is found, false otherwise.

Definition at line 251 of file TableInfo.cc.

bool Hypertable::TableInfo::maintenance_disabled ( )
inline

Checks if maintenance has been disabled for this table.

Returns
true if maintenance has been disabled, false otherwise

Definition at line 171 of file TableInfo.h.

void TableInfo::promote_staged_range ( RangePtr range)

Promotes a range from the staged set to the active set.

This function removes the range info object corresponding to the range specified by range from m_staged_set and then inserts it into m_active_set and then signals m_cond.

Parameters
rangesmart pointer to range object

Definition at line 204 of file TableInfo.cc.

bool TableInfo::remove ( const String start_row,
const String end_row 
)
virtual

Remove range with the given start and end row from the active set.

Parameters
start_rowStart row of range to remove
end_rowEnd row of range to remove
Returns
true if range was successfully remove, false if range was not found in set

Implements Hypertable::RangeSet.

Definition at line 42 of file TableInfo.cc.

bool TableInfo::remove_range ( const RangeSpec range_spec,
RangePtr range 
)

Removes the range specified by the given RangeSpec from the active set.

Parameters
range_specRange specification of range to remove
rangeReference to returned range object that was removed
Returns
true if removed, false if not found

Definition at line 141 of file TableInfo.cc.

void Hypertable::TableInfo::set_maintenance_disabled ( bool  val)
inline

Sets the maintenance disabled flag.

Parameters
valValue for maintenance disabled flag

Definition at line 178 of file TableInfo.h.

void TableInfo::stage_range ( const RangeSpec range_spec,
std::chrono::fast_clock::time_point  deadline 
)

Stages a range to being added.

This function first check to see if the range is already in the process of being staged. If so it does a timed wait on m_cond, waiting for the previous staging to abort. If it times out, an exception is thrown. Otherwise, it checks m_active_set to see if the range has already been added and if so, it throws an exception. If it passes all of the aforementioned checks, a RangeInfo object is created for the range and it is added to m_staged_set. Lastly, it signals m_cond.

Parameters
range_specrange specification of range to remove
deadlineTimeout if operation not complete by this time
Exceptions
Exceptionif the range has already been added with the error code set to Error::RANGESERVER_RANGE_NOT_YET_RELINQUISHED if the range is not in the RangeState::STEADY state or Error::RANGESERVER_RANGE_ALREADY_LOADED if it is

If already staged, wait for staging to complete

Throw exception if already or still loaded

Definition at line 163 of file TableInfo.cc.

void TableInfo::unstage_range ( const RangeSpec range_spec)

Unstages a previously staged range.

This function removes the range specified by range_spec from m_staged_set and then signals m_cond.

Parameters
range_specrange specification of range to remove

Definition at line 195 of file TableInfo.cc.

void TableInfo::update_schema ( SchemaPtr schema)

Updates schema, propagating change to all ranges in active set.

This method verifies that the generation number of schema is greater than that of m_schema, calls Range::update_schema() for all ranges in m_active_set, and then sets m_schema to schema.

Parameters
schemaNew schema object
Exceptions
Exceptionwith error code Error::RANGESERVER_GENERATION_MISMATCH

Definition at line 278 of file TableInfo.cc.

Member Data Documentation

std::set<RangeInfo> Hypertable::TableInfo::m_active_set
private

Set of active ranges.

Definition at line 302 of file TableInfo.h.

std::condition_variable Hypertable::TableInfo::m_cond
private

Condition variable signalled on m_staged_set change.

Definition at line 293 of file TableInfo.h.

TableIdentifierManaged Hypertable::TableInfo::m_identifier
private

Table identifier

Definition at line 296 of file TableInfo.h.

bool Hypertable::TableInfo::m_maintenance_disabled {}
private

Flag indicating if maintenance is disabled for table.

Definition at line 308 of file TableInfo.h.

std::mutex Hypertable::TableInfo::m_mutex
private

Mutex for serializing member access

Definition at line 290 of file TableInfo.h.

SchemaPtr Hypertable::TableInfo::m_schema
private

Table schema object

Definition at line 299 of file TableInfo.h.

std::set<RangeInfo> Hypertable::TableInfo::m_staged_set
private

Set of staged ranges (soon to become active)

Definition at line 305 of file TableInfo.h.


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