-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Geo: geo library support #74
Conversation
acelyc111
commented
Jun 9, 2018
•
edited
Loading
edited
- add geo library, support set/del/search_radial/distance APIs
- integrate the library into redis proxy
src/geo/sample/sample.cpp
Outdated
// ./pegasus_geo_test onebox temp temp_geo | ||
int main(int argc, char **argv) | ||
{ | ||
if (argc != 4) { |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
src/geo/sample/sample.cpp
Outdated
auto extractor = [](const std::string &value, S2LatLng &latlng) { | ||
std::vector<std::string> data; | ||
dsn::utils::split_args(value.c_str(), data, '|'); | ||
if (data.size() <= 6) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
< 6
return ret; | ||
} | ||
|
||
void geo_client::async_del(const std::string &hash_key, |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
src/geo/lib/geo_client.cpp
Outdated
int timeout_milliseconds, | ||
int ttl_seconds) | ||
{ | ||
async_del( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
另外在set的时候有没有必要check下现在的经纬度是不是和之前的一样?一样是不是可以做一些优化?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个没有必要,一是我们不对业务数据做假设,二是没必要增加逻辑复杂度
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
也还好吧,反正set前会有一轮get的。感觉不会增加多大复杂度。而且业务是那种没事灌一批的话去,其实这么做也是挺值得的。
可以先留个TODO
src/geo/lib/geo_client.cpp
Outdated
scan_one_area_callback &&callback, | ||
std::vector<SearchResult> &result) | ||
{ | ||
dsn::tasking::enqueue(LPC_GEO_SCAN_DATA, |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
// generate hash key | ||
S2CellId leaf_cell_id = S2Cell(latlng).id(); | ||
S2CellId parent_cell_id = leaf_cell_id.parent(_min_level); | ||
geo_hash_key = parent_cell_id.ToString(); // [0,5]{1}/[0,3]{_min_level} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个注释没看明白啥意思……
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
正则表达式
src/geo/lib/geo_client.cpp
Outdated
} | ||
|
||
// scan all cell ids | ||
std::shared_ptr<std::list<std::vector<SearchResult>>> results( |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
src/geo/lib/geo_client.cpp
Outdated
} | ||
}; | ||
|
||
std::shared_ptr<dsn::task_tracker> tracker(new dsn::task_tracker); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
src/shell/commands.h
Outdated
@@ -1708,19 +1708,22 @@ inline bool copy_data(command_executor *e, shell_context *sc, arguments args) | |||
{"max_split_count", required_argument, 0, 's'}, | |||
{"max_batch_count", required_argument, 0, 'b'}, | |||
{"timeout_ms", required_argument, 0, 't'}, | |||
{"geo_data", optional_argument, 0, 'g'}, |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
src/shell/commands.h
Outdated
|
||
optind = 0; | ||
while (true) { | ||
int option_index = 0; | ||
int c; | ||
c = getopt_long(args.argc, args.argv, "c:a:s:b:t:", long_options, &option_index); | ||
c = getopt_long(args.argc, args.argv, "c:a:s:b:t:g:", long_options, &option_index); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
g后面没有冒号,因为是无参的
* add geo library, support set/del/search_radial/distance APIs * integrate the library into redis proxy Former-commit-id: cb41fabdc0711354c7760c0882598ed981a31374 [formerly 24fec41] Former-commit-id: d97b5f76ee0dc10974d0edcbf57a0d35c9a3e3b3