Skip to content

Conversation

@morningman
Copy link
Contributor

ISSUE #315

Also fix a bug that when calling check_none_row_oriented_table,
store is null, it cannot be used to create table.
Instead, OLAPHeader can be used to get storage type information.

Also fix a bug that when calling check_none_row_oriented_table,
store is null, it cannot be used to create table.
Instead, OLAPHeader can be used to get storage type information.
continue;
}

boost::hash_combine<std::string>(hash, part);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be use the hash function in util/hash_util.hpp? it has been already optimized

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::hash has already been used in other functions in string_util.h.
So just for unification.

std::size_t hash = std::hash<std::string>()(identifier);
std::vector<std::string> path_parts;
boost::split(path_parts, path, boost::is_any_of("/"));
for (std::string part : path_parts) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use reference for part, And you can use auto

Suggested change
for (std::string part : path_parts) {
for (auto& part : path_parts) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

StorePath(const std::string& path_, int64_t capacity_bytes_)
: path(path_), capacity_bytes(capacity_bytes_) { }
std::string path;
int64_t path_hash;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add path_hash here.
StorePath is what user can define, not store's status

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forgot to remove it

LOG(INFO) << "Master FE is changed or restarted. report tablet and disk info immediately";
std::unique_lock<std::mutex> lk(OLAPEngine::get_instance()->report_mtx);
OLAPEngine::get_instance()->report_cv.notify_all();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. notify_all needn't to hold mutex first.
  2. report_cv.notify_all() should encapsulate in a function
  3. you can use _olap_engine instead of OLAPEngine::get_instance()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

} else {
// when Master FE restarted, host and port remains the same, but epoch will be increased.
if (master_info.epoch > _epoch) {
_epoch = master_info.epoch;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function may be called concurrently. and changing _epoch and testing _epoch without any protect would lead to strange result

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a mutex to protect _heartbeat() function

if (_is_drop_tables) {
disk_broken_cv.notify_all();
std::unique_lock<std::mutex> lk(report_mtx);
report_cv.notify_all();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

notify_all doesn't need lock held

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

}
};

struct PathHash {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you define a struct? A function is better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why other 'functions' in string_util are defined as struct. Just for unification.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

em...
Other struct can be used for std::map or std::unordered_map. However your struct can't be used as a comparator or a hasher for these container.

So, you'd better to define a function here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got it. Fixed.

Copy link
Contributor

@imay imay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@imay imay merged commit 9a2ad18 into apache:master Nov 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants