Holds set of range objects for a table. More...
#include <TableInfo.h>
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... | |
TableIdentifier & | identifier () |
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< RangeInfo > | m_active_set |
Set of active ranges. More... | |
std::set< RangeInfo > | m_staged_set |
Set of staged ranges (soon to become active) More... | |
bool | m_maintenance_disabled {} |
Flag indicating if maintenance is disabled for table. More... | |
Holds set of range objects for a table.
Definition at line 118 of file TableInfo.h.
TableInfo::TableInfo | ( | const TableIdentifier * | identifier, |
SchemaPtr & | schema, | ||
bool | maintenance_disabled | ||
) |
Constructor.
identifier | Table identifier |
schema | Smart pointer to schema object |
maintenance_disabled | Flag indicating if maintenance is disabled for this table |
Definition at line 35 of file TableInfo.cc.
|
inlinevirtual |
Destructor.
Definition at line 130 of file TableInfo.h.
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.
range | Range object to add |
remove_if_exists | Remove existing entry if one exists |
Definition at line 217 of file TableInfo.cc.
|
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
start_row | Start row of range to modify |
old_end_row | End row of range to modify |
new_end_row | New end row for range |
Implements Hypertable::RangeSet.
Definition at line 65 of file TableInfo.cc.
|
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
old_start_row | Start row of range to modify |
new_start_row | New start row for range |
end_row | End 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.
row | Row key used to locate range |
range | Reference to Range pointer to hold located range |
start_row | Starting row of range |
end_row | Ending row of range |
Definition at line 234 of file TableInfo.cc.
Returns range object corresponding to the given RangeSpec.
range_spec | Range specification |
range | Reference to returned range object |
Definition at line 116 of file TableInfo.cc.
size_t TableInfo::get_range_count | ( | ) |
Returns the 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.
ranges | Address of range statistics vector |
Definition at line 259 of file TableInfo.cc.
|
inline |
Returns a 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.
range_spec | range specification |
Definition at line 132 of file TableInfo.cc.
|
inline |
Returns a 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.
row | row to lookup |
row
is found, false otherwise. Definition at line 251 of file TableInfo.cc.
|
inline |
Checks if maintenance has been disabled for this table.
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.
range | smart pointer to range object |
Definition at line 204 of file TableInfo.cc.
Remove range with the given start and end row from the active set.
start_row | Start row of range to remove |
end_row | End row of range to remove |
Implements Hypertable::RangeSet.
Definition at line 42 of file TableInfo.cc.
Removes the range specified by the given RangeSpec from the active set.
range_spec | Range specification of range to remove |
range | Reference to returned range object that was removed |
Definition at line 141 of file TableInfo.cc.
|
inline |
Sets the maintenance disabled flag.
val | Value 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.
range_spec | range specification of range to remove |
deadline | Timeout if operation not complete by this time |
Exception | if 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.
range_spec | range 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
.
schema | New schema object |
Exception | with error code Error::RANGESERVER_GENERATION_MISMATCH |
Definition at line 278 of file TableInfo.cc.
|
private |
Set of active ranges.
Definition at line 302 of file TableInfo.h.
|
private |
Condition variable signalled on m_staged_set change.
Definition at line 293 of file TableInfo.h.
|
private |
Table identifier
Definition at line 296 of file TableInfo.h.
|
private |
Flag indicating if maintenance is disabled for table.
Definition at line 308 of file TableInfo.h.
|
private |
Mutex for serializing member access
Definition at line 290 of file TableInfo.h.
|
private |
Table schema object
Definition at line 299 of file TableInfo.h.
|
private |
Set of staged ranges (soon to become active)
Definition at line 305 of file TableInfo.h.