36 bool maintenance_disabled)
37 : m_identifier(*identifier), m_schema(schema),
38 m_maintenance_disabled(maintenance_disabled) {
43 lock_guard<mutex> lock(
m_mutex);
48 HT_INFOF(
"Unable to remove %s[%s..%s] from TableInfo because non-existant",
53 HT_ASSERT(iter->start_row.compare(start_row) == 0);
55 HT_INFOF(
"Removing %s[%s..%s] from TableInfo",
66 const String &new_end_row) {
67 lock_guard<mutex> lock(
m_mutex);
68 RangeInfo range_info(start_row, old_end_row);
72 HT_FATALF(
"Problem changing old end row '%s' to '%s' (start row '%s')",
73 old_end_row.c_str(), new_end_row.c_str(), start_row.c_str());
75 range_info.
range = iter->range;
76 range_info.
end_row = new_end_row;
78 HT_INFOF(
"Changing end row %s removing old row '%s' (start row '%s')",
85 HT_INFOF(
"Changing end row %s adding new row '%s' (start row '%s')",
92 lock_guard<mutex> lock(
m_mutex);
93 RangeInfo range_info(old_start_row, end_row);
97 HT_FATALF(
"Problem changing old start row '%s' to '%s' (end row '%s')",
98 old_start_row.c_str(), new_start_row.c_str(), end_row.c_str());
100 range_info.
range = iter->range;
103 HT_INFOF(
"Changing start row %s removing old row '%s' (end row '%s')",
110 HT_INFOF(
"Changing start row %s adding new start row '%s' (end row '%s')",
117 lock_guard<mutex> lock(
m_mutex);
133 lock_guard<mutex> lock(
m_mutex);
142 lock_guard<mutex> lock(
m_mutex);
147 HT_INFOF(
"Problem removing range %s[%s..%s] from TableInfo, range not found",
154 HT_INFOF(
"Removing range %s[%s..%s] from TableInfo",
165 unique_lock<mutex> lock(
m_mutex);
170 if (
m_cond.wait_until(lock, deadline) == std::cv_status::timeout)
181 int state = iter->range->get_state();
184 "Unable to stage range %s because is in state %s",
196 lock_guard<mutex> lock(
m_mutex);
205 lock_guard<mutex> lock(
m_mutex);
206 String start_row, end_row;
207 range->get_boundary_rows(start_row, end_row);
208 RangeInfo range_info(start_row, end_row);
211 range_info.
range = range;
218 lock_guard<mutex> lock(
m_mutex);
219 String start_row, end_row;
220 range->get_boundary_rows(start_row, end_row);
221 RangeInfo range_info(start_row, end_row);
222 range_info.
range = range;
229 HT_INFOF(
"Adding range %s to TableInfo", range->get_name().c_str());
236 lock_guard<mutex> lock(
m_mutex);
240 if (iter ==
m_active_set.end() || iter->start_row.compare(row) >= 0)
243 start_row = iter->start_row;
244 end_row = iter->end_row;
254 if (iter ==
m_active_set.end() || iter->start_row.compare(row) >= 0)
260 lock_guard<mutex> lock(
m_mutex);
267 lock_guard<mutex> lock(
m_mutex);
273 lock_guard<mutex> lock(
m_mutex);
279 lock_guard<mutex> lock(
m_mutex);
281 if (schema->get_generation() <
m_schema->get_generation())
283 "Updated schema generation %lld < current schema generation %lld",
287 range_info.range->update_schema(schema);
bool remove_range(const RangeSpec &range_spec, RangePtr &range)
Removes the range specified by the given RangeSpec from the active set.
RangePtr range
Smart pointer to Range object.
void stage_range(const RangeSpec &range_spec, std::chrono::fast_clock::time_point deadline)
Stages a range to being added.
void clear()
Clears the active range set.
bool has_range(const RangeSpec &range_spec)
Checks if range corresponding to the given RangeSpec exists in the active set.
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.
std::string String
A String is simply a typedef to std::string.
String format(const char *fmt,...)
Returns a String using printf like format facilities Vanilla snprintf is about 1.5x faster than this...
chrono::time_point< fast_clock > time_point
std::condition_variable m_cond
Condition variable signalled on m_staged_set change.
void update_schema(SchemaPtr &schema)
Updates schema, propagating change to all ranges in active set.
String end_row
Cached end row of range.
std::set< RangeInfo > m_active_set
Set of active ranges.
bool find_containing_range(const String &row, RangePtr &range, String &start_row, String &end_row)
Finds the range to which the given row belongs.
void get_ranges(Ranges &ranges)
Fills Ranges vector with ranges from the active set.
std::set< RangeInfo > m_staged_set
Set of staged ranges (soon to become active)
std::vector< RangeData > array
Vector of RangeData objects.
Logging routines and macros.
Compatibility Macros for C/C++.
bool get_range(const RangeSpec &range_spec, RangePtr &range)
Returns range object corresponding to the given RangeSpec.
void add_range(RangePtr &range, bool remove_if_exists=false)
Adds a range to the active set.
static std::string get_text(uint8_t state)
Returns string representation of range state value.
void promote_staged_range(RangePtr &range)
Promotes a range from the staged set to the active set.
Holds pointer to range and cached start and end rows.
size_t get_range_count()
Returns the number of ranges in the active set.
virtual bool remove(const String &start_row, const String &end_row)
Remove range with the given start and end row from the active set.
#define HT_FATALF(msg,...)
long long int Lld
Shortcut for printf formats.
Declarations for TableInfo.
void unstage_range(const RangeSpec &range_spec)
Unstages a previously staged range.
bool includes_row(const String &row) const
Checks to see if a given row belongs to any of the ranges in the active set.
#define HT_INFOF(msg,...)
#define HT_THROWF(_code_, _fmt_,...)
std::shared_ptr< Range > RangePtr
Smart pointer to Range.
String start_row
Cached start row of range.
std::shared_ptr< Schema > SchemaPtr
Smart pointer to Schema.
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.
TableIdentifierManaged m_identifier
Table identifier
std::mutex m_mutex
Mutex for serializing member access
Holds pointers to a Range and associated Range::MaintenanceData.
SchemaPtr m_schema
Table schema object
Holds vector of RangeData objects and memory arena.